Closed ezynda3 closed 1 year ago
TL;DR; install templ with go and make sure your go bin is on your path then you can do your lsp config.
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
local util = require("lspconfig.util")
-- add custom templ lsp
configs .templ = {
default_config = {
cmd = { "templ", "lsp", },
filetypes = { "templ" },
root_dir = util.root_pattern("go.mod", ".git"),
settings = {},
}
}
-- setup same way you do with other lsp configs
-- assumes you have an on_attach and capabilities generation of some sort already.
lspconfig["templ"].setup({ on_attach = on_attach, capabilities = capabilities })
If you have questions post your config.
My PR to add it to mason.nvim got accepted: https://github.com/mason-org/mason-registry/pull/2832
I plan to create a PR for the lspconfig and conform.nvim repo.
TL;DR; install templ with go and make sure your go bin is on your path then you can do your lsp config.
local lspconfig = require("lspconfig") local configs = require("lspconfig.configs") local util = require("lspconfig.util") -- add custom templ lsp configs .templ = { default_config = { cmd = { "templ", "lsp", }, filetypes = { "templ" }, root_dir = util.root_pattern("go.mod", ".git"), settings = {}, } } -- setup same way you do with other lsp configs -- assumes you have an on_attach and capabilities generation of some sort already. lspconfig["templ"].setup({ on_attach = on_attach, capabilities = capabilities })
If you have questions post your config.
Thanks!
That's really cool.
Do the docs need updating to explain how to get the templ LSP working with Mason, or will it be automatic since @zbindenren's PR?
Should be automatic with mason if you add to your install list. The custom LSP config will be required until someone makes a pr there. Then for most depending on what your config looks like it would be adding a single item to a table and the rest is all automatic.
That's really cool.
Do the docs need updating to explain how to get the templ LSP working with Mason, or will it be automatic since @zbindenren's PR?
When everything is done I will make a PR here to update the templ doc.
Great work, those two PRs are merged. Just a docs PR to go, I've just signed up to Hacktoberfest, so now's a great time to update the docs. 😁
I'm trying to use the builtin LSP but since it's not supported by Mason, I'm not sure how to use it with my LazyVim setup. Would it be possible to add an example for how to add this as a custom LSP using LazyVim?