9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
196 stars 26 forks source link

scala metals (lsp) - dynamic root directory #24

Closed gdiazlo closed 5 years ago

gdiazlo commented 5 years ago

Following the instructions in https://scalameta.org/metals/docs/editors/new-editor.html, I have installed metals.

This language server uses the RootUri (RootDirectory in acme-lsp config) as the project starting point, supporting the addition of workspaces using the lsp messages.

I'm not sure if this is a common practice. This server works with multiple editor (vscode, emacs, vim, etc.). If it is, having a way to specify RootDirectory from cli instead the config file could come handy for acme-lsp.

fhs commented 5 years ago

gopls treats rootUri as just another workspace folder. acme-lsp defaults to file:/// for rootUri and I haven't encountered any issues with that, which is why there is no flag for it. I don't mind adding a -rootdir flag if it's important for other language servers.

gdiazlo commented 5 years ago

Thanks! I didn't have the time to answer! :) The flag comes handy, I can have now an Ametals script to be run from acme tag project folder:

#!/usr/bin/env bash
rootDir=$(pwd)
acme-lsp --rootdir $rootDir -v -server "(\.scala)|(\.sbt)$:metals" -workspaces "$rootDir:$1"

Still testing it, but now it starts and seems to work :)