From f2d590dd90da4cd1d13e39f5aa9b7ca48f8c05d5 Mon Sep 17 00:00:00 2001 From: Sadra Saderi Date: Tue, 18 Aug 2026 14:08:05 +0330 Subject: [PATCH] Change LSP setup to use `vim.lsp.config` API --- lua/theprimeagen/lazy/lsp.lua | 107 +++++++++++++++------------------- 1 file changed, 46 insertions(+), 61 deletions(-) diff --git a/lua/theprimeagen/lazy/lsp.lua b/lua/theprimeagen/lazy/lsp.lua index bac0f606..3320c075 100644 --- a/lua/theprimeagen/lazy/lsp.lua +++ b/lua/theprimeagen/lazy/lsp.lua @@ -27,6 +27,52 @@ return { vim.lsp.protocol.make_client_capabilities(), cmp_lsp.default_capabilities()) + vim.lsp.config("*", { + capabilities = capabilities, + }) + + vim.lsp.config("zls", { + root_dir = require("lspconfig.util").root_pattern(table.unpack(root_files)), + settings = { + zls = { + enable_inlay_hints = true, + enable_snippets = true, + warn_style = true, + }, + }, + }) + vim.g.zig_fmt_parse_errors = 0 + vim.g.zig_fmt_autosave = 0 + + vim.lsp.config("lua_ls", { + settings = { + Lua = { + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = "2", + }, + }, + }, + }, + }) + + vim.lsp.config("tailwindcss", { + filetypes = { + "html", + "css", + "scss", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "svelte", + "heex", + }, + }) + require("fidget").setup({}) require("mason").setup() require("mason-lspconfig").setup({ @@ -37,67 +83,6 @@ return { "vtsls", "tailwindcss", }, - handlers = { - function(server_name) -- default handler (optional) - require("lspconfig")[server_name].setup { - capabilities = capabilities - } - end, - - zls = function() - local lspconfig = require("lspconfig") - lspconfig.zls.setup({ - root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"), - settings = { - zls = { - enable_inlay_hints = true, - enable_snippets = true, - warn_style = true, - }, - }, - }) - vim.g.zig_fmt_parse_errors = 0 - vim.g.zig_fmt_autosave = 0 - - end, - ["lua_ls"] = function() - local lspconfig = require("lspconfig") - - lspconfig.lua_ls.setup { - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - }, - diagnostics = { - globals = { 'vim' }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - format = { - enable = true, - -- Put format options here - -- NOTE: the value should be STRING!! - defaultConfig = { - indent_style = "space", - indent_size = "2", - } - }, - } - } - } - end, - ["tailwindcss"] = function() - local lspconfig = require("lspconfig") - lspconfig.tailwindcss.setup({ - capabilities = capabilities, - filetypes = { "html", "css", "scss", "javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "svelte", "heex" }, - }) - end, - } }) local cmp_select = { behavior = cmp.SelectBehavior.Select }