From a3046b056b591eacc6f5032f82d2126a6efb61e3 Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Tue, 30 Jan 2024 10:04:10 +0100 Subject: [PATCH] add trouble.nvim and keybinds for diagnostics/trouble --- lazy-lock.json | 2 +- lua/weeheavy/plugins/troube.lua | 28 ++++++++++++++++++++++++++++ lua/weeheavy/remap.lua | 27 ++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 lua/weeheavy/plugins/troube.lua diff --git a/lazy-lock.json b/lazy-lock.json index 9aea111..b1515a9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,7 +3,6 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "conform.nvim": { "branch": "master", "commit": "cbc5745bf7519acaf3a5cbaaa677fd556aa813d7" }, "gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" }, - "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lazygit.nvim": { "branch": "main", "commit": "1e08e3f5ac1152339690140e61a4a32b3bdc7de5" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "dec1c21204e2d9d49dad989b577c88958ed2c113" }, @@ -22,6 +21,7 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "tokyonight.nvim": { "branch": "main", "commit": "633039585dff7fd2b9b62fb190bf768702609d95" }, + "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, "vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, diff --git a/lua/weeheavy/plugins/troube.lua b/lua/weeheavy/plugins/troube.lua new file mode 100644 index 0000000..d03dd4f --- /dev/null +++ b/lua/weeheavy/plugins/troube.lua @@ -0,0 +1,28 @@ +-- A pretty diagnostics, references, telescope results, quickfix and location +-- list to help you solve all the trouble your code is causing. +-- https://github.com/folke/trouble.nvim +return { + "folke/trouble.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + --config = function() + -- local oil = require("oil") + -- oil.setup({ + -- default_file_explorer = true, + -- columns = { + -- --"size", + -- "icon", + -- }, + -- view_options = { + -- show_hidden = true, + -- }, + -- keymaps = { + -- -- This should be matched to the open action in remap.lua + -- ["e"] = "actions.close", + -- [""] = "actions.select_vsplit", + -- [""] = "actions.select_split", + -- }, + -- }) + --end, +} diff --git a/lua/weeheavy/remap.lua b/lua/weeheavy/remap.lua index 73c9a59..23c9860 100644 --- a/lua/weeheavy/remap.lua +++ b/lua/weeheavy/remap.lua @@ -77,4 +77,29 @@ vim.keymap.set({ "n", "v" }, "o", function() }) end, { desc = "Format file or range (in visual mode)" }) -vim.keymap.set("n", "z", ":ZenMode") -- toggle zen-mode.nvim +-- Toggle zen-mode.nvim +vim.keymap.set("n", "z", ":ZenMode") + +-- Got to next diagnostic item (any severity) +vim.keymap.set({ "n", "v" }, "da", function() + vim.diagnostic.goto_next({}) + vim.api.nvim_feedkeys("zz", "n", false) +end, { desc = "Go to next diagnostic" }) + +-- Got to next diagnostic item (error severity) +vim.keymap.set({ "n", "v" }, "de", function() + vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR }) + vim.api.nvim_feedkeys("zz", "n", false) +end, { desc = "Go to next diagnostic" }) + +-- Got to next diagnostic item (warning severity) +vim.keymap.set({ "n", "v" }, "dw", function() + vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.WARN }) + vim.api.nvim_feedkeys("zz", "n", false) +end, { desc = "Go to next diagnostic" }) + +-- Toggle trouble (for document) +vim.keymap.set("n", "qq", ":TroubleToggle") + +-- Toggle trouble (for workspace) +vim.keymap.set("n", "QQ", ":TroubleToggle workspace_diagnostics")