# Helix editor with multiple lsp's for one language

The helix editor is in its early days. It's <s>quite</s> insanely cool as it stands, and even cooler if you choose which branch to run yourself.

> Warning! This is a typical blog post of mine... **"lest I forget, do these steps and you'll be fine!"**

I did this on [fedora37 in a toolbox](https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/). You don't have to.

The goal is to get **pyright** *and* **ruff** running for python in Helix.

### Srsly!

Start by reading the [Helix Editor install](https://docs.helix-editor.com/install.html) page. Seriously.

Move on to install things you might or might not be missing. Chances are if you start from a toolbox you'll be missing a lot.

```bash
# Install nvm, node, pyright, tree-sitter, rust, cargo, dev tools..
me@toolbox ~ dnf groupinstall "Development Tools"
me@toolbox ~ dnf install gcc-c++
me@toolbox ~ dnf install rust cargo
me@toolbox ~ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
me@toolbox ~ nvm install v16.19.1
me@toolbox ~ node install pyright tree-sitter tree-sitter-cli
```

All this happens in a toolbox. Read about it [here](https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/).

### There is one particular Helix branch that I'm interested in.

> Hopefully, these instructions will be obsolete very, very soon.
> 
> Read all about it [here](https://github.com/helix-editor/helix/pull/2507)

```bash
me@toolbox ~ git clone git@github.com:Philipp-M/helix.git
me@toolbox ~ cd helix
me@toolbox ~ git checkout remotes/origin/multiple-language-servers-with-options-manager
me@toolbox ~ cargo install --locked --path helix-term
me@toolbox ~ ln -s $PWD/runtime ~/.config/helix/runtime
```

The above is explained on the [Helix Editor install](https://docs.helix-editor.com/install.html) page.

The final step is to create *~/.config/helix/config.toml* and *~/.config/helix/languages.toml*

```yaml
# ~/.config/helix/config.toml
# This is an example which happens to be how I have helix right now
theme = "base16_transparent"

[editor]
line-number = "relative"
scroll-lines = 1
scrolloff = 8
true-color = true

[editor.cursor-shape]
insert = "bar"

[editor.lsp]
display-messages = true

[editor.statusline]
left = ["mode", "spinner", "file-name"]
center = []
mode.normal = "NORMAL"
mode.insert = "INSERT"
mode.select = "SELECT"
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
separator = "│"

[editor.indent-guides]
render = true
character = "|"
```

And the language file.

```yaml
[language-server.pyright]
command = "pyright-langserver"
args = ["--stdio"]

[language-server.pyright.config]
lint = true
inlayHint.enable = true

[language-server.ruff-lsp]
command = "ruff-lsp"
[[language]]
name = "python"
scope ="source.python"
auto-format = true
indent = { tab-width = 4, unit = " " }
formatter = { command = "black", args = ["-", "-q"] }
roots = ["pyproject.toml", "pyrightconfig.json", "Poetry.lock"]
language-servers = [
    { name = "pyright" },
    { name = "ruff-lsp" },
]
```

Is the language.toml config 100% correct? I don't think so. It works - so there's that, but this is hardly an authoritative source on how to configure **pyright** and **ruff**.

I've found it easiest to just add **ruff-lsp** to my *pyproject.toml* file and use Helix when in the virtual env.

To make the most of ruff, add this section in your *pyproject.toml* file

```yaml
[tool.ruff]
extend-select = ["A", "B", "C4", "D", "I", "ERA", "PLR", "SIM", "TCH", "ANN"]
show-fixes = true
line-length=119
```

Learn about what it all means [here](https://beta.ruff.rs/docs/)

### ...at last

..we have arrived at the objective of this blog post. Running two **lsp** servers in helix. This feature is currently unavailable in release 22.12, hence the usage of the **multiple-language-servers-with-options-manager** branch.

There's one more thing I'd like to have as well, namely **inlayHints** [https://github.com/helix-editor/helix/pull/5934](https://github.com/helix-editor/helix/pull/5934)

I have absolutely no idea how, [or if it's even possible, to merge two repos..(turns out it is).](https://gist.github.com/msrose/2feacb303035d11d2d05) I'm hoping for these patches to make it into the next helix release. Until then - I'm happy with having two lsp's.
