1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:40:03 +08:00

Improve todo manager (#2942)

This commit is contained in:
Wang Shidong 2019-07-11 18:26:29 +08:00 committed by GitHub
parent d206f949b6
commit a446220add
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 59 additions and 8 deletions

View File

@ -9,8 +9,8 @@
let s:JOB = SpaceVim#api#import('job')
let s:BUFFER = SpaceVim#api#import('vim#buffer')
let s:labels = map(['todo', 'fixme'], '"@" . v:val')
" @question any other recommanded tag?
let s:labels = map(['fixme', 'question', 'todo', 'idea'], '"@" . v:val')
function! SpaceVim#dev#todo#list() abort
call s:open_win()
@ -37,7 +37,7 @@ function! s:update_todo_content() abort
let s:todos = []
let s:todo = {}
" @fixme fix the rg command for todo manager
let argv = ['rg','--hidden', '--no-heading', '--color=never', '--with-filename', '--line-number', '--column', '-e', join(s:labels, '|'), '.']
let argv = ['rg','--hidden', '--no-heading', '-g', '!.git', '--color=never', '--with-filename', '--line-number', '--column', '-e', join(s:labels, '|'), '.']
call SpaceVim#logger#info('todo cmd:' . string(argv))
let jobid = s:JOB.start(argv, {
\ 'on_stdout' : function('s:stdout'),
@ -56,6 +56,7 @@ function! s:stdout(id, data, event) abort
let column = matchstr(data, '\(:\d\+\)\@<=:\d\+:')[1:-2]
let lebal = matchstr(data, join(s:labels, '\|'))
let title = split(data, lebal)[1]
" @todo add time tag
call add(s:todos,
\ {
\ 'file' : file,
@ -75,6 +76,7 @@ endfunction
function! s:exit(id, data, event ) abort
call SpaceVim#logger#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.lebal)'))
let file_w = max(map(deepcopy(s:todos), 'strlen(v:val.file)'))
let expr = "v:val.lebal . repeat(' ', label_w - strlen(v:val.lebal)) . ' ' ."
@ -84,6 +86,11 @@ function! s:exit(id, data, event ) abort
call s:BUFFER.buf_set_lines(s:bufnr, 0 , -1, 0, lines)
endfunction
function! s:compare_todo(a, b) abort
let a = index(s:labels, a:a.lebal)
let b = index(s:labels, a:b.lebal)
return a == b ? 0 : a > b ? 1 : -1
endfunction
function! s:open_todo() abort
let todo = s:todos[line('.') - 1]

View File

@ -16,6 +16,11 @@ call SpaceVim#custom#SPC('nnoremap', ['a', 'o'], 'call SpaceVim#dev#todo#list()'
let &runtimepath .= ',' . fnamemodify(g:_spacevim_root_dir, ':p:h') . '/build/vader'
augroup vader_filetype
autocmd!
autocmd FileType vader-result setlocal nobuflisted
augroup END
" vader language specific key bindings
function! s:language_specified_mappings() abort

View File

@ -6,6 +6,8 @@ syntax case ignore
syn match FileName /\(@[a-zA-Z]*\s\+\)\@<=[^ ]*/
syn match TODOTAG /^\s*@[a-zA-Z]*/
syn match TODOQUESTION /^\s*@ques[a-z]*/
syn match TODOFIXME /^\s*@fixm[a-z]*/
" syn match TODOCHECKBOX /[\d\+/\d\+\]/
syn match TODOINDEX /^\s\+\d\+\.\s/
syn match TODOCHECKBOXPANDING /\s\+√\s\+/
@ -14,3 +16,5 @@ syn match TODOCHECKBOXNOTE /\s\+·\s\+/
syn match TODODUETIME /\d\+[d]$\|\d\+[d]\s\*$/
hi def link FileName Comment
hi def link TODOTAG Todo
hi def link TODOQUESTION Question
hi def link TODOFIXME ErrorMsg

View File

@ -21,14 +21,14 @@ let g:neomake_verbose = get(g:, 'neomake_verbose', 0)
let g:neomake_java_javac_delete_output = get(g:, 'neomake_java_javac_delete_output', 0)
let g:neomake_error_sign = get(g:, 'neomake_error_sign', {
\ 'text': get(g:, 'spacevim_error_symbol', '✖'),
\ 'texthl': (g:spacevim_colorscheme ==# 'gruvbox' ? 'GruvboxRedSign' : 'error'),
\ 'texthl': (get(g:, 'spacevim_colorscheme', 'gruvbox') ==# 'gruvbox' ? 'GruvboxRedSign' : 'error'),
\ })
let g:neomake_warning_sign = get(g:, 'neomake_warning_sign', {
\ 'text': get(g:,'spacevim_warning_symbol', '➤'),
\ 'texthl': (g:spacevim_colorscheme ==# 'gruvbox' ? 'GruvboxYellowSign' : 'todo'),
\ 'texthl': (get(g:, 'spacevim_colorscheme', 'gruvbox') ==# 'gruvbox' ? 'GruvboxYellowSign' : 'todo'),
\ })
let g:neomake_info_sign = get(g:, 'neomake_info_sign', {
\ 'text': get(g:,'spacevim_info_symbol', '🛈'),
\ 'texthl': (g:spacevim_colorscheme ==# 'gruvbox' ? 'GruvboxYellowSign' : 'todo'),
\ 'texthl': (get(g:, 'spacevim_colorscheme', 'gruvbox') ==# 'gruvbox' ? 'GruvboxYellowSign' : 'todo'),
\ })
" vim:set et sw=2:

View File

@ -1,5 +1,5 @@
let s:VCOP = SpaceVim#api#import('vim#compatible')
if g:spacevim_filetree_direction ==# 'right'
if get(g:, 'spacevim_filetree_direction', 'right') ==# 'right'
let g:NERDTreeWinPos = 'rightbelow'
else
let g:NERDTreeWinPos = 'left'

View File

@ -1,5 +1,5 @@
scriptencoding utf-8
let g:airline_powerline_fonts = g:spacevim_enable_powerline_fonts
let g:airline_powerline_fonts = get(g:, 'spacevim_enable_powerline_fonts', 1)
let g:airline_skip_empty_sections = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tmuxline#enabled = 1

View File

View File

@ -0,0 +1,12 @@
-- @idea add list lua api
-- pop({list})
local list = {}
function list.pop(l)
end
return list

View File

@ -0,0 +1 @@
-- @todo add lua string api

View File

@ -0,0 +1,4 @@
Execute ( Plugin config: LeaderF.vim ):
so config/plugins/LeaderF.vim

2
test/config/goyo.vader Normal file
View File

@ -0,0 +1,2 @@
Execute ( Plugin config: goyo.vim ):
so config/plugins/goyo.vim

View File

@ -0,0 +1,3 @@
Execute ( Plugin config: java_getset.vim ):
so config/plugins/java_getset.vim

View File

@ -0,0 +1,3 @@
Execute ( Plugin config: neomake.vim ):
so config/plugins/neomake.vim

View File

@ -0,0 +1,3 @@
Execute ( Plugin config: nerdtree.vim ):
so config/plugins/nerdtree.vim

View File

@ -0,0 +1,3 @@
Execute ( Plugin config: vim-airline.vim ):
so config/plugins/vim-airline.vim

View File

@ -0,0 +1,4 @@
Execute ( Plugin config: vim-ref.vim ):
so config/plugins/vim-ref.vim
AssertEqual g:ref_source_webdict_sites.default, 'cn'