2024-04-01 10:41:54 +03:00
|
|
|
-- 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"
|
2024-06-05 13:29:33 +03:00
|
|
|
|
|
|
|
|
2024-04-01 10:41:54 +03:00
|
|
|
-- 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
|
2024-06-05 13:29:33 +03:00
|
|
|
|
|
|
|
|
|
|
|
-- 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
|
|
|
|
|
2024-04-01 10:41:54 +03:00
|
|
|
lspconfig.gopls.setup({
|
2024-06-05 13:29:33 +03:00
|
|
|
on_attach = on_attach,
|
|
|
|
on_init = on_init,
|
|
|
|
capabilities = capabilities,
|
2024-04-01 10:41:54 +03:00
|
|
|
settings = {
|
|
|
|
gopls = {
|
|
|
|
analyses = {
|
|
|
|
unusedparams = true,
|
|
|
|
},
|
|
|
|
staticcheck = true,
|
|
|
|
gofumpt = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-09-15 00:15:56 +03:00
|
|
|
lspconfig.clangd.setup{}
|
2024-08-04 01:43:04 +03:00
|
|
|
|
2024-11-23 21:35:43 +02:00
|
|
|
-- 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 })
|