feat(neovim): Rust dev with rustaceanvim & LSP servers installation through OS installer and NOT mason

- Use `rustaceanvim` for Rust development
- `rustaceanvim` keymaps in NeoVim `after` file
- Remove Rust LSP setup through builtin LSP
- Remove LSP installations from Mason when equivalent available through
  OS installers
- All LSP plugins in `code-lsp.lua`
This commit is contained in:
Pratik Tripathy
2025-07-28 10:44:32 +05:30
parent e6827f91ad
commit dd9246cda7
7 changed files with 104 additions and 33 deletions

View File

@@ -0,0 +1,23 @@
-- TODO: Map all native Nvim 0.11 LSP commands to corresponding rustaceanvim ones
-- grn -> Rename
-- grr -> References
-- gri -> Implementation
-- gO -> document_symbol
-- gra -> code_action
-- Mine
-- F2 -> Rename
-- gD -> Go to definition
-- <leader>cr -> References
-- <leader>co -> document_symbol
if pcall(require, "rustaceanvim") then
local bufnr = vim.api.nvim_get_current_buf()
vim.keymap.set("n", "<C-.>", function()
vim.cmd.RustLsp("codeAction")
end, { silent = true, buffer = bufnr })
vim.keymap.set("n", "K", function()
vim.cmd.RustLsp({ "hover", "actions" })
end, { silent = true, buffer = bufnr })
end

View File

@@ -1 +0,0 @@
return {}

View File

@@ -1,3 +1,7 @@
-- TIP:
-- Step 1: Install the LSP through either of the following:
-- OS Installer > Brew-linux > Mason NeoVim Plugin
-- Step 2: Append the LSP server name in the below array
vim.lsp.enable({ vim.lsp.enable({
"bashls", "bashls",
"cssls", "cssls",
@@ -6,38 +10,58 @@ vim.lsp.enable({
"html", "html",
"jsonls", "jsonls",
"lua_ls", "lua_ls",
"omnisharp",
"pylsp", "pylsp",
"rust_analyzer",
"sqlls", "sqlls",
"ts_ls", "ts_ls",
-- TODO: Enable inlay_hints for all of them
}) })
-- TIP: On new systems, install these through Mason -- TIP: On new systems, install these through Mason
-- They aren't usually found on either OS installer or brew-linux
---@diagnostic disable-next-line: unused-local ---@diagnostic disable-next-line: unused-local
local to_installed = vim.tbl_keys({ local to_installed = vim.tbl_keys({
"black", -- Python formatter "codelldb",
"csharpier", -- C# formatter "css-lsp",
"djlint", -- Handlebar Formatter "docker-compose-language-service",
"markdown-toc", "html-lsp",
"markdownlint", "json-lsp",
"netcoredbg", -- C# Debugger "sqlls",
"prettier",
"prettierd",
"shellharden",
"shfmt",
"stylua",
"trivy", -- Vulnerability Linter
"yamlfmt",
}) })
-- Setup native diagnostic
vim.diagnostic.config({
underline = true,
update_in_insert = false,
severity_sort = true,
float = {
border = "rounded",
source = true,
},
virtual_text = {
enabled = true,
severity = { min = vim.diagnostic.severity.ERROR },
},
virtual_lines = {
current_line = true,
severity = { min = vim.diagnostic.severity.INFO },
},
})
-- Change diagnostic symbols in the sign column (gutter)
if vim.g.have_nerd_font then
local signs = require("config.util").icons.diagnostics
local diagnostic_signs = {}
for type, icon in pairs(signs) do
diagnostic_signs[vim.diagnostic.severity[type]] = icon
end
vim.diagnostic.config({ signs = { text = diagnostic_signs } })
end
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
callback = function(event) callback = function(event)
local client = vim.lsp.get_client_by_id(event.data.client_id) local client = vim.lsp.get_client_by_id(event.data.client_id)
-- Setup LSP completion -- Setup native LSP completion
-- This is already done by blink, but better prefer the builtin one -- This is already done by blink, but better prefer the builtin one
if client:supports_method("textDocument/completion") then if client:supports_method("textDocument/completion") then
vim.opt.completeopt = { "menu", "menuone", "noinsert", "fuzzy", "popup" } vim.opt.completeopt = { "menu", "menuone", "noinsert", "fuzzy", "popup" }

View File

@@ -57,4 +57,28 @@ return {
}, },
}, },
}, },
-- Rust
{
"mrcjkb/rustaceanvim",
version = "^6",
config = function()
vim.g.rusteceanvim = {
dap = {
adapter = {
type = "executable",
command = "codelldb",
name = "codelldb",
},
},
}
end,
},
{
"saecki/crates.nvim",
tag = "stable",
config = function()
require("crates").setup()
end,
},
} }

View File

@@ -1,9 +0,0 @@
return {
{
"saecki/crates.nvim",
tag = "stable",
config = function()
require("crates").setup()
end,
},
}

View File

@@ -3,6 +3,7 @@
bat bat
bats-core bats-core
dnscrypt-proxy dnscrypt-proxy
dockerfile-language-server
fd fd
fzf fzf
gitleaks gitleaks
@@ -13,20 +14,31 @@ kondo
lazydocker lazydocker
lazygit lazygit
lua lua
luajit
lua-language-server lua-language-server
luajit
markdown-toc
markdownlint-cli
marksman
n n
neovim neovim
prettier
prettierd prettierd
python-lsp-server
python@3.12 python@3.12
rclone rclone
sccache sccache
shellcheck shellcheck
shellharden
shodan shodan
speedtest-cli speedtest-cli
sqlite sqlite
stylua
taplo
tlrc tlrc
tokei tokei
tree-sitter tree-sitter
typescript-language-server
vue-language-server
yamlfmt
yt-dlp yt-dlp
zoxide zoxide

View File

@@ -10,6 +10,7 @@ libavcodec-extra
akmod-nvidia akmod-nvidia
dnf-plugins-core dnf-plugins-core
libva-nvidia-driver libva-nvidia-driver
nodejs-bash-language-server
xorg-x11-drv-nvidia-cuda xorg-x11-drv-nvidia-cuda
# Common # Common
@@ -17,7 +18,6 @@ aspnetcore-runtime-8.0
bash bash
bat bat
bleachbit bleachbit
brave-browser
btop btop
cmake cmake
code code
@@ -29,8 +29,6 @@ docker-ce-cli
docker-compose-plugin docker-compose-plugin
dolphin dolphin
dolphin-plugins dolphin-plugins
dotnet-runtime-8.0
dotnet-sdk-8.0
evolution-ews evolution-ews
evolution-mapi evolution-mapi
fd-find fd-find
@@ -72,7 +70,7 @@ qbittorrent
rclone rclone
ripgrep ripgrep
sccache sccache
ShellCheck shellcheck
simplescreenrecorder simplescreenrecorder
smplayer smplayer
software-properties-common software-properties-common
@@ -81,6 +79,7 @@ syncthing
tmux tmux
tokei tokei
tree-sitter-cli tree-sitter-cli
trivy
ufw ufw
ulauncher ulauncher
vim vim
@@ -94,7 +93,6 @@ zsh
# FreeBSD packages # FreeBSD packages
codespell codespell
dotnet
html html
fusefs-lkl fusefs-lkl
firefox-esr firefox-esr