turn all == into ==# or ==? when comparing strings
or vimwiki#path#is_equal, if the strings are file names
This commit is contained in:
parent
b240b52a3f
commit
9ada4d2041
@ -436,7 +436,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
if update_prev_link
|
||||
if a:0
|
||||
let vimwiki_prev_link = [a:1, []]
|
||||
elseif &ft == 'vimwiki'
|
||||
elseif &ft ==# 'vimwiki'
|
||||
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
||||
endif
|
||||
endif
|
||||
@ -519,7 +519,8 @@ function! vimwiki#base#backlinks() "{{{
|
||||
let links = s:get_links(source_file, idx)
|
||||
for [target_file, _, lnum, col] in links
|
||||
" don't include links from the current file to itself
|
||||
if target_file == current_filename && target_file != source_file
|
||||
if vimwiki#path#is_equal(target_file, current_filename) &&
|
||||
\ !vimwiki#path#is_equal(target_file, source_file)
|
||||
call add(locations, {'filename':source_file, 'lnum':lnum, 'col':col})
|
||||
endif
|
||||
endfor
|
||||
@ -689,9 +690,9 @@ function! s:link_target(source_file, wiki_nr, link_text) "{{{
|
||||
return []
|
||||
elseif url == '' && anchor != '' " only anchor
|
||||
return [fnamemodify(a:source_file, ':p'), anchor]
|
||||
elseif scheme == 'file'
|
||||
elseif scheme ==# 'file'
|
||||
return [url, '']
|
||||
elseif scheme == 'local'
|
||||
elseif scheme ==# 'local'
|
||||
return [vimwiki#path#normalize(source_dir.lnk), '']
|
||||
elseif target_idx >= len(g:vimwiki_list) " a malformed link
|
||||
return ['', '']
|
||||
@ -699,7 +700,7 @@ function! s:link_target(source_file, wiki_nr, link_text) "{{{
|
||||
return []
|
||||
endif
|
||||
|
||||
if scheme == 'diary'
|
||||
if scheme ==# 'diary'
|
||||
let root_dir = VimwikiGet('path',a:wiki_nr).
|
||||
\ VimwikiGet('diary_rel_path', a:wiki_nr)
|
||||
let ext = VimwikiGet('ext', a:wiki_nr)
|
||||
@ -858,7 +859,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) "{{{
|
||||
" which happens if we jump to an achor in the current file.
|
||||
" This hack is necessary because apparently Vim messes up the result of
|
||||
" getpos() directly after this command. Strange.
|
||||
if !(a:command == ':e ' && a:filename == expand('%:p'))
|
||||
if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p')))
|
||||
execute a:command.' '.fname
|
||||
endif
|
||||
if a:anchor != ''
|
||||
@ -1124,11 +1125,11 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
|
||||
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split)
|
||||
endif
|
||||
else
|
||||
if a:split == "split"
|
||||
if a:split ==# "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
elseif a:split ==# "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
elseif a:split ==# "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
|
@ -134,7 +134,7 @@ fun! s:group_links(links) "{{{
|
||||
endfun "}}}
|
||||
|
||||
fun! s:sort(lst) "{{{
|
||||
if VimwikiGet("diary_sort") == 'desc'
|
||||
if VimwikiGet("diary_sort") ==? 'desc'
|
||||
return reverse(sort(a:lst))
|
||||
else
|
||||
return sort(a:lst)
|
||||
@ -311,7 +311,7 @@ endfunction "}}}
|
||||
function! vimwiki#diary#generate_diary_section() "{{{
|
||||
let current_file = vimwiki#path#path_norm(expand("%:p"))
|
||||
let diary_file = vimwiki#path#path_norm(s:diary_index())
|
||||
if current_file == diary_file
|
||||
if vimwiki#path#is_equal(current_file, diary_file)
|
||||
call s:delete_diary_section()
|
||||
call s:insert_diary_section()
|
||||
else
|
||||
@ -327,7 +327,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
|
||||
let link = a:year.'-'.month.'-'.day
|
||||
if winnr('#') == 0
|
||||
if a:dir == 'V'
|
||||
if a:dir ==? 'V'
|
||||
vsplit
|
||||
else
|
||||
split
|
||||
|
@ -27,7 +27,7 @@ function! s:root_path(subdir) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:syntax_supported() " {{{
|
||||
return VimwikiGet('syntax') == "default"
|
||||
return VimwikiGet('syntax') ==? "default"
|
||||
endfunction " }}}
|
||||
|
||||
function! s:remove_blank_lines(lines) " {{{
|
||||
@ -204,7 +204,7 @@ function! s:subst_func(line, regexp, func, ...) " {{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:save_vimwiki_buffer() "{{{
|
||||
if &filetype == 'vimwiki' && filewritable(expand('%'))
|
||||
if &filetype ==? 'vimwiki' && filewritable(expand('%'))
|
||||
silent update
|
||||
endif
|
||||
endfunction "}}}
|
||||
@ -214,7 +214,7 @@ function! s:process_title(placeholders, default_title) "{{{
|
||||
if !empty(a:placeholders)
|
||||
for [placeholder, row, idx] in a:placeholders
|
||||
let [type, param] = placeholder
|
||||
if type == 'title' && !empty(param)
|
||||
if type ==# 'title' && !empty(param)
|
||||
return param
|
||||
endif
|
||||
endfor
|
||||
@ -484,7 +484,8 @@ function! s:make_tag(line, regexp, func, ...) "{{{
|
||||
|
||||
"FIXME FIXME !!! these can easily occur on the same line!
|
||||
"XXX {{{ }}} ??? obsolete
|
||||
if '`[^`]\+`' == a:regexp || '{{{.\+}}}' == a:regexp || g:vimwiki_rxEqIn == a:regexp
|
||||
if '`[^`]\+`' ==# a:regexp || '{{{.\+}}}' ==# a:regexp ||
|
||||
\ g:vimwiki_rxEqIn ==# a:regexp
|
||||
let res_line = s:subst_func(a:line, a:regexp, a:func)
|
||||
else
|
||||
let pos = 0
|
||||
@ -675,7 +676,7 @@ function! s:close_tag_table(table, ldest, header_ids) "{{{
|
||||
call s:sum_rowspan(table)
|
||||
call s:sum_colspan(table)
|
||||
|
||||
if table[0] == 'center'
|
||||
if table[0] ==# 'center'
|
||||
call add(ldest, "<table class='center'>")
|
||||
else
|
||||
call add(ldest, "<table>")
|
||||
@ -1402,10 +1403,10 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
endif
|
||||
|
||||
if !empty(state.placeholder)
|
||||
if state.placeholder[0] == 'nohtml'
|
||||
if state.placeholder[0] ==# 'nohtml'
|
||||
let nohtml = 1
|
||||
break
|
||||
elseif state.placeholder[0] == 'template'
|
||||
elseif state.placeholder[0] ==# 'template'
|
||||
let template_name = state.placeholder[1]
|
||||
else
|
||||
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
|
||||
|
@ -922,7 +922,7 @@ endfunction "}}}
|
||||
|
||||
function! s:decrease_level(item) "{{{
|
||||
let removed_indent = 0
|
||||
if VimwikiGet('syntax') == 'media' && a:item.type == 1 &&
|
||||
if VimwikiGet('syntax') ==? 'media' && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
if s:string_length(a:item.mrkr) >= 2
|
||||
call s:substitute_string_in_line(a:item.lnum,
|
||||
@ -944,7 +944,7 @@ endfunction "}}}
|
||||
|
||||
function! s:increase_level(item) "{{{
|
||||
let additional_indent = 0
|
||||
if VimwikiGet('syntax') == 'media' && a:item.type == 1 &&
|
||||
if VimwikiGet('syntax') ==? 'media' && a:item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, a:item.mrkr .
|
||||
\ s:first_char(a:item.mrkr))
|
||||
@ -966,7 +966,7 @@ endfunction "}}}
|
||||
"a:indent_by can be negative
|
||||
function! s:indent_line_by(lnum, indent_by) "{{{
|
||||
let item = s:get_item(a:lnum)
|
||||
if VimwikiGet('syntax') == 'media' && item.type == 1 &&
|
||||
if VimwikiGet('syntax') ==? 'media' && item.type == 1 &&
|
||||
\ index(s:multiple_bullet_chars, s:first_char(item.mrkr)) > -1
|
||||
if a:indent_by > 0
|
||||
call s:substitute_string_in_line(a:lnum, item.mrkr,
|
||||
@ -983,17 +983,17 @@ endfunction "}}}
|
||||
function! s:change_level(from_line, to_line, direction, plus_children) "{{{
|
||||
let from_item = s:get_corresponding_item(a:from_line)
|
||||
if from_item.type == 0
|
||||
if a:direction == 'increase' && a:from_line == a:to_line &&
|
||||
if a:direction ==# 'increase' && a:from_line == a:to_line &&
|
||||
\ empty(getline(a:from_line))
|
||||
"that's because :> doesn't work on an empty line
|
||||
normal! gi
|
||||
else
|
||||
execute a:from_line.','.a:to_line.(a:direction == 'increase' ? '>' : '<')
|
||||
execute a:from_line.','.a:to_line.(a:direction ==# 'increase' ? '>' : '<')
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
if a:direction == 'decrease' && s:get_level(from_item.lnum) == 0
|
||||
if a:direction ==# 'decrease' && s:get_level(from_item.lnum) == 0
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1026,7 +1026,7 @@ function! s:change_level(from_line, to_line, direction, plus_children) "{{{
|
||||
let more_than_one_level_concerned = 0
|
||||
|
||||
let first_line_indented_by =
|
||||
\ (a:direction == 'increase') ?
|
||||
\ (a:direction ==# 'increase') ?
|
||||
\ s:increase_level(from_item) : s:decrease_level(from_item)
|
||||
|
||||
let cur_ln = s:get_next_line(from_item.lnum)
|
||||
@ -1121,7 +1121,7 @@ function! s:set_new_mrkr(item, new_mrkr) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
||||
let cur_col_from_eol = col("$") - (a:mode == "i" ? col("'^") : col('.'))
|
||||
let cur_col_from_eol = col("$") - (a:mode ==# "i" ? col("'^") : col('.'))
|
||||
let new_mrkr = a:new_mrkr
|
||||
let cur_ln = a:from_line
|
||||
while 1
|
||||
@ -1138,13 +1138,13 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
||||
"use *** if the item above has *** too
|
||||
let item_above = s:get_prev_list_item(cur_item, 1)
|
||||
if item_above.type == 1 &&
|
||||
\ s:first_char(item_above.mrkr) ==s:first_char(new_mrkr)
|
||||
\ s:first_char(item_above.mrkr) ==# s:first_char(new_mrkr)
|
||||
let new_mrkr = item_above.mrkr
|
||||
else
|
||||
"use *** if the item below has *** too
|
||||
let item_below = s:get_next_list_item(cur_item, 1)
|
||||
if item_below.type == 1 &&
|
||||
\ s:first_char(item_below.mrkr) == s:first_char(new_mrkr)
|
||||
\ s:first_char(item_below.mrkr) ==# s:first_char(new_mrkr)
|
||||
let new_mrkr = item_below.mrkr
|
||||
else
|
||||
"if the old is ### and the new is * use ***
|
||||
@ -1155,7 +1155,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) "{{{
|
||||
"use *** if the parent item has **
|
||||
let parent_item = s:get_parent(cur_item)
|
||||
if parent_item.type == 1 &&
|
||||
\ s:first_char(parent_item.mrkr) == s:first_char(new_mrkr)
|
||||
\ s:first_char(parent_item.mrkr) ==# s:first_char(new_mrkr)
|
||||
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
||||
\ s:string_length(parent_item.mrkr)+1)
|
||||
endif
|
||||
@ -1193,7 +1193,7 @@ endfunction "}}}
|
||||
|
||||
"sets kind of the item depending on neighbor items and the parent item
|
||||
function! s:adjust_mrkr(item) "{{{
|
||||
if a:item.type == 0 || VimwikiGet('syntax') == 'media'
|
||||
if a:item.type == 0 || VimwikiGet('syntax') ==? 'media'
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1208,7 +1208,7 @@ function! s:adjust_mrkr(item) "{{{
|
||||
\ index(s:multiple_bullet_chars, s:first_char(a:item.mrkr)) > -1
|
||||
let parent_item = s:get_parent(a:item)
|
||||
if parent_item.type == 1 &&
|
||||
\ s:first_char(parent_item.mrkr) == s:first_char(a:item.mrkr)
|
||||
\ s:first_char(parent_item.mrkr) ==# s:first_char(a:item.mrkr)
|
||||
let new_mrkr = repeat(s:first_char(parent_item.mrkr),
|
||||
\ s:string_length(parent_item.mrkr)+1)
|
||||
endif
|
||||
|
@ -81,11 +81,11 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso
|
||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
else
|
||||
if a:split == "split"
|
||||
if a:split ==# "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
elseif a:split ==# "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
elseif a:split ==# "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
|
@ -17,7 +17,7 @@ if vimwiki#u#is_windows()
|
||||
endfunction
|
||||
else
|
||||
function! vimwiki#path#is_equal(p1, p2)
|
||||
return a:p1 == a:p2
|
||||
return a:p1 ==# a:p2
|
||||
endfunction
|
||||
endif "}}}
|
||||
|
||||
@ -26,7 +26,7 @@ function! vimwiki#path#normalize(path) "{{{
|
||||
let path = a:path
|
||||
while 1
|
||||
let result = substitute(path, '/[^/]\+/\.\.', '', '')
|
||||
if result == path
|
||||
if result ==# path
|
||||
break
|
||||
endif
|
||||
let path = result
|
||||
|
@ -134,11 +134,11 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
for idx in range(strlen(a:line))
|
||||
" The only way I know Vim can do Unicode...
|
||||
let ch = a:line[idx]
|
||||
if state == 'NONE'
|
||||
if state ==# 'NONE'
|
||||
if ch == '|'
|
||||
let state = 'CELL'
|
||||
endif
|
||||
elseif state == 'CELL'
|
||||
elseif state ==# 'CELL'
|
||||
if ch == '[' || ch == '{'
|
||||
let state = 'BEFORE_QUOTE_START'
|
||||
let quote = ch
|
||||
@ -148,7 +148,7 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
else
|
||||
let cell .= ch
|
||||
endif
|
||||
elseif state == 'BEFORE_QUOTE_START'
|
||||
elseif state ==# 'BEFORE_QUOTE_START'
|
||||
if ch == '[' || ch == '{'
|
||||
let state = 'QUOTE'
|
||||
let quote .= ch
|
||||
@ -157,12 +157,12 @@ function! vimwiki#tbl#get_cells(line) "{{{
|
||||
let cell .= quote.ch
|
||||
let quote = ''
|
||||
endif
|
||||
elseif state == 'QUOTE'
|
||||
elseif state ==# 'QUOTE'
|
||||
if ch == ']' || ch == '}'
|
||||
let state = 'BEFORE_QUOTE_END'
|
||||
endif
|
||||
let quote .= ch
|
||||
elseif state == 'BEFORE_QUOTE_END'
|
||||
elseif state ==# 'BEFORE_QUOTE_END'
|
||||
if ch == ']' || ch == '}'
|
||||
let state = 'CELL'
|
||||
endif
|
||||
@ -495,7 +495,7 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
if !(&filetype ==? 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
@ -570,7 +570,7 @@ function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||
if !(&filetype == 'vimwiki')
|
||||
if !(&filetype ==? 'vimwiki')
|
||||
return
|
||||
endif
|
||||
let line = getline(a:lnum)
|
||||
|
@ -43,7 +43,7 @@ function! Complete_wikifiles(findstart, base)
|
||||
if startoflink != -1
|
||||
return startoflink
|
||||
endif
|
||||
if VimwikiGet('syntax') == 'markdown'
|
||||
if VimwikiGet('syntax') ==? 'markdown'
|
||||
let startofinlinelink = match(line, '\[.*\](\zs.*$')
|
||||
if startofinlinelink != -1
|
||||
return startofinlinelink
|
||||
|
@ -39,7 +39,8 @@ function! s:find_wiki(path) "{{{
|
||||
while idx < len(g:vimwiki_list)
|
||||
let idx_path = expand(VimwikiGet('path', idx))
|
||||
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
|
||||
if vimwiki#path#path_common_pfx(idx_path, path) == idx_path
|
||||
if vimwiki#path#is_equal(
|
||||
\ vimwiki#path#path_common_pfx(idx_path, path), idx_path)
|
||||
return idx
|
||||
endif
|
||||
let idx += 1
|
||||
@ -91,7 +92,7 @@ function! s:setup_buffer_leave() "{{{
|
||||
if g:vimwiki_debug == 3
|
||||
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
if &filetype == 'vimwiki'
|
||||
if &filetype ==? 'vimwiki'
|
||||
" cache global vars of current state XXX: SLOW!?
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endif
|
||||
@ -210,7 +211,7 @@ function! s:setup_buffer_enter() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
elseif &syntax == 'vimwiki'
|
||||
elseif &syntax ==? 'vimwiki'
|
||||
" to force a rescan of the filesystem which may have changed
|
||||
" and update VimwikiLinks syntax group that depends on it;
|
||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
||||
@ -227,15 +228,15 @@ function! s:setup_buffer_enter() "{{{
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding == 'expr'
|
||||
if g:vimwiki_folding ==? 'expr'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding == 'list' || g:vimwiki_folding == 'lists'
|
||||
elseif g:vimwiki_folding ==? 'list' || g:vimwiki_folding ==? 'lists'
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
elseif g:vimwiki_folding == 'syntax'
|
||||
elseif g:vimwiki_folding ==? 'syntax'
|
||||
setlocal fdm=syntax
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user