a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
8.25k stars 272 forks source link

request: Jet Brains Goland plugin #127

Closed a-h closed 9 months ago

a-h commented 1 year ago

Since Goland now supports LSPs - it's possible to create a plugin for it.

https://blog.jetbrains.com/platform/2023/07/lsp-for-plugin-developers/

It has to be written in Java, but it's potentially not many lines of code. I don't use JetBrains IDEs myself day to day to test it though.

PaluMacil commented 1 year ago

Super pumped! I've never written Java or used the LSP on a programmatic level, but I use Goland for 100% of my Go code except where I'm writing some templ right now. I'll be able to test it out a bit for you.

Crocmagnon commented 1 year ago

I'd love to beta-test implementations if needed. I don't have experience with templ though, nor do I have extensive codebase to test in. (currently listening to the Changelog Go Time podcast 😊)

DRSchlaubi commented 1 year ago

I predict that there will be a solution to this within the next 5 minutes

topi314 commented 1 year ago

I quickly threw together this plugin: https://github.com/topi314/templ-goland That being said it works, but there is sadly no syntax highlighting yet

I'd be happy to transfer this code to you and assist with the next steps to publish & co

a-h commented 1 year ago

I realised that Jet Brains have a programme where you can ask for a license to support open source development, so I applied for a license for @joerdav and I.

I can't think of a more fitting use case for the programme than to support building a plugin for Jet Brains!

I can use the trial for now, but haven't had chance to yet. Been working on a lot of other core improvements and PRs.

topi314 commented 1 year ago

the Jetbrains LSP support is quit limiting right now you can read more about it in this blog post https://blog.jetbrains.com/platform/2023/07/lsp-for-plugin-developers/

for a better experience custom language support https://plugins.jetbrains.com/docs/intellij/custom-language-support.html would be awesome

DRSchlaubi commented 1 year ago

Also worth reading is this guide written by the intellij rust team: https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md#project-structure

adasauce commented 1 year ago

fwiw if you just import the vscode extension as a textmade bundle, it recognizes the .tmlanguage file in the syntax directory and does ... something with it. without it enabled it's just white text. swappy-20231004_164410

not sure if that actually gets us any closer to the plugin working properly or if it will save work.


e: just removed the top level source.go include to make sure that include imports were working and it un-highlighted the package keyword. so that much is indeed working.

alexisvisco commented 1 year ago

IMO creating a custom language based on the feature called MultiHostInjector might be a brilliant solution

https://plugins.jetbrains.com/docs/intellij/language-injection.html#multihostinjector

The challenge is inside the html, I have no clue how to do it to have go expression works

topi314 commented 1 year ago

I'd say we just wait for jetbrains to bring more LSP support :)

alexisvisco commented 1 year ago

I don't think it's a good approach with a IDE like jetbrain because you lose all custom go and html features that intellij brings .

Evert-Arends commented 1 year ago

This is almost a blocker to use templ :cry: I'll install vscode for the template side of things for now.

joerdav commented 1 year ago

I've just installed GoLand, hopefully can make some progress here.

joerdav commented 1 year ago

(making no promises about it being fast to be complete, it involves writing kotlin)

viktorvoltaire commented 1 year ago

(making no promises about it being fast to be complete, it involves writing kotlin)

I’ve never written an LSP or a custom language based on the feature called MultiHostInjector. But I know kotlin if you need help :)

joerdav commented 1 year ago

@viktorvoltaire Thanks! I'll be sure to reach out if I hit a road block.

Thought this was worth a quick update. Last week I got the LSP working, I now need to work on defining the syntax highlighter, I wanted to re-use the treesitter definitions in https://github.com/vrischmann/tree-sitter-templ but I'm not sure it's possible!

Here's a sneak peak: image

image

joerdav commented 12 months ago

The syntax highlighting is proving a bit of a bigger task, I want to avoid re-implementing the Go parser/lexer in this plugin, but need to do some more learning about intellij plugins to figure it out!

I propose that we ship a version 1 of the plugin with just LSP support and no syntax highlighting for now. @a-h should we put this in a new org, or under your github account so it's an officially maintained plugin?

mohdaqib57 commented 12 months ago

is there any planned release date for Goland plugin? This is a blocker for me as I only used Goland IDE

Evert-Arends commented 12 months ago

@mohdaqib57 I have used templ in Goland for the past week, it does not have to be a blocker, I keep vscode open just for the .templ files but I noticed that I use it less and less, the syntax is really simple.

On a side note, I really like the templating language, there's a small "wtf" curve, but I think I got over the steepest part now. Thanks @joerdav and @a-h for the effort and ofc for this plugin. Support is adoption, this is going to be big :)

a-h commented 12 months ago

I think it makes sense to ship without syntax highlighting, and add that next.

I've invited you to a new org @joerdav, we can work out how to migrate the a-h/templ library to it without breaking everything over time, and I'll move the templ-vscode over to it, since that can move without breaking Go module imports.

@Evert-Arends - I'd like to know what the wtf curve was so we can work on smoothing it out (in a discussion or other issue to avoid overloading this thread). It's your first few minutes with a tool that make you decide whether you'll stick with it. 😁

Crocmagnon commented 12 months ago

I think it makes sense to ship without syntax highlighting, and add that next.

+1. This way you’ll also be able to collect feedback earlier.

0x090909 commented 11 months ago

+1

a-h commented 11 months ago

@0x090909 - please use the emoji responses to express +1 instead of adding a comment.

Adding a comment results in everyone that's subscribed to the issue receiving an update notification.

Thanks!

joerdav commented 11 months ago

I've implemented a very simple and lazy goland plugin: https://plugins.jetbrains.com/plugin/23088-templ

It's under review by jetbrains at the moment, so won't be installable, unless done so manually from the zip file: https://github.com/templ-go/templ-jetbrains/releases/tag/v0.0.5

It uses the experimental LSP feature, so I didn't have to rewrite the completion features.

It uses the textmate parser for syntax highlighting, so I only had to provide colors for each token, but didn't have to re-implement the parser.

2 lazy approaches, but it seems to get the job done!

0x090909 commented 11 months ago

Great! How about HTML highlighting? Does it work?

Nov 10, 2023 11:39:56 Joe Davidson @.***>:

I've implemented a very simple and lazy goland plugin: https://plugins.jetbrains.com/plugin/23088-templ

It's under review by jetbrains at the moment, so won't be installable, unless done so manually from the zip file: https://github.com/templ-go/templ-jetbrains/releases/tag/v0.0.5

It uses the experimental LSP feature, so I didn't have to rewrite the completion features.

It uses the textmate parser for syntax highlighting, so I only had to provide colors for each token, but didn't have to re-implement the parser.

2 lazy approaches, but it seems to get the job done!

— Reply to this email directly, view it on GitHub[https://github.com/a-h/templ/issues/127#issuecomment-1805484704], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AEBESU2QI7FLPFS76GSPWOLYDX77ZAVCNFSM6AAAAAA3XP4MROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBVGQ4DINZQGQ]. You are receiving this because you were mentioned. [Tracking image][https://github.com/notifications/beacon/AEBESU7K7XYJTZ3MAUGFF6LYDX77ZA5CNFSM6AAAAAA3XP4MROWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTLTWBKA.gif]

joerdav commented 11 months ago

To an extent @0x090909 :

image

jonerer commented 11 months ago

@0x090909 yes it seems to work. please try it out before posting, or see the attached screenshots

Great work @joerdav. A few notes:

Not sure if I need to start the LSP manually or so? Or if I can find any debug logs

I'm on Goland 2023.2.4. Also tried on Goland 2023.2.1

joerdav commented 11 months ago

@jonerer The LSP should start on it's own. I've added a preferences menu, so you should be able to specify your templ binary location if it can't be found automatically.

joerdav commented 11 months ago

image

0x090909 commented 11 months ago

@joerdav I tried it but nothing happens when adding manually

joerdav commented 11 months ago

@0x090909 No code highlighting either? May be worth waiting for the marketplace to approve the plugin if you're having trouble installing.

jonerer commented 11 months ago

I tried to add the binary in there, but no change in behaviour.

Code highlighting works fine, but no type information.

0x090909 commented 11 months ago

@0x090909 No code highlighting either? May be worth waiting for the marketplace to approve the plugin if you're having trouble installing.

Seems like plugin is not even loaded

joerdav commented 11 months ago

Okay, thanks @jonerer . I don't believe hoverring for type info us supported by the Intellij LSP yet. But autocompletion, diagnostics and "jump to definition" should all work.

I'll work on some troubleshooting steps for you when I get chance.

joerdav commented 11 months ago

image

There is now a plugin for templ on the jetbrains marketplace.

joerdav commented 11 months ago

@jonerer do you find any useful logs? If you follow this: https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

They should be in idea.log

0x090909 commented 11 months ago

Screenshot 2023-11-13 at 10 20 11

joerdav commented 11 months ago

@0x090909 same for you. Are there any logs pertaining to templ if you follow this: intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

They should be in idea.log

0x090909 commented 11 months ago

2023-11-13 10:21:39,664 [ 8984] INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@project(RUNNING;0): Starting server 2023-11-13 10:21:39,674 [ 8994] INFO - #c.i.p.l.a.LspServerDescriptor - TemplLspServerDescriptor@project: starting LSP server: / [lsp] 2023-11-13 10:21:39,683 [ 9003] WARN - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@project(RUNNING;0): Failed to start server

@joerdav I put lsp path as well in the settings

joerdav commented 11 months ago

Okay, thanks for this.

I think obviously starting LSP server: / [lsp] is not your templ binary. The config must be loading incorrectly.

@0x090909 What OS are you running?

0x090909 commented 11 months ago

MacOS latest version

Nov 13, 2023 10:36:14 Joe Davidson @.***>:

Okay, thanks for this.

I think obviously starting LSP server: / [lsp] is not your templ binary. The config must be loading incorrectly.

@0x090909[https://github.com/0x090909] What OS are you running?

— Reply to this email directly, view it on GitHub[https://github.com/a-h/templ/issues/127#issuecomment-1807777753], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AEBESU6JQYRXZDM3Q6QBNULYEHSY5AVCNFSM6AAAAAA3XP4MROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBXG43TONZVGM]. You are receiving this because you were mentioned. [Tracking image][https://github.com/notifications/beacon/AEBESU6EFX624TITHCXIGHTYEHSY5A5CNFSM6AAAAAA3XP4MROWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTLYB75S.gif]

joerdav commented 11 months ago

Turns out I messed up the settings page for the plugin (this is my first intellij plugin).

Please try this release: https://github.com/templ-go/templ-jetbrains/releases/tag/v0.0.6 (I'm not sure how quickly it'll appear on the marketplace)

jonerer commented 11 months ago

@jonerer do you find any useful logs? If you follow this: https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

They should be in idea.log

I'm on Ubuntu. Installed v0.0.6 via Marketplace (seems to release quickly)

Idea logs show:

2023-11-13 21:52:21,809 [   2677]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;0): Starting server
2023-11-13 21:52:21,811 [   2679]   INFO - #c.i.p.l.a.LspServerDescriptor - TemplLspServerDescriptor@go_htmx: starting LSP server: /home/jon/go/bin/templ [lsp]
2023-11-13 21:52:21,908 [   2776]   WARN - #o.j.p.t.l.s.SyntaxNodeDescriptor - Can't find repository 12
2023-11-13 21:52:21,909 [   2777]   WARN - #o.j.p.t.l.s.SyntaxNodeDescriptor - Can't find repository 19
2023-11-13 21:52:21,923 [   2791]   INFO - #c.i.p.l.i.c.LspServerProcessListener - LSP server process started: /home/jon/go/bin/templ lsp
2023-11-13 21:52:21,925 [   2793]   INFO - #c.i.p.l.i.c.LspServerProcessListener - LSP server process terminated, exit code = 1, command line: /home/jon/go/bin/templ lsp
2023-11-13 21:52:21,943 [   2811]   WARN - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;0): Failed to start server
java.lang.RuntimeException: LSP server failed to initialize
    at com.intellij.platform.lsp.impl.connector.Lsp4jServerConnector.s(Lsp4jServerConnector.java:119)
    at com.intellij.platform.lsp.impl.connector.Lsp4jServerConnector.connect(Lsp4jServerConnector.java:88)
    at com.intellij.platform.lsp.impl.LspServerImpl.k(LspServerImpl.java:379)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:272)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: Stream closed
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.request(RemoteEndpoint.java:161)
    at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:91)
    at jdk.proxy2/jdk.proxy2.$Proxy127.initialize(Unknown Source)
    at com.intellij.platform.lsp.impl.connector.Lsp4jServerConnector.s(Lsp4jServerConnector.java:102)
    ... 12 more
Caused by: java.io.IOException: Stream closed
    at java.base/java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:445)
    at java.base/java.io.OutputStream.write(OutputStream.java:162)
    at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
    at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:69)
    ... 16 more
2023-11-13 21:52:21,948 [   2816]   WARN - #c.i.p.l.i.c.Lsp4jServerConnector - TemplLspServerDescriptor@go_htmx: `shutdown` request failed: java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: Stream closed
2023-11-13 21:52:21,949 [   2817]   INFO - org.eclipse.lsp4j.jsonrpc.RemoteEndpoint - Failed to send notification message.
org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: Stream closed
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.notify(RemoteEndpoint.java:126)
    at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:88)
    at jdk.proxy2/jdk.proxy2.$Proxy127.exit(Unknown Source)
    at com.intellij.platform.lsp.impl.connector.Lsp4jServerConnector.shutdownExitDisconnect(Lsp4jServerConnector.java:151)
    at com.intellij.platform.lsp.impl.LspServerImpl.s(LspServerImpl.java:406)
    at com.intellij.platform.lsp.impl.LspServerImpl.cleanupShutdownAndExit(LspServerImpl.java:415)
    at com.intellij.platform.lsp.impl.LspServerImpl.k(LspServerImpl.java:388)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:272)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: Stream closed
    at java.base/java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:445)
    at java.base/java.io.OutputStream.write(OutputStream.java:162)
    at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
    at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:69)
    ... 17 more

If I try to run it by myself in a terminal it works:

➜  go_htmx git:(master) ✗ /home/jon/go/bin/templ lsp
^C%                                                                             
➜  go_htmx git:(master) ✗ templ version
0.2.428
jonerer commented 11 months ago

I was able to reproduce my problem in a terminal. For some reason it seems to happen because GoLand isn't run with the same environment variables that my terminal has. My terminal is set up via ~/.zshrc. I typically run GoLand from the shortcut created by JetBrains Toolbox. Unsure why, but the problem seems to be inside templ lsp. Templ lsp quits immediately without output when I run it without my typical PATH, with no feedback. I guess it gets sad that there is no go binary?

➜ Desktop env -i bash --norc --noprofile
bash-5.1$ cd /home/jon/prog/go/src/go_htmx bash-5.1$ /home/jon/go/bin/templ lsp bash-5.1$ echo $? 1 bash-5.1$ which go bash-5.1$

I guess that Templ isn't really at fault here, but it is a situation that likely many will face, and that could use some improvements in DX. Notes: It doesn't happen in VS Code (I also start VS Code from a shortcut icon, but somehow it sets up the environment I guess). But for GoLand, golang has been set up via the built-in SDK management functionality of the JetBrains IDE (in settings, Go->GOROOT).

EDIT: managed to get a stack trace:

bash-5.1$ /home/jon/go/bin/templ lsp -log debug
bash-5.1$ cat debug                            
{"level":"info","ts":"2023-11-14T09:35:44+01:00","caller":"lspcmd/main.go:74","msg":"lsp: starting up..."}
{"level":"info","ts":"2023-11-14T09:35:44+01:00","caller":"lspcmd/main.go:81","msg":"lsp: starting gopls..."}
{"level":"error","ts":"2023-11-14T09:35:44+01:00","caller":"lspcmd/main.go:87","msg":"failed to start gopls","error":"cannot find gopls on the path (\"\"), you can install it with `go install golang.org/x/tools/gopls@latest`","stacktrace":"github.c
[...]

I'd say this is likely what happens in GoLand as well.

EDIT2: Maybe templ lsp should look in $HOME/go/bin, in case it can't find gopls on the $PATH? Or look in the same directory as the templ binary finds itself in

a-h commented 11 months ago

Good idea on probing some directories @jonerer, I've done that.

joerdav commented 11 months ago

@jonerer let me know if that update to templ fixes your issue!

jonerer commented 11 months ago

Tried it, and /home/jon/go/bin/templ lsp works fine :)

But there seem to be other symptoms of the same problem. The logs show:

2023-11-14 13:28:39,779 [   2606]   INFO - #c.i.p.l.i.c.Lsp4jServerConnector - TemplLspServerDescriptor@go_htmx: server initialized, name = gopls, version = {"GoVersion":"go1.21.0","Path":"golang.org/x/tools/gopls","Main":{"Path":"golang.org/x/tools/gopls","Version":"v0.14.1","Sum":"h1:XaTETpi7Q67XO8nftquJitcx+9c2bPclO8Kz2sBVvec=","Replace":null},"Deps":[{"Path":"github.com/BurntSushi/toml","Version":"v1.2.1","Sum":"h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=","Replace":null},{"Path":"github.com/google/go-cmp","Version":"v0.5.9","Sum":"h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=","Replace":null},{"Path":"github.com/sergi/go-diff","Version":"v1.1.0","Sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=","Replace":null},{"Path":"golang.org/x/exp/typeparams","Version":"v0.0.0-20221212164502-fae10dda9338","Sum":"h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=","Replace":null},{"Path":"golang.org/x/mod","Version":"v0.13.0","Sum":"h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=","Replace":null},{"Path":"golang.org/x/sync","Version":"v0.4.0","Sum":"h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=","Replace":null},{"Path":"golang.org/x/sys","Version":"v0.13.0","Sum":"h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=","Replace":null},{"Path":"golang.org/x/telemetry","Version":"v0.0.0-20231011160506-788d5629a052","Sum":"h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y=","Replace":null},{"Path":"golang.org/x/text","Version":"v0.13.0","Sum":"h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=","Replace":null},{"Path":"golang.org/x/tools","Version":"v0.14.1-0.20231026192422-8b5abd452b28","Sum":"h1:5YgdZAe2w0x3Xrjv0+GXrI0jvm7qCQK/ySGFfiEHMfU=","Replace":null},{"Path":"golang.org/x/vuln","Version":"v1.0.1","Sum":"h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=","Replace":null},{"Path":"honnef.co/go/tools","Version":"v0.4.5","Sum":"h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo=","Replace":null},{"Path":"mvdan.cc/gofumpt","Version":"v0.4.0","Sum":"h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=","Replace":null},{"Path":"mvdan.cc/xurls/v2","Version":"v2.4.0","Sum":"h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=","Replace":null}],"Settings":[{"Key":"-buildmode","Value":"exe"},{"Key":"-compiler","Value":"gc"},{"Key":"DefaultGODEBUG","Value":"panicnil=1"},{"Key":"CGO_ENABLED","Value":"1"},{"Key":"CGO_CFLAGS","Value":""},{"Key":"CGO_CPPFLAGS","Value":""},{"Key":"CGO_CXXFLAGS","Value":""},{"Key":"CGO_LDFLAGS","Value":""},{"Key":"GOARCH","Value":"amd64"},{"Key":"GOOS","Value":"linux"},{"Key":"GOAMD64","Value":"v1"}],"Version":"v0.14.1"}
2023-11-14 13:28:39,780 [   2607]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;0): Loading packages...
2023-11-14 13:28:39,783 [   2610]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;0): Error loading packages: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 
2023-11-14 13:28:39,783 [   2610]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;0): Error loading workspace folders (expected 1, got 0)
failed to load view for file:///home/jon/prog/go/src/go_htmx: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 

2023-11-14 13:28:39,804 [   2631]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Loading packages...
2023-11-14 13:28:39,805 [   2632]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error loading packages: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 
2023-11-14 13:28:39,805 [   2632]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error loading workspace folders (expected 1, got 0)
failed to load view for file:///home/jon/prog/go/src/go_htmx/views: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 

2023-11-14 13:28:39,811 [   2638]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Loading packages...
2023-11-14 13:28:39,812 [   2639]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error loading packages: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 
2023-11-14 13:28:39,812 [   2639]   INFO - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error loading workspace folders (expected 1, got 0)
failed to load view for file:///home/jon/prog/go/src/go_htmx/views: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 

[...]
2023-11-14 13:29:15,342 [  38169]   WARN - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error response from server: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: no views in session
2023-11-14 13:29:16,093 [  38920]   WARN - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error response from server: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: no views in session
2023-11-14 13:29:17,264 [  40091]   WARN - #c.i.p.l.i.LspServerImpl - TemplLspServerDescriptor@go_htmx(RUNNING;2): Error response from server: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: no views in session

It also shows a bit more visually:

Screenshot from 2023-11-14 13-30-01

FWIW autoformatting works fine in .go files, and I can build the project. So goland knows where the "go" binary is. A workaround is to launch goland from my zsh shell, that has all the env variables set up

joerdav commented 11 months ago

Okay, this sounds like a plugin issue, I'll find a way to make it find the go binary. And maybe make it configurable too.

xerullian commented 11 months ago

Love the work you all are doing on this plugin! I was able to get it installed without too much hassle. Go code auto-completion appears to be working. Though I am seeing some inconsistencies with syntax error reporting.

Using GoLand on Xero Linux (Arch distro). I installed gopls with my package manager, so it handled the path setup.


Is it expected that this plugin should auto-complete HTML tags in .templ files, or is this handled by a different part of GoLand?

I had HTML auto-completion working when I associated .templfiles with Go template files in GoLand. I removed that association before installing this plugin so it wouldn't break anything. When I try that same association, GoLand states .templ files are already associated with some sort of Go templates. I've looked through all the file associations and don't see .templ anywhere.

File Types reference for GoLand setting Goland_file_types_go_html_wildcard_1 Goland_file_types_go_html_wildcard_2

joerdav commented 11 months ago

I think plugins can define file associated that aren't configurable, and the templ plugin at the moment claims templ files at the moment.

I know that there is some functionality in the templ LSP for HTML completion, but the intellij LSP support is quite new, so we may be using a feature that isn't supported yet in intellij LSP.

Although I believe the snippets use the completion feature, which intellij should support: https://blog.jetbrains.com/platform/2023/07/lsp-for-plugin-developers/#supported-features