mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
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:
@@ -4,15 +4,22 @@
|
||||
-- Step 2: Append the LSP server name in the below array
|
||||
vim.lsp.enable({
|
||||
"bashls",
|
||||
"cssls",
|
||||
"shellcheck",
|
||||
"shellharden",
|
||||
"shfmt",
|
||||
"docker_compose_language_service",
|
||||
"dockerls",
|
||||
"html",
|
||||
"jsonls",
|
||||
"lua_ls",
|
||||
"pylsp",
|
||||
"sqlls",
|
||||
"cssls",
|
||||
"html",
|
||||
"ts_ls",
|
||||
"prettier",
|
||||
"marksman",
|
||||
"markdownlint",
|
||||
"trivy",
|
||||
})
|
||||
|
||||
-- TIP: On new systems, install these through Mason
|
||||
@@ -61,34 +68,22 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(event)
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
|
||||
-- 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" }
|
||||
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
|
||||
-- Generic Keymaps
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or "n"
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
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("<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
|
||||
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>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")
|
||||
-- e to jump to the symbol under cursor; q to quit
|
||||
map("<leader>co", "<cmd>Lspsaga outline<cr>", "Outline Panel on Left")
|
||||
|
||||
@@ -3,7 +3,11 @@ 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.nvim",
|
||||
config = true,
|
||||
opts = { PATH = "append" },
|
||||
},
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
"saghen/blink.cmp",
|
||||
@@ -156,11 +160,49 @@ return {
|
||||
-- Highlight colors
|
||||
{
|
||||
"brenoprata10/nvim-highlight-colors",
|
||||
setup = {
|
||||
enable_tailwind = true,
|
||||
},
|
||||
setup = { enable_tailwind = true },
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user