-- EXAMPLE local on_attach = require("nvchad.configs.lspconfig").on_attach local on_init = require("nvchad.configs.lspconfig").on_init local capabilities = require("nvchad.configs.lspconfig").capabilities local lspconfig = require "lspconfig" -- local servers = { "gopls" } -- lsps with default config -- for _, lsp in ipairs(servers) do -- lspconfig[lsp].setup { -- on_attach = on_attach, -- on_init = on_init, -- capabilities = capabilities, -- } -- end -- local gopls_on_attach = function(client, bufnr) -- if client.supports_method("textDocument/inlayHint") then -- vim.lsp.inlay_hint.enable(true, { -- assignVariableTypes = true, -- compositeLiteralFields = true, -- compositeLiteralTypes = true, -- constantValues = true, -- functionTypeParameters = true, -- parameterNames = true, -- rangeVariableTypes = true, -- }) -- end -- end lspconfig.gopls.setup({ on_attach = on_attach, on_init = on_init, capabilities = capabilities, settings = { gopls = { analyses = { unusedparams = true, }, staticcheck = true, gofumpt = true, }, }, }) lspconfig.clangd.setup{} -- lspconfig.pyright.setup{} -- lspconfig.html.setup({ -- on_attach = on_attach, -- capabilities = capabilities, -- filetypes = { "html", "templ" }, -- }) -- lspconfig.htmx.setup({ -- on_attach = on_attach, -- capabilities = capabilities, -- filetypes = { "html", "templ" }, -- }) lspconfig.templ.setup({ on_attach = on_attach, capabilities = capabilities, filetypes = { "templ" }, }) lspconfig.tailwindcss.setup({ on_attach = on_attach, capabilities = capabilities, filetypes = { "templ" }, settings = { tailwindCSS = { includeLanguages = { templ = "html", }, }, }, }) local templ_format = function() local bufnr = vim.api.nvim_get_current_buf() local filename = vim.api.nvim_buf_get_name(bufnr) local cmd = "templ fmt " .. vim.fn.shellescape(filename) vim.fn.jobstart(cmd, { on_exit = function() -- Reload the buffer only if it's still the current buffer if vim.api.nvim_get_current_buf() == bufnr then vim.cmd('e!') end end, }) end vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = { "*.templ" }, callback = templ_format })