diff --git a/Configs/nvim/.config/nvim/after/ftplugin/rust.lua b/Configs/nvim/.config/nvim/after/ftplugin/rust.lua new file mode 100644 index 0000000..e23cef2 --- /dev/null +++ b/Configs/nvim/.config/nvim/after/ftplugin/rust.lua @@ -0,0 +1,35 @@ +local rust = vim.cmd.RustLsp + +-- Override some LSP mappings + +local function opts(desc) + return { + silent = true, + buffer = vim.api.nvim_get_current_buf(), + desc = desc + } +end + +vim.keymap.set("n", "la", function() rust('codeAction') end, opts("Code action")) +vim.keymap.set("n", "lj", function() rust({ 'renderDiagnostic', "cycle" }) end, opts("Next diagnostic")) +vim.keymap.set("n", "lk", function() rust({ 'renderDiagnostic', "cycle_prev" }) end, opts("Prev diagnostic")) +vim.keymap.set("n", "ld", function() rust({ 'renderDiagnostic', "current" }) end, opts("Current diagnostic")) +vim.keymap.set("n", "K", function() rust({ 'hover', 'actions' }) end, opts("Lsp hover")) +vim.keymap.set("n", "J", function() rust("joinLines") end, opts("Keep cursor in column while joining lines")) +vim.keymap.set("v", "J", function() rust({ "moveItem", "down" }) end, opts("Move line down")) +vim.keymap.set("v", "K", function() rust({ "moveItem", "up" }) end, opts("Move line up")) + + +vim.keymap.set("n", "lq", function() + vim.ui.select({ + { label = "Expand macro", cmd = { "expandMacro", } }, + { label = "Explain error under cursor", cmd = { "explainError", "current" } }, + { label = "Go to related diagnostic", cmd = { "relatedDiagnostics", } }, + { label = "Open cargo.toml", cmd = { "openCargo", } }, + { label = "Open docs.rs of symbol", cmd = { "openDocs", } }, + { label = "Go to parent module", cmd = { "parentModule", } }, + }, { prompt = "RustLsp: ", format_item = function(item) return item.label end }, function(opt) + if opt == nil then return end + rust(opt.cmd) + end) +end, opts("Execute RustLsp action")) diff --git a/Configs/nvim/.config/nvim/lazy-lock.json b/Configs/nvim/.config/nvim/lazy-lock.json index e91621d..5b65762 100644 --- a/Configs/nvim/.config/nvim/lazy-lock.json +++ b/Configs/nvim/.config/nvim/lazy-lock.json @@ -18,6 +18,7 @@ "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-dap": { "branch": "master", "commit": "5dd4d50f2e6a2eaf9e57fad023d294ef371bda35" }, "nvim-dap-view": { "branch": "main", "commit": "390dae6bf67f3342ebb481159932ef0fe54822ba" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-lint": { "branch": "master", "commit": "b47cbb249351873e3a571751c3fb66ed6369852f" }, "nvim-lspconfig": { "branch": "master", "commit": "b8e7957bde4cbb3cb25a13a62548f7c273b026e9" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, @@ -26,10 +27,12 @@ "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "render-markdown": { "branch": "main", "commit": "4a39681990fb515d00dd898de3d7bf2973805f1a" }, + "rustaceanvim": { "branch": "master", "commit": "66398662c07d265b226897500ed50eafba3dffb4" }, "smart-splits.nvim": { "branch": "master", "commit": "5ef94ca23b28148187846fc46f10184aad4d17b0" }, "transfer.nvim": { "branch": "main", "commit": "ab12253c09f83a5b0b6ee108fc131be45abe446a" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "ts-node-action": { "branch": "master", "commit": "bfaa787cc85d753af3c19245b4142ed727a534b5" }, + "typescript-tools.nvim": { "branch": "master", "commit": "3c501d7c7f79457932a8750a2a1476a004c5c1a9" }, "vim-dadbod": { "branch": "master", "commit": "e95afed23712f969f83b4857a24cf9d59114c2e6" }, "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" }, "vim-dadbod-ui": { "branch": "master", "commit": "2900a1617b3df1a48683d872eadbe1101146a49a" }, diff --git a/Configs/nvim/.config/nvim/lua/aleidk/keymaps.lua b/Configs/nvim/.config/nvim/lua/aleidk/keymaps.lua index f7a3019..5be823b 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/keymaps.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/keymaps.lua @@ -31,4 +31,10 @@ vim.keymap.set("n", "", "j", { desc = "Move to bottom window", silent vim.keymap.set("n", "", "k", { desc = "Move to top window", silent = true }) vim.keymap.set("n", "", "l", { desc = "Move to right window", silent = true }) --- stylua: ignore end +-- LSP + +vim.keymap.set("n", "lf", vim.lsp.buf.format, { desc = "Format document with LSP", silent = true }) +vim.keymap.set("n", "lj", function() vim.diagnostic.jump({ count = 1 }) end, + { desc = "Go to next diagnostic", silent = true }) +vim.keymap.set("n", "lk", function() vim.diagnostic.jump({ count = -1 }) end, + { desc = "Go to next diagnostic", silent = true }) diff --git a/Configs/nvim/.config/nvim/lua/aleidk/options.lua b/Configs/nvim/.config/nvim/lua/aleidk/options.lua index 07f633b..e5eec57 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/options.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/options.lua @@ -150,15 +150,27 @@ vim.filetype.add({ -- ╭─────────────────────────────────────────────────────────╮ -- │ LSP │ -- ╰─────────────────────────────────────────────────────────╯ + +vim.lsp.config("rust-analyzer", { + tools = { + code_actions = { + ui_select_fallback = true + } + } +}) + vim.lsp.enable({ "bashls", + "biome", "lua_ls", "nushell", "pyright", "ruff", - "rust_analyzer", + -- "rust_analyzer", -- managed by rustacean.nvim }) +vim.lsp.inlay_hint.enable(true) + vim.diagnostic.config({ virtual_lines = { current_line = true }, }) diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua index cc0c78b..1e4764c 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua @@ -24,10 +24,22 @@ return { }, }, config = function() - require("dap").adapters.codelldb = { + local dap = require("dap") + + dap.adapters.codelldb = { type = "executable", command = "codelldb", } + + dap.listeners.before['event_initialized']['toggle_lsp_virtual_text'] = function() + vim.lsp.inlay_hint.enable(false) + end + + dap.listeners.after['event_terminated']['toggle_lsp_virtual_text'] = function() + vim.lsp.inlay_hint.enable(true) + end + + require("nvim-dap-virtual-text").setup() end, keys = { { @@ -71,5 +83,16 @@ return { { "dX", function() require("dap").terminate() end, desc = "Terminate" }, { "ud", function() require("dap-view").toggle(true) end, desc = "Toggle dap-view" }, } - } + }, + { + "theHamsta/nvim-dap-virtual-text", + dependencies = { "mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter" }, + config = function() + require('nvim-dap-virtual-text').setup({ + only_first_definition = false, + all_references = true, + virt_text_pos = "eol", + }) + end + }, } diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua index 153e3f6..948f2b3 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua @@ -13,18 +13,6 @@ return { { "ls", function() require("ts-node-action").node_action() end, desc = "Node Action" } } }, - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = "${3rd}/luv/library", words = { "vim%.uv" } } - }, - }, - }, { -- allow to reuse the same nvim instance when opening files in the same terminal context "willothy/flatten.nvim", diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/language-support.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/language-support.lua new file mode 100644 index 0000000..c47309b --- /dev/null +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/language-support.lua @@ -0,0 +1,24 @@ +return { + { + 'mrcjkb/rustaceanvim', + version = '^6', -- Recommended + lazy = false, -- This plugin is already lazy + }, + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } } + }, + }, + }, + { + "pmizio/typescript-tools.nvim", + dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + opts = {}, + } +} diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua index d9d304b..7a7ab66 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua @@ -149,6 +149,7 @@ return { { mode = "n", keys = "bl", postkeys = "b" }, { mode = "n", keys = "d", desc = "+Debugger" }, { mode = "n", keys = "dh", postkeys = "d" }, + { mode = "n", keys = "dJ", postkeys = "d" }, { mode = "n", keys = "dj", postkeys = "d" }, { mode = "n", keys = "dk", postkeys = "d" }, { mode = "n", keys = "dl", postkeys = "d" },