4 ms·
Show HN: Create a full language server in Go with 3.17 spec support
- bbkane 6mo agoStarted in case I ever build a language server, thanks! The interface looks very understandable, and the debug server looks really nice. Now that I think about it, it might be really cool to add LSP to my CLI framework[0] (I already have tab completion for shells, why not make an editor plugin if it's this easy ..) 0: https://github.com/bbkane/warg https://github.com/bbkane/warg
- rumno0 6mo agoI wrote this for the infracost LSP so I could write multiple IDE extensions. Its not even really a language server, its just a neat way to parse the Terraform/Cloudformation and return diagnostics. Language servers are cool!
- SwiftyBug 6mo agoVery nice. Now I want to build a language server. If only I had anything to build it for.
- catlifeonmars 6mo agoTo give you some idea how versatile a language server is, I wrote one once to provide go-to-definition between two related blocks in a large proprietary YAML configuration file. If the definition was missing, it would also render the red squiggly line to indicate that something was misspelled. Another time I used one to make the hosts in my SSH configuration file clickable to either open a terminal with a session or just to display cpu/memory statistics. Lots of neat editor-independent interactions can be enabled using language servers.
- rumno0 6mo agoI've been thinking about this comment for a few hours now! I love it! I like building VS Code extensions and realized quickly the benefit of writing the logic in an LSP but I would never have thought to do the SSH config thing you describe. I've now started a Makefile lsp since you've inspired me to think about the painful scenarios that LSP can solve if I think a bit wider. Cheers for that!!
- rumno0 6mo agothanks! Thankfully, I finally had a reason to build an LSP (infracost LSP), so it motivated this and I'm really pleased with it
- devnotes77 6mo ago[dead]
- zephyrwhimsy 6mo ago[flagged]
- whateveracct 6mo ago// DiagnosticSeverity indicates the severity of a diagnostic. type DiagnosticSeverity int Hmmm :robot:
- jryio 6mo agoThe godoc format enforces that the comment start with the name of the identifier and be a complete sentence(s) describing what that identifier does. Predates LLMs
- badc0ffee 6mo agoI wouldn't say it enforces that the comment start with the name of the identifier. Maybe certain linter options enforce that? In https://go.dev/doc/comment https://go.dev/doc/comment it seems to be a convention, but there are a couple of examples there where the don't follow it.
- rumno0 6mo agoYeah some times godoc comments look crap by necessity
- fainpul 6mo agoBut you don't have to add a docstring. Cases like this are worse than no docstring at all, because it wastes the reader's time. If you add one, at least make the effort to provide some useful information. For example which is more severe: higher or lower numbers.
- rumno0 6mo agoI disagree - you should have docstring and I don't think this is worse by having it... its just not ideal
- hrmtst93837 6mo ago[flagged]
- 6mo ago
- peaklineops 6mo ago[dead]
- zephyrwhimsy 6mo ago[flagged]
- Myzel394 6mo agoHave you tried out https://github.com/tliron/glsp https://github.com/tliron/glsp?
- rumno0 6mo agoI actually started out using that. I wanted a debug UI to track messages which was the major driver in creating my own tbh
- pmoati 6mo agoI really like the interface-based auto-registration pattern, so elegeant! The implementation of HoverHandler seems clever... no manual wiring. That's the kind of API design that makes Go's implicit interfaces shine. I'm curious: How does error recovery work when a handler panics? Does the server keep the connection alive, or does it tear down?
- rumno0 6mo agoThanks - If its a straight error, then the error response is returned and we're all happy! If the handler panics, the server crashes, so that's something I'm off to fix now! Thanks!!!!
- rumno0 6mo agoJust to show what it can do, some language servers built with it - Makefile: https://github.com/owenrumney/make-ls https://github.com/owenrumney/make-ls - Goreleaser: https://github.com/owenrumney/goreleaser-ls https://github.com/owenrumney/goreleaser-ls