descriptionA plugin for the vis editor
ownerrepo.or.cz@soba23.anonaddy.me
last changeWed, 4 Oct 2023 10:26:44 +0000 (4 18:26 +0800)
content tags
add:
readme

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

Configuration

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.

Differences with vim

Lua API

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.

Advanced Usage

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.)

Bugs

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.

shortlog
2023-10-04 Georgi KirilovSquash commitsmaster
heads
6 months ago master