mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08: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:
1
common/.config/nvim/lsp/markdownlint.lua
Normal file
1
common/.config/nvim/lsp/markdownlint.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
1
common/.config/nvim/lsp/markman.lua
Normal file
1
common/.config/nvim/lsp/markman.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
1
common/.config/nvim/lsp/prettier.lua
Normal file
1
common/.config/nvim/lsp/prettier.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
1
common/.config/nvim/lsp/shellcheck.lua
Normal file
1
common/.config/nvim/lsp/shellcheck.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
1
common/.config/nvim/lsp/shellharden.lua
Normal file
1
common/.config/nvim/lsp/shellharden.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
1
common/.config/nvim/lsp/shfmt.lua
Normal file
1
common/.config/nvim/lsp/shfmt.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
1
common/.config/nvim/lsp/trivy.lua
Normal file
1
common/.config/nvim/lsp/trivy.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return {}
|
||||||
@@ -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")
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user