Skip to content

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

Notifications You must be signed in to change notification settings

catgoose/templ-goto-definition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

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

See this templ issue: a-h/templ#387 VSCode version not made by me, but was mentioned in the above issue: a-h/templ#387 (comment)

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages