Files
dotfiles/common/.config/nvim/lua/plugins/code-lsp.lua
Pratik Tripathy 8c52c7a881 feat(neovim-rust): Rust LSP, debugging, testing and keymaps
- `rustaceanvim` for LSP config
- Rust ft specific keymaps in `after/ftplugin`
- `nvim-dap` for Rust debugging with codelldb
- `rustaceanvim.neotest` for Rust testing
- `rcasia/neotest-bash` for Bash testing
- Better keymaps for running tests
- Inlay hint UI improvements
2025-07-29 11:25:08 +05:30

167 lines
6.0 KiB
Lua

return {
{
"neovim/nvim-lspconfig",
cond = require("config.util").is_not_vscode(),
dependencies = {
{ "williamboman/mason.nvim", config = true }, -- TIP: Must be loaded before dependants
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
"saghen/blink.cmp",
},
config = function()
local servers = {}
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- TIP: `nvim-lspconfig` has default LSP configs in its DB which saves time
-- Useful even after NeoVim 0.11, which made LSP setup much easier
-- Configs in `nvim/lsp/*` are APPENDED to each LSP setup here
require("mason-lspconfig").setup({
handlers = {
function(server_name)
local server = servers[server_name] or {}
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
server.inlay_hints = { enabled = true }
server.diagnostics = {
underline = true,
update_in_insert = false,
severity_sort = true,
}
require("lspconfig")[server_name].setup(server)
end,
},
})
end,
},
{
"j-hui/fidget.nvim",
cond = require("config.util").is_not_vscode(),
opts = {
progress = {
poll_rate = 1, -- How and when to poll for progress messages
suppress_on_insert = true, -- Suppress new messages while in insert mode
ignore_done_already = true, -- Ignore new tasks that are already complete
ignore_empty_message = true, -- Ignore new tasks that don't contain a message
ignore = {}, -- List of LSP servers to ignore
display = {
render_limit = 1, -- How many LSP messages to show at once
-- skip_history = true, -- Whether progress notifications should be omitted from history
},
},
notification = {
poll_rate = 2, -- How often to udate and render notifications
filter = vim.log.levels.WARN, -- Minimum notifications level
window = { winblend = 0 },
},
},
},
-- NeoVim
{ "folke/lazydev.nvim", ft = "lua" },
-- Rust
{
"mrcjkb/rustaceanvim",
version = "^6",
lazy = false,
init = function()
vim.g.rustaceanvim = {
server = {
-- Keymaps in ../../after/ftplugin/rust.lua
-- LSP configuration
default_settings = {
["rust-analyzer"] = {
cargo = { allFeatures = true },
diagnostics = {
enable = true,
enableExperimental = true,
},
completion = {
addCallArgumentSnippets = true,
addCallParenthesis = true,
postfix = { enable = true },
autoimport = { enable = true },
},
},
inlayHints = {
bindingModeHints = { enable = false },
chainingHints = { enable = true },
closingBraceHints = { enable = true, minLines = 25 },
closureReturnTypeHints = { enable = "never" },
lifetimeElisionHints = { enable = "never", useParameterNames = false },
maxLength = 25,
parameterHints = { enable = true },
reborrowHints = { enable = "never" },
renderColons = true,
typeHints = {
enable = true,
hideClosureInitialization = false,
hideNamedConstructor = false,
},
},
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
},
},
},
dap = {
adapter = {
type = "executable",
command = "codelldb",
name = "codelldb",
},
},
}
end,
},
{
"saecki/crates.nvim",
tag = "stable",
config = function()
require("crates").setup()
end,
},
-- Javascript/Typescript/React/Vue
--
-- Automatically add closing tags for HTML and JSX
{
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup()
end,
},
-- Intelligent commenting on JSX
{
"JoosepAlviste/nvim-ts-context-commentstring",
opts = {
options = {
enable_autocmd = false,
},
},
config = function()
vim.g.skip_ts_context_commentstring_module = true
end,
},
-- Highlight colors
{
"brenoprata10/nvim-highlight-colors",
setup = {
enable_tailwind = true,
},
config = function()
require("nvim-highlight-colors").setup()
end,
},
}