1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-22 08:45:42 +08:00

Improve todo plugins (#3276)

This commit is contained in:
Wang Shidong 2020-01-01 23:00:30 +08:00 committed by GitHub
parent 4a2edb3047
commit ef36d19f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,15 +34,26 @@ function! s:open_win() abort
exe 'bd ' . s:bufnr exe 'bd ' . s:bufnr
endif endif
botright split __todo_manager__ botright split __todo_manager__
" @todo add win_getid api
let s:winid = win_getid(winnr('#'))
let lines = &lines * 30 / 100 let lines = &lines * 30 / 100
exe 'resize ' . lines exe 'resize ' . lines
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber winfixheight nomodifiable setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber winfixheight nomodifiable
set filetype=SpaceVimTodoManager set filetype=SpaceVimTodoManager
let s:bufnr = bufnr('%') let s:bufnr = bufnr('%')
call s:update_todo_content() call s:update_todo_content()
augroup spacevim_plugin_todo
autocmd! * <buffer>
autocmd WinEnter <buffer> call s:WinEnter()
augroup END
nnoremap <buffer><silent> <Enter> :call <SID>open_todo()<cr> nnoremap <buffer><silent> <Enter> :call <SID>open_todo()<cr>
endfunction endfunction
function! s:WinEnter() abort
" @todo add win_getid api
let s:winid = win_getid(winnr('#'))
endfunction
" @todo Improve todo manager " @todo Improve todo manager
function! s:update_todo_content() abort function! s:update_todo_content() abort
let s:todos = [] let s:todos = []
@ -128,6 +139,8 @@ function! s:open_todo() abort
close close
catch catch
endtry endtry
" @todo add win_gotoid api
call win_gotoid(s:winid)
exe 'e ' . todo.file exe 'e ' . todo.file
call cursor(todo.line, todo.column) call cursor(todo.line, todo.column)
noautocmd normal! : noautocmd normal! :