fix(neovim-lsp): Default LSP configured with default LSP client & color

completions

- Default configs for: markdownlint, marksman, prettier, shellcheck, shellharden, shfmt,
  trivy
- Configure `mason` to `append` PATH
- Configure completions for `nvim-highlight-colors`
This commit is contained in:
Pratik Tripathy
2025-07-29 11:33:35 +05:30
parent 8c52c7a881
commit 22157e682a
9 changed files with 67 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,15 +4,22 @@
-- Step 2: Append the LSP server name in the below array -- Step 2: Append the LSP server name in the below array
vim.lsp.enable({ vim.lsp.enable({
"bashls", "bashls",
"cssls", "shellcheck",
"shellharden",
"shfmt",
"docker_compose_language_service", "docker_compose_language_service",
"dockerls", "dockerls",
"html",
"jsonls", "jsonls",
"lua_ls", "lua_ls",
"pylsp", "pylsp",
"sqlls", "sqlls",
"cssls",
"html",
"ts_ls", "ts_ls",
"prettier",
"marksman",
"markdownlint",
"trivy",
}) })
-- TIP: On new systems, install these through Mason -- TIP: On new systems, install these through Mason
@@ -61,34 +68,22 @@ vim.api.nvim_create_autocmd("LspAttach", {
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 native LSP completion -- Generic Keymaps
-- 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" }
vim.lsp.completion.enable(true, client.id, event.buf, { autotrigger = true })
vim.keymap.set("i", "<C-Space>", function()
vim.lsp.completion.get()
end)
end
-- Keymaps
local map = function(keys, func, desc, mode) local map = function(keys, func, desc, mode)
mode = mode or "n" mode = mode or "n"
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end end
map("<F2>", vim.lsp.buf.rename, "Rename Symbol") map("<F2>", vim.lsp.buf.rename, "Rename Symbol")
map("<leader>cR", vim.lsp.buf.rename, "Rename Symbol")
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
map("<leader>nf", function()
vim.fn.setreg("+", vim.fn.expand("%:p"))
print("Copied: " .. vim.fn.expand("%:p") .. " to + register")
end, "Copy current [F]ile path to register")
-- LspSaga -- LspSaga
map("<C-.>", "<cmd>Lspsaga code_action<cr>", "Code Actions") map("<C-.>", "<cmd>Lspsaga code_action<cr>", "Code Actions")
map("K", "<cmd>Lspsaga hover_doc<cr>", "Hover Documentation")
map("<leader>cr", "<cmd>Lspsaga finder<cr>", "Goto References") map("<leader>cr", "<cmd>Lspsaga finder<cr>", "Goto References")
map("<leader>cF", "<cmd>Lspsaga peek_definition<cr>", "Peek definition: Function") map("<leader>cF", "<cmd>Lspsaga peek_definition<cr>", "Peek definition: Function")
map("<leader>cT", "<cmd>Lspsaga peek_type_definition<cr>", "Peek definition: Class") map("<leader>cT", "<cmd>Lspsaga peek_type_definition<cr>", "Peek definition: Type")
map("<leader>cI", "<cmd>Lspsaga finder imp<cr>", "Peek: Implementations") map("<leader>cI", "<cmd>Lspsaga finder imp<cr>", "Peek: Implementations")
-- e to jump to the symbol under cursor; q to quit -- e to jump to the symbol under cursor; q to quit
map("<leader>co", "<cmd>Lspsaga outline<cr>", "Outline Panel on Left") map("<leader>co", "<cmd>Lspsaga outline<cr>", "Outline Panel on Left")

View File

@@ -3,7 +3,11 @@ return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
cond = require("config.util").is_not_vscode(), cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
{ "williamboman/mason.nvim", config = true }, -- TIP: Must be loaded before dependants {
"williamboman/mason.nvim",
config = true,
opts = { PATH = "append" },
},
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim",
"saghen/blink.cmp", "saghen/blink.cmp",
@@ -156,11 +160,49 @@ return {
-- Highlight colors -- Highlight colors
{ {
"brenoprata10/nvim-highlight-colors", "brenoprata10/nvim-highlight-colors",
setup = { setup = { enable_tailwind = true },
enable_tailwind = true,
},
config = function() config = function()
require("nvim-highlight-colors").setup() require("nvim-highlight-colors").setup({
render = "virtual",
virtual_symbol_position = "eow",
virtual_symbol_prefix = " ",
virtual_symbol_suffix = "",
completion = {
menu = {
draw = {
components = {
-- customize the drawing of kind icons
kind_icon = {
text = function(ctx)
-- default kind icon
local icon = ctx.kind_icon
-- if LSP source, check for color derived from documentation
if ctx.item.source_name == "LSP" then
local color_item = require("nvim-highlight-colors").format(ctx.item.documentation, { kind = ctx.kind })
if color_item and color_item.abbr ~= "" then
icon = color_item.abbr
end
end
return icon .. ctx.icon_gap
end,
highlight = function(ctx)
-- default highlight group
local highlight = "BlinkCmpKind" .. ctx.kind
-- if LSP source, check for color derived from documentation
if ctx.item.source_name == "LSP" then
local color_item = require("nvim-highlight-colors").format(ctx.item.documentation, { kind = ctx.kind })
if color_item and color_item.abbr_hl_group then
highlight = color_item.abbr_hl_group
end
end
return highlight
end,
},
},
},
},
},
})
end, end,
}, },
} }