diff --git a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua index ed7f0bf..5b4f78a 100644 --- a/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua +++ b/Configs/nvim_unstable/.config/nvim_unstable/lua/aleidk/options.lua @@ -50,7 +50,6 @@ opt.splitbelow = true -- Put new windows below current opt.splitright = true -- Put new windows right of current opt.tabstop = 2 -- Number of spaces tabs count for opt.termguicolors = true -- True color support -opt.timeoutlen = 300 opt.undofile = true opt.undolevels = 10000 opt.updatetime = 200 -- Save swap file and trigger CursorHold @@ -157,5 +156,24 @@ vim.lsp.enable({ }) vim.diagnostic.config({ - virtual_lines = { current_line = true } + virtual_lines = { current_line = true }, + on_attach = function(_, bufnr) + vim.keymap.set({ "n", "x", "v" }, "la", vim.lsp.buf.code_action, { buffer = bufnr, desc = "Code Action" }) + vim.keymap.set({ "n", "x", "v" }, "ld", vim.diagnostic.open_float, { desc = "Show diagnostic under cursor" }) + vim.keymap.set({ "n", "x", "v" }, "lc", function() + local curpos = vim.fn.getcurpos() + vim.print(curpos) + local diagnostics = vim.diagnostic.get(0, { lnum = curpos[2] - 1 }) + + if #diagnostics == 0 then + vim.notify("No diagnostic under cursor") + return + end + + local diagnostic = diagnostics[1] + local msg = string.format("%s [%s]: %s", diagnostic.source, diagnostic.code, diagnostic.message) + vim.fn.setreg("+", msg) + vim.notify("Diagnostic saved to clipboard:\n" .. msg) + end, { buffer = bufnr, desc = "Copy diagnostic to clipboard" }) + end, })