diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 83cadffc..5cd3283e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -132,7 +132,7 @@ local defaults = { } M.json = { - version = 5, + version = 6, data = { version = nil, ---@type string? news = {}, ---@type table diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 3c98ba8e..bd59b52b 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -238,12 +238,7 @@ return { opts = function() local actions = require("telescope.actions") - local open_with_trouble = function(...) - 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 open_with_trouble = require("trouble.sources.telescope").open local find_files_no_ignore = function() local action_state = require("telescope.actions.state") local line = action_state.get_current_line() @@ -275,7 +270,7 @@ return { mappings = { i = { [""] = open_with_trouble, - [""] = open_selected_with_trouble, + [""] = open_with_trouble, [""] = find_files_no_ignore, [""] = find_files_with_hidden, [""] = actions.cycle_history_next, @@ -424,15 +419,21 @@ return { cmd = { "TroubleToggle", "Trouble" }, opts = { use_diagnostic_signs = true }, keys = { - { "xx", "TroubleToggle document_diagnostics", desc = "Document Diagnostics (Trouble)" }, - { "xX", "TroubleToggle workspace_diagnostics", desc = "Workspace Diagnostics (Trouble)" }, - { "xL", "TroubleToggle loclist", desc = "Location List (Trouble)" }, - { "xQ", "TroubleToggle quickfix", desc = "Quickfix List (Trouble)" }, + { "xx", "Trouble diagnostics toggle", desc = "Diagnostics (Trouble)" }, + { "xX", "Trouble diagnostics toggle filter.buf=0", desc = "Buffer Diagnostics (Trouble)" }, + { "cs", "Trouble symbols toggle focus=false", desc = "Symbols (Trouble)" }, + { + "cS", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP references/definitions/... (Trouble)", + }, + { "xL", "Trouble loclist toggle", desc = "Location List (Trouble)" }, + { "xQ", "Trouble qflist toggle", desc = "Quickfix List (Trouble)" }, { "[q", function() if require("trouble").is_open() then - require("trouble").previous({ skip_groups = true, jump = true }) + require("trouble").prev({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cprev) if not ok then diff --git a/lua/lazyvim/plugins/extras/editor/trouble-v3.lua b/lua/lazyvim/plugins/extras/editor/trouble-v3.lua deleted file mode 100644 index d7ceff2e..00000000 --- a/lua/lazyvim/plugins/extras/editor/trouble-v3.lua +++ /dev/null @@ -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 = { - { "xx", "Trouble diagnostics toggle", desc = "Diagnostics (Trouble)" }, - { "xX", "Trouble diagnostics toggle filter.buf=0", desc = "Buffer Diagnostics (Trouble)" }, - { "cs", "Trouble symbols toggle focus=false", desc = "Symbols (Trouble)" }, - { - "cS", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP references/definitions/... (Trouble)", - }, - { "xL", "Trouble loclist toggle", desc = "Location List (Trouble)" }, - { "xQ", "Trouble qflist toggle", 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 = { - [""] = open_with_trouble, - [""] = open_with_trouble, - }, - }, - }, - }) - end, - }, -} diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index f2249edd..4ccdc5f0 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -105,6 +105,19 @@ return { 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 end, }, diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 0d401f23..94d72a12 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -128,6 +128,17 @@ return { 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 { options = { theme = "auto", @@ -151,6 +162,10 @@ return { }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, { LazyVim.lualine.pretty_path() }, + { + symbols and symbols.get, + cond = symbols and symbols.has, + }, }, lualine_x = { -- stylua: ignore diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua index 3e17662e..60466a45 100644 --- a/lua/lazyvim/util/json.lua +++ b/lua/lazyvim/util/json.lua @@ -89,6 +89,10 @@ function M.migrate() json.data.extras = vim.tbl_filter(function(extra) return not (extra == "lazyvim.plugins.extras.lazyrc") 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 M.save() diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 77a1c28e..084b2ff9 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -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.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.editor.trouble-v3"] = "Trouble v3 has been merged in main", } M.deprecated_modules = {