azdavis / millet

A language server for Standard ML.
https://azdavis.net/posts/millet
Apache License 2.0
196 stars 12 forks source link

allow configuring path to lang-srv executable #8

Closed smasher164 closed 1 year ago

smasher164 commented 1 year ago

First of all, thank you for building this project!

Currently, the VSCode extension hardcodes the path to the lang-srv executable, which is the absolute path to out/lang-srv. However, I would like to propose that this be configurable to a user-specified path.

My current use case requires this because on NixOS, executables produced on other OSes don't directly run, because the path to the ELF interpreter and RPATH to libraries are different. So in my case, the lang-srv executable fails to launch. The way that nix packages for VSCode extensions workaround this is by either building it the executable themselves and pointing the extension to it, or if that's not possible, patching the extension or executable.

The former method doesn't require making patches to the package, but requires the package provide some way to configure the path to the binary. A common approach I see with language server extensions is to provide a field in their package.json like contributes.configuration.langSrvPath with a default fallback. The extension would then load that value via vscode.workspace.getConfiguration.

azdavis commented 1 year ago

This is reminding me of a post I vaguely remember reading. It's written by matklad, the primary author of rust-analyzer, a language server for Rust.

Let me look into how rust-analyzer handles this (probably by doing exactly what you said) and try that. Since I'm unfamiliar with NixOS/can't test it, would you be able to help me test it locally? If yes, I'm thinking I could make a PR, tag you in it, and you could clone it and let met know how it goes.

I'll try to get to this soon.

In the meantime, another user @.marsam packaged the millet language server binary for NixOS; maybe that helps? (marsam indicated they use emacs, though, so it might not help if you're using VS Code because it's just the language server binary, not the whole VS Code extension.)

azdavis commented 1 year ago

Actually, I think I figured out how to do this just by looking at rust-analyzer. I verified it works locally.

azdavis commented 1 year ago

Should be able to set millet.server.path in your VS Code settings in v0.3.3: https://github.com/azdavis/millet/blob/main/docs/config.md#milletserverpath

smasher164 commented 1 year ago

Thank you!