An open API service indexing awesome lists of open source software.

https://github.com/catgoose/templ-goto-definition

Fixes golang templ goto definition to open .templ file instead of generated .go file
https://github.com/catgoose/templ-goto-definition

golang neovim-plugin nvim-plugin templ

Last synced: 11 months ago
JSON representation

Fixes golang templ goto definition to open .templ file instead of generated .go file

Awesome Lists containing this project

README

          

# templ-goto-definition

Fixes Neovim gopls LSP goto definition for templ templates

When using `vim.lsp.buf.definition` in a Go file for a templ template, gopls
only knows about the generated Go file. This plugin overrides `vim.lsp.buf.definition`
for the Go filetype and tries to open the correct temple file at the function
definition

`templ` treesitter grammar is required for treesitter query to locate function name
in .templ file. If treesitter is unavailable, text search strategy is used

## Setup

Lazy.nvim

```lua
return {
"catgoose/templ-goto-definition",
ft = { "go" },
config = true,
dependenciies = "nvim-treesitter/nvim-treesitter", -- optional
}
```

See this templ issue:
VSCode version not made by me, but was mentioned in the above issue: