return { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile" }, dependencies = { "hrsh7th/cmp-nvim-lsp", { "antosha417/nvim-lsp-file-operations", config = true }, { "folke/neodev.nvim", opts = {} }, { "pmizio/typescript-tools.nvim", dependencies = { "nvim-lua/plenary.nvim" }, }, }, config = function() local lspconfig = require("lspconfig") local mason_lspconfig = require("mason-lspconfig") local cmp_nvim_lsp = require("cmp_nvim_lsp") local keymap = vim.keymap mason_lspconfig.setup({ ensure_installed = { "cssls", "emmet_ls", "eslint", "gopls", "graphql", "html", -- "jdtls", -- uncomment if you’re actively doing Java "lua_ls", "prismals", "pyright", "svelte", "tailwindcss", }, }) local capabilities = cmp_nvim_lsp.default_capabilities() vim.diagnostic.config({ signs = { severity = { min = vim.diagnostic.severity.WARN, }, icons = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " ", }, }, }) local servers = { cssls = {}, emmet_ls = {}, eslint = {}, gopls = {}, graphql = {}, html = {}, -- jdtls = {}, -- same here lua_ls = { settings = { Lua = { diagnostics = { globals = { "vim" } }, workspace = { library = vim.api.nvim_get_runtime_file("", true), checkThirdParty = false, }, }, }, }, prismals = {}, pyright = {}, svelte = {}, tailwindcss = {}, } for server, config in pairs(servers) do config.capabilities = capabilities lspconfig[server].setup(config) end -- ✅ Correct way to setup typescript-tools require("typescript-tools").setup({ capabilities = capabilities, -- optional settings: -- settings = { -- tsserver_plugins = {}, -- tsserver_max_memory = 4096, -- } }) vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) local opts = { buffer = ev.buf, silent = true } local mappings = { ["gR"] = { "Telescope lsp_references", "Show LSP references" }, ["gD"] = { vim.lsp.buf.declaration, "Go to declaration" }, ["gd"] = { "Telescope lsp_definitions", "Show LSP definitions" }, ["gi"] = { "Telescope lsp_implementations", "Show LSP implementations" }, ["gt"] = { "Telescope lsp_type_definitions", "Show LSP type definitions" }, ["ca"] = { vim.lsp.buf.code_action, "See available code actions" }, ["rn"] = { vim.lsp.buf.rename, "Smart rename" }, ["D"] = { "Telescope diagnostics bufnr=0", "Show buffer diagnostics" }, ["dd"] = { vim.diagnostic.open_float, "Show line diagnostics" }, ["[d"] = { vim.diagnostic.goto_prev, "Go to previous diagnostic" }, ["]d"] = { vim.diagnostic.goto_next, "Go to next diagnostic" }, ["K"] = { vim.lsp.buf.hover, "Show documentation for cursor" }, ["rs"] = { ":LspRestart", "Restart LSP" }, } for key, map in pairs(mappings) do keymap.set("n", key, map[1], { desc = map[2], silent = true }) end vim.api.nvim_create_autocmd("CursorHold", { buffer = ev.buf, callback = function() vim.diagnostic.open_float(nil, { focusable = false }) end, }) vim.o.updatetime = 250 end, }) end, }