-
Notifications
You must be signed in to change notification settings - Fork 7
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
Format document raises an exception #7
Comments
I'm a beginner in Elixir, but looks like |
If that's the case, perhaps you opened an elixir file by itself -- without a folder. It is perhaps possible that this language server assumes you will open a folder. For instance, open an elixir project with |
Can you open the SublimeText console and run the following?
It should print the folders of your window. If it's empty, that means that sublime-window is operating in "single file mode". |
I have set up a .sublime-project file. I don't understand what you mean by opening a folder. I have a Sublime Text project, within which I have few files opened, including this Elixir file. |
That is apparently not the case when
In the ST console. It should print the file path of the .sublime-project, or print nothing when the window is not attached to a project file. For instance for me it prints
|
|
Setting up a project doesn't imply that there are workspace folders. To add a folder just drag some folder into the ST window. Or use |
I have never used "Add Folder to Project" as I don't see any use for that feature. I did that now but that doesn't help at all: |
Is the file you are trying to format within that folder? LSP treats files within the workspace folders differently than files outside. |
Ok, it's working now: After adding folder to project I closed Sublime Text and re-opened project. Then I got prompt to install rebar3, after which I got few minutes of 100% CPU consumption, and then code formatting started working. If LSP-elixir only works with files opened from project-folders, then that limitation should be mentioned in documentation. |
Even better would be if the plugin would tell you automatically that the server can’t be started. But that is only possible with the ST4 api, which this helper package doesn’t yet implement. |
I think the server is started in this case, just the formatting command is broken. Langauge servers generally are more useful in projects (so when you add the whole folder of your project) as then they provide features like project-wide symbols and go-to-definition. If you are opening just single files then you might be loosing out on features. As far as formatting not working on individual files, it would probably be something that the underlying server is responsible for. You might want to make an issue on https://github.com/elixir-lsp/elixir-ls/ and see what maintainers say. Maybe it's possible to support it for all cases... |
As a contributor to ElixirLS I'd like to echo this, and ElixirLS doesn't support the single-file use-case. It is being tracked in elixir-lsp/elixir-ls#307 but there aren't any current plans to work on it. |
What about adding alternative ways to configure project directory so I don't need to use "Add Folder to Project" which just wastes space in sidebar? For example using directory of |
Nowadays Elixir LS works on separate files. |
When I right-click in Elixir file and select "LSP > Format Document", status bar shows "an exception was raised:" and file is not formatted. I get this error in LSP Log Panel:
The text was updated successfully, but these errors were encountered: