request: Jet Brains Goland plugin
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.
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. (currently listening to the Changelog Go Time podcast 😊)
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 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
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 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
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
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.
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.
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 :cry: 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)
(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!
Here's a sneak peak:
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?
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 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. 😁
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.
+1
@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!
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[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]
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:
- Mousing over a type doesn't show any info, just "Cannot find declaration to go to".
- Same for ctrl-clicking a @Component in the HTML, "Cannot find declaration to go to"
- It would be great if the generated files were merged in the project view. I don't know what it's called, but JetBrains has a feature that merges for instance ".ts" files with their generated ".js" files into one item in the left hand list.
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.
@joerdav I tried it but nothing happens when adding manually