feat(integration): Use trouble.nvim
If installed and enabled (via `config.trouble`; defaults to true if installed), `:Gitsigns setqflist` and `:Gitsigns seqloclist` will open Trouble instead of Neovim's built-in quickfix or location list windows.
This commit is contained in:
parent
ceb2dcb23f
commit
fc81385888
|
@ -228,6 +228,10 @@ null_ls.setup {
|
|||
Will enable `:lua vim.lsp.buf.code_action()` to retrieve code actions from Gitsigns.
|
||||
Alternatively if you have [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) installed, you can use `:Telescope lsp_code_actions`.
|
||||
|
||||
### [trouble.nvim](https://github.com/folke/trouble.nvim)
|
||||
|
||||
If installed and enabled (via `config.trouble`; defaults to true if installed), `:Gitsigns setqflist` or `:Gitsigns seqloclist` will open Trouble instead of Neovim's built-in quickfix or location list windows.
|
||||
|
||||
## Similar plugins
|
||||
|
||||
- [coc-git](https://github.com/neoclide/coc-git)
|
||||
|
|
|
@ -708,6 +708,12 @@ current_line_blame_formatter *gitsigns-config-current_line_blame_formatter*
|
|||
The result of this function is passed directly to the `opts.virt_text`
|
||||
field of |nvim_buf_set_extmark|.
|
||||
|
||||
trouble *gitsigns-config-trouble*
|
||||
Type: `boolean`, Default: true if installed
|
||||
|
||||
When using setqflist() or setloclist(), open Trouble instead of the
|
||||
quickfix/location list window.
|
||||
|
||||
yadm *gitsigns-config-yadm*
|
||||
Type: `table`, Default: `{ enable = false }`
|
||||
|
||||
|
|
|
@ -703,10 +703,18 @@ M.setqflist = void(function(target, opts)
|
|||
if opts.use_location_list then
|
||||
local nr = opts.nr or 0
|
||||
vim.fn.setloclist(nr, {}, ' ', qfopts)
|
||||
vim.cmd([[lopen]])
|
||||
if config.trouble then
|
||||
require('trouble').open("loclist")
|
||||
else
|
||||
vim.cmd([[lopen]])
|
||||
end
|
||||
else
|
||||
vim.fn.setqflist({}, ' ', qfopts)
|
||||
vim.cmd([[copen]])
|
||||
if config.trouble then
|
||||
require('trouble').open("quickfix")
|
||||
else
|
||||
vim.cmd([[copen]])
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ local M = {Config = {DiffOpts = {}, SignsConfig = {}, watch_gitdir = {}, current
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -536,6 +538,19 @@ M.schema = {
|
|||
]],
|
||||
},
|
||||
|
||||
trouble = {
|
||||
type = 'boolean',
|
||||
default = function()
|
||||
local has_trouble = pcall(require, 'trouble')
|
||||
return has_trouble
|
||||
end,
|
||||
default_help = "true if installed",
|
||||
description = [[
|
||||
When using setqflist() or setloclist(), open Trouble instead of the
|
||||
quickfix/location list window.
|
||||
]],
|
||||
},
|
||||
|
||||
yadm = {
|
||||
type = 'table',
|
||||
default = { enable = false },
|
||||
|
|
|
@ -703,10 +703,18 @@ M.setqflist = void(function(target: integer|string, opts: M.QFListOpts)
|
|||
if opts.use_location_list then
|
||||
local nr = opts.nr or 0
|
||||
vim.fn.setloclist(nr, {}, ' ', qfopts)
|
||||
vim.cmd[[lopen]]
|
||||
if config.trouble then
|
||||
require'trouble'.open("loclist")
|
||||
else
|
||||
vim.cmd[[lopen]]
|
||||
end
|
||||
else
|
||||
vim.fn.setqflist({}, ' ', qfopts)
|
||||
vim.cmd[[copen]]
|
||||
if config.trouble then
|
||||
require'trouble'.open("quickfix")
|
||||
else
|
||||
vim.cmd[[copen]]
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ local record M
|
|||
enable: boolean
|
||||
end
|
||||
|
||||
trouble: boolean
|
||||
|
||||
-- Undocumented
|
||||
word_diff: boolean
|
||||
_refresh_staged_on_update: boolean
|
||||
|
@ -536,6 +538,19 @@ M.schema = {
|
|||
]]
|
||||
},
|
||||
|
||||
trouble = {
|
||||
type = 'boolean',
|
||||
default = function(): boolean
|
||||
local has_trouble = pcall(require, 'trouble')
|
||||
return has_trouble
|
||||
end,
|
||||
default_help = "true if installed",
|
||||
description = [[
|
||||
When using setqflist() or setloclist(), open Trouble instead of the
|
||||
quickfix/location list window.
|
||||
]]
|
||||
},
|
||||
|
||||
yadm = {
|
||||
type = 'table',
|
||||
default = { enable = false },
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
local record Trouble
|
||||
open: function(mode: string)
|
||||
end
|
||||
|
||||
return Trouble
|
Loading…
Reference in New Issue