Code Monkey home page Code Monkey logo

Comments (3)

a-h avatar a-h commented on June 6, 2024

Thanks for the report, much appreciated. I'll look into it.

from templ.

a-h avatar a-h commented on June 6, 2024

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.

mattn avatar mattn commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.