description | A plugin for the vis editor |
owner | repo.or.cz@soba23.anonaddy.me |
last change | Wed, 4 Oct 2023 10:26:44 +0000 (4 18:26 +0800) |
URL | git://repo.or.cz/vis-quickfix.git |
https://repo.or.cz/vis-quickfix.git | |
push URL | ssh://repo.or.cz/vis-quickfix.git |
https://repo.or.cz/vis-quickfix.git (learn more) | |
bundle info | vis-quickfix.git downloadable bundles |
content tags |
Quickfix commands, like in vim.
To create an error list:
:cf [errorfile]
:cb
:cex shell-command
:grep args...
:make [args]...
To navigate the list:
:cn [count]
:cp [count]
:cnf [count]
:cpf [count]
:cc [count]
:cr
:cla
To toggle the error window:
:cw
If the defaults work for you:
require'quickfix'
If you need to customize:
local qf = require'quickfix'
qf.grepprg = 'git grep -n --column'
qf.makeprg = 'luacheck *.lua'
qf.errorfile = 'command.out'
table.remove(qf.errorformat, 3)
qf.grepformat[#qf.grepformat + 1] = '^"([^"]+)":(%d+) (.-)(.*)$')
qf.peek = false
qf.menu = true
peek
and menu
are also available as :set qfp
and :set qfm
, respectively.
peek
(on by default) - :make
, :grep
, :cex
, and cexpr()
will open the error window but not jump to the first "error" just yet.
menu
(off by default) - pressing <Enter>
in the error window will close it after jumping to the selected error.
peek
above. In vim, the affected commands behave as if peek
is off (i.e., will jump to the error location without opening the error window).:cw
will open the error window regardless of whether there are recognized errors or not.:make
/:grep
etc. will open the error window (even when peek
is off) if there were no recognized errors but the exit status was non-zero.:cex
takes a shell command as argument; in vim, it takes a VimScript expression.<Enter>
on an "invalid" line in the error window will "glide" forward and act on the next valid one.errorformat
and grepformat
support only single-line patterns, each of which should have 4 captures, in this order - file, line, column, message. If you need to skip a field, you can use (.-)
for an empty match. For anything more complex you will have to write your own filter or wrapper that massages the output accordingly. (See Advanced Usage below for an example.)To create an error list:
qf.cexpr(shell-command[, format[, title]])
shell-command
(string).
format
(string, Lua pattern) - for when shell-command
's output does not match any of the patterns in errorformat
.
title
(string) - will appear in the status line instead of shell-command
- [Quickfix List] :title
.
To navigate an error list:
qf.action.cn()
, qf.action.cp()
, etc.
Faster navigation:
vis.map(vis.modes.NORMAL, '<M-j>', qf.action.cn)
vis.map(vis.modes.NORMAL, '<M-k>', qf.action.cp)
vis.map(vis.modes.NORMAL, '<M-l>', qf.action.cnf)
vis.map(vis.modes.NORMAL, '<M-h>', qf.action.cpf)
vis:map(vis.modes.NORMAL, "<M-L>", qf.action.cla)
vis:map(vis.modes.NORMAL, "<M-H>", qf.action.cr)
vis.map(vis.modes.NORMAL, '<C-w><C-w>', ':cw<Enter>')
Cscope integration:
vis:map(vis.modes.NORMAL, '<M-r>', function()
local cword = vis.win.file:content(vis.win.file:text_object_word(vis.win.selection.pos))
qf.cexpr('cscope -L -3 '.. cword)
end, "Find all locations calling function <cword>")
An example git-diff(1)
wrapper is included - :cex gitw
. (Not a great example, as git-jump(1)
already exists.)
The navigation :-commands may occasionally cause a segfault. This is because the current window is switched away from or closed while the :-command handler is running.
You can use the direct Lua qf.action.*
functions via mappings instead, like in the Advanced Usage example.
2023-10-04 | Georgi Kirilov | Squash commitsmaster | commitcommitdifftreesnapshot (tar.gz zip) |
6 months ago | master | logtree |