I recently discovered the text editor Helix, a relatively new project written in Rust. Many features, like Tree-sitter integration or support for the Language Server Protocol LSP are available by default without any plugins and laborious configuration. This short note shows how to integrate Helix with the template tool Tp-Note and the grammar checker LanguageTool.

Helix syntax highlighting with Tree-Sitter

Installation and configuration

Tp-Note

Download a recent version of Tp-Note and follow the Tp-Note's installation instructions.

Tp-Note needs to know how to start your favourite terminal emulator in a way that it invokes Helix at startup. For configuration follow the instructions in Tp-Note's manual page. A typical configuration example that starts Helix within the XFCE4 terminal emulator could look like this:

editor = [
  [
    'xfce4-terminal',
    '--disable-server',
    '-x',
    'hx',
  ],
]

LanguageTool

As LanguageTool has no direct support the Language Server Protocol LSP, we need a protocol converter. The proxy software LTeX ships with a LanguageTool standalone version and exposes the LSP protocol. Follow the installation instructions for LTeX-LS.

Helix

Helix has built-in support for the LSP protocol. In order to tell Helix the path to the above LTeX-LS installation, we create the additional configuration file /home/<username>/.config/helix/languages.toml with the following content:

[[language]]
name = "markdown"
language-server = { command = "/opt/ltex-ls/bin/ltex-ls" }
file-types = ["md", "txt"]
scope = "source.markdown"
roots = []

Hereby indicates the expression command =/opt/ltex-ls/bin/ltex-ls the path to the shell script ltex-ls which is part of the LTeX-LS installation. Change this to path to the location where you unpacked LTeX-LS.

Usage

Create a new note by invoking Tp-Note (more examples here):

mkdir "Build a Crypto Currency"
cd "Build a Crypto Currency"
tpnote

Tp-Note opens the Helix editor which starts for its part the LanguageTool grammar checker. Note, that the grammar checker reads the header variable lang: indicating the language of the current note. If Tp-Note's suggestion derived from the user's default language does not fit, it can be overwritten in the note's YAML header.

Hover the cursor over the word “However” to see what is wrong:

A comma may be missing ...

Type [space], [a] to see the suggested corrections:

Navigate with Ctrl-n and commit your choice with Enter:

Extra

No additional plugins or any further configuration is needed so far. Everything should work out of the box.

However, for completeness you will find below my Helix configuration file ~/.config/helix/config.toml.

theme = "autumn"

[editor]
true-color = true
color-modes = true

[editor.statusline]
left = ["mode", "spinner", "diagnostics"]
center = ["file-name"]
right = ["selections", "position", "file-encoding", "file-type"]

[keys.insert]
j = { k = "normal_mode" } # Maps `jk` to exit insert mode
# Move cursor in insert mode
A-h = "move_char_left"
A-j = "move_line_down"
A-k = "move_line_up"
A-l = "move_char_right"
up =    "move_line_up"
down =  "move_line_down"
left =  "move_char_left"
right = "move_char_right"

[keys.normal]
C-j = "jump_backward" # Additional key: Midnight Commander captures `C-o`

Read more about Tp-Note

A good start is Tp-Note's project page or the introductory video. The source code is available on GitHub - getreu/tp-note and some binaries and packages for Linux, Windows and Mac can be found here. To fully profit of Tp-note, I recommend reading Tp-Note's user manual. If you like Tp-Note, you probably soon want to customize it. How to do so, is explained in Tp-Note's manual page.