Skip to content

LSP warning of editing generated file #1200

@dimmerz92

Description

@dimmerz92

Describe the bug
Just today, the templ lsp has started warning me that I am editing a generated file, even though I have never opened the *_templ.go files.

E.g., I open layout.templ, go to insert mode, start typing. As soon as I type, I get the error: LSP[templ][Warning] Warning: editing layout_templ.go, a generated file.

To Reproduce
I have no idea if this is an lsp bug or if I've done something dumb, unsure how to reproduce.

Expected behavior
No warning as I'm not editing the generated file.

Logs

which go gopls templ
/opt/homebrew/bin/go
/opt/homebrew/bin/gopls
/Users/macpig/go/bin/templ

templ info output

(✓) os [ goos=darwin goarch=arm64 ]
(✓) go [ location=/opt/homebrew/bin/go version=go version go1.24.4 darwin/arm64 ]
(✓) gopls [ location=/opt/homebrew/bin/gopls version=golang.org/x/tools/gopls v0.19.1 ]
(✓) templ [ location=/Users/macpig/go/bin/templ version=v0.3.898 ]

Desktop (please complete the following information):

  • OS: MacOS
  • templ CLI version v0.3.898
  • Go version go version go1.24.4 darwin/arm64
  • gopls version golang.org/x/tools/gopls v0.19.1

Additional context
My neovim lsp & treesitter config below:

LSP

return {
	"mason-org/mason-lspconfig.nvim",
	opts = {
		ensure_installed = {
			"clangd",
			"cssls",
			"gopls",
			"html",
			"htmx",
			"lua_ls",
			"pyright",
			"templ",
			"ts_ls",
		},
	},
	dependencies = {
		{ "j-hui/fidget.nvim",    opts = { notification = { window = { winblend = 0 } } } },
		{ "mason-org/mason.nvim", opts = {} },
		"neovim/nvim-lspconfig",
	},
}

Treesitter

return {
	"nvim-treesitter/nvim-treesitter",
	branch = "master",
	lazy = false,
	build = ":TSUpdate",
	opts = {
		ensure_installed = {
			"c",
			"css",
			"go",
			"html",
			"javascript",
			"jsdoc",
			"lua",
			"markdown",
			"markdown_inline",
			"python",
			"query",
			"sql",
			"templ",
			"toml",
			"typescript",
			"vim",
			"vimdoc",
			"yaml",
		},
		sync_install = false,
		auto_install = true,
		highlight = { enable = true },
		indent = { enable = true },
		additional_vim_regex_highlighting = false,
	},
	config = function(_, opts)
		require("nvim-treesitter.install").prefer_git = true
		require("nvim-treesitter.configs").setup(opts)
		vim.diagnostic.config({ virtual_text = true })
	end
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions