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
LSP Mk I #3213
LSP Mk I #3213
Conversation
It probably helps a lot that I also use Coc.nvim, but I just copy/pasted your config and opened a scratch file and hover and error diagnostics Just Worked™️! Awesome stuff, @ChrisPenner. 🎉 |
Hrmm, it looks like the cli-integration tests are failing to exit on windows for some reason, I wonder if it's waiting for the LSP server to shut down or something, weird it's windows-only though. |
lspPort <- getLspPort | ||
TCP.serve (TCP.Host "127.0.0.1") lspPort $ \(sock, _sockaddr) -> do | ||
sockHandle <- socketToHandle sock ReadWriteMode | ||
Ki.scoped \scope -> do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of an anti-pattern to pass a scope
down into a function; could this scope be created closer to where it's used, or not really?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it can/I don't think we want to, the goal of this scope is for every background thread and request which is related to a given LSP connection should be tied to the scope for that connection, so that if the client ever hangs up, all the background work terminates as well. Since this is where the thread will "hang" waiting for a hang-up, I think this is the right place to put it for that behaviour.
I understand why it's generally an anti-pattern, but here I legitimately do want the nested threads to be forked on this scope, and I can't create new scopes at a lower level and get the same behaviour.
The io manager on windows hangs indefinitely when waiting on a port and it prevents UCM from closing :'(
Overview
LSP's probably don't need much introduction;
This adds the foundation of an LSP server into UCM!
This iteration supports:
Other interesting notes:
Installation and setup
Currently the only supported configuration is to connect to the LSP via a specified port.
The default is
127.0.0.1:5757
, but you can change the port usingUNISON_LSP_PORT=1234
.I've got this configuration in my CocConfig for nvim, your setup may vary.
Note that you'll need to start UCM before you try connecting to it in your editor or your editor might give up.
For VSCode I believe we'll have to publish an npm package to make an extension.
Implementation notes
While the
lsp
package does a ton of heavy lifting, this was still a lot of work.Interesting/controversial decisions
Currently the LSP is built into UCM itself, and you need to have a UCM session running to use it (though it also works in headless mode)
Test coverage
LSP is tough to test, so everyone will just have to dog-food it 😄
Transcripts should detect if I accidentally altered any existing Type errors or anything.
In the Future
This change is