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

feat(todo): add todo_close_list option

This commit is contained in:
Eric Wong 2024-03-24 21:46:37 +08:00
parent 714e3b41ca
commit 833c9ac3d0
4 changed files with 42 additions and 16 deletions

View File

@ -1278,6 +1278,17 @@ let g:spacevim_commandline_prompt = '>'
" Option for setting todo labels in current project.
let g:spacevim_todo_labels = ['fixme', 'question', 'todo', 'idea']
""
" @section todo_close_list, options-close_list
" @parentsection options
" Option for setting todo windows behavior when open item in todo list.
" Default is `true`, set to `false` will not close todo windows.
""
" Option for setting todo windows behavior when open item in todo list.
" Default is 1, set to 0 will not close todo windows.
let g:spacevim_todo_close_list = 0
""
" @section todo_prefix, options-todo_prefix
" @parentsection options

View File

@ -166,10 +166,12 @@ endfunction
function! s:open_todo() abort
let todo = s:todos[line('.') - 1]
try
close
catch
endtry
if g:spacevim_todo_close_list
try
close
catch
endtry
endif
exe s:winnr . 'wincmd w'
exe 'e ' . todo.file
call cursor(todo.line, todo.column)
@ -191,7 +193,7 @@ function! s:get_labels_regex()
endif
return join(map(copy(s:labels), "s:prefix . v:val . '\\b'"),
\ separator)
\ separator)
endfunc
function! s:get_labels_pattern()

View File

@ -83,16 +83,17 @@ CONTENTS *SpaceVim-contents*
63. statusline_separator.........|SpaceVim-options-statusline_separator|
64. statusline_unicode.............|SpaceVim-options-statusline_unicode|
65. terminal_cursor_shape.......|SpaceVim-options-terminal_cursor_shape|
66. todo_labels...........................|SpaceVim-options-todo_labels|
67. todo_prefix...........................|SpaceVim-options-todo_prefix|
68. vim_help_language...............|SpaceVim-options-vim_help_language|
69. vimcompatible.......................|SpaceVim-options-vimcompatible|
70. warning_symbol.....................|SpaceVim-options-warning_symbol|
71. wildignore.............................|SpaceVim-options-wildignore|
72. windisk_encoding.................|SpaceVim-options-windisk_encoding|
73. windows_index_type.............|SpaceVim-options-windows_index_type|
74. windows_leader.....................|SpaceVim-options-windows_leader|
75. windows_smartclose.............|SpaceVim-options-windows_smartclose|
66. todo_close_list........................|SpaceVim-options-close_list|
67. todo_labels...........................|SpaceVim-options-todo_labels|
68. todo_prefix...........................|SpaceVim-options-todo_prefix|
69. vim_help_language...............|SpaceVim-options-vim_help_language|
70. vimcompatible.......................|SpaceVim-options-vimcompatible|
71. warning_symbol.....................|SpaceVim-options-warning_symbol|
72. wildignore.............................|SpaceVim-options-wildignore|
73. windisk_encoding.................|SpaceVim-options-windisk_encoding|
74. windows_index_type.............|SpaceVim-options-windows_index_type|
75. windows_leader.....................|SpaceVim-options-windows_leader|
76. windows_smartclose.............|SpaceVim-options-windows_smartclose|
3. Configuration...........................................|SpaceVim-config|
4. Commands..............................................|SpaceVim-commands|
5. Public functions.....................................|SpaceVim-functions|
@ -927,6 +928,12 @@ the following to ~/.tmux.conf:
set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
<
==============================================================================
TODO_CLOSE_LIST *SpaceVim-options-close_list*
Option for setting todo windows behavior when open item in todo list. Default
is `true`, set to `false` will not close todo windows.
==============================================================================
TODO_LABELS *SpaceVim-options-todo_labels*
@ -1531,6 +1538,10 @@ Config the command line prompt for flygrep and denite etc.
*g:spacevim_todo_labels*
Option for setting todo labels in current project.
*g:spacevim_todo_close_list*
Option for setting todo windows behavior when open item in todo list. Default
is 1, set to 0 will not close todo windows.
*g:spacevim_lint_on_the_fly*
Enable/Disable lint on the fly feature of SpaceVim's maker. Default is 0.
>

View File

@ -86,7 +86,9 @@ end
-- }}}
local function open_todo() -- {{{
local t = todos[vim.fn.line('.')]
vim.cmd('close')
if vim.g.spacevim_todo_close_list == 1 or vim.g.spacevim_todo_close_list == true then
vim.cmd('close')
end
vim.cmd(winnr .. 'wincmd w')
vim.cmd('e ' .. t.file)
vim.fn.cursor(t.line, t.column)