-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request: Jet Brains Goland plugin #127
Comments
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. |
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. |
I predict that there will be a solution to this within the next 5 minutes |
I quickly threw together this plugin: https://github.com/topi314/templ-goland I'd be happy to transfer this code to you and assist with the next steps to publish & co |
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. |
the Jetbrains LSP support is quit limiting right now for a better experience custom language support https://plugins.jetbrains.com/docs/intellij/custom-language-support.html would be awesome |
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 |
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 |
I'd say we just wait for jetbrains to bring more LSP support :) |
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 |
This is almost a blocker to use templ 😢 I'll install vscode for the template side of things for now. |
I've just installed GoLand, hopefully can make some progress here. |
(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 :) |
@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! |
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. |
is there any planned release date for Goland plugin? This is a blocker for me as I only used Goland IDE |
@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 :) |
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 @Evert-Arends - I'd like to know what the |
+1. This way you’ll also be able to collect feedback earlier. |
+1 |
@0x090909 - please use the emoji responses to express Adding a comment results in everyone that's subscribed to the issue receiving an update notification. Thanks! |
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! |
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[#127 (comment)], 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]
|
To an extent @0x090909 : |
@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 |
@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. |
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 on Ubuntu. Installed v0.0.6 via Marketplace (seems to release quickly) Idea logs show:
If I try to run it by myself in a terminal it works:
|
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 ➜ Desktop env -i bash --norc --noprofile 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:
I'd say this is likely what happens in GoLand as well. EDIT2: Maybe |
Good idea on probing some directories @jonerer, I've done that. |
@jonerer let me know if that update to templ fixes your issue! |
Tried it, and But there seem to be other symptoms of the same problem. The logs show:
It also shows a bit more visually: 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 |
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. |
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 Is it expected that this plugin should auto-complete HTML tags in I had HTML auto-completion working when I associated |
I think plugins can define file associated that aren't configurable, and the templ plugin at the moment claims 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 |
I just added this code to the templ-vscode plugin to do a bit more looking around for the |
I'll add these locations to the goland plugin. I think the most recent issue that @jonerer is encountering though is that the go command cannot be found by templ. |
@jonerer It's possible that his is related: golang/vscode-go#2499 It could be a permissions issue of the go executable. |
@joerdav Im still having this issues (MacOs), after manually adding the LSP path
|
@ziganagelj Can you please try running the lsp manually in your project:
And please report any errors shown in the resulting log file. |
@joerdav Thanks for the quick response. Log showed the following issue:
Which i solved with: But then i get this issue:
Which i just solved by adding path to .zshrc: Now in idea.log the plugins loads proper. However the plugin still doesnt doesn't work. Running
|
@ziganagelj I think the issue will be that your IDE won't have the PATH var that you constructed in templ will look in your |
I'm facing the same issue as @xerullian where html tags aren't autocompleting.. or even autoformatting. Unfortunately this is a huge blocker to use it in production, has anyone found any fixes for it? I've tried installing vscode alongside the plugin although it kinda is of the same story. Autoformatting works there, but still no html tag autocompletion :/ |
No autocompletion for me at all, just syntax highlighting. Huge blocker. |
would be nice to get templ support for GoLand out, I dislike VSCode for go and having to restart the language server and not having the QOL features of GoLand is quite frustrating. |
Remember this is nothing you are paying money for but rather an attempt to create something we can all use and benefit from. If you want I got the LSP running and integration running inside GoLand following the comments above:
DX on the plugin: Hit me up if you need help going further with this plugin. |
Thank you! I'll give it a try when I get out of work I missed this. |
I'm using WSL2 on Windows and to get the plugin working I did this:
However, I decided to configure *.templ files as HTML files in Goland. For me, templ files are HTML heavy and I also need HTMX and Alpinejs plugins and I couldn't get them to work correctly in templ functions. |
To fix auto-formatting for now I created a File-Watcher using "go fmt" as a base-template, inserted the templ executable into "Program:" and saved it. Afterwards you can create an "Action on Save" with the File-Watcher you just created. This is the default "go fmt" behaviour you would expect and this also produces error-messages and opens a window if something is not right, which I found really handy. |
For me, plugin at version 0.0.8 running in GoLand 2023.3.2, macOS 14.2.1, produces the following errors:
and
This errors are produced when navigating to plugin settings, and also when opening any .templ file. In file, only syntax highlighting works (although this is already not bad for working with simple templates in my opinion). |
@a-h I think we should close this, as conversations relating to the goland plugin are happening over in that repo. |
Closing, thanks for everyone's input and the continued work on the JetBrains side! |
Thanks for the discussed work. As explicit reminder to everyone who is interested in the Jetbrains plugin: These are the links you should probably follow: |
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.
The text was updated successfully, but these errors were encountered: