1
0
mirror of https://github.com/helix-editor/helix synced 2024-11-10 10:34:45 +01:00
A post-modern modal text editor. https://helix-editor.com
Go to file
Michael Davis d5f17d3f69
Fix initial highlight layer sort order (#5196)
The purpose of this change is to remove the mutable self borrow on
`HighlightIterLayer::sort_key` so that we can sort layers with the
correct ordering using the `Vec::sort` function family.
`HighlightIterLayer::sort_key` needs `&mut self` since it calls
`Peekable::peek` which needs `&mut self`. `Vec::sort` functions
only give immutable borrows of the elements to ensure the
correctness of the sort.

We could instead approach this by creating an eager Peekable and using
that instead of `std::iter::Peekable` to wrap `QueryCaptures`:

```rust
struct EagerPeekable<I: Iterator> {
    iter: I,
    peeked: Option<I::Item>,
}

impl<I: Iterator> EagerPeekable<I> {
    fn new(mut iter: I) -> Self {
        let peeked = iter.next();
        Self { iter, peeked }
    }

    fn peek(&self) -> Option<&I::Item> {
        self.peeked.as_ref()
    }
}

impl<I: Iterator> Iterator for EagerPeekable<I> {
    type Item = I::Item;

    fn next(&mut self) -> Option<Self::Item> {
        std::mem::replace(&mut self.peeked, self.iter.next())
    }
}
```

This would be a cleaner approach (notice how `EagerPeekable::peek`
takes `&self` rather than `&mut self`), however this doesn't work in
practice because the Items emitted by the `tree_sitter::QueryCaptures`
Iterator must be consumed before the next Item is returned.
`Iterator::next` on `tree_sitter::QueryCaptures` modifies the
`QueryMatch` returned by the last call of `next`. This behavior is
not currently reflected in the lifetimes/structure of `QueryCaptures`.

This fixes an issue with layers being out of order when using combined
injections since the old code only checked the first range in the
layer. Layers being out of order could cause missing highlights for
combined-injections content.
2023-02-01 16:28:56 -05:00
.cargo
.github ci: Merge two jobs 2022-12-13 15:14:40 +09:00
book rework positioning/rendering and enable softwrap/virtual text (#5420) 2023-02-01 02:03:19 +09:00
contrib Add Appstream metadata file (#5643) 2023-01-24 17:26:42 -06:00
docs Add Appstream metadata file (#5643) 2023-01-24 17:26:42 -06:00
helix-core Fix initial highlight layer sort order (#5196) 2023-02-01 16:28:56 -05:00
helix-dap build(deps): bump which from 4.3.0 to 4.4.0 (#5655) 2023-01-23 17:25:49 -06:00
helix-loader build(deps): bump toml from 0.6.0 to 0.7.0 (#5726) 2023-01-30 08:49:26 -06:00
helix-lsp Support goto-declaration LSP command (#5646) 2023-01-31 05:38:53 -05:00
helix-term rework positioning/rendering and enable softwrap/virtual text (#5420) 2023-02-01 02:03:19 +09:00
helix-tui Fix clippy 1.67 warnings (#5697) 2023-01-27 09:43:46 -06:00
helix-vcs build(deps): bump git-repository from 0.31.0 to 0.32.0 (#5476) 2023-01-10 08:12:04 +08:00
helix-view rework positioning/rendering and enable softwrap/virtual text (#5420) 2023-02-01 02:03:19 +09:00
runtime Add ayu_evolve theme (#5638) 2023-02-01 16:17:59 -05:00
xtask build(deps): bump toml from 0.6.0 to 0.7.0 (#5726) 2023-01-30 08:49:26 -06:00
.envrc
.gitattributes
.gitignore
.ignore
base16_theme.toml Set ui.text.inactive for official themes 2022-12-17 13:59:05 -06:00
Cargo.lock build(deps): bump toml from 0.7.0 to 0.7.1 (#5745) 2023-01-30 17:49:50 -06:00
Cargo.toml Show (git) diff signs in gutter (#3890) 2022-12-01 17:35:23 +09:00
CHANGELOG.md Add changelog notes for 22.12 (#4822) 2022-12-07 11:54:50 +09:00
default.nix
flake.lock build(nix): update inputs (#5219) 2022-12-19 17:36:56 -06:00
flake.nix flake: Fix devshell for darwin hosts (#5368) 2023-01-03 01:12:32 +09:00
grammars.nix
languages.toml Modify env language to extend bash (#5720) 2023-01-30 08:56:42 -06:00
LICENSE
logo_dark.svg Add logo with text included (#4973) 2022-12-03 11:05:15 +09:00
logo_light.svg Add logo with text included (#4973) 2022-12-03 11:05:15 +09:00
logo.svg Add the new logo! 2022-12-02 12:06:17 +09:00
README.md Update the cargo installation instructions to include --locked (#5443) 2023-01-07 16:42:45 -05:00
rust-toolchain.toml
rustfmt.toml
screenshot.png
shell.nix
theme.toml Add markup.strikethrough theme keys (#5619) 2023-01-21 16:21:26 -06:00
VERSION Add changelog notes for 22.12 (#4822) 2022-12-07 11:54:50 +09:00

Helix

Build status GitHub Release Documentation GitHub contributors Matrix Space

Screenshot

A Kakoune / Neovim inspired editor, written in Rust.

The editing model is very heavily based on Kakoune; during development I found myself agreeing with most of Kakoune's design decisions.

For more information, see the website or documentation.

All shortcuts/keymaps can be found in the documentation on the website.

Troubleshooting

Features

  • Vim-like modal editing
  • Multiple selections
  • Built-in language server support
  • Smart, incremental syntax highlighting and code editing via tree-sitter

It's a terminal-based editor first, but I'd like to explore a custom renderer (similar to Emacs) in wgpu or skulpin.

Note: Only certain languages have indentation definitions at the moment. Check runtime/queries/<lang>/ for indents.scm.

Installation

Packages are available for various distributions (see Installation docs).

If you would like to build from source:

git clone https://github.com/helix-editor/helix
cd helix
cargo install --locked --path helix-term

This will install the hx binary to $HOME/.cargo/bin and build tree-sitter grammars in ./runtime/grammars.

Helix needs its runtime files so make sure to copy/symlink the runtime/ directory into the config directory (for example ~/.config/helix/runtime on Linux/macOS, or %AppData%/helix/runtime on Windows).

OS Command
Windows (Cmd) xcopy /e /i runtime %AppData%\helix\runtime
Windows (PowerShell) xcopy /e /i runtime $Env:AppData\helix\runtime
Linux / macOS ln -s $PWD/runtime ~/.config/helix/runtime

Starting with Windows Vista you can also create symbolic links on Windows. Note that this requires elevated privileges - i.e. PowerShell or Cmd must be run as administrator.

PowerShell:

New-Item -ItemType SymbolicLink -Target "runtime" -Path "$Env:AppData\helix\runtime"

Cmd:

cd %appdata%\helix
mklink /D runtime "<helix-repo>\runtime"

The runtime location can be overridden via the HELIX_RUNTIME environment variable.

NOTE: if HELIX_RUNTIME is set prior to calling cargo install --locked --path helix-term, tree-sitter grammars will be built in $HELIX_RUNTIME/grammars.

If you plan on keeping the repo locally, an alternative to copying/symlinking runtime files is to set HELIX_RUNTIME=/path/to/helix/runtime (HELIX_RUNTIME=$PWD/runtime if you're in the helix repo directory).

Packages already solve this for you by wrapping the hx binary with a wrapper that sets the variable to the install dir.

NOTE: running via cargo also doesn't require setting explicit HELIX_RUNTIME path, it will automatically detect the runtime directory in the project root.

If you want to customize your languages.toml config, tree-sitter grammars may be manually fetched and built with hx --grammar fetch and hx --grammar build.

In order to use LSP features like auto-complete, you will need to install the appropriate Language Server for a language.

Packaging status

Adding Helix to your desktop environment

If installing from source, to use Helix in desktop environments that supports XDG desktop menu, including Gnome and KDE, copy the provided .desktop file to the correct folder:

cp contrib/Helix.desktop ~/.local/share/applications
cp contrib/helix.png ~/.local/share/icons

To use another terminal than the default, you will need to modify the .desktop file. For example, to use kitty:

sed -i "s|Exec=hx %F|Exec=kitty hx %F|g" ~/.local/share/applications/Helix.desktop
sed -i "s|Terminal=true|Terminal=false|g" ~/.local/share/applications/Helix.desktop

macOS

Helix can be installed on macOS through homebrew:

brew install helix

Contributing

Contributing guidelines can be found here.

Getting help

Your question might already be answered on the FAQ.

Discuss the project on the community Matrix Space (make sure to join #helix-editor:matrix.org if you're on a client that doesn't support Matrix Spaces yet).

Credits

Thanks to @JakeHL for designing the logo!