Giter VIP home page Giter VIP logo

vscode-elixir-ls's Introduction

ElixirLS: Elixir support and debugger for VS Code

Actions Status Visual Studio Marketplace Installs Open VSX Installs Slack

Provides Elixir language server and debug adapter. This extension is powered by the Elixir Language Server (ElixirLS), an Elixir implementation of Microsoft's IDE-agnostic Language Server Protocol and Debug Adapter Protocol. Visit its page for more information. For a guide to debugger usage in Elixir, read this blog post.

Features include:

  • Code completion
  • Debugger support VSCode debugging docs
  • Test discovery, running and debugging via Test Explorer VSCode test API announcment
  • Automatic, incremental Dialyzer analysis
  • Automatic suggestion for @spec annotations based on Dialyzer's inferred success typings
  • Diagnostic reporting of build warnings and errors
  • Go-to-definition and Go-to-implementation
  • Task provider with collection of mix tasks VSCode tasks
  • Smart automatic closing of code blocks
  • Documentation lookup on hover
  • Function signature provider
  • Code formatter (Triggered by Alt + Shift + F hotkey or enabling editor.formatOnSave)
  • Find references to functions and modules
  • Document and Workspace symbols provider
  • Multi-root workspaces

Screenshot

This is the main vscode-elixir-ls repo

The elixir-lsp/vscode-elixir-ls repo began as a fork when the original repo at JakeBecker/vscode-elixir-ls became inactive for an extended period of time. So we decided to start an active fork to merge dormant PR's and fix issues where possible. We also believe in an open and shared governance model to share the work instead of relying on one person to shoulder the whole burden.

The original repository has now been deprecated in favor of this one. Future updates to the original VS Code ElixirLS extension will come from this repo.

Default settings

ElixirLS is opinionated and sets the following default settings for Elixir files:

{
  // Based on Elixir formatter's style
  "editor.insertSpaces": true,
  // Note: While it is possible to override this in your VSCode configuration, the Elixir Formatter
  // does not support a configurable tab size, so if you override this then you should not use the
  // formatter.
  "editor.tabSize": 2,
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "files.trimFinalNewlines": true,

  // Provides smart completion for "do" and "fn ->" blocks. Does not run the Elixir formatter.
  "editor.formatOnType": true,

  // Misc
  "editor.wordBasedSuggestions": false,
  "editor.trimAutoWhitespace": false
}

You can, of course, change these in your user settings, or on a per project basis in .vscode/settings.json.

Advanced Configuration

Add support for emmet

emmet is a plugin that makes it easier to write HTML: https://code.visualstudio.com/docs/editor/emmet

Open VSCode and hit Ctrl+Shift+P (or Cmd+Shift+P) and type "Preference: Open Settings (JSON)" Add or edit your emmet.includedLanguages to include the new Language ID:

"emmet.includeLanguages": {
  "html-eex": "html"
}

Supported versions

See ElixirLS for details on the supported Elixir and Erlang versions.

Troubleshooting

If you run into issues with the extension, try these debugging steps:

  • Make sure you have hex and git installed.
  • Make sure github.com and hex.pm are accessible. You may need to configure your HTTPS proxy. If your setup uses TLS man-in-the-middle inspection, you may need to set HEX_UNSAFE_HTTPS=1.
  • If ElixirLS fails to start, you can try cleaning the Mix.install directory. (The location on your system can be obtained by calling Path.join(Mix.Utils.mix_cache(), "installs") from an iex session.)
  • Restart ElixirLS with a custom command restart
  • Run mix clean or mix clean --deps in ElixirLS with the custom command mixClean.
  • Restart your editor (which will restart ElixirLS).
  • After stopping your editor, remove the entire .elixir_ls directory, then restart your editor.
    • NOTE: This will cause you to have to re-run the entire dialyzer build

You may need to set elixirLS.mixEnv, elixirLS.mixTarget, and elixirLS.projectDir if your project requires it. By default, ElixirLS compiles code with MIX_ENV=test, MIX_TARGET=host, and assumes that mix.exs is located in the workspace root directory.

If you get an error like the following immediately on startup:

[Warn  - 1:56:04 PM] ** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{...snip...}}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

and you installed Elixir and Erlang from the Erlang Solutions repository, you may not have a full installation of Erlang. This can be solved with sudo apt-get install esl-erlang. (This was originally reported in #208.)

On fedora if you only install the elixir package you will not have a full erlang installation, this can be fixed by running sudo dnf install erlang (This was reported in #231.)

If you are seeing the message "Invalid beam file or no abstract code", you need to make sure that your Mix project is set to use the elixirc compiler option --debug-info, which can be done by adding the following line to your mix.exs project section:

elixirc_options: [debug_info: Mix.env() == :dev]

For example:

defmodule MyApp.MixProject do
  use Mix.Project

  def project do
    [
      app: :my_app,
      version: "0.1.0",
      elixir: "~> 1.11",
      elixirc_paths: elixirc_paths(Mix.env()),
      elixirc_options: [debug_info: Mix.env() == :dev],
    ...

Check ElixirLS Output

Check the output log by opening View > Output and selecting "ElixirLS" in the dropdown.

View ElixirLS Output

Check the Developer Tools

Check the developer console by opening Help > Toggle Developer Tools and include any errors that look relevant.

Contributing

Installation

# Clone this repo recursively to ensure you get the elixir-ls submodule
git clone --recursive [email protected]:elixir-lsp/vscode-elixir-ls.git

# Fetch vscode-elixir-ls dependencies
cd vscode-elixir-ls
npm install

# Fetch elixir-ls dependencies
cd elixir-ls
mix deps.get
MIX_ENV=prod mix compile

To launch the extension from VS Code, run the "Launch Extension local" launch configuration from Run and Debug view or press F5.

Alternatively, you can build and install the extension locally using the vsce command and the code CLI.

# Navigate to vscode-elixir-ls project root
cd ..

# Build the extension
npx vsce package

# Install it locally
code --install-extension *.vsix --force

Note that if you have the extension installed from the Visual Studio Marketplace and are also installing a locally built package, you may need to disable the Extensions: Auto Check Updates setting to prevent your local install from being replaced with the Marketplace version.

elixir-ls submodule

Most of the functionality of this extension comes from ElixirLS, which is included as a Git submodule in the elixir-ls folder. Make sure you clone the repo using git clone --recursive or run git submodule init && git submodule update after cloning.

Including elixir-ls as a submodule makes it easy to develop and test code changes for ElixirLS itself. If you want to modify ElixirLS, not just its VS Code client code, you'll want to change the code in the elixir-ls subdirectory. Most often you don't need to explicitly build it. The ElixirLS launch script should be able to pick up changes and rebuild accordingly via Mix.install.

When you're ready to contribute your changes back to ElixirLS, you need to fork the ElixirLS repo on Github and push any changes you make to the ElixirLS submodule to your fork. Here is an example of how that might look:

# Enter the submodule directory. Now, if you run git commands, they run in the submodule
cd vscode-elixir-ls/elixir-ls

# Create your feature branch
git checkout -b my_new_branch

# Add your forked elixir-ls repository as a remote
git remote add my_fork [email protected]:<your_github_username>/elixir-ls.git

# Make changes in the elixir-ls folder, commit them, and push to your forked repo
git commit ...
git push my_fork my_new_branch

# Visit https://github.com/elixir-lsp/elixir-ls/compare to start a new Pull Request

Running the tests locally

You should ensure that the tests run locally before submitting a PR, and if relevant add automated tests in the PR.

rm -rf out
npm run compile
npm test

Alternatively, you can use the test.sh/test.bat script which does the above.

Telemetry

This extension collects telemetry information emitted by ElixirLS language server and debug adapter for feature insight and performance and health monitoring. Collected telemetry data include usage, performance, environment info and error reports. Data is anonymised and not personally identifiable. Data is sent to Azure Application Insights via @vscode/extension-telemetry. The extension respects VSCode telemetry.telemetryLevel setting. For transparency telemetry.json details all collected information. If you would like inspect what is being collected or change your telemetry settings, please refer to VSCode Telemetry documentation.

Acknowledgements and related projects

There is another VS Code extension for Elixir, VSCode Elixir. It's powered by Elixir Sense, another language "smartness" server similar to ElixirLS. Much of this extension's client code (such as syntax highlighting) was copied directly from VSCode Elixir, for which they deserve all the credit.

vscode-elixir-ls's People

Contributors

alex88 avatar arjuns500 avatar axelson avatar caiquemitsuoka avatar carl-foster avatar crbelaus avatar dependabot[bot] avatar dustypomerleau avatar j3rn avatar jakebecker avatar jayjun avatar lukaszsamson avatar maxmellen avatar michallepicki avatar michalmuskala avatar msaraiva avatar niku avatar nobbz avatar omrisama avatar oo6 avatar polvalente avatar richmorin avatar rrichardsonv avatar samcharles93 avatar strajnarfilip avatar teeseal avatar tiagoefmoraes avatar timothyvanderaerden avatar vanjabucic avatar wingyplus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-elixir-ls's Issues

accept suggestions on enter instead of tab not working

Hey all,

Thanks for this awesome vs code plugin. Everything is working great, but I can't seem to be able to get it to accept suggestions on enter. I'm probably missing something simple, but I can't get it working.

Here is my vs code settings.json
{ "workbench.colorTheme": "dark+(elixir)", "editor.formatOnSave": true, "editor.acceptSuggestionOnEnter": "on" }

From reading the readme, it seems like that's all that should be required. Completeing with tab is working fine btw.

Edit: Enter is working to accept suggestions in .html.eex files, but not .ex files. Not sure if that helps

Compiler error and @spec suggestion not working

Elixir Version:
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.9.4 (compiled with Erlang/OTP 20)

Extension version: 0.2.28 (I've also tried downgrading)
Had same issue with Elixir 1.10.0 also.

VSCode(Stable latest release) has stopped showing compile error (underline highlights and error message) and @SPEC suggestions. They used work fine but I don't remember exactly when, for user it was with Elixir 1.9.4.

What all I have tried:

  • I was running Elixir 1.10.0 on ubunut, installed asdf to downgrade to 1.9.4
  • I have tried removing and regenerating the .elixirls, deps, and build folders
  • PLTs were generated again
  • Vim coc-elixir is working fine without any customization

Here is my mix file:

defmodule MyProject.MixProject do
  @moduledoc """
   Example:
  """
  use Mix.Project

  def project do
    [
      app: :my_project,
      version: "0.1.0",
      elixir: "~> 1.8",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
      {:earmark, "~> 1.4", only: :dev},
      {:ex_doc, "~> 0.19", only: :dev},
      {:dialyxir, "~> 1.0.0-rc.7", only: [:dev, :test], runtime: false},
      {:credo, "~> 1.1.0", only: [:dev, :test], runtime: false}
    ]
  end
end

Here is the fresh ElixirLS log on cold start with the project in VSCode stable version.

Compiling with Mix env test
[Info - 12:30:54 PM] Compile took 61 milliseconds
[Info - 12:30:54 PM] [ElixirLS Dialyzer] Checking for stale beam files
[Info - 12:30:55 PM] [ElixirLS Dialyzer] Analyzing 0 modules: []
[Info - 12:30:55 PM] [ElixirLS Dialyzer] Analysis finished in 12 milliseconds
[Info - 12:30:55 PM] Dialyzer analysis is up to date
[Info - 12:30:56 PM] [ElixirLS Dialyzer] Writing manifest...
[Info - 12:31:00 PM] [ElixirLS Dialyzer] Done writing manifest.
[Error - 12:31:13 PM] Request textDocument/documentSymbol failed.
Message: an exception was raised:
** (SyntaxError) nofile:14: unexpected token: end
(language_server) lib/language_server/providers/document_symbols.ex:41: ElixirLS.LanguageServer.Providers.DocumentSymbols.list_symbols/1
(language_server) lib/language_server/providers/document_symbols.ex:35: ElixirLS.LanguageServer.Providers.DocumentSymbols.symbols/2
(language_server) lib/language_server/server.ex:442: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2
Code: -32000

12:31:13.192 [error] Process #PID<0.1356.0> raised an exception
** (SyntaxError) nofile:14: unexpected token: end
(language_server) lib/language_server/providers/document_symbols.ex:41: ElixirLS.LanguageServer.Providers.DocumentSymbols.list_symbols/1
(language_server) lib/language_server/providers/document_symbols.ex:35: ElixirLS.LanguageServer.Providers.DocumentSymbols.symbols/2
(language_server) lib/language_server/server.ex:442: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2

Umbrella test/build tasks path output isn't highlighted

Hey, thanks for the great editor support for elixir!

I faced with some UI missing feature. So straight to the details. If you have a simple non umbrella project then paths are relative to the project's root which is totally fine to hover and click on the path. But if you have an umbrella app then task output is relative to the application running the test, so you can't hover and click the path to open. Seems it comes from fileLocation in problem matcher(not 100% sure). Rapidly checking the doc didn't give me an insight how to handle this. And googling didn't give me the answer on "is it possible to show stacktrace with absolute paths?"

So the question now it is possible at all?

Document local development instructions

This comment has some instructions that should be a good starting point:
JakeBecker/elixir-ls#163 (comment)

But if you don't want to wait for the package to be published, you can build the package yourself:

git clone --recursive https://github.com/leandrocp/vscode-elixir-ls
cd vscode-elixir-ls
git checkout support-phoenix-live-view
npm install
npm install -g vsce
vsce package

A file elixir-ls-0.2.24.vsix will be generated in the current path. On vscode, go to Extensions > ... > Install from VSIX... to install the package.

Repeatedly fails to build core Dialyzer Elixir PLT

The VS Code extension repeatedly loops, failing to build the core PLT file. It's attempting to write it to /.mix, rather than ~/.mix.

Environment

Version: 1.44.2
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T17:50:03.709Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 5.3.0-46-generic

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]

Elixir 1.10.2 (compiled with Erlang/OTP 21)

  • VSCode ElixirLS version: 0.3.3
  • Operating System Version: linux 5.3.0-46-generic

Diagnosis

I cloned the vscode-elixir-ls project and added some tracing in elixir_plt_path():

JsonRpc.show_message(:info,
    "XDG_DATA_HOME is #{System.get_env("XDG_DATA_HOME")}, MIX_HOME is #{System.get_env("MIX_HOME")}, ~/.mix is #{Path.expand("~/.mix")}, Mix home is #{Mix.Utils.mix_home()}")
XDG_DATA_HOME is , MIX_HOME is /.mix, ~/.mix is /home/roger/.mix, Mix home is /.mix

This evaluates the environment variables used by Mix.Utils.mix_home/0. Now, it's fairly obvious that MIX_HOME is getting set somehow. But I'm not setting it:

$ env | grep MIX
$ 

If I explicitly set it:

$ MIX_HOME=$HOME/.mix code .

...then everything's fine. How can I debug/fix this problem?


The extension works fine on VS Code on my Mac, incidentally.

Incorrect Elixir being used.

Hello, I use ASDF for elixir version management, and it seems this plugin is trying to use my global elixir version rather than the local version set by the .tool-versions and ASDF.

Feature: Good support for eex/leex files

If VSCode had direct support for universally embedding languages that would be ideal, but it's currently on the backlog:

You can embed syntax highlighting, this might be the lowest hanging fruit:
https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#embedded-languages

You can also embed support for another language server:
https://code.visualstudio.com/api/language-extensions/embedded-languages

If you use tailwind css, this extension has support for eex (and leex?) files, and might be a good source of inspiration:
https://github.com/bradlc/vscode-tailwindcss

Getting invalid association warning when using belongs_to

Hi! I'm getting what I believe is a false-positive warning:

I have a schema called "regions" that defines many "zones":

# region.ex
schema "regions" do
    field :name, :string
    has_many :zones, Zone
    timestamps()
end

# zone.ex
schema "zones" do
    field :name, :string
    belongs_to :region, Region
    timestamps()
end

I'm receiving the warning:

invalid association `zones` in schema Region: associated schema Zone does not have field `region_id`

Since the field region_id in the "zones" schema is inferred from the belongs_to association, I don't understand why this warning is necessary. Is this a problem!?

Rename to vscode-elixir-languageservice

The official language servers are named,

so I propose renaming this fork to vscode-elixir-languageservice. Community language servers don’t follow this convention but if we’re renaming to avoid collision, we might as well follow the official ones. Now would be the best time too, before word gets around.

This shouldn’t be confused with Microsoft/vscode-languageserver-node, which is a LSP implementation in Node.

Happy to submit a pull request but this involves changing the repo’s name too.

Leex syntax highlighting not working v 0.3.3 on WSL Ubuntu

Environment

Erlang/OTP 22 [erts-10.4.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.10.0-dev (495148e) (compiled with Erlang/OTP 20)

VSCode ElixirLS Fork version: 0.3.3

Operating System Version:
Microsoft Windows [Version 10.0.18362.720]
WSL:
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"

Problem

No syntax highlighting for *.LEEX files (But changelog says it does.)

Highlight works fine on *.EEX files.

I read https://thinkingelixir.com/vs-code-broken-for-elixir/ but nothing there works, either.

Ideas?

Thanks.

This plugin breaks VSCode's git integration.

Any other project, git shows changes normally.

This same project, with all extensions disabled git changes shown properly.

This same project, with ElixirLS Fork causes git changes to not be shown and also presents itself as if git wasn't even initialized in the repo.

image

Tried restarting my mac, deleting _build and deps, and restarting the extension itself, but no changes.

Any ideas?

Add syntax highlighting in Markdown code block

Since this is missing from this package, and I think that this is the only package that you need to work with Elixir, will you be interested in adding a support for syntax highlighting in markdown code blocks?

There is an existing addon that this, but I think it might be good if it is integrated into this one, as I personally expected this to work, instead of looking for an additional package.

If you think that this is a good idea, I can create a PR

Thank you

Inconsistent formatting when opening multiple projects

Environment

Most of this can be filled out by running the VSCode command (by default bound to Ctrl+Shift+P) "ElixirLS Fork: Copy Debug Info"

  * Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.10.2 (compiled with Erlang/OTP 22)

  * VSCode ElixirLS Fork version: 0.3.2
  * Operating System Version: darwin 19.4.0

Troubleshooting

  • Restart your editor (which will restart ElixirLS) sometimes fixes issues
  • Stop your editor, remove the entire .elixir_ls directory, then restart your editor
    • NOTE: This will cause you to have to re-run the entire dialyzer build

Starting with a new phoenix repo my formatter file consists of:

[
  import_deps: [:ecto, :phoenix],
  inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
  subdirectories: ["priv/*/migrations"]
]

and a sample ecto schema file the fields are without parenthesis because of https://github.com/elixir-ecto/ecto/blob/master/.formatter.exs

So this code snippet when formatting via VSCode and via CLI stays the same

  schema "users" do
    field :name, :string

    timestamps()
  end

So far everything is correct.

In the case where I have multiple projects (e.g. I usually open both the frontend and backend) and the elixir project is not first (backend first then frontend), the formatter doesn't seem to respect the .formatter.exs file.
After moving the project in the 2nd+ position it adds the parenthesis:

  schema "users" do
    field(:name, :string)

    timestamps()
  end

getting html autocompletes (such as css) to work

Did anyone get basic autocomplete of CSS class names and other HTML attributes to work with this plugin? I'm only getting emmet to work by adding

  "emmet.includeLanguages": {
    "HTML (EEx)": "html"
  },

but autocompletes like
image

are not working (tried both master versions of bradlc.vscode-tailwindcss and ecmel.vscode-html-css)

Symbol search does not work

Command+T allows to search for modules but it seems to be the default VSC functionnality. Using prefixes like f or t does not find anything.

Otherwise the outline panel shows all symbols without problem.

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
  • Elixir 1.10.2 (compiled with Erlang/OTP 22)
  • VSCode ElixirLS Fork version: 0.3.2
  • Operating System Version: darwin 18.7.0
  • Visual studio:
    Version: 1.44.2
    Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
    Date: 2020-04-16T17:07:18.473Z (2 wks ago)
    Electron: 7.1.11
    Chrome: 78.0.3904.130
    Node.js: 12.8.1
    V8: 7.8.279.23-electron.0
    OS: Darwin x64 18.7.0

Use of ${relativeFile} with taskArgs and mix test

I have the following launch configuration setup:

        {
            "type": "mix_task",
            "name": "mix test current file",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace",
                "${relativeFile}"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}",
            "requireFiles": [
                "test/**/test_helper.exs",
                "test/**/*_test.exs"
            ]
        }

However when I run this, it runs all of my tests, not just the one in the currently open file.

Cannot make this extension completely work on windows or WSL

I've been using this extension on Mac for a year (well, first the original and then the fork) and it works very well. However I've switched to a Windows machine recently and I've tried to make it work with no success.

Having Elixir and erlang with a compatible OTP (1.9.1-otp22 and otp 22), I open up an elixir project and:

  • On both platforms I always get the message saying that the build is stopped because the cwd has changed (just removing the trailing .)
  • In windows I get everything working except the @SPEC feature
  • In WSL I cannot even get the code problems to be processed, so I only get the code documentation when hoovered. Taking a look on the Output window I can see that CodeLens gives an error.

WSL uses asdf, by the way

Is there anything I must do to make it work?

VSCode `mix test` task fails on fresh `phx.new` application

Problem

The vscode-elixir-ls plugin debugger fails on a new phoenix application mix test task.

Reproduce

  1. Create a new phoenix application
mix phx.new hello # accept when prompted
cd hello
  1. Verify that mix test works in terminal
 mix test

# 13:12:05.053 [info]  Already up
# ...

# Finished in 0.07 seconds
# 3 tests, 0 failures

# Randomized with seed 130324
  1. Verify that mix_test task fails in VS Code
    • .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "mix_task",
            "name": "mix (Default task)",
            "request": "launch",
            "projectDir": "${workspaceRoot}"
        },
        {
            "type": "mix_task",
            "name": "mix test",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}",
            "requireFiles": [
                "test/**/test_helper.exs",
                "test/**/*_test.exs"
            ]
        }
    ]
}
Started ElixirLS Fork debugger v0.3.1
Elixir version: "1.10.2 (compiled with Erlang/OTP 22)"
Erlang version: "22"
** Invalid beam file or no abstract code: 'Elixir.HelloWeb.PageControllerTest'
** Invalid beam file or no abstract code: 'Elixir.HelloWeb.ErrorViewTest'
** Invalid beam file or no abstract code: 'Elixir.HelloWeb.LayoutViewTest'
** Invalid beam file or no abstract code: 'Elixir.HelloWeb.PageViewTest'
(Debugger) Task failed because an exception was raised:
    ** (UndefinedFunctionError) function HelloWeb.PageViewTest.__ex_unit__/0 is undefined (module HelloWeb.PageViewTest is not available)
        HelloWeb.PageViewTest.__ex_unit__()
        (ex_unit 1.10.2) lib/ex_unit/runner.ex:118: ExUnit.Runner.run_module/2

Expected Behaviour

I expect the tests to execute in the same way as in the external terminal.

When I comment out all of the requireFiles, the task runs but I am unable to set breakpoints.

Environment

elixir -v  # Elixir version
# Erlang/OTP 22 [erts-10.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
# Elixir 1.10.2 (compiled with Erlang/OTP 22)

mix phx # Phoenix version
# Phoenix v1.4.16

code -v # Microsoft Visual Studio Code version
# 1.43.0
# 78a4c91400152c0f27ba4d363eb56d2835f9903a
# x64

uname -srvmo # machine information
# Linux 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux
Name: ElixirLS Fork: Elixir support and debugger
Id: elixir-lsp.elixir-ls
Description: Elixir support with debugger, autocomplete, and more. Powered by ElixirLS.
Version: 0.3.1
Publisher: elixir-lsp
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=elixir-lsp.elixir-ls

Set up ElixirLS fork for Visual Studio Marketplace

In an effort to get this project revitalized, I am setting things up for publishing to the marketplace before I start trying to merge in any fixes or features. I want the published extension to be clearly labeled as a fork of Jake's work but I also want to be set up so that, if we end up being viable long term, we don't have code and settings littered with fork for example. Here is what I propose.

  1. We use elixir-lsp (display name Elixir Language Server Protocol) as the publisher. Sticking with this as our org name and publisher name feels like consistent branding that should help users understand where it came from. Alternatively we switch to just ElixirLS (I grabbed the elixir-ls org if needed) since this is the language server not the protocol, but that's not super important.
  2. We use elixir-ls for the package name, making the full package id be elixir-lsp.elixir-ls or elixir-ls.elixir-ls if we dropped the P.
  3. We use something like "ElixirLS Fork: ..." as the display name of the extension, so that anyone who finds us in the marketplace knows right away that this is a fork and isn't misled if they were trying to find Jake's extension.
  4. We ensure that the README as displayed on the extension's entry in the marketplace clearly calls out Jake's great work and the reason for the fork, and points people to Jake's extension if that is what they were looking for.
  5. We use ElixirLS for the langId as opposed to Jake's elixirLS. This is very similar I know, but it is different enough to not squash config people are using from his extension and doesn't require that fork or similar be left in settings for users of this fork.
  6. We use "ElixirLS" and not "ElixirLS Fork" in the UI labels. It seems unlikely that someone will have both extensions installed at the same time so it doesn't feel necessary to call out fork in those labels.

@JakeBecker I'd love to hear your opinion on this if you can spare the time. I don't want to do anything disrespectful to your work and hope to help this thrive for the sake of the community.

Anyone else have an opinion? @axelson? @msaraiva?

Support multiple project folders

I'm fairly new to VSCode, so maybe I'm using it wrong. I have a single project containing multiple microservices in different languages, several in Elixir. I'd eventually like to manage the whole thing in VSCode--launch Skaffold and deploy everything into Minikube, switch between Kotlin and Elixir services in different editor groups, etc.

Unfortunately, I can't see the Mix project directory setting in my workspace configurations.

Again, I'm new to VSCode. Maybe I should be opening each microservice in its own window, and should give up on trying to wrangle the whole thing in a single project. But it did work fine until we added another Elixir project, so I'm wondering how painful it'd be to run several separate language server instances and let me configure the Mix project directory per workspace. May take up more RAM, but that's wy I have 32 GB. :)

Or maybe workspaces are the wrong fix? Can I add .vscode/ directories in each subdirectory containing an Elixir project, then opening a file in one of those directories will automatically run the language server with the correct context, even if my project is still in a single tabbed window?

Thanks.

Unable to run extension in development mode

Environment

  • VSCode ElixirLS Fork version: master@93da0f9203be0efdbc486e38a9c02a99cbb95939

Troubleshooting

It seems that recent repo changes broke something. This is the output from Developer Tools console

Warning: jakebecker.elixir-ls is not compatible with ElixirLS Fork, please uninstall jakebecker.elixir-ls
Activating extension 'JakeBecker.elixir-ls' failed: command 'extension.copyDebugInfo' already exists.
ERR No application in the Launch Services database matches the input criteria.: Error: No application in the Launch Services database matches the input criteria.

Make Eex Language IDs compliant with guidelines?

The language identifier guidelines state that language ids should be lowercase and contain no spaces.
https://code.visualstudio.com/docs/languages/identifiers#_new-identifier-guidelines

This causes issues with displaying icons for .html.eex files as noted here:
vscode-icons/vscode-icons#1414 (comment)

This was requested and implemented in a Pull Request on the vscode-elixir project.
timmhirsens/vscode-elixir#114 corrects the issue but was never merged.

The largest impact of this change is that other extensions that rely on the current identifier would have to be changed for support to continue.

Was there a larger reason this change hasn't occurred? The icon issue definitely persists.

Improve elixir grammar: function calls without parenthesis

As a follow up on #22: This new issue is meant to track progress on expanding the entity.name.function-call.elixir scope added on #40 to function calls without parenthesis.
As exemplified here, while we can't disambiguate calls for niladic functions, we probably could do it for functions that have at least one parameter.

Example: The current behavior for greet/1 is that greet("Hello") will be scoped to entity.name.function-call.elixir while greet "Hello" will be scoped to source.elixir.

Moving people over to the new extension

Thank you very much for the efforts! This tool improves my life greatly.

One thing I am wondering is whether it would be a good idea to start redirecting people who post on https://github.com/JakeBecker/vscode-elixir-ls over here. The current install count for VS Code is just under 73k whereas this most excellent fork is still under 4k.

Would it be valuable to you if I keep an eye on said repo and respond to new messages with a note directing them over here? I am thinking of something like the below:


Hello!

I am not a maintainer of this project but would like to let you know that this repository has been inactive since May 2019. There is a fork that is being actively developed by community members, and I recommend you switch over!

The GitHub repository is here:
https://github.com/elixir-lsp/vscode-elixir-ls

And the Visual Studio Code extension is here:
https://marketplace.visualstudio.com/items?itemName=elixir-lsp.elixir-ls

If you are having any issues or would like to open any pull requests, please try the new extension or clone the new repository first. You may find that the problem is already resolved 🙂

Thank you and happy Elixiring.


Would this be helpful? Any edits?

Make use of ASDF managed OTP versions

As the LS needs to be compiled with the appropriate version of erlang, try to pick and precompile proper LS version depending on the erlang configured in .tool-versions or whatever asdf tells us its using.

Conflict with Code Spell Checker

There is an conflict with Code Spell Checker extension, (and maybe with other spell checkers as well).

When I have both extension installed, there is no grammar check in .ex and .exs files. I know the problem is caused by VSCode Elixir LS extension. Because when I disable it, I loose syntax highlight etc, but spell checker mark typos.

And big thank you for keeping this package alive!

Improve elixir grammar: module prefixes

As a follow up on #22: This new issue is meant to track progress on adding a specific scope for "namespaces" to the Elixir grammar.

As previously discussed in the original issue, Elixir does not have namespaces as a builtin language construct, even though part of the module name it acts like it conceptually by convention. So, the objective is to provide an optional configuration to support further customization while keeping the current behavior as a fallback (if the configuration is not specified).

As @axelson suggested here, a better name could be "module prefixes", which captures the essence of the scope without compromising semantics about the language specification.

Notice that this should work for both module definitions and calls. It should also work for aliases, imports and requires.

Support EEx tags inside HTML attributes

Hello,

I'm using VS Code 1.43.2 and ElixirLS Fork 0.3.2.

Somehow, I can't get EEx tags to highlight correctly inside HTML attributes, as the entire quoted attribute highlights as a single string.

Example:
<div id="user_<%= @id %>">

In the above example, "user_<%= @id %>" highlights as a string. Ideally, <%= @id %> would highlight in the usual EEx tag format inside the string highlighting.

The issue is illustrated nicely with two pictures in this pull request for the original ElixirLS: https://github.com/JakeBecker/vscode-elixir-ls/pull/121). Not sure why it's not working for me, maybe it didn't make it into the published extension (I don't know much about how VS Code extensions work)?

Thank you for any help on this and all the work on this really useful extension!

Doesn't work with VS Code Remote Dev Container

Hello,

I'm not sure if it's the right repo (vs elixir-lsp/elixir-ls) but since it's related to VS Code (with its Remote Dev Container features) I'm asking here.

Simply put, nothing happen with this extension when it's installed on the Remote Dev Container (and that the container is up and running etc.)

To contrast, if I disable (or uninstall) this extension on the container and use back the original one from jakebecker/elixir-ls), everything work out of the box.

Does this extension need something particular to set up and that I'm missing?

For example, the default installation folder when installed on a Dev Container is
~/.vscode-server/extensions rather than ~/.vscode/extensions. Could it be a problem with an harcoded path?

I have VS Code 1.43.2, Elixir 1.10, and this extension as 0.3.2

Support debug with user defined node full name

As described in issue here JakeBecker/vscode-elixir-ls#97 one would like to debug erlang/elixir node that is part of some cluster. I suggested to respect ERL OPTIONS env variable so it can be injected on application start.

Here is launch config I suggested

{
      "type": "mix_task",
      "name": "mix phx.server",
      "request": "launch",
      "projectDir": "${workspaceRoot}",
      "task": "phx.server",
      "startApps": true,
      "env":{
        "ELIXIR_ERL_OPTIONS": "-name [email protected]"
      }
}

At the moment, LS will never connect to node since this VS Code plugin will generate node name anyways and pass it to LS, and above would only make confusion. Probably it is the best way to be explicit in launch confing with dedicated attribute for sname or name flag for instance

{
     "type": "mix_task",
     "name": "mix phx.server",
     "request": "launch",
     "projectDir": "${workspaceRoot}",
     "task": "phx.server",
     "startApps": true,
     "nodeName": "[email protected]"
}

EDIT:

For the sake of the safety if node should connect to prod cluster, there can be also flag for "hidden" and nodeCookie, in case one would like to run hidden node in the cluster with all code up but don't want that node to participate in cluster workload.

{
     "type": "mix_task",
     "name": "mix phx.server",
     "request": "launch",
     "projectDir": "${workspaceRoot}",
     "task": "phx.server",
     "startApps": true,
     "erlOpts": {
           "name": "[email protected]",
           "cookie": "dskajhd98asd9ohasdh98hsad9",
           "hidden": true
     }
}

the list could go on :) for any erl flag

"Go to definition" not working

My system config,

Ubuntu - 18.04
VS Code - 1.43.0
Elixir 1.9.2

I've the docker elixir project and I'm using "bitwalker/alpine-elixir:1.9.2" image.

When I click F12. It's only showing "No definition found". It's not working. When I try Ctrl + Shift + F, I can able to find the function.

Improve elixir grammar

Hi! I was wondering if you have plans to improve the current elixir grammar.

I'm asking because I was recently extending some elixir color schemes and noticed that some tokens are missing or don't have a distinction from others. For instance, both key: (parameter) and :key (atom) are defined as source.elixir > constant.other.symbol.elixir which prevents me from highlighting only atoms.

I was looking for solutions and saw that the ruby extension has a little bit more definitions:
https://github.com/rubyide/vscode-ruby/blob/master/packages/vscode-ruby/syntaxes/ruby.cson.json (if you search the page for "hashkey" you'll see some good examples).

Formatter hangs on VSCode 1.42.0

I get this everytime I try to save an Elixir file:

Running Save Participants for 'test/users/notifications/mailer/some_mailer_test.exs': Formatting

It doesn't even save the file until i Cancel the message above. Once I cancelled it, it also formats the file. However, it's a really annoying behaviour.

It works fine if you downgrade VSCode to 1.41 or less.

Am I the only one with this problem on VSCode 1.42.0 ?

I've seen there are other Extensions with this problem, here's a PR from another project that explains and fixes it: zxh0/vscode-proto3#73

Parentheses get inserted incorrectly on save when strings have emoji

Environment

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.10.3 (compiled with Erlang/OTP 21)

  • VSCode ElixirLS Fork version: 0.3.2
  • Operating System Version: linux 5.4.0-7626-generic

Troubleshooting

  • Restart your editor (which will restart ElixirLS) sometimes fixes issues
  • Stop your editor, remove the entire .elixir_ls directory, then restart your editor
    • NOTE: This will cause you to have to re-run the entire dialyzer build

If you have the following code:

IO.puts "🎧"

On save this gets formatted to:

IO.puts("🎧)"

But running mix format path/to/file.ex gives you:

IO.puts("🎧")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.