elixir-tools / elixir-tools.vscode Goto Github PK
View Code? Open in Web Editor NEWVisual Studio Code extension for Elixir
Home Page: https://marketplace.visualstudio.com/items?itemName=elixir-tools.elixir-tools
License: Other
Visual Studio Code extension for Elixir
Home Page: https://marketplace.visualstudio.com/items?itemName=elixir-tools.elixir-tools
License: Other
There should be tests!
I believe that this is a must have feature for a Language Server. I don't know if I didn't configure the extension correctly, but it doesn't show.
Next LS is now distributed by a prebuilt binary, and the extensions should download and install it for the user.
I am playing with this but I am not sure if it s working or not. does it handle having a .credo file in my repo that configure the check I am interested in?
After the automatic download of NextLS it instantly fails to start the extension.
OS: NixOS 23.05
vscode version: VSCodium 1.78.2 (installed through home-manager with programs.vscode.package = pkgs.vscodium.fhsWithPackages (ps: with ps; [ nil nixpkgs-fmt ]);
)
[NextLS] NextLS v0.13.4 has initialized!
[NextLS] Booting runtimes...
[NextLS] Beginning DB migration...
[Warn - 11:37:12 AM] [NextLS] sqlite3 error: Database busy
statement: SELECT MAX(version) FROM schema;
arguments: []
[Error - 11:37:12 AM] LSP Exited.
Last message received: handle_notification %{"jsonrpc" => "2.0", "method" => "initialized", "params" => %{}}
** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, NextLS.DB, {%Protocol.UndefinedError{protocol: String.Chars, value: {:error, "Database busy"}, description: ""}, [{String.Chars, :impl_for!, 1, [file: ~c"lib/string/chars.ex", line: 3]}, {String.Chars, :to_string, 1, [file: ~c"lib/string/chars.ex", line: 22]}, {NextLS.DB.Schema, :init, 1, [file: ~c"lib/next_ls/db/schema.ex", line: 56]}, {NextLS.DB, :init, 1, [file: ~c"lib/next_ls/db.ex", line: 33]}, {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 962]}, {:gen_server, :init_it, 6, [file: ~c"gen_server.erl", line: 917]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}]}}}}
(next_ls 0.13.4) lib/next_ls.ex:571: anonymous fn/3 in NextLS.handle_notification/2
(elixir 1.15.5) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
(next_ls 0.13.4) lib/next_ls.ex:565: NextLS.handle_notification/2
(gen_lsp 0.6.0) lib/gen_lsp.ex:285: anonymous fn/4 in GenLSP.loop/3
(gen_lsp 0.6.0) lib/gen_lsp.ex:308: GenLSP.attempt/3
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
11:37:12.388 [error] LSP Exited.
I enabled elixir-tools as my formatter via:
"[elixir]": {
"editor.defaultFormatter": "elixir-tools.elixir-tools"
}
but every time I try to save a file I get this notification: The NextLS runtime is still initializing!
.
Here is the only console output from NextLS:
[NextLS] NextLS v0.17.1 has initialized!
[Info - 4:22:39 PM] [NextLS] [extension] Credo initializing with options %NextLS.InitOpts.Extensions.Credo{enable: true, cli_options: []}
[NextLS] Booting runtimes...
[Info - 4:22:39 PM] [NextLS] Beginning DB migration...
[Info - 4:22:39 PM] [NextLS] Database is on the latest version: 5
[Info - 4:22:39 PM] [NextLS] Finished DB migration...
[Info - 4:22:39 PM] [NextLS] Using `elixir` found at: /Users/kyle.bishop/.asdf/shims/elixir
I mean, the title kind says it all. The rest of my files are being formatted on save, but my H_sigil templates just aren't. I ran mix format to make sure it wasn't something I'd done, and that worked fine. Additionally, I explicitly had vscode format the document and that didn't do anything. Looking in the NexLS logs, there's no errors. Let me know what I can do to help debugging.
Allow a user to optionally activate debug logging for al Language Server requests and responses.
Since the languange server is still in development, it would allow to debug the Languange Server better while using it, improving the feedbacks to the repository.
Hi, I never had the project on my system before and wanted to give it a try. This is the output I got in VSCode:
** (FunctionClauseError) no function clause matching in :net_kernel.start/1
The following arguments were given to :net_kernel.start/1:
# 1
["next-ls-1687777365509196500", :shortnames, 15000]
(kernel 9.0.1) net_kernel.erl:461: :net_kernel.start/1
/Users/ulbrich/.vscode/extensions/elixir-tools.elixir-tools-0.2.1/bin/nextls:3: (file)
[Error - 13:02:45] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 13:02:45] Connection to server got closed. Server will restart.
true
[Error - 13:02:45] NextLS client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
** (FunctionClauseError) no function clause matching in :net_kernel.start/1
The following arguments were given to :net_kernel.start/1:
# 1
["next-ls-1687777365943525750", :shortnames, 15000]
(kernel 9.0.1) net_kernel.erl:461: :net_kernel.start/1
/Users/ulbrich/.vscode/extensions/elixir-tools.elixir-tools-0.2.1/bin/nextls:3: (file)
[Error - 13:02:45] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 13:02:45] Connection to server got closed. Server will restart.
true
[Error - 13:02:45] NextLS client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
** (FunctionClauseError) no function clause matching in :net_kernel.start/1
The following arguments were given to :net_kernel.start/1:
# 1
["next-ls-1687777366355695417", :shortnames, 15000]
(kernel 9.0.1) net_kernel.erl:461: :net_kernel.start/1
/Users/ulbrich/.vscode/extensions/elixir-tools.elixir-tools-0.2.1/bin/nextls:3: (file)
[Error - 13:02:46] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 13:02:46] Connection to server got closed. Server will restart.
true
[Error - 13:02:46] NextLS client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 13:02:46] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
** (FunctionClauseError) no function clause matching in :net_kernel.start/1
The following arguments were given to :net_kernel.start/1:
# 1
["next-ls-1687777366811706167", :shortnames, 15000]
(kernel 9.0.1) net_kernel.erl:461: :net_kernel.start/1
/Users/ulbrich/.vscode/extensions/elixir-tools.elixir-tools-0.2.1/bin/nextls:3: (file)
[Error - 13:02:46] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 13:02:46] Connection to server got closed. Server will restart.
true
[Error - 13:02:46] NextLS client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 13:02:46] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
** (FunctionClauseError) no function clause matching in :net_kernel.start/1
The following arguments were given to :net_kernel.start/1:
# 1
["next-ls-1687777367242188542", :shortnames, 15000]
(kernel 9.0.1) net_kernel.erl:461: :net_kernel.start/1
/Users/ulbrich/.vscode/extensions/elixir-tools.elixir-tools-0.2.1/bin/nextls:3: (file)
[Error - 13:02:47] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 13:02:47] The NextLS server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 13:02:47] NextLS client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 13:02:47] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
Installation of Erlang/Elixir is done using asdf
and here's the .tool-versions
file:
erlang 26.0.1
elixir 1.15.0-otp-26
I can't see any error on my side so far… 😇
I am trying next-ls and so far it is working great even though it is still in heavy development mode.
One thing that I've noticed is that, while it formats the .ex and .exs files automatically, it does not format the .heex files.
When using elixir-ls I have this configuration that does the trick:
"[phoenix-heex]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "JakeBecker.elixir-ls"
},
If I change the default formatter to the next-ls one it doesn't seem to do anything:
"[phoenix-heex]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "elixir-tools.elixir-tools"
},
Am I doing something wrong? Or is it just that HEEx is not yet supported in the current development phase?
By default VSCode has the following shortcut, that toggles commenting the selected lines:
{
"key": "cmd+/",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
}
When I use that shortcut with NextLS it does not do anything. If I disable NextLS it works. It also works with ElixirLS and Lexical.
@mhanberg I got the extension working after launching with epmd running and launching from command line using code
. The first time it ran it downloaded and compiled the dependencies and warnings/errors in the main codebase went to the Problems panel as expected (except those in tests). Strangely, upon restarting VS Code it goes back into a bad state I had before I launched via the command line. Deleting the .elixir_tools
folder fixes the problem but causes a full recompile. Also worth noting that it's an umbrella project.
[NextLS] NextLS v0.10.3 has initialized!
[NextLS] Booting runtimes...
[NextLS] Beginning DB migration...
[Info - 18:31:46] [NextLS] Database is on the latest version: 4
[NextLS] Finished DB migration...
[NextLS] Debuggable: true
[NextLS] Connected to node nextls-runtime-1693038706576956625@[redacted]
[NextLS] Runtime for folder services is ready...
[NextLS] Unchecked dependencies for environment dev:
* vix (Hex package)
the dependency is not available, run "mix deps.get"
... [snip] ....
* elixir_make (Hex package)
the dependency is not available, run "mix deps.get"
* cowboy_telemetry (Hex package)
[NextLS] the dependency is not available, run "mix deps.get"
* sweet_xml (Hex package)
the dependency is not available, run "mix deps.get"
* ratio (Hex package)
the dependency is not available, run "mix deps.get"
[Warn - 18:31:47] [NextLS] Unexpected compiler response: {:error, %{message: "Can't continue due to errors on dependencies", __struct__: Mix.Error, __exception__: true, mix: 1}}
I then tried running a server in the command line on port 9000 and running again, and it fails just like above, but then:
[Error - 18:44:17] [NextLS] The runtime for services has crashed with reason: {:shutdown, :nodedown}
[NextLS] Debuggable: true
[NextLS] Connected to node nextls-runtime-1693039457723948291@[redacted]
[NextLS] Runtime for folder services is ready...
[NextLS] Compiled services!
Also, while I had it working before, I was editing files, particularly in tests, and noticed the errors were attributed to nofile
causing them not to show up in the Problems panel. But now I'm finding that the test files don't get parsed at all. But maybe I can spin up another issue for this.
Let me know if there's anything more I can do to debug these issues, or if there's anything more you want to know.
With the Credo Language server disabled and NextLS enabled, I'm getting the following error on Ubuntu 22.04.4.
[Error - 9:28:02 AM] Client NextLS: connection to server is erroring. Shutting down server.
[Error - 9:28:02 AM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
at _.shutdown (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:96701)
at _.stop (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:96282)
at _.stop (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:258296)
at _.handleConnectionError (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:102789)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
I'm also getting an error with NextLS timing out on MacOS, but it didn't have a stack trace.
This is my first try at enabling NextLS. I did get the dialog box to download it and the nextls
binary prints out help when I manually run it.
I'm using the stdio
adapter. When I tried the tcp
adapter, I received the same stack trace.
Any ideas on debugging this?
The download URL for NextLS is incorrect and so I cannot download it. The /latest
path appears to not be valid anymore
I am having trouble getting NextLS to start from VSCode. I always get the following message in the "Extension host" output tab.
2023-10-04 08:19:32.954 [error] Error: Client is not running and can't be stopped. It's current state is: starting
at _.shutdown (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:96701)
at _.stop (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:96282)
at _.stop (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:258296)
at e.deactivate (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:433218)
at n.Z (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:9460)
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:7585
at Array.map (<anonymous>)
at n.S (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:7572)
at n.terminate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:7844)
at o.terminate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:122:1513)
at D (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:135:9800)
at MessagePortMain.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:135:6225)
at MessagePortMain.emit (node:events:513:28)
at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)
I can run the nextls
executable manually and start it on port 9000 as explained in the README:
➜ ~ ~/.cache/elixir-tools/nextls/bin/nextls --port 9000
Starting on port 9000
Then, I can switch the VSCode configuration to use the TCP adapter and port 9000 but it still seems not to do anything. I can't see the .elixir_tools
directory and the language server functionality does not work.
To reach feature parity with elixir-tools.nvim
Basically, this functionality from elixir-tools.nvim should be ported over to elixir-tools.vscode.
Ubuntu 22.04
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]
Elixir 1.15.2 (compiled with Erlang/OTP 26)
NextLS is enabled in settings
[Error - 8:21:13 AM] Client NextLS: connection to server is erroring. Shutting down server.
[Error - 8:21:13 AM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
at _.shutdown (/home/user/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150023)
at _.stop (/home/user/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:149604)
at _.stop (/home/user/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:311618)
at _.handleConnectionError (/home/user/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:156111)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
I did a fresh install of the elixir-tools extension in VSCode on MacOS. It's currently not starting and this seems to be the error.
2023-08-23 21:26:07.219 [error] Activating extension elixir-tools.elixir-tools failed due to an error:
2023-08-23 21:26:07.219 [error] TypeError: Cannot read properties of undefined (reading 'replace')
at /Users/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.7.0/dist/extension.js:2:430330
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /Users/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.7.0/dist/extension.js:2:430078
at async e.activate (/Users/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.7.0/dist/extension.js:2:429825)
at async p.n (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:6206)
at async p.m (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:6169)
at async p.l (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:5626)
Does any of this look familiar? If not, I'll dig in more.
With the following asdf
versions
erlang 26.0.2
elixir 1.15.2-otp-26
nodejs 16.19.1
The VSCode extension fails to start since it looks for the Elixir instalation on /usr/bin
folder, but asdf installs it on $HOME/.asdf/shims/
.
Either add $HOME/.asdf/shims
to the search path for the binaries, or add a VSCode Setting to allow a user to manually override the /usr/bin
prefix
I use gitpod for my dev environments, which most often starts a fresh workspace. Every time I open one up I get the VS code pop up asking whether it should install NextLS.
Is it possible to set it to always install it? My extension settings are synced across workspaces.
Readability of Credo output is challenging in VSCode using this plugin (compared, at least, to other behavior such as the compiler and approach used by the 'Credo (Elixir Linter)' plugin).
Specifially, if you view issues in the tree view (not tabular view), the output is hard to manage because:
I think it would make more sense to emulate the approach taken by the native compiler output and 'Credo (Elixir Linter)' plugin, specifically:
This also points out another (related) issue, in that code highlighted is currently broken and only underlines the first character of a problem statement (versus the entire statement).
macOS 13.5.1 (ARM), VSCode 1.81.1, elixir-tools.vscode 0.7.0
I'm not sure if I messed something up, but I installed the extension (uninstalled all other Elixir extensions), restarted VSCode, but I don't see anything happening on any of my Elixir projects - no .elixir-tools directory being created, no Credo or Elixir options in the Output dropdown. I turned on the NextLS option and same thing. It seems like nothing's running at all.
Did I miss some sort of setup?
In next-ls/288 users are describing an issue wherein credo rules are applied whenever the runtime environment has credo loaded (via mix.exs). There are many cases where a project uses credo, but runs it with different command line options than the defaults.
Since next-ls will load credo and run with a fixed set of arguments, and since there's no way to conditionally change this on each developers system, it leaves developers in a precarious situation wherein they have no way to disable the sometimes thousands of credo warnings.
Longer term, more configuration can be added to allow passing specific flags to credo.
As a short-term solution, can we expose a configuration variable to disable credo entirely in next-ls? (Not to disable Credo Language Server, but to disable next-ls's credo checking entirely?)
This would require updating both elixir-tools.vscode
and next-ls
, but it would solve a severe ergonomics issue, which is holding back adoption of elixir-tools. (On my team, several people have tried switching from ElixirLS to elixir-tools, but then switched back, thinking it wasn't ready for prime-time. In my personal experience, this inability to disable credo entirely is the only issue that really hampers my use of elixir-tools/elixir-ls.)
On a Linux machine configured with NixOS, dynamic loading is different. Because of this it's often not possible to simply download a binary that depends on libc and run it.
This manifests as vscode not starting the nextls
binary
[Error - 11:51:56 AM] NextLS client: couldn't create connection to server.
Launching server using command /home/elliott/.cache/elixir-tools/nextls/bin/nextls failed. Error: spawn /home/elliott/.cache/elixir-tools/nextls/bin/nextls ENOENT
Nix provides a utility to change all the loads in place. That seems to get nextls running
steam-run ./nextls
Next LS v0.12.6
The language server for Elixir that just works.
Author: Mitchell Hanberg
Home page: https://www.elixir-tools.dev/next-ls
Source code: https://github.com/elixir-tools/next-ls
nextls [flags]
FLAGS
--stdio Use stdio as the transport mechanism
--port <port> Use TCP as the transport mechanism, with the given port
--help Show help
--version Show nextls version
It might be possible to detect that vscode is on Nixos and then run steam-run nextls
in the extension.
Rust Analyzer also has a similar issue of needing a running process downloaded from the internet. They chose to solve this by having nixos fix up the binary.
Hello everyone
Any tips how to solve the following errors?
write EPIPE
Shutting down server.
[Error - 16:53:22] Client Next LS: connection to server is erroring.
write EPIPE
[Error - 16:53:22] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
at Dp.shutdown (/home/newton.neto/.vscode/extensions/elixir-tools.elixir-tools-0.14.1/dist/extension.js:52:8492)
at Dp.stop (/home/newton.neto/.vscode/extensions/elixir-tools.elixir-tools-0.14.1/dist/extension.js:52:8071)
at Dp.stop (/home/newton.neto/.vscode/extensions/elixir-tools.elixir-tools-0.14.1/dist/extension.js:55:37705)
at Dp.handleConnectionError (/home/newton.neto/.vscode/extensions/elixir-tools.elixir-tools-0.14.1/dist/extension.js:54:63)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[Error - 16:53:22] Server initialization failed.
Message: write EPIPE
Code: -32099
[Error - 16:53:22] Next LS client: couldn't create connection to server.
Message: write EPIPE
Code: -32099
[Info - 16:53:22] Connection to server got closed. Server will restart.
true
error: AccessDenied
trying to run it manually
~ ~/.cache/elixir-tools/nextls/bin/nextls --port 9000
error: AccessDenied
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.