diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 56d6a5d..bc5f4da 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -27,7 +27,7 @@ "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, - "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, + "rustaceanvim": { "branch": "master", "commit": "c8856f9ab078976422a04e857da3b6eadce7cd3d" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 257a455..b98b9eb 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -247,18 +247,20 @@ return { "neovim/nvim-lspconfig", }, config = function() - local config = require "mason-lspconfig" - local lsp = require "lspconfig" - local cmp = require "cmp_nvim_lsp" + local config = require "mason-lspconfig" + local lsp = require "lspconfig" + local cmp = require "cmp_nvim_lsp" + + local noop = function() end config.setup { automatic_installation = true, -- NOTE - -- Haskell: Use GHCup installation instead of hls + -- Haskell: Managed by GHCup ensure_installed = { "lua_ls", -- Lua - "bashls", -- Bash "rust_analyzer", -- Rust + "bashls", -- Bash "html", -- HTML "cssls", -- CSS / SCSS "tsserver", -- TypeScript @@ -273,12 +275,13 @@ return { } config.setup_handlers { - function(server) - lsp[server].setup { + function(name) + lsp[name].setup { single_file_support = true, capabilities = cmp.default_capabilities(), } end, + ['rust_analyzer'] = noop, } end, }, @@ -323,9 +326,13 @@ return { }, -- Tools for Rust - require "plugins.rust-tools" { - "simrat39/rust-tools.nvim", - ft = "rust", + { + "mrcjkb/rustaceanvim", + version = "^3", + ft = { "rust" }, + init = function() + require 'plugins.rust-tools' + end }, -- Tools for Haskell diff --git a/nvim/lua/plugins/rust-tools.lua b/nvim/lua/plugins/rust-tools.lua index 5f2ec29..5331e8a 100644 --- a/nvim/lua/plugins/rust-tools.lua +++ b/nvim/lua/plugins/rust-tools.lua @@ -1,44 +1,26 @@ -local nmap = require("utility").keymap('n') -local M = {} +local util = require 'utility' +local n = util.keymap 'n' -function M.config() - local tools = require "rust-tools" - local mason = require "mason-registry" - local capabilities = require("cmp_nvim_lsp").default_capabilities() +vim.g.rustaceanvim = function() + local mason = require 'mason-registry' + local tools = require 'rustaceanvim' + local config = require 'rustaceanvim.config' - local lsp_root = mason.get_package("codelldb"):get_install_path() .. "/extension/" - local lsp_path = lsp_root .. "adapter/codelldb" - local lib_path = lsp_root .. "lldb/lib/liblldb.so" + local lsp_root = mason.get_package('codelldb'):get_install_path() .. '/extension/' + local lsp_path = lsp_root .. 'adapter/codelldb' + local lib_path = lsp_root .. 'lldb/lib/liblldb.so' - local opts = { + ---@type RustaceanOpts + return { server = { - standalone = true, - capabilities = capabilities, on_attach = function(_, bufnr) - nmap "" (tools.hover_actions.hover_actions) {buffer=bufnr} - nmap "a" (tools.code_action_group.code_action_group) {buffer=bufnr} + n '' (tools.hover_actions.hover_actions) {buffer=bufnr} + n 'a' (tools.code_action_group.code_action_group) {buffer=bufnr} end, - ["rust-analyzer"] = { - cargo = { allFeatures = true }, - checkOnSave = { - -- default = "cargo check", - command = "clippy", - allFeatures = true, - } - } }, dap = { - adapter = require("rust-tools.dap").get_codelldb_adapter(lsp_path, lib_path), + adapter = config.get_codelldb_adapter(lsp_path, lib_path), }, } - - tools.setup(opts) -end - - ----@param config table ----@return table -return function(config) - return vim.tbl_extend("keep", config, M) end