Helix way of doing things
In this post we are going to take a look at how a Neovim user can easily transition to Helix by ignoring the plugins and how to achieve the same functionality without plugins in Helix.
Package manager
In Neovim, usually people on a majority of the time use a package manager like packer or lazy.nvim to install plugins for extending Neovim functionalities.
In Helix you don't need a package manager, because there are no plugins.
Let's us take a look at each capability that are obtained by Neovim plugins and how Helix offers them without any plugins.
LSP config
LSP facilitates features like go-to-definition, find-references, hover, completion, rename, format, refactor, etc., using semantic whole-project analysis (unlike ctags).
Plugins:
In Helix, you configure everything related to LSP in a config file called languages.toml
Helix supports a large number of languages and Language Servers. To use Language Server features, you must first install the appropriate Language Server.
You can check the language support in your installed helix version with hx --health
.
You can also take a look at the Language Configuration docs and the Adding Languages guide for more language configuration information.
toml
[[language]]
name = "mylang"
scope = "source.mylang"
injection-regex = "mylang"
file-types = ["mylang", "myl"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
language-server = { command = "mylang-lsp", args = ["--stdio"], environment = { "ENV1" = "value1", "ENV2" = "value2" } }
formatter = { command = "mylang-formatter" , args = ["--stdin"] }
Autocompletion
Autocomplete of source code is also known as code completion. In a source code editor, autocomplete is greatly simplified by the regular structure of the programming language. There are usually only a limited number of words meaningful in the current context or namespace, such as names of variables and functions.
It involves showing a pop-up list of possible completions for the current input prefix to allow the user to choose the right one. This is particularly useful in object-oriented programming because often the programmer will not know exactly what members a particular class has. Therefore, autocomplete then serves as a form of convenient documentation as well as an input method.
In Neovim you achieve the autocompletion functionality using the following list of plugins. It contains both completion engines and snippets.
Plugins:
- nvim-cmp
- cmp-nvim-lsp
- LuaSnip
- friendly-snippets
- cmp_luasnip
In Helix, the autocompletion is automatically provided by the configured LSP servers. You don't have to any specific autocomplete related configuration, it is enabled by default. As soon as you installed your respective language servers inside your machine, Helix identifies them and use them as source of completion.
Highlight, edit and navigate code
Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms.
Plugins:
- nvim-treesitter
- nvim-treesitter-textobjects
In Helix, treesitter comes prefconfigured with your LSP servers.
Navigating using tree-sitter textobjects
Helix comes with a mode called Unimpaired, which gives us a set of bindings on [
and ]
to jump to the prior and next of a textobject. This is made more powerful by tree-sitter driven textobjects.
Navigating between functions, classes, parameters, and other elements is possible using tree-sitter and textobject queries. For example to move to the next function use ]f
, to move to previous class use [c
, and so on.
Say, for example, if you want to know the Treesitter support for TSX
files, you can check your treesitter support with something like:
hx --health tsx
Buffer line
Buffer line displays the list of currently opened buffers with their status, whether they are modified, pending changes to be saved or similar, at the top of your editor.
In Neovim, we have awesome plugins like barbar.nvim and bufferline to achieve this.
In Helix you can enable bufferlines automatically with a simple config. You can tell Helix when to enable/show the bufferline with the values:
- always => Always show the bufferline
- multiple => Show only when there is more than one buffer
- never => Never show the bufferline (default)
[editor]
bufferline = "always|multiple|never"
The bufferline in Helix may not be as advanced or sophisticated like Neovim plugins, but it does the job.
Themes
Though Neovim comes with some default themes, they are not that good and attractive. So by default a lot of developers would like to install themes via external plugins. I personally like the Dracula theme a lot and there is a Neovim plugin for the same.
Helix by default comes up with a lot of predefined themes, you can choose them whenever you want using the :theme
command or you can configure a permanently in the config.toml
theme = "onedark"
Status line plugins
The statusline is intended to give you information about the status of a buffer with the default statusline including the path, permissions, line and a percentage representation of where you are in the file.
In Neovim I was using the lualine.nvim plugin for configuring the statusline.
In Helix you can configure your status line using the editor.statusline
setting
[editor.statusline]
left = ["mode", "spinner"]
center = ["file-name"]
right = ["version-control", "diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
separator = "│"
mode.normal = "NORMAL"
mode.insert = "INSERT"
mode.select = "SELECT"
Normal mode statusline
Insert mode statusline
Select (Visual) mode statusline
Indentation guides
One of the most helpful things in a code editor is visualizing the indent levels. This can be a very useful tweak when dealing with an indentation-based language like YAML or Python.
In Neovim, we have plugins to display vertical indicators for every indentation level in deeply nested code like indent-blankline.nvim
Helix comes with a default configuration for indent-guides. You can turn on them and customize the indent line characters.
[editor.indent-guides]
render = true
character = "╎" # Some characters that work well: "▏", "┆", "┊", "⸽"
skip-levels = 1
Commenting
For enhanced commenting in Neovim, I was using a plugin Comment.nvim
You can comment any code in Helix using the Ctrl-c
key binding
Fuzzy finder
In Neovim, telescope.nvim is a highly extendable fuzzy finder over lists. Built on the latest awesome features from neovim core. Telescope is centered around modularity, allowing for easy customization.
I was also using other related Plugins like plenary.nvim and telescope-fzf-native.nvim
In Helix, you already have a fuzzy-finder which can be opened with Space+f
or Space+F
key bindings
Which key
WhichKey is a lua plugin for Neovim that displays a popup with possible key bindings of the command you started typing. Heavily inspired by the original emacs-which-key and vim-which-key.
Helix by default opens a popup which shows the possible key bindings when you press a key. Say for example, when you press the Space
key, you will get this popup showing the different commands you can do with the Space key prefix.
Surround
The original vim-surround is a plugin which helps you to add/change/delete surrounding delimiter pairs with ease. It is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs.
For Neovim we have something called nvim-surround
Helix comes with a Surround/match mode, a flexible way to manipulate braces, quotes and other pairings around your selections bound to m
, made even more powerful as it includes the ability to expand selections by tree-sitter driven textobjects
.
Helix includes built-in functionality similar to vim-surround. The key mappings have been inspired from vim-sandwich. You can know more about it in the surround usage section in the official docs.
Hope you enjoyed this post and it will help you to make the transition from Neovim to Helix. Even if you are not 100% convinced, I highly recommend you to just try Helix once to understand and appreciate the principles and philosophy behind Helix.
Top comments (4)
Absolutely fantastic article for someone who just moved from nvim to helix and can't stand reading kinda dry documentation. This article gets to the point of what we actually want to know, which is how do we keep doing in helix what we already used to do in nvim. 👏
Thank you ☺️👌
What about plug-ins for AI-powered coding assistants?
That's actually a good problem to solve, I think given Helix's conventions it would be best if the core team bring support for this one way or other, there is already a discussion going on here github.com/helix-editor/helix/issu...