The Helix way
Tags: productivity, helix, editors, neovim
Published: 2023-07-15 04:08:52

# 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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pd94yjxcrzra8vw0os4c.jpg)

## 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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pm3qgn5nt3nxr9zrvs62.jpg)

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](https://microsoft.github.io/language-server-protocol/) facilitates features like go-to-definition, find-references, hover, completion, rename, format, refactor, etc., using semantic whole-project analysis (unlike ctags).

Plugins:
- [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
- [mason.nvim](https://github.com/williamboman/mason.nvim)
- [mason-lspconfig.nvim](https://github.com/williamboman/mason-lspconfig.nvim)
- [neodev.nvim](https://github.com/folke/neodev.nvim)

In Helix, you configure everything related to LSP in a config file called `languages.toml`

Helix [supports](https://docs.helix-editor.com/lang-support.html) 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`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8b6qh2fo5tafohq9wehw.png)

You can also take a look at the [Language Configuration docs](https://docs.helix-editor.com/languages.html) and the [Adding Languages guide](https://docs.helix-editor.com/guides/adding_languages.html) 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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1xcz5q4lv8j8oq1r79j.png)

### 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.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9y0tsu4y4vclgy6ifcp.png)

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.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ei7w4dbsatzukohscm7b.png)

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
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/br1szwczl3d6nr5mdlcl.png)


## 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](https://github.com/romgrk/barbar.nvim) and [bufferline](https://github.com/akinsho/bufferline.nvim) 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)

```toml
[editor]
bufferline = "always|multiple|never"
```

The bufferline in Helix may not be as advanced or sophisticated like Neovim plugins, but it does the job.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lweu94bk950zhhbj50g.png)

## 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](https://github.com/Mofiqul/dracula.nvim) 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

```toml
theme = "onedark"
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj1cq97lbni89rltuwko.png)

## 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](https://github.com/nvim-lualine/lualine.nvim) plugin for configuring the statusline.

In Helix you can configure your status line using the `editor.statusline` setting


```toml
[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
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6llexe7p06y9nc3tyg6.png)

### Insert mode statusline

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2c4l1j4o9gm9bq9lhzm.png)

### Select (Visual) mode statusline

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cj345d5jeygnnzlgal19.png)

## 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](https://github.com/lukas-reineke/indent-blankline.nvim)

Helix comes with a default configuration for indent-guides. You can turn on them and customize the indent line characters.


```toml
[editor.indent-guides]
render = true
character = "╎" # Some characters that work well: "▏", "┆", "┊", "⸽"
skip-levels = 1
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/arzzp9fy104igowj1ot1.png)

## Commenting
For enhanced commenting in Neovim, I was using a plugin [Comment.nvim](https://github.com/numToStr/Comment.nvim) 

You can comment any code in Helix using the `Ctrl-c` key binding

## Fuzzy finder
In Neovim, [telescope.nvim](https://github.com/nvim-telescope/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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7yliqrhygulou6b8wotw.png)

## Which key
[WhichKey](https://github.com/folke/which-key.nvim) 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](https://github.com/justbur/emacs-which-key) and [vim-which-key](https://github.com/liuchengxu/vim-which-key).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6ve2gsovjtek4ychgtb.png)

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](https://github.com/tpope/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](https://github.com/kylechui/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](https://github.com/machakann/vim-sandwich). You can know more about it in the [surround usage](https://docs.helix-editor.com/usage.html#surround) section in the official docs.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnj460gsg757fs6db1of.png)


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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2d4aq99s00dwj75a0s4.jpg)

## References
- [Autocomplete](https://en.wikipedia.org/wiki/Autocomplete)
- [Syntax Highlighting](https://en.wikipedia.org/wiki/Syntax_highlighting)
- [Build your own Vim statusline](https://shapeshed.com/vim-statuslines/)