Jump to content

Helix: Difference between revisions

From Official NixOS Wiki
Add information about steelix
m "Setup", nixfmt-rfc-style is now just nixfmt
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
[https://helix-editor.com/ Helix] is a modal text-editor inspired by [[Neovim]] and [[Kakoune]], written in Rust. Compared to neovim, it is preconfigured with the functions that most people need (for example tree-sitter for syntax highlighting). It uses (neo-)vim motions keybindings, but it uses the object-verb approach (visually highlighting text and then executing a function on it). It is intended for people who like to use a modal text editor but don't want to spend a lot of time configuring it.
[https://helix-editor.com/ Helix] is a modal text-editor inspired by [[Neovim]] and [[Kakoune]], written in Rust. Compared to neovim, it is preconfigured with the functions that most people need (for example tree-sitter for syntax highlighting). It uses (neo-)vim motions keybindings, but it uses the object-verb approach (visually highlighting text and then executing a function on it). It is intended for people who like to use a modal text editor but don't want to spend a lot of time configuring it.


There is an open and actively worked on [https://github.com/helix-editor/helix/pull/8675 PR] to add [https://helix-plugins.com/ plugins], which can be tested by using the <code>steelix</code> package [https://search.nixos.org/packages?channel=unstable&query=steelix from nixpkgs-unstable].
== Setup ==
 
== Installation ==
Helix can be installed system-wide on NixOS with the <code>helix</code> package:
Helix can be installed system-wide on NixOS with the <code>helix</code> package:
<syntaxhighlight lang=nix>
<syntaxhighlight lang=nix>
Line 24: Line 22:
     name = "nix";
     name = "nix";
     auto-format = true;
     auto-format = true;
     formatter.command = lib.getExe pkgs.nixfmt-rfc-style;
     formatter.command = lib.getExe pkgs.nixfmt;
   }];
   }];
   themes = {
   themes = {
Line 33: Line 31:
   };
   };
};
};
</syntaxhighlight>
</syntaxhighlight>The full configuration options are described on the [https://docs.helix-editor.com/ Helix documentation]. For programming languages (LSP, formatter, ..) see the [https://github.com/helix-editor/helix/wiki/Language-Server-Configurations Helix wiki].


== Configuration ==
== Configuration ==
The configuration is stored in two files: <code>~/.config/helix/config.toml</code> and <code>~/.config/helix/language.toml</code>.


* The full configuration options are described on the [https://docs.helix-editor.com/ Helix documentation].
=== Language server ===
* For programming languages (LSP, formatter, ..) see the [https://github.com/helix-editor/helix/wiki/Language-Server-Configurations Helix wiki].
For further auto-completion features and syntax evaluation, a language server such <code>nixd</code> can be configured using Home-Manager.<syntaxhighlight lang="nix">
programs.helix = {
  enable = true;
  [...]
  languages = {
    language-server = {
      nixd = {
        command = "${lib.getExe pkgs.nixd}";
        args = [ "--semantic-tokens=true" ];
        config.nixd =
          let
            nixosConfiguration = "mynixos";
            flakeRef = "(builtins.getFlake (toString /etc/nixos/.))";
            nixosOpts = "${flakeRef}.nixosConfigurations.${nixosConfiguration}.options";
          in
          {
            nixpkgs.expr = "${flakeRef}.inputs.nixpkgs";
            options = {
              nixos.expr = nixosOpts;
              home-manager.expr = "${nixosOpts}.home-manager.users.type.getSubOptions []";
            };
          };
      };
    };
  };
};
</syntaxhighlight>Adapt <code>nixosConfiguration</code> variable, file path to your flake.nix in <code>flakeRef</code> and the list of expression paths in the <code>options</code> attribute set, according to your system and your needs.
 
== Tips and tricks ==


=== Plugins ===
There is an open and actively worked on [https://github.com/helix-editor/helix/pull/8675 PR] to add [https://helix-plugins.com/ plugins], which can be tested by using the <code>steelix</code> package [https://search.nixos.org/packages?channel=unstable&query=steelix from nixpkgs-unstable].
[[Category:Applications]]
[[Category:Applications]]
[[Category:CLI Applications]]
[[Category:CLI Applications]]
[[Category:Text Editor]]
[[Category:Text Editor]]

Latest revision as of 20:26, 8 September 2026

Helix is a modal text-editor inspired by Neovim and Kakoune, written in Rust. Compared to neovim, it is preconfigured with the functions that most people need (for example tree-sitter for syntax highlighting). It uses (neo-)vim motions keybindings, but it uses the object-verb approach (visually highlighting text and then executing a function on it). It is intended for people who like to use a modal text editor but don't want to spend a lot of time configuring it.

Setup

Helix can be installed system-wide on NixOS with the helix package:

environment.systemPackages = [ pkgs.helix ];

Depending on the programming languages it is helpful to install additional packages from nixpkgs. To show what packages are needed, it is helpful to check hx --health.

With Home Manager

Home Manager provides a module for configuring helix.

programs.helix = {
  enable = true;
  settings = {
    theme = "autumn_night_transparent";
    editor.cursor-shape = {
      normal = "block";
      insert = "bar";
      select = "underline";
    };
  };
  languages.language = [{
    name = "nix";
    auto-format = true;
    formatter.command = lib.getExe pkgs.nixfmt;
  }];
  themes = {
    autumn_night_transparent = {
      "inherits" = "autumn_night";
      "ui.background" = { };
    };
  };
};

The full configuration options are described on the Helix documentation. For programming languages (LSP, formatter, ..) see the Helix wiki.

Configuration

Language server

For further auto-completion features and syntax evaluation, a language server such nixd can be configured using Home-Manager.

programs.helix = {
  enable = true;
  [...]
  languages = {
    language-server = {
      nixd = {
        command = "${lib.getExe pkgs.nixd}";
        args = [ "--semantic-tokens=true" ];
        config.nixd =
          let
            nixosConfiguration = "mynixos";
            flakeRef = "(builtins.getFlake (toString /etc/nixos/.))";
            nixosOpts = "${flakeRef}.nixosConfigurations.${nixosConfiguration}.options";
          in
          {
            nixpkgs.expr = "${flakeRef}.inputs.nixpkgs";
            options = {
              nixos.expr = nixosOpts;
              home-manager.expr = "${nixosOpts}.home-manager.users.type.getSubOptions []";
            };
          };
      };
    };
  };
};

Adapt nixosConfiguration variable, file path to your flake.nix in flakeRef and the list of expression paths in the options attribute set, according to your system and your needs.

Tips and tricks

Plugins

There is an open and actively worked on PR to add plugins, which can be tested by using the steelix package from nixpkgs-unstable.