Tweak LSP config

This commit is contained in:
Vaclav Uruba 2025-05-22 17:43:40 -06:00
parent c5c9521c16
commit 77b8f9617f
Signed by: uruba
GPG Key ID: 9D8E987C4B2E1E9C
3 changed files with 69 additions and 58 deletions

View File

@ -6,7 +6,6 @@ return {
lint.linters_by_ft = { lint.linters_by_ft = {
javascript = { "eslint_d" }, javascript = { "eslint_d" },
typescript = { "eslint_d" },
svelte = { "eslint_d" }, svelte = { "eslint_d" },
python = { "pylint" }, python = { "pylint" },
} }

View File

@ -8,9 +8,6 @@ return {
{ "folke/lazydev.nvim", opts = {} }, { "folke/lazydev.nvim", opts = {} },
}, },
config = function() config = function()
-- import lspconfig plugin
local lspconfig = require("lspconfig")
-- import mason_lspconfig plugin -- import mason_lspconfig plugin
local mason_lspconfig = require("mason-lspconfig") local mason_lspconfig = require("mason-lspconfig")
@ -55,10 +52,14 @@ return {
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
opts.desc = "Go to previous diagnostic" opts.desc = "Go to previous diagnostic"
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer keymap.set("n", "[d", function()
vim.diagnostic.jump({ count = -1, float = true })
end, opts) -- jump to previous diagnostic in buffer
opts.desc = "Go to next diagnostic" opts.desc = "Go to next diagnostic"
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer keymap.set("n", "]d", function()
vim.diagnostic.jump({ count = 1, float = true })
end, opts) -- jump to next diagnostic in buffer
opts.desc = "Show documentation for what is under cursor" opts.desc = "Show documentation for what is under cursor"
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
@ -68,12 +69,18 @@ return {
end, end,
}) })
-- Change the Diagnostic symbols in the sign column (gutter) -- Diagnostic config
local signs = { Error = "", Warn = "", Hint = "󰠠 ", Info = "" } vim.diagnostic.config({
for type, icon in pairs(signs) do signs = {
local hl = "DiagnosticSign" .. type text = {
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) [vim.diagnostic.severity.ERROR] = "",
end [vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.HINT] = "󰠠",
[vim.diagnostic.severity.INFO] = "",
},
},
virtual_text = true,
})
-- used to enable autocompletion (assign to every lsp server config) -- used to enable autocompletion (assign to every lsp server config)
local capabilities = cmp_nvim_lsp.default_capabilities() local capabilities = cmp_nvim_lsp.default_capabilities()

View File

@ -1,50 +1,55 @@
return { return {
"nvim-treesitter/nvim-treesitter", {
event = { "nvim-treesitter/nvim-treesitter",
"BufReadPre", event = {
"BufNewFile", "BufReadPre",
}, "BufNewFile",
build = ":TSUpdate", },
dependencies = { build = ":TSUpdate",
"windwp/nvim-ts-autotag", dependencies = {
}, "windwp/nvim-ts-autotag",
config = function() },
local treesitter = require("nvim-treesitter.configs") config = function()
local treesitter = require("nvim-treesitter.configs")
treesitter.setup({ treesitter.setup({
highlight = { highlight = {
enable = true, enable = true,
},
indent = {
enable = true,
},
autotag = {
enable = true,
},
ensure_installed = {
"json",
"javascript",
"yaml",
"html",
"css",
"lua",
"vim",
"dockerfile",
"gitignore",
"markdown",
"bash",
"go",
"php",
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
}, },
}, indent = {
}) enable = true,
end, },
autotag = {
enable = true,
},
ensure_installed = {
"json",
"javascript",
"yaml",
"html",
"css",
"lua",
"vim",
"dockerfile",
"gitignore",
"markdown",
"bash",
"go",
"php",
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
})
end,
},
{
"nvim-treesitter/nvim-treesitter-context",
},
} }