mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:10:04 +08:00
Add todo syntax (#2361)
* Add todo syntax * Remove error hi * Add debug info * Add todo manager
This commit is contained in:
parent
99faefc2cf
commit
4d8176fbe2
@ -28,23 +28,25 @@ function! s:open_win() abort
|
|||||||
nnoremap <buffer><silent> <Enter> :call <SID>open_todo()<cr>
|
nnoremap <buffer><silent> <Enter> :call <SID>open_todo()<cr>
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" @todo Improve todo manager
|
||||||
function! s:update_todo_content() abort
|
function! s:update_todo_content() abort
|
||||||
let s:todos = []
|
let s:todos = []
|
||||||
let argv = ['rg', '--hidden', '--no-heading', '--color=never', '--with-filename', '--line-number', '--column',
|
let argv = ['findstr', '/RSN', '/I', '@t'. 'odo ', '*.*']
|
||||||
\ '-g', '!.git','@t'. 'odo ']
|
|
||||||
call s:JOB.start(argv, {
|
call s:JOB.start(argv, {
|
||||||
\ 'on_stdout' : function('s:stdout'),
|
\ 'on_stdout' : function('s:stdout'),
|
||||||
|
\ 'on_stderr' : function('s:stderr'),
|
||||||
\ 'on_exit' : function('s:exit'),
|
\ 'on_exit' : function('s:exit'),
|
||||||
\ })
|
\ })
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:stdout(id, data, event) abort
|
function! s:stdout(id, data, event) abort
|
||||||
|
call SpaceVim#logger#info('todomanager stdout: ' . string(a:data))
|
||||||
for data in a:data
|
for data in a:data
|
||||||
if !empty(data)
|
if !empty(data)
|
||||||
let file = fnameescape(split(data, ':\d\+:')[0])
|
let file = fnameescape(split(data, ':\d\+:')[0])
|
||||||
let line = matchstr(data, ':\d\+:')[1:-2]
|
let line = matchstr(data, ':\d\+:')[1:-2]
|
||||||
let column = matchstr(data, '\(:\d\+\)\@<=:\d\+:')[1:-2]
|
let column = matchstr(data, '\(:\d\+\)\@<=:\d\+:')[1:-2]
|
||||||
let title = split(data, '@todo')[1]
|
let title = split(data, '@to' . 'do')[1]
|
||||||
call add(s:todos,
|
call add(s:todos,
|
||||||
\ {
|
\ {
|
||||||
\ 'file' : file,
|
\ 'file' : file,
|
||||||
@ -57,9 +59,16 @@ function! s:stdout(id, data, event) abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:stderr(id, data, event) abort
|
||||||
|
call SpaceVim#logger#info('todomanager stderr: ' . string(a:data))
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:exit(id, data, event ) abort
|
function! s:exit(id, data, event ) abort
|
||||||
|
call SpaceVim#logger#info('todomanager exit: ' . string(a:data))
|
||||||
let g:lines = map(deepcopy(s:todos), "v:val.file . ' ' . v:val.title")
|
let g:lines = map(deepcopy(s:todos), "v:val.file . ' ' . v:val.title")
|
||||||
|
call setbufvar(s:bufnr, '&modifiable', 1)
|
||||||
call setline(1, g:lines)
|
call setline(1, g:lines)
|
||||||
|
call setbufvar(s:bufnr, '&modifiable', 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,4 +5,11 @@ let b:current_syntax = 'SpaceVimTodoManager'
|
|||||||
syntax case ignore
|
syntax case ignore
|
||||||
|
|
||||||
syn match FileName /^[^ ]*/
|
syn match FileName /^[^ ]*/
|
||||||
|
syn match TODOTAG /^\s*@[a-zA-Z]*/
|
||||||
|
" syn match TODOCHECKBOX /[\d\+/\d\+\]/
|
||||||
|
syn match TODOINDEX /^\s\+\d\+\.\s/
|
||||||
|
syn match TODOCHECKBOXPANDING /\s\+√\s\+/
|
||||||
|
syn match TODOCHECKBOXDONE /\s\+□\s\+/
|
||||||
|
syn match TODOCHECKBOXNOTE /\s\+·\s\+/
|
||||||
|
syn match TODODUETIME /\d\+[d]$\|\d\+[d]\s\*$/
|
||||||
hi def link FileName Comment
|
hi def link FileName Comment
|
||||||
|
@ -248,6 +248,10 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
function! s:self.set_buf_line() abort
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#api#vim#compatible#get() abort
|
function! SpaceVim#api#vim#compatible#get() abort
|
||||||
return deepcopy(s:self)
|
return deepcopy(s:self)
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user