Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trouble)!: v3 support #1281

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions lua/keymap/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,19 @@ local plug_map = {
:with_desc("git: Toggle lazygit"),

-- Plugin: trouble
["n|gt"] = map_cr("TroubleToggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"),
["n|<leader>ll"] = map_cr("TroubleToggle lsp_references")
["n|gt"] = map_cr("Trouble diagnostics toggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"),
["n|<leader>lw"] = map_cr("Trouble diagnostics toggle")
:with_noremap()
:with_silent()
:with_desc("lsp: Show lsp references"),
["n|<leader>ld"] = map_cr("TroubleToggle document_diagnostics")
:with_noremap()
:with_silent()
:with_desc("lsp: Show document diagnostics"),
["n|<leader>lw"] = map_cr("TroubleToggle workspace_diagnostics")
:with_desc("lsp: Show workspace diagnostics"),
["n|<leader>lp"] = map_cr("Trouble project_diagnostics toggle")
:with_noremap()
:with_silent()
:with_desc("lsp: Show workspace diagnostics"),
["n|<leader>lq"] = map_cr("TroubleToggle quickfix")
:with_desc("lsp: Show project diagnostics"),
["n|<leader>ld"] = map_cr("Trouble diagnostics toggle filter.buf=0")
:with_noremap()
:with_silent()
:with_desc("lsp: Show quickfix list"),
["n|<leader>lL"] = map_cr("TroubleToggle loclist"):with_noremap():with_silent():with_desc("lsp: Show loclist"),
:with_desc("lsp: Show document diagnostics"),

-- Plugin: telescope
["n|<C-p>"] = map_callback(function()
Expand Down
75 changes: 29 additions & 46 deletions lua/modules/configs/tool/trouble.lua
Original file line number Diff line number Diff line change
@@ -1,55 +1,38 @@
return function()
local icons = {
ui = require("modules.utils.icons").get("ui"),
diagnostics = require("modules.utils.icons").get("diagnostics"),
ui = require("modules.utils.icons").get("ui", true),
}

require("modules.utils").load_plugin("trouble", {
position = "bottom", -- position of the list can be: bottom, top, left, right
height = 10, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
fold_open = icons.ui.ArrowOpen, -- icon used for open folds
fold_closed = icons.ui.ArrowClosed, -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
action_keys = {
-- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example:
-- close = {},
close = "q", -- close the list
cancel = "<Esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = { "<CR>", "<TAB>" }, -- jump to the diagnostic or open / close folds
open_split = { "<C-x>" }, -- open buffer in new split
open_vsplit = { "<C-v>" }, -- open buffer in new vsplit
open_tab = { "<C-t>" }, -- open buffer in new tab
jump_close = { "o" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location
close_folds = { "zM", "zm" }, -- close all folds
open_folds = { "zR", "zr" }, -- open all folds
toggle_fold = { "zA", "za" }, -- toggle fold of current file
previous = "k", -- preview item
next = "j", -- next item
auto_open = false,
auto_close = false,
auto_jump = false,
auto_preview = true,
auto_refresh = true,
focus = false, -- do not focus the window when opened
follow = true,
restore = true,
icons = {
indent = {
fold_open = icons.ui.ArrowOpen,
fold_closed = icons.ui.ArrowClosed,
},
folder_closed = icons.ui.Folder,
folder_open = icons.ui.FolderOpen,
},
indent_lines = true, -- add an indent guide below the fold icons
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
signs = {
-- icons / text used for a diagnostic
error = icons.diagnostics.Error_alt,
warning = icons.diagnostics.Warning_alt,
hint = icons.diagnostics.Hint_alt,
information = icons.diagnostics.Information_alt,
other = icons.diagnostics.Question_alt,
modes = {
project_diagnostics = {
mode = "diagnostics",
filter = {
any = {
{
function(item)
return item.filename:find(vim.fn.getcwd(), 1, true)
end,
},
},
},
},
},
use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client
})
end
1 change: 1 addition & 0 deletions lua/modules/configs/ui/catppuccin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ return function()

-- For trouble.nvim
TroubleNormal = { bg = transparent_background and cp.none or cp.base },
TroubleNormalNC = { bg = transparent_background and cp.none or cp.base },

-- For telescope.nvim
TelescopeMatching = { fg = cp.lavender },
Expand Down