Prettyfy: Plugin: Comment and one antipattern
This commit is contained in:
parent
0b85dd1a7b
commit
d93858509d
@ -92,7 +92,6 @@ function! s:setup_new_wiki_buffer() abort
|
|||||||
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
|
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
|
||||||
" sourced
|
" sourced
|
||||||
call vimwiki#u#ft_set()
|
call vimwiki#u#ft_set()
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@ -260,37 +259,40 @@ endif
|
|||||||
" Write a level 1 header to new wiki files
|
" Write a level 1 header to new wiki files
|
||||||
" a:fname should be an absolute filepath
|
" a:fname should be an absolute filepath
|
||||||
function! s:create_h1(fname) abort
|
function! s:create_h1(fname) abort
|
||||||
if vimwiki#vars#get_global('auto_header')
|
" Clause: Don't do anything for unregistered wikis
|
||||||
let idx = vimwiki#vars#get_bufferlocal('wiki_nr')
|
let idx = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
|
|
||||||
" don't do anything for unregistered wikis
|
|
||||||
if idx == -1
|
if idx == -1
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" don't create header for the diary index page
|
" Clause: no auto_header
|
||||||
|
if !vimwiki#vars#get_global('auto_header')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Clause: don't create header for the diary index page
|
||||||
if vimwiki#path#is_equal(a:fname,
|
if vimwiki#path#is_equal(a:fname,
|
||||||
\ vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx).
|
\ vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx).
|
||||||
\ vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx))
|
\ vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx))
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" get tail of filename without extension
|
" Get tail of filename without extension
|
||||||
let title = expand('%:t:r')
|
let title = expand('%:t:r')
|
||||||
|
|
||||||
" don't insert header for index page
|
" Clause: don't insert header for index page
|
||||||
if title ==# vimwiki#vars#get_wikilocal('index', idx)
|
if title ==# vimwiki#vars#get_wikilocal('index', idx)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" don't substitute space char for diary pages
|
" Don't substitute space char for diary pages
|
||||||
if title !~# '^\d\{4}-\d\d-\d\d'
|
if title !~# '^\d\{4}-\d\d-\d\d'
|
||||||
" NOTE: it is possible this could remove desired characters if the 'links_space_char'
|
" NOTE: it is possible this could remove desired characters if the 'links_space_char'
|
||||||
" character matches characters that are intentionally used in the title.
|
" character matches characters that are intentionally used in the title.
|
||||||
let title = substitute(title, vimwiki#vars#get_wikilocal('links_space_char'), ' ', 'g')
|
let title = substitute(title, vimwiki#vars#get_wikilocal('links_space_char'), ' ', 'g')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" insert the header
|
" Insert the header
|
||||||
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
|
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
|
||||||
keepjumps call append(0, '# ' . title)
|
keepjumps call append(0, '# ' . title)
|
||||||
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
|
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
|
||||||
@ -299,7 +301,6 @@ function! s:create_h1(fname) abort
|
|||||||
else
|
else
|
||||||
keepjumps call append(0, '= ' . title . ' =')
|
keepjumps call append(0, '= ' . title . ' =')
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Define autocommands for all known wiki extensions
|
" Define autocommands for all known wiki extensions
|
||||||
@ -307,7 +308,7 @@ let s:known_extensions = s:vimwiki_get_known_extensions()
|
|||||||
|
|
||||||
if index(s:known_extensions, '.wiki') > -1
|
if index(s:known_extensions, '.wiki') > -1
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" clear FlexWiki's stuff
|
" Clear FlexWiki's stuff
|
||||||
au! * *.wiki
|
au! * *.wiki
|
||||||
augroup end
|
augroup end
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user