Skip to content

Commit

Permalink
docs: document how to enable Neovim 5.x Language Server support - tha…
Browse files Browse the repository at this point in the history
…nks @Joe-Davidson1802
  • Loading branch information
a-h committed Oct 16, 2021
1 parent feefab5 commit 46b3b0b
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,51 @@ func PersonTemplate(p Person) (t templ.Component) {
# IDE Support
## vim / neovim
## vscode
There's a VS Code extension, just make sure you've already installed templ and that it's on your path.
* https://marketplace.visualstudio.com/items?itemName=a-h.templ
* https://github.com/a-h/templ-vscode
## Neovim 5
A vim / neovim plugin is available from https://github.com/Joe-Davidson1802/templ.vim which adds syntax highlighting.
Neovim 5 supports Language Servers directly. For the moment, I'm using https://github.com/neoclide/coc.nvim to test the language server after using Joe-Davidson1802's plugin to set the language type:
To enable the built-in Language Server support of Neovim 5.x add the following code to your `.vimrc` prior to calling `setup` on the language servers, e.g.:
```lua
-- Add templ configuration.
local configs = require'lspconfig/configs'
if not nvim_lsp.templ then
configs.templ = {
default_config = {
cmd = {"templ", "lsp"},
filetypes = {'templ'},
root_dir = nvim_lsp.util.root_pattern("go.mod", ".git"),
settings = {},
};
}
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'gopls', 'ccls', 'cmake', 'tsserver', 'templ' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
},
}
end
```
## vim / neovim 4.x
A vim / neovim plugin is available from https://github.com/Joe-Davidson1802/templ.vim which adds syntax highlighting.
https://github.com/neoclide/coc.nvim can be used to run the language server after using Joe-Davidson1802's plugin to set the language type:
```json
{
Expand Down Expand Up @@ -586,13 +626,6 @@ To add extensive debug information, you can include additional args to the LSP,
}
```
## vscode
There's a VS Code extension, just make sure you've already installed templ and that it's on your path.
* https://marketplace.visualstudio.com/items?itemName=a-h.templ
* https://github.com/a-h/templ-vscode
# Development
## Local builds
Expand Down

0 comments on commit 46b3b0b

Please sign in to comment.