Prettyfy: Plugin: Comment and one antipattern

This commit is contained in:
Tinmarino 2020-08-13 01:59:47 -04:00
parent 0b85dd1a7b
commit d93858509d

View File

@ -92,7 +92,6 @@ function! s:setup_new_wiki_buffer() abort
" this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
" sourced
call vimwiki#u#ft_set()
endfunction
@ -260,37 +259,40 @@ endif
" Write a level 1 header to new wiki files
" a:fname should be an absolute filepath
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')
" don't do anything for unregistered wikis
if idx == -1
return
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,
\ 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))
return
endif
" get tail of filename without extension
" Get tail of filename without extension
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)
return
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'
" NOTE: it is possible this could remove desired characters if the 'links_space_char'
" character matches characters that are intentionally used in the title.
let title = substitute(title, vimwiki#vars#get_wikilocal('links_space_char'), ' ', 'g')
endif
" insert the header
" Insert the header
if vimwiki#vars#get_wikilocal('syntax') ==? 'markdown'
keepjumps call append(0, '# ' . title)
for _ in range(vimwiki#vars#get_global('markdown_header_style'))
@ -299,7 +301,6 @@ function! s:create_h1(fname) abort
else
keepjumps call append(0, '= ' . title . ' =')
endif
endif
endfunction
" 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
augroup filetypedetect
" clear FlexWiki's stuff
" Clear FlexWiki's stuff
au! * *.wiki
augroup end
endif