mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 07:00:04 +08:00
Hot fix for vim-todo (#3910)
This commit is contained in:
parent
b75e389edb
commit
eb26c88238
@ -198,6 +198,7 @@ EOT
|
||||
_detect autoload/SpaceVim/api/data/string.vim
|
||||
_detect autoload/SpaceVim/api/file.vim
|
||||
_detect autoload/SpaceVim/api/vim/buffer.vim
|
||||
_detect autoload/SpaceVim/api/vim/regex.vim
|
||||
_detect autoload/SpaceVim/api/vim/compatible.vim
|
||||
_detect autoload/SpaceVim/logger.vim
|
||||
_detect autoload/SpaceVim/mapping/search.vim
|
||||
|
@ -91,7 +91,7 @@ endfunction
|
||||
|
||||
function! s:self.win_close(id, focuce) abort
|
||||
return nvim_win_close(a:id, a:focuce)
|
||||
" @fixme: nvim_win_close only support one argv in old version
|
||||
" @fixme nvim_win_close only support one argv in old version
|
||||
try
|
||||
return nvim_win_close(a:id, a:focuce)
|
||||
catch /^Vim\%((\a\+)\)\=:E118/
|
||||
|
@ -44,7 +44,15 @@ function! s:self.parser(regex, is_perl) abort
|
||||
|
||||
" word boundary
|
||||
" \bword\b => <word>
|
||||
let vim_regex = substitute(vim_regex, '\\b\(\w\+\)\\b', '\\<\1\\>', 'g')
|
||||
let vim_regex = substitute(vim_regex, '\\b\(\w\+\)\\b', '<\1>', 'g')
|
||||
|
||||
" right word boundary
|
||||
" \bword => \<word
|
||||
let vim_regex = substitute(vim_regex, '\\b\(\w\+\)', '<\1', 'g')
|
||||
|
||||
" left word boundary
|
||||
" word\b => word\>
|
||||
let vim_regex = substitute(vim_regex, '\(\w\+\)\\b', '\1>', 'g')
|
||||
|
||||
" case-insensitive
|
||||
" (?i)abc => \cabc
|
||||
|
@ -913,7 +913,7 @@ endfunction
|
||||
" }}}
|
||||
|
||||
function! s:update_statusline() abort
|
||||
if !g:FlyGrep_enable_statusline
|
||||
if !get(g:, 'FlyGrep_enable_statusline', 1)
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -10,6 +10,7 @@ let s:JOB = SpaceVim#api#import('job')
|
||||
let s:BUFFER = SpaceVim#api#import('vim#buffer')
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
let s:LOG = SpaceVim#logger#derive('todo')
|
||||
let s:REG = SpaceVim#api#import('vim#regex')
|
||||
|
||||
|
||||
let [
|
||||
@ -65,10 +66,12 @@ function! s:update_todo_content() abort
|
||||
|
||||
let s:todos = []
|
||||
let s:todo = {}
|
||||
let s:labels_regex = s:get_labels_regex()
|
||||
let s:labels_partten = s:get_labels_pattern()
|
||||
let argv = [s:grep_default_exe] +
|
||||
\ s:grep_default_opt +
|
||||
\ s:grep_default_expr_opt
|
||||
let argv += [s:get_labels_regex()]
|
||||
let argv += [s:labels_regex]
|
||||
if s:SYS.isWindows && (s:grep_default_exe ==# 'rg' || s:grep_default_exe ==# 'ag' || s:grep_default_exe ==# 'pt' )
|
||||
let argv += ['.']
|
||||
elseif s:SYS.isWindows && s:grep_default_exe ==# 'findstr'
|
||||
@ -76,24 +79,27 @@ function! s:update_todo_content() abort
|
||||
endif
|
||||
let argv += s:grep_default_ropt
|
||||
call s:LOG.info('cmd: ' . string(argv))
|
||||
let jobid = s:JOB.start(argv, {
|
||||
call s:LOG.info(' labels_partten: ' . s:labels_partten)
|
||||
let s:todo_jobid = s:JOB.start(argv, {
|
||||
\ 'on_stdout' : function('s:stdout'),
|
||||
\ 'on_stderr' : function('s:stderr'),
|
||||
\ 'on_exit' : function('s:exit'),
|
||||
\ })
|
||||
call s:LOG.info('jobid: ' . string(jobid))
|
||||
call s:LOG.info('jobid: ' . string(s:todo_jobid))
|
||||
endfunction
|
||||
|
||||
function! s:stdout(id, data, event) abort
|
||||
if a:id !=# s:todo_jobid
|
||||
return
|
||||
endif
|
||||
for data in a:data
|
||||
call s:LOG.info('stdout: ' . data)
|
||||
if !empty(data)
|
||||
let file = fnameescape(split(data, ':\d\+:')[0])
|
||||
let line = matchstr(data, ':\d\+:')[1:-2]
|
||||
let column = matchstr(data, '\(:\d\+\)\@<=:\d\+:')[1:-2]
|
||||
let full_label = matchstr(data, s:get_labels_pattern())
|
||||
let trimmed_label = substitute(full_label, '\W', '', 'g')
|
||||
let title = get(split(data, full_label), 1, '')
|
||||
let label = matchstr(data, s:labels_partten)
|
||||
let title = get(split(data, label), 1, '')
|
||||
" @todo add time tag
|
||||
call add(s:todos,
|
||||
\ {
|
||||
@ -101,7 +107,7 @@ function! s:stdout(id, data, event) abort
|
||||
\ 'line' : line,
|
||||
\ 'column' : column,
|
||||
\ 'title' : title,
|
||||
\ 'label' : trimmed_label,
|
||||
\ 'label' : label,
|
||||
\ }
|
||||
\ )
|
||||
endif
|
||||
@ -109,21 +115,28 @@ function! s:stdout(id, data, event) abort
|
||||
endfunction
|
||||
|
||||
function! s:stderr(id, data, event) abort
|
||||
if a:id !=# s:todo_jobid
|
||||
return
|
||||
endif
|
||||
for date in a:data
|
||||
call s:LOG.info('stderr: ' . string(a:data))
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:exit(id, data, event ) abort
|
||||
call s:LOG.info('exit code: ' . string(a:data))
|
||||
if a:id !=# s:todo_jobid
|
||||
return
|
||||
endif
|
||||
call s:LOG.info('todomanager exit: ' . string(a:data))
|
||||
let s:todos = sort(s:todos, function('s:compare_todo'))
|
||||
let label_w = max(map(deepcopy(s:todos), 'strlen(v:val.label)'))
|
||||
let file_w = max(map(deepcopy(s:todos), 'strlen(v:val.file)'))
|
||||
let expr = "tolower(v:val.label) . repeat(' ', label_w - strlen(v:val.label)) . ' ' ."
|
||||
let expr = "v:val.label . repeat(' ', label_w - strlen(v:val.label)) . ' ' ."
|
||||
\ . "SpaceVim#api#import('file').unify_path(v:val.file, ':.') . repeat(' ', file_w - strlen(v:val.file)) . ' ' ."
|
||||
\ . 'v:val.title'
|
||||
\ . "v:val.title"
|
||||
let lines = map(deepcopy(s:todos),expr)
|
||||
call s:BUFFER.buf_set_lines(s:bufnr, 0 , -1, 0, lines)
|
||||
let g:wsd = s:todos
|
||||
endfunction
|
||||
|
||||
function! s:compare_todo(a, b) abort
|
||||
@ -159,13 +172,12 @@ function! s:get_labels_regex()
|
||||
let separator = '|'
|
||||
endif
|
||||
|
||||
return join(map(copy(s:labels),
|
||||
\ "(v:val[0] =~ '\w' ? '\\b' : '') . v:val . '\\b:?'"),
|
||||
return join(map(copy(s:labels), "v:val . '\\b'"),
|
||||
\ separator)
|
||||
endfunc
|
||||
|
||||
function! s:get_labels_pattern ()
|
||||
return '\C' . join(map(copy(s:labels), "(v:val[0] =~ '\w' ? '\\<' : '') . v:val . '\\>:\\?'"), '\|')
|
||||
function! s:get_labels_pattern()
|
||||
return s:REG.parser(s:get_labels_regex(), 0)
|
||||
endfunc
|
||||
|
||||
|
||||
|
@ -1242,17 +1242,7 @@ Config the command line prompt for flygrep and denite etc.
|
||||
|
||||
*g:spacevim_todo_labels*
|
||||
Option for setting todo labels in current project.
|
||||
By default, it matches "@todo", "@question", "@fixme" and "@idea".
|
||||
|
||||
The following configuration will match todos in the form "TODO", "FIXME" and
|
||||
"XXX".
|
||||
>
|
||||
let g:spacevim_todo_labels = [
|
||||
\ 'FIXME',
|
||||
\ 'TODO',
|
||||
\ 'XXX',
|
||||
\ ]
|
||||
<
|
||||
*g:spacevim_lint_on_the_fly*
|
||||
Enable/Disable lint on the fly feature of SpaceVim's maker. Default is 0.
|
||||
>
|
||||
|
@ -1,25 +1,25 @@
|
||||
if exists('b:current_syntax') && b:current_syntax ==# 'SpaceVimTasksInfo'
|
||||
finish
|
||||
endif
|
||||
let b:current_syntax = 'SpaceVimTasksInfo'
|
||||
syntax case ignore
|
||||
|
||||
syn match TaskName /^\[.*\]/
|
||||
syn match TaskTitle /^Task\s\+Type\s\+Command/
|
||||
|
||||
" @question Why \zs does not work in syntax file?
|
||||
" ref:
|
||||
" https://github.com/vim/vim/issues/598
|
||||
" https://stackoverflow.com/questions/49323753/vim-syntax-file-not-matching-with-zs
|
||||
" https://stackoverflow.com/questions/64153655/why-taskinfo-syntax-file-does-not-work-as-expect
|
||||
" syn match TaskType /^\[.*\]\s*\zs[a-z]*/
|
||||
" syn match TaskDescription /^\[.*\]\s*[a-z]*\s\+\zs.*/
|
||||
|
||||
syn match TaskType /\(^\[.\+\]\s\+\)\@<=[a-z]*/
|
||||
syn match TaskDescription /\(^\[.*\]\s\+[a-z]\+\s\+\)\@<=.*/
|
||||
hi def link TaskTitle Title
|
||||
hi def link TaskName String
|
||||
hi def link TaskType Todo
|
||||
hi def link TaskDescription Comment
|
||||
|
||||
|
||||
if exists('b:current_syntax') && b:current_syntax ==# 'SpaceVimTasksInfo'
|
||||
finish
|
||||
endif
|
||||
let b:current_syntax = 'SpaceVimTasksInfo'
|
||||
syntax case ignore
|
||||
|
||||
syn match TaskName /^\[.*\]/
|
||||
syn match TaskTitle /^Task\s\+Type\s\+Command/
|
||||
|
||||
" @question Why \zs does not work in syntax file?
|
||||
" ref:
|
||||
" https://github.com/vim/vim/issues/598
|
||||
" https://stackoverflow.com/questions/49323753/vim-syntax-file-not-matching-with-zs
|
||||
" https://stackoverflow.com/questions/64153655/why-taskinfo-syntax-file-does-not-work-as-expect
|
||||
" syn match TaskType /^\[.*\]\s*\zs[a-z]*/
|
||||
" syn match TaskDescription /^\[.*\]\s*[a-z]*\s\+\zs.*/
|
||||
|
||||
syn match TaskType /\(^\[.\+\]\s\+\)\@<=[a-z]*/
|
||||
syn match TaskDescription /\(^\[.*\]\s\+[a-z]\+\s\+\)\@<=.*/
|
||||
hi def link TaskTitle Title
|
||||
hi def link TaskName String
|
||||
hi def link TaskType Todo
|
||||
hi def link TaskDescription Comment
|
||||
|
||||
|
||||
|
@ -4,12 +4,10 @@ endif
|
||||
let b:current_syntax = 'SpaceVimTodoManager'
|
||||
syntax case ignore
|
||||
|
||||
syn match FileName /\(^\S\+\s\+\)\@<=[^ ]*/
|
||||
syn match FileName /\(@[a-zA-Z]*\s\+\)\@<=[^ ]*/
|
||||
syn match TODOTAG /^\s*@[a-zA-Z]*/
|
||||
syn match TODOTAG /^\s*@\?todo*/
|
||||
syn match TODOQUESTION /^\s*@ques[a-z]*/
|
||||
syn match TODOFIXME /^\s*@\?fixm[a-z]*/
|
||||
syn match TODOFIXME /^\s*@\?xxx*/
|
||||
syn match TODOFIXME /^\s*@fixm[a-z]*/
|
||||
" syn match TODOCHECKBOX /[\d\+/\d\+\]/
|
||||
syn match TODOINDEX /^\s\+\d\+\.\s/
|
||||
syn match TODOCHECKBOXPANDING /\s\+√\s\+/
|
||||
@ -20,4 +18,3 @@ hi def link FileName Comment
|
||||
hi def link TODOTAG Todo
|
||||
hi def link TODOQUESTION Question
|
||||
hi def link TODOFIXME ErrorMsg
|
||||
|
||||
|
@ -5,7 +5,9 @@ Execute ( SpaceVim api: vim#key ):
|
||||
AssertEqual regex.parser('(?:exp)', 0), '\v%(exp)'
|
||||
AssertEqual regex.parser('\a\f\v', 0), '\v%x07%x0C%x0B'
|
||||
AssertEqual regex.parser('[:word:]', 0), '\v[0-9A-Za-z_]'
|
||||
AssertEqual regex.parser('\bspace\b', 0), '\v\<space\>'
|
||||
AssertEqual regex.parser('\bspace\b', 0), '\v<space>'
|
||||
AssertEqual regex.parser('\bspace', 0), '\v<space'
|
||||
AssertEqual regex.parser('space\b', 0), '\vspace>'
|
||||
AssertEqual regex.parser('if%@&ab', 0), '\vif\%\@\&ab'
|
||||
AssertEqual regex.parser('(?P<name>exp)', 0), '\v(exp)'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user