Hacker News new | past | comments | ask | show | jobs | submit login

Possibly dumb question: what is a language server in this context and what’s it used for outside of the AST package?



It's used by editors like Visual Studio Code to provide intellisense, autocomplete, breakpoints and the like.

The idea is that instead of each editor writing it's own (incomplete) Python or Go plugin, someone writes a language server which is then used (and improved) by everybody.


From the official website [1][2][3]

> The Language Server protocol is used between a tool (the client) and a language smartness

> provider (the server) to integrate features like auto complete, go to definition, find all

> references and alike into the tool. The LSP was created by Microsoft to define a common

> language for programming language analyzers to speak. Today, several companies have come

> together to support its growth, including Codenvy, Red Hat, and Sourcegraph, and the protocol

> is becoming supported by a rapidly growing list of editor and language communities.

[1] https://langserver.org

[2] https://news.ycombinator.com/item?id=18041419

[3] https://microsoft.github.io/language-server-protocol/specifi...


Look at https://microsoft.github.io/language-server-protocol/ for more info. It's a standard interface IDEs can use for things such as autocomplete rather than every IDE having to reinvent the wheel.


To add to this: the beauty of the protocol is that it uses JSON over stdin/stdout for communication. So if your language can make console apps, you can write a language server in it that works with any compliant editor/IDE - no FFI necessary, no need to learn how to author extensions for that editor etc.

And, conversely, if your editor/IDE can fork a child process and redirect its standard streams, you can support any language server and not care about how it's implemented.

I think this more than anything else has contributed to its rapid adoption, especially on Unix-likes.


Why was this downvoted? Is it not factual? If it's not, it would be far more helpful if it would be pointed out.

If it's implemented as stated by int_19h then it's my favourite interface - stdio instead of FFI. So one could implement a server even in Brainfuck.


The protocol itself is transport-agnostic - it just needs a bidirectional stream, and the spec doesn't define what it is. In practice, both stdin/stdout and sockets are used - the latter usually for language servers that are "heavyweight", such that it is advantageous to spin up the server once, "prime" it (let it do any indexing etc), and then reuse it between concurrent sessions. The standard streams are usually the default choice for simplicity reasons, though.

Implementing a server in Brainfuck is theoretically possible, but only if you ignore the heat death of the universe as the upper time boundary. ~


Interesting, I wonder if Vim is able to use this protocol as well.



Look up vim lsp plugins.


Also, I wanted to ask: how does this project compares to https://github.com/mdempsky/gocode?


Go code doesn’t work with go 1.11 or at least I can’t get it to work.


mdempsky's fork of gocode should work with Go 1.11... and rstambler's fork of that fork (https://github.com/stamblerre/gocode) should work with modules.

* edit: mdempksy's fork should work with Go 1.11 used outside of a module or with GO111MODULE=off; Rebecca's fork adds support for modules on top of that


It doesn't work half the time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: