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

19
flake.lock generated

@ -216,7 +216,8 @@
"flake-utils": "flake-utils",
"gen-luarc": "gen-luarc",
"nixpkgs": "nixpkgs_2",
"presence-nvim": "presence-nvim"
"presence-nvim": "presence-nvim",
"workspace-diagnostics-nvim": "workspace-diagnostics-nvim"
}
},
"systems": {
@ -233,6 +234,22 @@
"repo": "default",
"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",

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

@ -99,6 +99,7 @@ with final.pkgs.lib; let
nvim-unception # Prevent nested neovim sessions | nvim-unception
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
trouble-nvim # A pretty diagnostics list | https://github.com/folke/trouble.nvim
# ^ Useful utilities
# libraries that other plugins depend on
@ -112,6 +113,7 @@ with final.pkgs.lib; let
# bleeding-edge plugins from flake inputs
(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
# ^ bleeding-edge plugins from flake inputs
];

@ -16,5 +16,9 @@ vim.lsp.start {
cmd = { 'asm-lsp' },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
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" },
}

@ -18,6 +18,7 @@ vim.lsp.start {
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
}

@ -25,6 +25,10 @@ vim.lsp.start {
cmd = { lua_ls_cmd },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
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 = {
Lua = {
runtime = {

@ -15,4 +15,8 @@ vim.lsp.start {
cmd = { 'nil' },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
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,
}

@ -15,29 +15,8 @@ vim.lsp.start {
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
-- capabilities = require('user.lsp').make_client_capabilities(),
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,
-- },
-- }

@ -12,6 +12,6 @@ require("aerial").setup({
-- end,
})
-- 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>")

@ -41,6 +41,25 @@ require('which-key').add({
{ "<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-'>", "<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)

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