mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 01:09:56 +08:00
feat(todo): add ctrl-q
to apply results to quickfix
This commit is contained in:
parent
3be76bca65
commit
5febb52913
@ -930,7 +930,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:save_current_file() abort
|
function! s:save_current_file() abort
|
||||||
let v:errmsg = ''
|
let v:errmsg = ''
|
||||||
silent! update
|
silent! write
|
||||||
if v:errmsg !=# ''
|
if v:errmsg !=# ''
|
||||||
echohl ErrorMsg
|
echohl ErrorMsg
|
||||||
echo v:errmsg
|
echo v:errmsg
|
||||||
|
@ -91,6 +91,27 @@ local function open_todo() -- {{{
|
|||||||
vim.cmd('noautocmd normal! :')
|
vim.cmd('noautocmd normal! :')
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
--
|
||||||
|
local function apply_to_quickfix() -- {{{
|
||||||
|
local qf = {}
|
||||||
|
for _, v in ipairs(todos) do
|
||||||
|
table.insert(qf, {
|
||||||
|
filename = v.file,
|
||||||
|
lnum = v.line,
|
||||||
|
col = v.column,
|
||||||
|
text = v.title,
|
||||||
|
type = v.label,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
vim.fn.setqflist({}, 'r', {
|
||||||
|
title = 'Todos',
|
||||||
|
items = qf,
|
||||||
|
})
|
||||||
|
vim.cmd('close')
|
||||||
|
vim.cmd(winnr .. 'wincmd w')
|
||||||
|
vim.cmd('botright copen')
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
local function indexof(t, v) -- {{{
|
local function indexof(t, v) -- {{{
|
||||||
for i, x in ipairs(t) do
|
for i, x in ipairs(t) do
|
||||||
@ -158,7 +179,6 @@ local function on_exit(id, data, event) -- {{{
|
|||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- labels to command line regex
|
-- labels to command line regex
|
||||||
local function get_labels_regex() -- {{{
|
local function get_labels_regex() -- {{{
|
||||||
local sep = ''
|
local sep = ''
|
||||||
@ -255,6 +275,9 @@ local function open_win() -- {{{
|
|||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Enter>', '', {
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Enter>', '', {
|
||||||
callback = open_todo,
|
callback = open_todo,
|
||||||
})
|
})
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-q>', '', {
|
||||||
|
callback = apply_to_quickfix,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user