Adding crates.io version check to Helix editor

Adding crates.io version check to Helix editor

TLDR version

  1. Install crates-lsp language server
    1
    2
    cargo install --git https://github.com/MathiasPius/crates-lsp.git --rev 53fb3b8d58c43ea799fdbc1fd28fa5db3f01b01a
    # ensure that ~/.cargo/bin is in $PATH
  2. Add language definition to your helix languages file at ~/.config/helix/languages.toml (create if not there)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [[language]]
    name = "crates"
    scope = "source.toml"
    injection-regex = "toml"
    file-types = [{ glob = "Cargo.toml" }]
    comment-token = "#"
    language-servers = [ "crates-lsp" ]
    grammar = "toml"
    indent = { tab-width = 2, unit = " " }
    diagnostic-severity = "info"

    [language-server.crates-lsp]
    command = "crates-lsp"
  3. Copy runtime/queries/toml to your config folder as queries
    1
    2
    3
    helix --health # find out where your runtime directory and config directories are
    mkdir -p ~/.config/helix/runtime/queries # create the subfolder, substitute path to yours
    cp -r /usr/lib/helix/runtime/queries/toml ~/.config/helix/runtime/queries/crates # copy the queries definition, substitute paths to yours

Why the queries copy?

It seems that at this time, language definitions are not able to point to other queries (formatting setups). Copying the runtime/queries subfolder is the easiest solution, thanks djo_kirawi at #helix.

Coming from VSCode

I’ve been a VSCode user for ages. Vim has always both fascinated and scared me, but I was never able to make the jump. I think similar to many others I’ve found the plugins and configuration just too much work to get me where I’d like my editor to be.

I found out about helix two weeks ago and really liked it. The select-action model resonated with me much better, since I already used it in my texel ascii art editor although I didn’t realize at the time that it has a name, or truly that it was even different from vim’s model.

Most things in helix just worked for me but the one major missing ingedient was seeing dependency version in Cargo.toml files. As it turns out, it was much easier to add than I expected :)