mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
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:
23
common/.config/nvim/after/ftplugin/rust.lua
Normal file
23
common/.config/nvim/after/ftplugin/rust.lua
Normal 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
|
||||
@@ -1 +0,0 @@
|
||||
return {}
|
||||
@@ -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({
|
||||
"bashls",
|
||||
"cssls",
|
||||
@@ -6,38 +10,58 @@ vim.lsp.enable({
|
||||
"html",
|
||||
"jsonls",
|
||||
"lua_ls",
|
||||
"omnisharp",
|
||||
"pylsp",
|
||||
"rust_analyzer",
|
||||
"sqlls",
|
||||
"ts_ls",
|
||||
-- TODO: Enable inlay_hints for all of them
|
||||
})
|
||||
|
||||
-- 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
|
||||
local to_installed = vim.tbl_keys({
|
||||
"black", -- Python formatter
|
||||
"csharpier", -- C# formatter
|
||||
"djlint", -- Handlebar Formatter
|
||||
"markdown-toc",
|
||||
"markdownlint",
|
||||
"netcoredbg", -- C# Debugger
|
||||
"prettier",
|
||||
"prettierd",
|
||||
"shellharden",
|
||||
"shfmt",
|
||||
"stylua",
|
||||
"trivy", -- Vulnerability Linter
|
||||
"yamlfmt",
|
||||
"codelldb",
|
||||
"css-lsp",
|
||||
"docker-compose-language-service",
|
||||
"html-lsp",
|
||||
"json-lsp",
|
||||
"sqlls",
|
||||
})
|
||||
|
||||
-- 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", {
|
||||
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
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
|
||||
if client:supports_method("textDocument/completion") then
|
||||
vim.opt.completeopt = { "menu", "menuone", "noinsert", "fuzzy", "popup" }
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"saecki/crates.nvim",
|
||||
tag = "stable",
|
||||
config = function()
|
||||
require("crates").setup()
|
||||
end,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user