mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
feat: trouble v3
This commit is contained in:
parent
ae098d67d6
commit
95d055dcf7
7 changed files with 47 additions and 134 deletions
|
@ -132,7 +132,7 @@ local defaults = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.json = {
|
M.json = {
|
||||||
version = 5,
|
version = 6,
|
||||||
data = {
|
data = {
|
||||||
version = nil, ---@type string?
|
version = nil, ---@type string?
|
||||||
news = {}, ---@type table<string, string>
|
news = {}, ---@type table<string, string>
|
||||||
|
|
|
@ -238,12 +238,7 @@ return {
|
||||||
opts = function()
|
opts = function()
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
|
|
||||||
local open_with_trouble = function(...)
|
local open_with_trouble = require("trouble.sources.telescope").open
|
||||||
return require("trouble.providers.telescope").open_with_trouble(...)
|
|
||||||
end
|
|
||||||
local open_selected_with_trouble = function(...)
|
|
||||||
return require("trouble.providers.telescope").open_selected_with_trouble(...)
|
|
||||||
end
|
|
||||||
local find_files_no_ignore = function()
|
local find_files_no_ignore = function()
|
||||||
local action_state = require("telescope.actions.state")
|
local action_state = require("telescope.actions.state")
|
||||||
local line = action_state.get_current_line()
|
local line = action_state.get_current_line()
|
||||||
|
@ -275,7 +270,7 @@ return {
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
["<c-t>"] = open_with_trouble,
|
["<c-t>"] = open_with_trouble,
|
||||||
["<a-t>"] = open_selected_with_trouble,
|
["<a-t>"] = open_with_trouble,
|
||||||
["<a-i>"] = find_files_no_ignore,
|
["<a-i>"] = find_files_no_ignore,
|
||||||
["<a-h>"] = find_files_with_hidden,
|
["<a-h>"] = find_files_with_hidden,
|
||||||
["<C-Down>"] = actions.cycle_history_next,
|
["<C-Down>"] = actions.cycle_history_next,
|
||||||
|
@ -424,15 +419,21 @@ return {
|
||||||
cmd = { "TroubleToggle", "Trouble" },
|
cmd = { "TroubleToggle", "Trouble" },
|
||||||
opts = { use_diagnostic_signs = true },
|
opts = { use_diagnostic_signs = true },
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>xx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
|
{ "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)" },
|
||||||
{ "<leader>xX", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
|
{ "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)" },
|
||||||
{ "<leader>xL", "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" },
|
{ "<leader>cs", "<cmd>Trouble symbols toggle focus=false<cr>", desc = "Symbols (Trouble)" },
|
||||||
{ "<leader>xQ", "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" },
|
{
|
||||||
|
"<leader>cS",
|
||||||
|
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
|
||||||
|
desc = "LSP references/definitions/... (Trouble)",
|
||||||
|
},
|
||||||
|
{ "<leader>xL", "<cmd>Trouble loclist toggle<cr>", desc = "Location List (Trouble)" },
|
||||||
|
{ "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", desc = "Quickfix List (Trouble)" },
|
||||||
{
|
{
|
||||||
"[q",
|
"[q",
|
||||||
function()
|
function()
|
||||||
if require("trouble").is_open() then
|
if require("trouble").is_open() then
|
||||||
require("trouble").previous({ skip_groups = true, jump = true })
|
require("trouble").prev({ skip_groups = true, jump = true })
|
||||||
else
|
else
|
||||||
local ok, err = pcall(vim.cmd.cprev)
|
local ok, err = pcall(vim.cmd.cprev)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
|
|
||||||
if vim.tbl_contains(Config.json.data.extras, "lazyvim.plugins.extras.editor.trouble-v3") then
|
|
||||||
for _, other in ipairs({ "aerial", "outline" }) do
|
|
||||||
local extra = "lazyvim.plugins.extras.editor." .. other
|
|
||||||
if vim.tbl_contains(Config.json.data.extras, extra) then
|
|
||||||
other = other:gsub("^%l", string.upper)
|
|
||||||
LazyVim.error({
|
|
||||||
"**Trouble v3** includes support for document symbols.",
|
|
||||||
("You currently have the **%s** extra enabled."):format(other),
|
|
||||||
"Please disable it in your config.",
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if vim.fn.has("nvim-0.9.2") == 0 then
|
|
||||||
LazyVim.error({
|
|
||||||
"Trouble v3 requires Neovim >= 0.9.2",
|
|
||||||
"Please update your Neovim version.",
|
|
||||||
})
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
desc = "Trouble rewrite including document symbols and a lualine component",
|
|
||||||
recommended = true,
|
|
||||||
{
|
|
||||||
"folke/trouble.nvim",
|
|
||||||
branch = "dev",
|
|
||||||
keys = {
|
|
||||||
{ "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)" },
|
|
||||||
{ "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)" },
|
|
||||||
{ "<leader>cs", "<cmd>Trouble symbols toggle focus=false<cr>", desc = "Symbols (Trouble)" },
|
|
||||||
{
|
|
||||||
"<leader>cS",
|
|
||||||
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
|
|
||||||
desc = "LSP references/definitions/... (Trouble)",
|
|
||||||
},
|
|
||||||
{ "<leader>xL", "<cmd>Trouble loclist toggle<cr>", desc = "Location List (Trouble)" },
|
|
||||||
{ "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", desc = "Quickfix List (Trouble)" },
|
|
||||||
{
|
|
||||||
"[q",
|
|
||||||
function()
|
|
||||||
if require("trouble").is_open() then
|
|
||||||
require("trouble").prev({ skip_groups = true, jump = true })
|
|
||||||
else
|
|
||||||
local ok, err = pcall(vim.cmd.cprev)
|
|
||||||
if not ok then
|
|
||||||
vim.notify(err, vim.log.levels.ERROR)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
desc = "Previous Trouble/Quickfix Item",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- lualine integration
|
|
||||||
{
|
|
||||||
"nvim-lualine/lualine.nvim",
|
|
||||||
optional = true,
|
|
||||||
opts = function(_, opts)
|
|
||||||
local trouble = require("trouble")
|
|
||||||
if not trouble.statusline then
|
|
||||||
LazyVim.error("You have enabled the **trouble-v3** extra,\nbut still need to update it with `:Lazy`")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local symbols = trouble.statusline({
|
|
||||||
mode = "symbols",
|
|
||||||
groups = {},
|
|
||||||
title = false,
|
|
||||||
filter = { range = true },
|
|
||||||
format = "{kind_icon}{symbol.name:Normal}",
|
|
||||||
hl_group = "lualine_c_normal",
|
|
||||||
})
|
|
||||||
table.insert(opts.sections.lualine_c, {
|
|
||||||
symbols.get,
|
|
||||||
cond = symbols.has,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"folke/edgy.nvim",
|
|
||||||
optional = true,
|
|
||||||
opts = function(_, opts)
|
|
||||||
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
|
|
||||||
opts[pos] = opts[pos] or {}
|
|
||||||
table.insert(opts[pos], {
|
|
||||||
ft = "trouble",
|
|
||||||
filter = function(_buf, win)
|
|
||||||
return vim.w[win].trouble
|
|
||||||
and vim.w[win].trouble.position == pos
|
|
||||||
and vim.w[win].trouble.type == "split"
|
|
||||||
and vim.w[win].trouble.relative == "editor"
|
|
||||||
and not vim.w[win].trouble_preview
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
optional = true,
|
|
||||||
opts = function(_, opts)
|
|
||||||
local open_with_trouble = require("trouble.sources.telescope").open
|
|
||||||
return vim.tbl_deep_extend("force", opts, {
|
|
||||||
defaults = {
|
|
||||||
mappings = {
|
|
||||||
i = {
|
|
||||||
["<c-t>"] = open_with_trouble,
|
|
||||||
["<a-t>"] = open_with_trouble,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -105,6 +105,19 @@ return {
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
|
||||||
|
opts[pos] = opts[pos] or {}
|
||||||
|
table.insert(opts[pos], {
|
||||||
|
ft = "trouble",
|
||||||
|
filter = function(_buf, win)
|
||||||
|
return vim.w[win].trouble
|
||||||
|
and vim.w[win].trouble.position == pos
|
||||||
|
and vim.w[win].trouble.type == "split"
|
||||||
|
and vim.w[win].trouble.relative == "editor"
|
||||||
|
and not vim.w[win].trouble_preview
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
return opts
|
return opts
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
|
@ -128,6 +128,17 @@ return {
|
||||||
|
|
||||||
vim.o.laststatus = vim.g.lualine_laststatus
|
vim.o.laststatus = vim.g.lualine_laststatus
|
||||||
|
|
||||||
|
local trouble = require("trouble")
|
||||||
|
local symbols = trouble.statusline
|
||||||
|
and trouble.statusline({
|
||||||
|
mode = "symbols",
|
||||||
|
groups = {},
|
||||||
|
title = false,
|
||||||
|
filter = { range = true },
|
||||||
|
format = "{kind_icon}{symbol.name:Normal}",
|
||||||
|
hl_group = "lualine_c_normal",
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
options = {
|
options = {
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
|
@ -151,6 +162,10 @@ return {
|
||||||
},
|
},
|
||||||
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
|
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
|
||||||
{ LazyVim.lualine.pretty_path() },
|
{ LazyVim.lualine.pretty_path() },
|
||||||
|
{
|
||||||
|
symbols and symbols.get,
|
||||||
|
cond = symbols and symbols.has,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
|
|
|
@ -89,6 +89,10 @@ function M.migrate()
|
||||||
json.data.extras = vim.tbl_filter(function(extra)
|
json.data.extras = vim.tbl_filter(function(extra)
|
||||||
return not (extra == "lazyvim.plugins.extras.lazyrc")
|
return not (extra == "lazyvim.plugins.extras.lazyrc")
|
||||||
end, json.data.extras or {})
|
end, json.data.extras or {})
|
||||||
|
elseif json.data.version == 5 then
|
||||||
|
json.data.extras = vim.tbl_filter(function(extra)
|
||||||
|
return not (extra == "lazyvim.plugins.extras.editor.trouble-v3")
|
||||||
|
end, json.data.extras or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
M.save()
|
M.save()
|
||||||
|
|
|
@ -14,6 +14,7 @@ M.deprecated_extras = {
|
||||||
["lazyvim.plugins.extras.ui.treesitter-rewrite"] = "Disabled `treesitter-rewrite` extra for now. Not ready yet.",
|
["lazyvim.plugins.extras.ui.treesitter-rewrite"] = "Disabled `treesitter-rewrite` extra for now. Not ready yet.",
|
||||||
["lazyvim.plugins.extras.coding.mini-ai"] = "`mini.ai` is now a core LazyVim plugin (again)",
|
["lazyvim.plugins.extras.coding.mini-ai"] = "`mini.ai` is now a core LazyVim plugin (again)",
|
||||||
["lazyvim.plugins.extras.lazyrc"] = "local spec files are now a lazy.nvim feature",
|
["lazyvim.plugins.extras.lazyrc"] = "local spec files are now a lazy.nvim feature",
|
||||||
|
["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.deprecated_modules = {
|
M.deprecated_modules = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue