feat(plugins): Add workspace-diagnostics.nvim and trouble.nvim

Fix `nvim-navic` for some LSPs
This commit is contained in:
Jiří Štefka 2024-10-01 12:55:40 +02:00
parent b2f592d529
commit 9e58b1629d
Signed by: jiriks74
GPG key ID: 1D5E30D3DB2264DE
11 changed files with 101 additions and 66 deletions

View file

@ -216,7 +216,8 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"gen-luarc": "gen-luarc", "gen-luarc": "gen-luarc",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"presence-nvim": "presence-nvim" "presence-nvim": "presence-nvim",
"workspace-diagnostics-nvim": "workspace-diagnostics-nvim"
} }
}, },
"systems": { "systems": {
@ -233,6 +234,22 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"workspace-diagnostics-nvim": {
"flake": false,
"locked": {
"lastModified": 1723294887,
"narHash": "sha256-lBj4KUPmmhtpffYky/HpaTwY++d/Q9socp/Ys+4VeX0=",
"owner": "artemave",
"repo": "workspace-diagnostics.nvim",
"rev": "573ff93c47898967efdfbc6587a1a39e3c2d365e",
"type": "github"
},
"original": {
"owner": "artemave",
"repo": "workspace-diagnostics.nvim",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -12,6 +12,10 @@
url = "github:jiriks74/presence.nvim"; url = "github:jiriks74/presence.nvim";
flake = false; flake = false;
}; };
workspace-diagnostics-nvim = {
url = "github:artemave/workspace-diagnostics.nvim";
flake = false;
};
# wf-nvim = { # wf-nvim = {
# url = "github:Cassin01/wf.nvim"; # url = "github:Cassin01/wf.nvim";
# flake = false; # flake = false;

View file

@ -99,6 +99,7 @@ with final.pkgs.lib; let
nvim-unception # Prevent nested neovim sessions | nvim-unception nvim-unception # Prevent nested neovim sessions | nvim-unception
better-escape-nvim # Map keys without delay when typing | https://github.com/max397574/better-escape.nvim better-escape-nvim # Map keys without delay when typing | https://github.com/max397574/better-escape.nvim
toggleterm-nvim # A neovim lua plugin to help easily manage multiple terminal windows | https://github.com/akinsho/toggleterm.nvim?tab=readme-ov-file toggleterm-nvim # A neovim lua plugin to help easily manage multiple terminal windows | https://github.com/akinsho/toggleterm.nvim?tab=readme-ov-file
trouble-nvim # A pretty diagnostics list | https://github.com/folke/trouble.nvim
# ^ Useful utilities # ^ Useful utilities
# libraries that other plugins depend on # libraries that other plugins depend on
@ -112,6 +113,7 @@ with final.pkgs.lib; let
# bleeding-edge plugins from flake inputs # bleeding-edge plugins from flake inputs
(mkNvimPlugin inputs.presence-nvim "presence.nvim") (mkNvimPlugin inputs.presence-nvim "presence.nvim")
(mkNvimPlugin inputs.workspace-diagnostics-nvim "workspace-diagnostics.nvim")
# (mkNvimPlugin inputs.wf-nvim "wf.nvim") # (example) keymap hints | https://github.com/Cassin01/wf.nvim # (mkNvimPlugin inputs.wf-nvim "wf.nvim") # (example) keymap hints | https://github.com/Cassin01/wf.nvim
# ^ bleeding-edge plugins from flake inputs # ^ bleeding-edge plugins from flake inputs
]; ];

View file

@ -16,5 +16,9 @@ vim.lsp.start {
cmd = { 'asm-lsp' }, cmd = { 'asm-lsp' },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
capabilities = require('user.lsp').make_client_capabilities(), capabilities = require('user.lsp').make_client_capabilities(),
on_attach = function(client, bufnr)
require("nvim-navic").attach(client, bufnr)
require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
end,
-- capabilities = { offsetEncoding = "utf-8" }, -- capabilities = { offsetEncoding = "utf-8" },
} }

View file

@ -17,8 +17,9 @@ vim.lsp.start {
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
capabilities = require('user.lsp').make_client_capabilities(), capabilities = require('user.lsp').make_client_capabilities(),
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
require("nvim-navic").attach(client, bufnr) require("nvim-navic").attach(client, bufnr)
end require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
end
} }
local dap = require("dap") local dap = require("dap")
@ -59,19 +60,19 @@ if vim.fn.executable('OpenDebugAD7') == 1 then
return coroutine.create(function(coro) return coroutine.create(function(coro)
local opts = {} local opts = {}
pickers pickers
.new(opts, { .new(opts, {
prompt_title = "Path to executable", prompt_title = "Path to executable",
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}), finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
attach_mappings = function(buffer_number) attach_mappings = function(buffer_number)
actions.select_default:replace(function() actions.select_default:replace(function()
actions.close(buffer_number) actions.close(buffer_number)
coroutine.resume(coro, action_state.get_selected_entry()[1]) coroutine.resume(coro, action_state.get_selected_entry()[1])
end) end)
return true return true
end, end,
}) })
:find() :find()
end) end)
end, end,
stopAtBeginningOfMainSubprogram = true, stopAtBeginningOfMainSubprogram = true,

View file

@ -25,6 +25,10 @@ vim.lsp.start {
cmd = { lua_ls_cmd }, cmd = { lua_ls_cmd },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
capabilities = require('user.lsp').make_client_capabilities(), capabilities = require('user.lsp').make_client_capabilities(),
on_attach = function(client, bufnr)
require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
require("nvim-navic").attach(client, bufnr)
end,
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {

View file

@ -15,4 +15,8 @@ vim.lsp.start {
cmd = { 'nil' }, cmd = { 'nil' },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
capabilities = require('user.lsp').make_client_capabilities(), capabilities = require('user.lsp').make_client_capabilities(),
on_attach = function(client, bufnr)
require("nvim-navic").attach(client, bufnr)
require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
end,
} }

View file

@ -15,29 +15,8 @@ vim.lsp.start {
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
-- capabilities = require('user.lsp').make_client_capabilities(), -- capabilities = require('user.lsp').make_client_capabilities(),
single_file_support = true, single_file_support = true,
on_attach = function(client, bufnr)
require("nvim-navic").attach(client, bufnr)
require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
end,
} }
-- local dap = require("dap")
--
-- if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/launch.json") then
-- require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
-- end
--
-- dap.adapters.gdb = {
-- type = "executable",
-- command = "gdb",
-- args = { "-i", "dap" }
-- }
--
-- dap.configurations.c = {
-- {
-- name = "Launch",
-- type = "gdb",
-- request = "launch",
-- program = function()
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- end,
-- cwd = "${workspaceFolder}",
-- stopAtBeginningOfMainSubprogram = false,
-- },
-- }

View file

@ -12,6 +12,6 @@ require("aerial").setup({
-- end, -- end,
}) })
-- You probably also want to set a keymap to toggle aerial -- You probably also want to set a keymap to toggle aerial
vim.keymap.set("n", "<leader>a", "<cmd>AerialToggle!<CR>") vim.keymap.set("n", "<leader>a", "<cmd>AerialToggle! right<CR>")

View file

@ -13,34 +13,53 @@ keymap.set('n', 'Y', 'y$', { silent = true, desc = '[Y]ank to end of line' })
require('which-key').add({ require('which-key').add({
-- Buffer list navigation, ordering, ... -- Buffer list navigation, ordering, ...
{ "<C-b>", "<Cmd>BufferLineTogglePin<Cr>", desc = '[p]in buffer' }, { "<C-b>", "<Cmd>BufferLineTogglePin<Cr>", desc = '[p]in buffer' },
{ "gB", "<Cmd>BufferLinePick<Cr>", desc = '[g]o to [b]uffer' }, { "gB", "<Cmd>BufferLinePick<Cr>", desc = '[g]o to [b]uffer' },
{ '>b', "<Cmd>BufferLineMoveNext<Cr>", desc = 'move [b]uffer right' }, { '>b', "<Cmd>BufferLineMoveNext<Cr>", desc = 'move [b]uffer right' },
{ '<b', "<Cmd>BufferLineMovePrev<Cr>", desc = 'move [b]uffer left' }, { '<b', "<Cmd>BufferLineMovePrev<Cr>", desc = 'move [b]uffer left' },
{ '[b', "<Cmd>BufferLineCyclePrev<Cr>", desc = 'previous [b]uffer' }, { '[b', "<Cmd>BufferLineCyclePrev<Cr>", desc = 'previous [b]uffer' },
{ ']b', "<Cmd>BufferLineCycleNext<Cr>", desc = 'next [b]uffer' }, { ']b', "<Cmd>BufferLineCycleNext<Cr>", desc = 'next [b]uffer' },
{ '[B', vim.cmd.bfirst, desc = 'first [B]uffer' }, { '[B', vim.cmd.bfirst, desc = 'first [B]uffer' },
{ ']B', vim.cmd.blast, desc = 'last [B]uffer' }, { ']B', vim.cmd.blast, desc = 'last [B]uffer' },
{ '<leader>tn', vim.cmd.tabnew, desc = '[t]ab: [n]ew' }, { '<leader>tn', vim.cmd.tabnew, desc = '[t]ab: [n]ew' },
{ '<leader>tq', "<Cmd>bd<Cr>", desc = '[t]ab: [q]uit/close' }, { '<leader>tq', "<Cmd>bd<Cr>", desc = '[t]ab: [q]uit/close' },
{ '<leader>c', "<Cmd>bd<Cr>", desc = '[c]lose tab' }, { '<leader>c', "<Cmd>bd<Cr>", desc = '[c]lose tab' },
-- Window resizing -- Window resizing
{ "<C-Up>", "<Cmd>resize -2<CR>", desc = "resize split up" }, { "<C-Up>", "<Cmd>resize -2<CR>", desc = "resize split up" },
{ "<C-Down>", "<Cmd>resize +2<CR>", desc = "resize split down" }, { "<C-Down>", "<Cmd>resize +2<CR>", desc = "resize split down" },
{ "<C-Left>", "<Cmd>vertical resize +2<CR>", desc = "resize split left" }, { "<C-Left>", "<Cmd>vertical resize +2<CR>", desc = "resize split left" },
{ "<C-Right>", "<Cmd>vertical resize -2<CR>", desc = "resize split right" }, { "<C-Right>", "<Cmd>vertical resize -2<CR>", desc = "resize split right" },
-- ToggleTerm -- ToggleTerm
{ "<leader>Tf", "<Cmd>ToggleTerm direction=float<CR>", desc = "[T]oggleterm [f]loat" }, { "<leader>Tf", "<Cmd>ToggleTerm direction=float<CR>", desc = "[T]oggleterm [f]loat" },
{ "<leader>Th", "<Cmd>ToggleTerm size=10 direction=horizontal<CR>", desc = "[T]oggleterm [h]orizontal split" }, { "<leader>Th", "<Cmd>ToggleTerm size=10 direction=horizontal<CR>", desc = "[T]oggleterm [h]orizontal split" },
{ "<leader>Tv", "<Cmd>ToggleTerm size=80 direction=vertical<CR>", desc = "[T]oggleterm [v]ertical split" }, { "<leader>Tv", "<Cmd>ToggleTerm size=80 direction=vertical<CR>", desc = "[T]oggleterm [v]ertical split" },
{ "<F7>", '<Cmd>execute v:count . "ToggleTerm"<CR>', desc = "Toggle terminal" }, { "<F7>", '<Cmd>execute v:count . "ToggleTerm"<CR>', desc = "Toggle terminal" },
{ mode = "t", "<F7>", "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, { mode = "t", "<F7>", "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" },
{ mode = "i", "<F7>", "<Esc><Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, { mode = "i", "<F7>", "<Esc><Cmd>ToggleTerm<CR>", desc = "Toggle terminal" },
{ "<C-'>", '<Cmd>execute v:count . "ToggleTerm"<CR>', desc = "Toggle terminal" }, -- requires terminal that supports binding <C-'> { "<C-'>", '<Cmd>execute v:count . "ToggleTerm"<CR>', desc = "Toggle terminal" }, -- requires terminal that supports binding <C-'>
{ "<C-'>", "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, -- requires terminal that supports binding <C-'> { "<C-'>", "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, -- requires terminal that supports binding <C-'>
{ "<C-'>", "<Esc><Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, -- requires terminal that supports binding <C-'>` { "<C-'>", "<Esc><Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, -- requires terminal that supports binding <C-'>`
-- Trouble
{ "<leader>x", group = "trouble" },
{ "<leader>xt", "<cmd>Trouble diagnostics toggle<cr>", desc = "trouble: [t]oggle", },
{ "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "trouble: [b]uffer diagnostics", },
{ "<leader>xs", "<cmd>Trouble symbols toggle focus=false<cr>", desc = "trouble: [s]ymbols (Trouble)", },
{ "<leader>xl", "<cmd>Trouble lsp toggle focus=false win.position=right<cr>", desc = "trouble: [l]sp definitions / references / ...", },
{ "<leader>xL", "<cmd>Trouble loclist toggle<cr>", desc = "trouble: [L]ocation list", },
{ "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", desc = "trouble: [q]uickfix list", },
{
"<leader>xw",
noremap = true,
callback = function()
for _, client in ipairs(vim.lsp.buf_get_clients()) do
require("workspace-diagnostics").populate_workspace_diagnostics(client, 0)
end
end,
desc = "trouble: load [w]orkspace"
},
}) })
-- Toggle the quickfix list (only opens if it is populated) -- Toggle the quickfix list (only opens if it is populated)

View file

@ -16,3 +16,4 @@ require("better_escape").setup()
require("todo-comments").setup() require("todo-comments").setup()
require("bufferline").setup{} require("bufferline").setup{}
require("toggleterm").setup() require("toggleterm").setup()
require("trouble").setup()