Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niuiic/quickfix.nvim
Neovim plugin providing extended functionality for quickfix.
https://github.com/niuiic/quickfix.nvim
Last synced: about 2 months ago
JSON representation
Neovim plugin providing extended functionality for quickfix.
- Host: GitHub
- URL: https://github.com/niuiic/quickfix.nvim
- Owner: niuiic
- License: mit
- Created: 2023-04-28T07:59:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-11T04:32:36.000Z (4 months ago)
- Last Synced: 2024-05-12T05:27:11.832Z (4 months ago)
- Language: Lua
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - niuiic/quickfix.nvim - Extended functionality for quickfix, including store, restore, make, remove, etc. (Debugging / Quickfix)
README
# quickfix.nvim
Extended functionality for quickfix.
[More neovim plugins](https://github.com/niuiic/awesome-neovim-plugins)
## Features
- store/restore
```lua
-- path: string
require('quickfix').store(path)
require('quickfix').restore(path)
```- make
```lua
-- name: string | nil
require('quickfix').make(name)
```- remove
```lua
-- remove qf item
require('quickfix').remove()
```## Dependencies
- [niuiic/core](https://github.com/niuiic/core.nvim)
- [folke/trouble.nvim](https://github.com/folke/trouble.nvim)(optional). Feature builtin does not support `\n` in text, it's recommended to use trouble for previewing quickfix list.## Config
Here is an example.
```lua
local config = {
---@type {[string]: quickfix.Make}
make = {
node = {
cmd = "node",
args = { "index.js" },
-- return false means this make config would not work
filter = function()
return vim.bo.filetype == "javascript"
end,
-- parse command output and set qf_list
-- for basic usage, just copy this function and modify the regex
-- note that error messages may come from `output` or `err`
-- for advanced user, do filtering, mapping or something else as you like.
parser = function(output, err)
-- in this example, the error messages comes from `err`(stderr)
local lines = vim.split(err, "\n")
---@type {file_name: string, lnum: number, text: string}
local qf_item
-- qf_list is an array of qf_item
local qf_list = {}
for _, line in ipairs(lines) do
-- if line match this regex, it should be the start of a new qf_item, or it should be extra info for the previous qf_item
local file, line_nr, msg = string.match(line, "^(%S+):(%d+):?(.*)")
if file and line then
if qf_item then
table.insert(qf_list, qf_item)
end
qf_item = { filename = file, lnum = tonumber(line_nr), text = msg }
else
if qf_item then
qf_item.text = qf_item.text .. "\n" .. line
end
end
end
table.insert(qf_list, qf_item)
vim.fn.setqflist(qf_list)
end,
},
tsc = {
cmd = "pnpm",
args = { "tsc", "index.ts" },
-- parser can be string or function
-- this parser is defined below
parser = "tsc",
},
},
---@type {[string]: fun(output: string, err: string)}
parser = {
tsc = function(output, _)
local lines = vim.split(output, "\n")
local qf_item
local qf_list = {}
for _, line in ipairs(lines) do
local file, line_nr, msg = string.match(line, "^(%S+)%((%d+),%d+%):(.*)")
if file and line then
if qf_item then
table.insert(qf_list, qf_item)
end
qf_item = { filename = file, lnum = tonumber(line_nr), text = msg }
else
if qf_item then
qf_item.text = qf_item.text .. "\n" .. line
end
end
end
table.insert(qf_list, qf_item)
vim.fn.setqflist(qf_list)
end,
},
}
```