From 59dd32000ca3cb738f50c7dabfd038aee5cdf703 Mon Sep 17 00:00:00 2001 From: spenserlee Date: Mon, 2 Dec 2024 02:19:35 -0800 Subject: [PATCH] Switch to rustaceanvim + update all plugins for nvim v0.10.2 Moving away from rust-tools since it's not maintained any longer and was causing AutoGroup bugs when in insert mode. Unfortunately, now when debugging rust programs, I get some weird errors when inspecting some variables: "Error: Invalid Value Object" Similar issue here: Possibly it's related to new rust version / codelldb incompatibility? --- .config/nvim/init.lua | 236 +++++++++++++----------------------- .config/nvim/lazy-lock.json | 9 +- README.md | 22 ++++ 3 files changed, 111 insertions(+), 156 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 49ab73b..2baee51 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,13 +1,6 @@ -- Keep nvim/vim independent configs in vimscript for basic functionality vim.cmd("source ~/.config/nvim/viml/init.vim") --- TODO: --- * fix rust debugging executable, tests work, but nothing else. --- * update neovim to latest 10.2 --- * switch to rustaceanvim --- * verify debugging still works. --- - -- @nocheckin -- good references -- https://github.com/Alexis12119/nvim-config/blob/main/lua/core/autocommands.lua @@ -453,21 +446,6 @@ require("lazy").setup({ -- -- }) -- end -- }, - { - "neovim/nvim-lspconfig", - dependencies = { - { - "folke/neodev.nvim", -- LSP for nvim config itself - config = function() - require("neodev").setup() - end - }, - }, - inlay_hints = { - enable = true, - }, - }, - -- TODO: get nvim-dap working with rust.. it's a huge pain.. { "williamboman/mason.nvim", build = ":MasonUpdate", @@ -491,7 +469,7 @@ require("lazy").setup({ -- import mason-lspconfig local mason_lspconfig = require("mason-lspconfig") local mason_tool_installer = require("mason-tool-installer") - local mason_dap = require("mason-nvim-dap") + -- local mason_dap = require("mason-nvim-dap") -- enable mason and configure icons mason.setup({ @@ -512,7 +490,7 @@ require("lazy").setup({ "dockerls", "lua_ls", "pylsp", - "rust_analyzer", + -- "rust_analyzer", "yamlls", }, -- auto-install configured servers (with lspconfig) @@ -565,16 +543,88 @@ require("lazy").setup({ end, }, { - "rust-lang/rust.vim", - ft = "rust", + -- https://github.com/mrcjkb/rustaceanvim/discussions/122 + 'mrcjkb/rustaceanvim', + version = '^5', -- Recommended + ft = { 'rust' }, + lazy = false, init = function() - -- vim.g.rustfmt_autosave = 1 - end - }, - -- {"simrat39/rust-tools.nvim"}, + vim.g.rustaceanvim = { + -- Plugin configuration + tools = { + autoSetHints = true, + -- the neovim 0.10 native inlay hints kind of suck... + -- https://github.com/neovim/neovim/issues/28261 + inlay_hints = { + show_parameter_hints = true, + parameter_hints_prefix = "<- ", + other_hints_prefix = "=> ", + } + }, + -- LSP configuration + server = { + on_attach = function(client, bufnr) + -- mappings(client, bufnr) + -- require("illuminate").on_attach(client) + + local bufopts = { + noremap = true, + silent = true, + buffer = bufnr + } + vim.keymap.set('n', 'A', "RustLsp codeAction", bufopts) + vim.keymap.set('n', 'a', "RustLsp hover actions", bufopts) + vim.keymap.set('n', 'K', "RustLsp hover actions", bufopts) + end, + settings = { + -- rust-analyzer language server configuration + ['rust-analyzer'] = { + -- assist = { + -- importEnforceGranularity = true, + -- importPrefix = "create" + -- }, + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + checkOnSave = { + -- default: `cargo check` + command = "clippy", + allFeatures = true, + extraArgs = { "--no-deps" }, + }, + -- inlayHints = { + -- lifetimeElisionHints = { + -- enable = true, + -- useParameterNames = true + -- } + -- } + } + } + }, + -- DAP configuration + dap = {}, + } + end + }, { - "Ciel-MC/rust-tools.nvim", - ft = "rust", + "neovim/nvim-lspconfig", + dependencies = { + { + "folke/neodev.nvim", -- LSP for nvim config itself + config = function() + require("neodev").setup() + end + }, + }, + -- config = function() + -- require("lspconfig").setup({ + -- servers = { + -- rust_analyzer = {}, + -- }, + -- }) + -- end, }, { -- nice plugin which solves the terrible native lsp inlay hint behaviour. @@ -592,69 +642,6 @@ require("lazy").setup({ -- useful command to toggle inlay hint native display -- require("lsp-endhints").toggle() }, - - - -- rustaceanvim supposedly replaces rust-tools and claims "no setup", but I - -- cannot get it to work... - -- { - -- 'mrcjkb/rustaceanvim', - -- version = '^4', -- Recommended - -- ft = { 'rust' }, - -- lazy = false, - -- init = function() - -- vim.g.rustaceanvim = { - -- -- Plugin configuration - -- tools = { - -- autoSetHints = true, - -- inlay_hints = { - -- show_parameter_hints = true, - -- parameter_hints_prefix = "<- ", - -- other_hints_prefix = "=> " - -- } - -- }, - -- -- LSP configuration - -- server = { - -- on_attach = function(client, bufnr) - -- mappings(client, bufnr) - -- require("illuminate").on_attach(client) - -- - -- local bufopts = { - -- noremap = true, - -- silent = true, - -- buffer = bufnr - -- } - -- -- vim.keymap.set('n', 'rr', "RustLsp runnables", bufopts) - -- vim.keymap.set('n', 'K', "RustLsp hover actions", bufopts) - -- end, - -- settings = { - -- -- rust-analyzer language server configuration - -- ['rust-analyzer'] = { - -- assist = { - -- importEnforceGranularity = true, - -- importPrefix = "create" - -- }, - -- cargo = { allFeatures = true }, - -- checkOnSave = { - -- -- default: `cargo check` - -- command = "clippy", - -- allFeatures = true - -- }, - -- inlayHints = { - -- lifetimeElisionHints = { - -- enable = true, - -- useParameterNames = true - -- } - -- } - -- } - -- } - -- }, - -- -- DAP configuration - -- dap = { - -- }, - -- } - -- end - -- }, - { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", @@ -1188,7 +1175,7 @@ vim.diagnostic.config({ severity_sort = true, float = { border = "rounded", - source = "always", + -- source = "always", }, }) @@ -1272,61 +1259,8 @@ require("mason-lspconfig").setup_handlers({ -- See :help lspconfig-setup lspconfig[server].setup({}) end, - ["rust_analyzer"] = function () - local rt = require("rust-tools") - -- local mason_registry = require("mason-registry") - -- - -- local codelldb = mason_registry.get_package("codelldb") - -- local extension_path = codelldb:get_install_path() .. "/extension/" - -- local codelldb_path = extension_path .. "adapter/codelldb" - -- local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib" - - local home_path = os.getenv("HOME") .. "/" - local mason_path = home_path .. ".local/share/nvim/mason/packages/" - local codelldb_path = mason_path .. "codelldb/extension/adapter/codelldb" - local liblldb_path = mason_path .. "codelldb/extension/lldb/lib/liblldb.so" - - -- print("codelldb_path = " .. codelldb_path) - -- print("liblldb_path = " .. liblldb_path) - - rt.setup({ - dap = { - adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path), - }, - server = { - capabilities = require("cmp_nvim_lsp").default_capabilities(), - on_attach = function(_, bufnr) - vim.keymap.set("n", "a", rt.hover_actions.hover_actions, {buffer = bufnr }) - vim.keymap.set("n", "A", rt.code_action_group.code_action_group, {buffer = bufnr }) - end - }, - tools = { - inlay_hints = { - auto = false, - }, - hover_actions = { - auto_focus = true, - }, - }, - -- why the hell doesn't clippy work... ffs man the documentation is - -- a clusterfuck. 20 pages of issues no full solutions... - cargo = { - allFeatures = true, - }, - checkOnSave = { - enable = true, - command = "clippy", - extraArgs = { - "--", - "--no-deps", - "-Dclippy::correctness", - "-Dclippy::complexity", - "-Wclippy::perf", - "-Wclippy::pedantic", - }, - } - }) - end, + -- don't setup rust_analyzer with meson, rustaceanvim handles it now. + ["rust_analyzer"] = function () end, ["lua_ls"] = function () lspconfig.lua_ls.setup { settings = { diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 4ac5363..ba43fab 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -29,19 +29,18 @@ "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, "nvim-lsp-endhints": { "branch": "main", "commit": "b39e719f0931df6734369d37c97a12a61c4d1d92" }, - "nvim-lspconfig": { "branch": "master", "commit": "911167921d49cd5c1c9b2436031d0da3945e787f" }, + "nvim-lspconfig": { "branch": "master", "commit": "f59eba2ec08edda0e09ecf34ec29ad10a429e48d" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-surround": { "branch": "main", "commit": "9f0cb495f25bff32c936062d85046fbda0c43517" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, - "nvim-treesitter": { "branch": "master", "commit": "04401b5dd17c3419dae5141677bd256f52d54733" }, - "nvim-treesitter-context": { "branch": "master", "commit": "0f3332788e0bd37716fbd25f39120dcfd557c90f" }, + "nvim-treesitter": { "branch": "master", "commit": "69170c93149ddb71a22bd954514806395c430c02" }, + "nvim-treesitter-context": { "branch": "master", "commit": "920999bf53daa63ddf12efdeb5137a7cea1cc201" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, "nvim-treesitter-textsubjects": { "branch": "master", "commit": "a8d2844bba925d9450ef7ab215f3b054028288ca" }, "nvim-web-devicons": { "branch": "master", "commit": "203da76ecfbb4b192cf830665b03eb651b635c94" }, "oil.nvim": { "branch": "master", "commit": "3c2de37accead0240fbe812f5ccdedfe0b973557" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, - "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, + "rustaceanvim": { "branch": "master", "commit": "0790912df13835ca9bdd5e17efc91a58629f2a23" }, "vim-fugitive": { "branch": "master", "commit": "320b18fba2a4f2fe3c8225c778c687e0d2620384" }, "vim-highlighter": { "branch": "main", "commit": "04b56c5bd44f1456e39dfee032ccf29bfaa9a587" }, "vim-obsession": { "branch": "master", "commit": "ed9dfc7c2cc917ace8b24f4f9f80a91e05614b63" }, diff --git a/README.md b/README.md index 06ec8ce..da4be0f 100644 --- a/README.md +++ b/README.md @@ -120,3 +120,25 @@ sudo apt install npm curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash ``` +* Luarocks +``` +# get latest release: http://luarocks.github.io/luarocks/releases +sudo apt install build-essential libreadline-dev unzip + + +# install latest lua (maybe not necessary...?) +curl -L -R -O https://www.lua.org/ftp/lua-5.4.7.tar.gz +tar zxf lua-5.4.7.tar.gz +cd lua-5.4.7 +make linux test +sudo make install +cd ../ + +# install laurocks +cd luarocks-3.11.1/ +./configure --with-lua-include=/usr/local/include +make +sudo make install +sudo apt install lua5.1 + +```