The elixir-tools Update Vol. 6
Welcome to the 6th volume of the elixir-tools Update!
It's been over 4 months since the last update, and a ton has happened, let's dive right in!
New team member!
I'd like to formally announce the first (non-me) member of the elixir-tools tools team, Nikola Jichev!
Nikola has demonstrated a level of tenacity in his open source contributions that I haven't personally seen before.
He has been blazing the trail for the feature set of code actions and workspace commands, both of which were new in the codebase, and took a bit of time to get right. Nikola perseveres and never cut corners.
I am proud to have him join as a member of the core team! Thank you Nikola!
New Sponsors!
I now have an incredible 44 sponsors! It would really be a dream to hit 100, so I've set that as my GitHub Sponsors goal. Let's see what the next year will bring 😄.
In particular, José Valim (the creator of Elixir) has joined as a sponsor through his company Dashbit, which is a major milestone for the project, thank you José!
If you'd like to see your name or company's logo appear on the website and README, be sure to sponsor!
Next LS
- 20,790 total downloads
- 2,332 from hex.pm (it switched to GitHub downloads at v0.8)
- 18,458 from GitHub releases
- 2,021 downloads of the latest release (v0.20.2)
- 66 releases
- 25 contributors
Latest Features
Since v0.15.0 (the latest version as of the Vol. 5 update), Next LS has gained a lot of amazing features.
Major improvements to autocomplete
Previously, Next LS only had minimal support for autocompletion, mainly: global modules, global structs, struct fields, remote functions (w/ documentation), special forms, bitstring modifiers, and filesystem paths in strings.
These were mostly cribbed from the implementation of IEx, but was missing a lot of context aware information. This is tricky, as it is typical for the document to be incomplete or contain errors while you are actively typing code.
Since then, two milestones have been met:
-
I have completed the Spitfire parser that I announced during the last update. Spitfire is a handwritten recursive descent parser that is resilient to errors. This means that it can parse Elixir code that contains errors, "autocorrecting" syntax error and then continue parsing. This is very important to enable IDE functionality.
-
José has implemented a handful of new APIs and compiler changes that allow us to create a "mini compiler". This mostly means that we can effectively expand macros and collect environment information like imports and aliases.
Combining these two means that autocomplete now completes 99% of what you would naively expect it to, including functions imported and aliased by import
and alias
, and any of those that are done within use
macros.
This is an amazing achievement, but there is still a bit of stabilizing that must be done and improvements to be made, so completions will still be opt-in behind a setting, but I encourage everyone to try!
Bundling the latest version of Elixir
In order to use these new APIs and compiler improvements, if you opt into completions, Next LS will use a bundled archive of Elixir v1.17 instead of the version found on your PATH
. Once completions stabilize, Next LS will always use the bundled Elixir.
This is certainly a trade-off. In exchange for getting access to the latest compiler features, you might see compiler warnings that you won't see when you run mix compile
in the terminal.
I believe this is a reasonable trade-off, but you can also now explicitly set the Elixir bin path used by Next LS, so if this is not acceptable, you can set it to a version manager shim or an absolute path to your locally installed Elixir, you just wont get access to the latest compiler features.
Snippets
Next LS also ships with snippets for many common Kernel
, SpecialForm
, and ExUnit
functions.
In the future, extensions will be able to provide snippets, so libraries will be able to define custom snippets for their functions.
Commands and Code Actions
We now have support for a several different commands and code actions:
Code Actions
Code actions are commands you can run, usually in response to a compiler diagnostic or some contextual information about the code.
We currently have support for:
-
While building this, Nikola and I contributed bug fixes to Credo to make this code action easier to implement
Commands
Commands are custom actions defined by Next LS that can usually be invoked by your editors command palette or through a keybind.
We currently have support for:
Convenience enhancements
When the compiler detects that your dependencies have changed (perhaps from switching branches), it will display a "yes/no" prompt. Upon selecting yes, it will run mix deps.get
and restart the project runtime.
This is beneficial so that you don't have to restart your editor when your mix.lock
changes.
Spitfire
Now that Spitfire is functional, you can enable Spitfire in your editor settings so that any feature that relies on AST, it will be parsed with Spitfire.parse
rather than Code.string_to_quoted
. This enables features like document symbols to still work even when your code has a syntax error.
Improvements to Elixir core
During my work on Spitfire, I helped identify and/or fix several bugs in the compiler, along with participate in the discussion for the new Macro.Env
functions that power the new completions engine.
- Column info in Module.get_definition/2 #13029
- Macro.to_string creates invalid/incorrect code #13248
- :end_of_expression metadata exists on expression outside of a block #13355
- No end of expression on grouped stab #13358
- formatter incorrectly transitions single quote charlists to sigil_c #13363
- include from_brackets metadata in all cases #13317
- Improved Macro and Macro.Env functions for language servers #13361
A goal for Next LS is to help push forward the language if we can, even reporting minor bugs or tiny feature requests can make a big difference.
Tableau
Tableau now has a mix tableau.new
task that you can use to bootstrap a brand new website.
It currently has options for using HEEx, EEx, Temple, TailwindCSS, and Vanilla stylesheets.
If you've made a website with Tableau, be sure to add it to the catalog in the README!
Community
Discord
The discord server keeps growing!
We currently have 207 members and are getting more every day, come join the party!
Thank you
I'd like to give a huge shout out to all of the contributors, bug reporters, and to all of my GitHub sponsors! Without the support of all of you, none of this would be possible.
How to get involved
If you'd like to get involved with elixir-tools, there are several ways:
- Contribute to the project via code on GitHub
- Contribute to the community via Discord or GitHub
- Contribute financially via GitHub Sponsors