Comments (3)
Thanks for the report, much appreciated. I'll look into it.
from templ.
Having looked into this, it looks like the root cause is because you haven't got gopls
on your path. templ uses the gopls
server to provide autocomplete for the Go expressions, so if you haven't got it installed, it can't run it.
However, regardless of whether you've got the gopls
executable installed, it shouldn't panic, so I've updated the code to check that gopls
has been installed and to exit more gracefully.
I guess everyone that's installed templ so far already had it installed.
Thanks for letting me know about the problem, and do re-open the issue if this doesn't fix it.
For anyone that's interested, I was able to reproduce the issue on my Mac by changing the code to try and run gopls2
instead of gopls
(here's my LSP log from Neovim 5.x).
[ ERROR ] 2021-10-31T15:23:58+0000 ] ...m-unwrapped-0.5.0/share/nvim/runtime/lua/vim/lsp/rpc.lua:462 ] "rpc" "templ" "stderr" "panic: runtime error: invalid memory address or nil pointer dereference\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x11edb3e]\n\ngoroutine 20 [running]:\n"
[ ERROR ] 2021-10-31T15:23:58+0000 ] ...m-unwrapped-0.5.0/share/nvim/runtime/lua/vim/lsp/rpc.lua:462 ] "rpc" "templ" "stderr" "github.com/sourcegraph/jsonrpc2.(*Conn).send(0x0, 0x12c4c78, 0xc000078400, 0xc000067370, 0x1, 0x0, 0x0, 0x0)\n\t/Users/adrian.hesketh/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:352 +0x7e\ngithub.com/sourcegraph/jsonrpc2.(*Conn).DispatchCall(0x0, 0x12c4c78, 0xc000078400, 0xc000018bc0, 0xa, 0x1218660, 0xc000078480, 0x0, 0x0, 0x0, ...)\n\t/Users/adrian.hesketh/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:449 +0x12b\ngithub.com/sourcegraph/jsonrpc2.(*Conn).Call(0x0, 0x12c4c78, 0xc000078400, 0xc000018bc0, 0xa, 0x1218660, 0xc000078480, 0x12189a0, 0xc000153110, 0x0, ...)\n\t/Users/adrian.hesketh/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:424 +0xa5\ngithub.com/a-h/templ/cmd/templ/lspcmd.(*Proxy).proxyInitialize(0xc0000a6000, 0x12c4c78, 0xc000078400, 0xc0000ac000, 0xc00007a370)\n\t/Users/adrian.hesketh/github.com/a-h/templ/cmd/templ/lspcmd/handler.go:230 +0x2d6\ngithub.com/a-h/templ/cmd/templ/lspcmd.(*Proxy).Handle(0xc0000a6000, 0x12c4c78, 0xc000078400, 0xc0000ac000, 0xc00007a370)\n\t/Users/adrian.hesketh/github.com/a-h/templ/cmd/templ/lspcmd/handler.go:196 +0xa4c\ngithub.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc0000ac000, 0x12c4c78, 0xc000078400)\n\t/Users/adrian.hesketh/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:553 +0x57e\ncreated by github.com/sourcegraph/jsonrpc2.NewConn\n\t/Users/adrian.hesketh/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:334 +0x1d5\n"
from templ.
Thanks for fixing this. But seems still having problem.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x4becd1]
goroutine 10 [running]:
github.com/a-h/templ/cmd/templ/lspcmd.(*Proxy).proxyInitialize(0xc000028440, {0x5746b8, 0xc000028400}, 0xc0000a0000?, 0xc000062050)
C:/Users/mattn/go/src/github.com/a-h/templ/cmd/templ/lspcmd/handler.go:235 +0x391
github.com/a-h/templ/cmd/templ/lspcmd.(*Proxy).Handle(0xc000028440, {0x5746b8, 0xc000028400}, 0x0?, 0xc000062050)
C:/Users/mattn/go/src/github.com/a-h/templ/cmd/templ/lspcmd/handler.go:196 +0x75d
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc000152120, {0x5746b8, 0xc000028400})
C:/Users/mattn/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:559 +0x2f8
created by github.com/sourcegraph/jsonrpc2.NewConn
C:/Users/mattn/go/pkg/mod/github.com/sourcegraph/[email protected]/jsonrpc2.go:334 +0x28c
"]]
from templ.
Related Issues (20)
- Getting multiple error message when parsing a simple templ file HOT 23
- VS Code plugin: changelog tab HOT 1
- Vm instead of generator HOT 5
- HTMX Hyperscript attribute is not accepted. HOT 1
- Using external JS lib HOT 15
- dynamic class wont work for form inputs HOT 3
- generator: allow go code statements in templates HOT 23
- lsp: textDocument/definition failed HOT 2
- parse error with templ elements HOT 5
- templ fmt indents weirdly if @component is put before/after text HOT 14
- css: Support arguments in CSS components HOT 5
- generator: option to disable whitespace normalization HOT 7
- element expression breaks on multiline function calls HOT 4
- email generation - inline css possible ? HOT 3
- bug: example code for blog HOT 1
- Back button nav HOT 3
- Idea: web components with templ HOT 5
- Explore batching strings HOT 9
- Explore multi type support HOT 1
- vscode: syntax broken when using children HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templ.