mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:40:03 +08:00
Add todo manager (#1939)
This commit is contained in:
parent
88606a9af4
commit
04dc1a1fa4
79
.SpaceVim.d/autoload/SpaceVim/dev/todo.vim
Normal file
79
.SpaceVim.d/autoload/SpaceVim/dev/todo.vim
Normal file
@ -0,0 +1,79 @@
|
||||
"=============================================================================
|
||||
" todo.vim --- todo manager for SpaceVim
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#dev#todo#list() abort
|
||||
call s:open_win()
|
||||
endfunction
|
||||
|
||||
let s:JOB = SpaceVim#api#import('job')
|
||||
|
||||
let s:bufnr = 0
|
||||
|
||||
function! s:open_win() abort
|
||||
if s:bufnr != 0 && bufexists(s:bufnr)
|
||||
exe 'bd ' . s:bufnr
|
||||
endif
|
||||
botright split __todo_manager__
|
||||
let lines = &lines * 30 / 100
|
||||
exe 'resize ' . lines
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber winfixheight nomodifiable
|
||||
set filetype=SpaceVimTodoManager
|
||||
let s:bufnr = bufnr('%')
|
||||
call s:update_todo_content()
|
||||
nnoremap <buffer><silent> <Enter> :call <SID>open_todo()<cr>
|
||||
endfunction
|
||||
|
||||
function! s:update_todo_content() abort
|
||||
let s:todos = []
|
||||
let argv = ['rg', '--hidden', '--no-heading', '--color=never', '--with-filename', '--line-number', '--column',
|
||||
\ '-g', '!.git','@t'. 'odo ']
|
||||
call s:JOB.start(argv, {
|
||||
\ 'on_stdout' : function('s:stdout'),
|
||||
\ 'on_exit' : function('s:exit'),
|
||||
\ })
|
||||
endfunction
|
||||
|
||||
function! s:stdout(id, data, event) abort
|
||||
for data in a: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 title = split(data, '@todo')[1]
|
||||
call add(s:todos,
|
||||
\ {
|
||||
\ 'file' : file,
|
||||
\ 'line' : line,
|
||||
\ 'column' : column,
|
||||
\ 'title' : title,
|
||||
\ }
|
||||
\ )
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:exit(id, data, event ) abort
|
||||
let g:lines = map(deepcopy(s:todos), "v:val.file . ' ' . v:val.title")
|
||||
call setline(1, g:lines)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:open_todo() abort
|
||||
let todo = s:todos[line('.') - 1]
|
||||
try
|
||||
close
|
||||
catch
|
||||
endtry
|
||||
exe 'e ' . todo.file
|
||||
call cursor(todo.line, todo.column)
|
||||
noautocmd normal! :
|
||||
endfunction
|
||||
|
||||
" @todo fuzzy find todo list
|
||||
" after open todo manager buffer, we should be able to fuzzy find the item we
|
||||
" need.
|
@ -10,3 +10,4 @@ let g:spacevim_force_global_config = 1
|
||||
call SpaceVim#custom#SPC('nnoremap', ['a', 'r'], 'call SpaceVim#dev#releases#open()', 'Release SpaceVim', 1)
|
||||
call SpaceVim#custom#SPC('nnoremap', ['a', 'w'], 'call SpaceVim#dev#website#open()', 'Open SpaceVim local website', 1)
|
||||
call SpaceVim#custom#SPC('nnoremap', ['a', 't'], 'call SpaceVim#dev#website#terminal()', 'Close SpaceVim local website', 1)
|
||||
call SpaceVim#custom#SPC('nnoremap', ['a', 'o'], 'call SpaceVim#dev#todo#list()', 'Open todo manager', 1)
|
||||
|
8
.SpaceVim.d/syntax/SpaceVimTodoManager.vim
Normal file
8
.SpaceVim.d/syntax/SpaceVimTodoManager.vim
Normal file
@ -0,0 +1,8 @@
|
||||
if exists('b:current_syntax') && b:current_syntax ==# 'SpaceVimTodoManager'
|
||||
finish
|
||||
endif
|
||||
let b:current_syntax = 'SpaceVimTodoManager'
|
||||
syntax case ignore
|
||||
|
||||
syn match FileName /^[^ ]*/
|
||||
hi def link FileName Comment
|
@ -343,7 +343,9 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# LayerManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimGitLogPopup'
|
||||
return '%#SpaceVim_statusline_a# Git log popup %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
||||
return '%#SpaceVim_statusline_a# Git log popup %#SpaceVim_statusline_a_SpaceVim_statusline_b# '
|
||||
elseif &filetype ==# 'SpaceVimTodoManager'
|
||||
return '%#SpaceVim_statusline_a# TODO manager %#SpaceVim_statusline_a_SpaceVim_statusline_b# '
|
||||
elseif &filetype ==# 'SpaceVimPlugManager'
|
||||
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# PlugManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
||||
|
@ -71,6 +71,7 @@ The next release is v0.9.0.
|
||||
### Others
|
||||
|
||||
- Fix ci lint ([#1946](https://github.com/SpaceVim/SpaceVim/pull/1946), [#1945](https://github.com/SpaceVim/SpaceVim/pull/1945), [#1944](https://github.com/SpaceVim/SpaceVim/pull/1944), [#1942](https://github.com/SpaceVim/SpaceVim/pull/1942))
|
||||
- Add todo manager for SpaceVim development ([#1939](https://github.com/SpaceVim/SpaceVim/pull/1939))
|
||||
|
||||
## Latest Release
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user