mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-18 21:33:07 +02:00
syntax: Move TaskwikiFoldText to autoload
Avoids useless reloading of the function. In practice, probably harmless, but it doesn't belong there, and neither does setting foldmethod/foldtext, and that is actually harmful (see further commits).
This commit is contained in:
parent
94409fd372
commit
2ab876a80a
2 changed files with 15 additions and 14 deletions
|
@ -56,19 +56,6 @@ if !exists('g:taskwiki_disable_concealcursor')
|
|||
endif
|
||||
|
||||
" Configure custom FoldText function
|
||||
" Altered version of the VimwikiFoldText
|
||||
setlocal foldmethod=syntax
|
||||
setlocal foldtext=taskwiki#FoldText()
|
||||
setlocal viewoptions-=options
|
||||
|
||||
function! TaskwikiFoldText()
|
||||
let line = getline(v:foldstart)
|
||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||
let short_text = substitute(main_text, '|[^=]* =', '=', '')
|
||||
let short_text = substitute(short_text, '@[^=]* =', '=', '')
|
||||
let short_text = substitute(short_text, ' @[A-Za-z0-9]\+', '', '')
|
||||
let fold_len = v:foldend - v:foldstart + 1
|
||||
let len_text = ' ['.fold_len.'] '
|
||||
return short_text.len_text.repeat(' ', 500)
|
||||
endfunction
|
||||
|
||||
setlocal foldtext=TaskwikiFoldText()
|
||||
|
|
14
autoload/taskwiki.vim
Normal file
14
autoload/taskwiki.vim
Normal file
|
@ -0,0 +1,14 @@
|
|||
if exists('g:loaded_taskwiki_auto') | finish | endif
|
||||
let g:loaded_taskwiki_auto = 1
|
||||
|
||||
" Altered version of the VimwikiFoldText, strips viewport params
|
||||
function! taskwiki#FoldText()
|
||||
let line = getline(v:foldstart)
|
||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||
let short_text = substitute(main_text, '|[^=]* =', '=', '')
|
||||
let short_text = substitute(short_text, '@[^=]* =', '=', '')
|
||||
let short_text = substitute(short_text, ' @[A-Za-z0-9]\+', '', '')
|
||||
let fold_len = v:foldend - v:foldstart + 1
|
||||
let len_text = ' ['.fold_len.'] '
|
||||
return short_text.len_text.repeat(' ', 500)
|
||||
endfunction
|
Loading…
Add table
Add a link
Reference in a new issue