forked from Mirrors/helix
Rewrite and refactor all documentation (#5534)
* Rewrite and refactor all documentation * Rewrite and refactor the guides * update runtime directory instructions for windows * Update the Ubuntu 3rd party repo section with 22.10 * Merge from upstream * Rewrite and refactor all documentation * Apply suggestions from code review Apply the suggestions that can be committed from the GitHub web interface. Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Add Windows themes folder Co-authored-by: digidoor <37601466+digidoor@users.noreply.github.com> * Apply the rest of the suggestions from the code review * Revert "Apply the rest of the suggestions from the code review" This reverts commit 498be1b7a1aec3ff567b95130148628beeef9b77. * Revert "Merge branch 'rewrite-and-refactor-all-documentation' of github.com:David-Else/helix into rewrite-and-refactor-all-documentation" This reverts commit 7c8404248ffef73b80b9051d5a4359c5bcfa5d1a, reversing changes made to d932969cfc9fadda12a74cc01665919dee7152fb. * Apply code review suggestions * Changes after re-reading all documents * Missed a full stop * Code review suggestions and remove macOS and Windows specific sections * Add OpenBSD to heading * Add back macOS and Windows sections and further simplify and improve * Change wording to nightly * Remove README installation section and turn into a link * Simplify building from source and follow code review suggestions * Code review revisions * Fix copy paste mistake * Apply the latest code review suggestions * More small code review items * Change minor modes for code review * Fix link and typos * Add note that you need a c++ compiler to install the tree-sitter grammars * Add pacman example * Make sure all headings are lower case * Revert to the original passage adding a reference to Windows that was missing * Update book/src/guides/adding_languages.md Fix grammar typo Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Update book/src/install.md Fix tree sitter typo Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Remove TOC links to main heading --------- Co-authored-by: CptPotato <3957610+CptPotato@users.noreply.github.com> Co-authored-by: Michael Davis <mcarsondavis@gmail.com> Co-authored-by: digidoor <37601466+digidoor@users.noreply.github.com>pull/5/head
parent
5ebe1014ac
commit
707457c632
@ -1,5 +1,5 @@
|
||||
# Commands
|
||||
|
||||
Command mode can be activated by pressing `:`, similar to Vim. Built-in commands:
|
||||
Command mode can be activated by pressing `:`. The built-in commands are:
|
||||
|
||||
{{#include ./generated/typable-cmd.md}}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Guides
|
||||
|
||||
This section contains guides for adding new language server configurations,
|
||||
tree-sitter grammars, textobject queries, etc.
|
||||
tree-sitter grammars, textobject queries, and other similar items.
|
||||
|
@ -1,45 +1,52 @@
|
||||
# Adding languages
|
||||
# Adding new languages to Helix
|
||||
|
||||
In order to add a new language to Helix, you will need to follow the steps
|
||||
below.
|
||||
|
||||
## Language configuration
|
||||
|
||||
To add a new language, you need to add a `[[language]]` entry to the
|
||||
`languages.toml` (see the [language configuration section]).
|
||||
1. Add a new `[[language]]` entry in the `languages.toml` file and provide the
|
||||
necessary configuration for the new language. For more information on
|
||||
language configuration, refer to the
|
||||
[language configuration section](../languages.md) of the documentation.
|
||||
2. If you are adding a new language or updating an existing language server
|
||||
configuration, run the command `cargo xtask docgen` to update the
|
||||
[Language Support](../lang-support.md) documentation.
|
||||
|
||||
When adding a new language or Language Server configuration for an existing
|
||||
language, run `cargo xtask docgen` to add the new configuration to the
|
||||
[Language Support][lang-support] docs before creating a pull request.
|
||||
When adding a Language Server configuration, be sure to update the
|
||||
[Language Server Wiki][install-lsp-wiki] with installation notes.
|
||||
> 💡 If you are adding a new Language Server configuration, make sure to update
|
||||
> the
|
||||
> [Language Server Wiki](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers)
|
||||
> with the installation instructions.
|
||||
|
||||
## Grammar configuration
|
||||
|
||||
If a tree-sitter grammar is available for the language, add a new `[[grammar]]`
|
||||
entry to `languages.toml`.
|
||||
|
||||
You may use the `source.path` key rather than `source.git` with an absolute path
|
||||
to a locally available grammar for testing, but switch to `source.git` before
|
||||
submitting a pull request.
|
||||
1. If a tree-sitter grammar is available for the new language, add a new
|
||||
`[[grammar]]` entry to the `languages.toml` file.
|
||||
2. If you are testing the grammar locally, you can use the `source.path` key
|
||||
with an absolute path to the grammar. However, before submitting a pull
|
||||
request, make sure to switch to using `source.git`.
|
||||
|
||||
## Queries
|
||||
|
||||
For a language to have syntax-highlighting and indentation among
|
||||
other things, you have to add queries. Add a directory for your
|
||||
language with the path `runtime/queries/<name>/`. The tree-sitter
|
||||
[website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
|
||||
gives more info on how to write queries.
|
||||
|
||||
> NOTE: When evaluating queries, the first matching query takes
|
||||
precedence, which is different from other editors like Neovim where
|
||||
the last matching query supersedes the ones before it. See
|
||||
[this issue][neovim-query-precedence] for an example.
|
||||
|
||||
## Common Issues
|
||||
|
||||
- If you get errors when running after switching branches, you may have to update the tree-sitter grammars. Run `hx --grammar fetch` to fetch the grammars and `hx --grammar build` to build any out-of-date grammars.
|
||||
|
||||
- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
|
||||
|
||||
[language configuration section]: ../languages.md
|
||||
[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
|
||||
[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
|
||||
[lang-support]: ../lang-support.md
|
||||
1. In order to provide syntax highlighting and indentation for the new language,
|
||||
you will need to add queries.
|
||||
2. Create a new directory for the language with the path
|
||||
`runtime/queries/<name>/`.
|
||||
3. Refer to the
|
||||
[tree-sitter website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
|
||||
for more information on writing queries.
|
||||
|
||||
> 💡 In Helix, the first matching query takes precedence when evaluating
|
||||
> queries, which is different from other editors such as Neovim where the last
|
||||
> matching query supersedes the ones before it. See
|
||||
> [this issue](https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090)
|
||||
> for an example.
|
||||
|
||||
## Common issues
|
||||
|
||||
- If you encounter errors when running Helix after switching branches, you may
|
||||
need to update the tree-sitter grammars. Run the command `hx --grammar fetch`
|
||||
to fetch the grammars and `hx --grammar build` to build any out-of-date
|
||||
grammars.
|
||||
- If a parser is causing a segfault, or you want to remove it, make sure to
|
||||
remove the compiled parser located at `runtime/grammars/<name>.so`.
|
||||
|
@ -1,180 +1,223 @@
|
||||
# Installation
|
||||
|
||||
We provide pre-built binaries on the [GitHub Releases page](https://github.com/helix-editor/helix/releases).
|
||||
# Installing Helix
|
||||
|
||||
<!--toc:start-->
|
||||
- [Pre-built binaries](#pre-built-binaries)
|
||||
- [Linux, macOS, Windows and OpenBSD packaging status](#linux-macos-windows-and-openbsd-packaging-status)
|
||||
- [Linux](#linux)
|
||||
- [Ubuntu](#ubuntu)
|
||||
- [Fedora/RHEL](#fedorarhel)
|
||||
- [Arch Linux community](#arch-linux-community)
|
||||
- [NixOS](#nixos)
|
||||
- [macOS](#macos)
|
||||
- [Homebrew Core](#homebrew-core)
|
||||
- [Windows](#windows)
|
||||
- [Scoop](#scoop)
|
||||
- [Chocolatey](#chocolatey)
|
||||
- [MSYS2](#msys2)
|
||||
- [Building from source](#building-from-source)
|
||||
- [Configuring Helix's runtime files](#configuring-helixs-runtime-files)
|
||||
- [Validating the installation](#validating-the-installation)
|
||||
- [Configure the desktop shortcut](#configure-the-desktop-shortcut)
|
||||
<!--toc:end-->
|
||||
|
||||
To install Helix, follow the instructions specific to your operating system.
|
||||
Note that:
|
||||
|
||||
- To get the latest nightly version of Helix, you need to
|
||||
[build from source](#building-from-source).
|
||||
|
||||
- To take full advantage of Helix, install the language servers for your
|
||||
preferred programming languages. See the
|
||||
[wiki](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers)
|
||||
for instructions.
|
||||
|
||||
## Pre-built binaries
|
||||
|
||||
Download pre-built binaries from the
|
||||
[GitHub Releases page](https://github.com/helix-editor/helix/releases). Add the binary to your system's `$PATH` to use it from the command
|
||||
line.
|
||||
|
||||
## Linux, macOS, Windows and OpenBSD packaging status
|
||||
|
||||
Helix is available for Linux, macOS and Windows via the official repositories listed below.
|
||||
|
||||
[![Packaging status](https://repology.org/badge/vertical-allrepos/helix.svg)](https://repology.org/project/helix/versions)
|
||||
|
||||
## OSX
|
||||
## Linux
|
||||
|
||||
Helix is available in homebrew-core:
|
||||
The following third party repositories are available:
|
||||
|
||||
```
|
||||
brew install helix
|
||||
```
|
||||
### Ubuntu
|
||||
|
||||
## Linux
|
||||
Helix is available via [Maveonair's PPA](https://launchpad.net/~maveonair/+archive/ubuntu/helix-editor):
|
||||
|
||||
### NixOS
|
||||
```sh
|
||||
sudo add-apt-repository ppa:maveonair/helix-editor
|
||||
sudo apt update
|
||||
sudo apt install helix
|
||||
```
|
||||
|
||||
A [flake](https://nixos.wiki/wiki/Flakes) containing the package is available in
|
||||
the project root. The flake can also be used to spin up a reproducible development
|
||||
shell for working on Helix with `nix develop`.
|
||||
### Fedora/RHEL
|
||||
|
||||
Flake outputs are cached for each push to master using
|
||||
[Cachix](https://www.cachix.org/). The flake is configured to
|
||||
automatically make use of this cache assuming the user accepts
|
||||
the new settings on first use.
|
||||
Helix is available via `copr`:
|
||||
|
||||
If you are using a version of Nix without flakes enabled you can
|
||||
[install Cachix cli](https://docs.cachix.org/installation); `cachix use helix` will
|
||||
configure Nix to use cached outputs when possible.
|
||||
```sh
|
||||
sudo dnf copr enable varlad/helix
|
||||
sudo dnf install helix
|
||||
```
|
||||
|
||||
### Arch Linux
|
||||
### Arch Linux community
|
||||
|
||||
Releases are available in the `community` repository.
|
||||
Releases are available in the `community` repository:
|
||||
|
||||
A [helix-git](https://aur.archlinux.org/packages/helix-git/) package is also available on the AUR, which builds the master branch.
|
||||
```sh
|
||||
sudo pacman -S helix
|
||||
```
|
||||
Additionally, a [helix-git](https://aur.archlinux.org/packages/helix-git/) package is available
|
||||
in the AUR, which builds the master branch.
|
||||
|
||||
### Fedora Linux
|
||||
### NixOS
|
||||
|
||||
You can install the COPR package for Helix via
|
||||
Helix is available as a [flake](https://nixos.wiki/wiki/Flakes) in the project
|
||||
root. Use `nix develop` to spin up a reproducible development shell. Outputs are
|
||||
cached for each push to master using [Cachix](https://www.cachix.org/). The
|
||||
flake is configured to automatically make use of this cache assuming the user
|
||||
accepts the new settings on first use.
|
||||
|
||||
```
|
||||
sudo dnf copr enable varlad/helix
|
||||
sudo dnf install helix
|
||||
```
|
||||
If you are using a version of Nix without flakes enabled,
|
||||
[install Cachix CLI](https://docs.cachix.org/installation) and use
|
||||
`cachix use helix` to configure Nix to use cached outputs when possible.
|
||||
|
||||
## macOS
|
||||
|
||||
### Void Linux
|
||||
### Homebrew Core
|
||||
|
||||
```
|
||||
sudo xbps-install helix
|
||||
```sh
|
||||
brew install helix
|
||||
```
|
||||
|
||||
## Windows
|
||||
|
||||
Helix can be installed using [Scoop](https://scoop.sh/), [Chocolatey](https://chocolatey.org/)
|
||||
Install on Windows using [Scoop](https://scoop.sh/), [Chocolatey](https://chocolatey.org/)
|
||||
or [MSYS2](https://msys2.org/).
|
||||
|
||||
**Scoop:**
|
||||
### Scoop
|
||||
|
||||
```
|
||||
```sh
|
||||
scoop install helix
|
||||
```
|
||||
|
||||
**Chocolatey:**
|
||||
### Chocolatey
|
||||
|
||||
```
|
||||
```sh
|
||||
choco install helix
|
||||
```
|
||||
|
||||
**MSYS2:**
|
||||
|
||||
Choose the [proper command](https://www.msys2.org/docs/package-naming/) for your system from below:
|
||||
|
||||
- For 32 bit Windows 7 or above:
|
||||
|
||||
```
|
||||
pacman -S mingw-w64-i686-helix
|
||||
```
|
||||
|
||||
- For 64 bit Windows 7 or above:
|
||||
|
||||
```
|
||||
pacman -S mingw-w64-x86_64-helix
|
||||
```
|
||||
### MSYS2
|
||||
|
||||
- For 64 bit Windows 8.1 or above:
|
||||
For 64-bit Windows 8.1 or above:
|
||||
|
||||
```
|
||||
```sh
|
||||
pacman -S mingw-w64-ucrt-x86_64-helix
|
||||
```
|
||||
|
||||
## Build from source
|
||||
## Building from source
|
||||
|
||||
```
|
||||
Clone the repository:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/helix-editor/helix
|
||||
cd helix
|
||||
cargo install --path helix-term --locked
|
||||
```
|
||||
|
||||
This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars in `./runtime/grammars`.
|
||||
|
||||
If you are using the musl-libc instead of glibc the following environment variable must be set during the build
|
||||
to ensure tree sitter grammars can be loaded correctly:
|
||||
Compile from source:
|
||||
|
||||
```sh
|
||||
cargo install --path helix-term --locked
|
||||
```
|
||||
RUSTFLAGS="-C target-feature=-crt-static"
|
||||
```
|
||||
|
||||
|
||||
Helix also 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). This location can be overridden
|
||||
via the `HELIX_RUNTIME` environment variable.
|
||||
This command will create the `hx` executable and construct the tree-sitter
|
||||
grammars either in the `runtime` folder, or in the folder specified in `HELIX_RUNTIME`
|
||||
(as described below). To build the tree-sitter grammars requires a c++ compiler to be installed, for example `gcc-c++`.
|
||||
|
||||
| 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` |
|
||||
> 💡 If you are using the musl-libc instead of glibc the following environment variable must be set during the build
|
||||
> to ensure tree-sitter grammars can be loaded correctly:
|
||||
>
|
||||
> ```sh
|
||||
> RUSTFLAGS="-C target-feature=-crt-static"
|
||||
> ```
|
||||
|
||||
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.
|
||||
> 💡 Tree-sitter grammars can be fetched and compiled if not pre-packaged. Fetch
|
||||
> grammars with `hx --grammar fetch` (requires `git`) and compile them with
|
||||
> `hx --grammar build` (requires a C++ compiler).
|
||||
|
||||
**PowerShell:**
|
||||
### Configuring Helix's runtime files
|
||||
|
||||
```powershell
|
||||
New-Item -ItemType Junction -Target "runtime" -Path "$Env:AppData\helix\runtime"
|
||||
```
|
||||
Note: "runtime" must be the absolute path to the runtime directory.
|
||||
- **Linux and macOS**
|
||||
|
||||
**Cmd:**
|
||||
Either set the `HELIX_RUNTIME` environment variable to point to the runtime files and add it to your `~/.bashrc` or equivalent:
|
||||
|
||||
```cmd
|
||||
cd %appdata%\helix
|
||||
mklink /D runtime "<helix-repo>\runtime"
|
||||
```sh
|
||||
HELIX_RUNTIME=/home/user-name/src/helix/runtime
|
||||
```
|
||||
|
||||
The runtime location can be overridden via the `HELIX_RUNTIME` environment variable.
|
||||
Or, create a symlink in `~/.config/helix` that links to the source code directory:
|
||||
|
||||
> NOTE: if `HELIX_RUNTIME` is set prior to calling `cargo install --path helix-term --locked`,
|
||||
> tree-sitter grammars will be built in `$HELIX_RUNTIME/grammars`.
|
||||
```sh
|
||||
ln -s $PWD/runtime ~/.config/helix/runtime
|
||||
```
|
||||
|
||||
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).
|
||||
- **Windows**
|
||||
|
||||
To use Helix in desktop environments that supports [XDG desktop menu](https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html), including Gnome and KDE, copy the provided `.desktop` file to the correct folder:
|
||||
Either set the `HELIX_RUNTIME` environment variable to point to the runtime files using the Windows setting (search for
|
||||
`Edit environment variables for your account`) or use the `setx` command in
|
||||
Cmd:
|
||||
|
||||
```bash
|
||||
cp contrib/Helix.desktop ~/.local/share/applications
|
||||
```sh
|
||||
setx HELIX_RUNTIME "%userprofile%\source\repos\helix\runtime"
|
||||
```
|
||||
|
||||
To use another terminal than the default, you will need to modify the `.desktop` file. For example, to use `kitty`:
|
||||
> 💡 `%userprofile%` resolves to your user directory like
|
||||
> `C:\Users\Your-Name\` for example.
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
Or, create a symlink in `%appdata%\helix\` that links to the source code directory:
|
||||
|
||||
Please note: there is no icon for Helix yet, so the system default will be used.
|
||||
| Method | Command |
|
||||
| ---------- | -------------------------------------------------------------------------------------- |
|
||||
| PowerShell | `New-Item -ItemType Junction -Target "runtime" -Path "$Env:AppData\helix\runtime"` |
|
||||
| Cmd | `cd %appdata%\helix` <br/> `mklink /D runtime "%userprofile%\src\helix\runtime"` |
|
||||
|
||||
## Finishing up the installation
|
||||
> 💡 On Windows, creating a symbolic link may require running PowerShell or
|
||||
> Cmd as an administrator.
|
||||
|
||||
To make sure everything is set up as expected you should finally run the helix healthcheck via
|
||||
### Validating the installation
|
||||
|
||||
```
|
||||
To make sure everything is set up as expected you should run the Helix health
|
||||
check:
|
||||
|
||||
```sh
|
||||
hx --health
|
||||
```
|
||||
|
||||
For more information on the information displayed in the health check results refer to [Healthcheck](https://github.com/helix-editor/helix/wiki/Healthcheck).
|
||||
For more information on the health check results refer to
|
||||
[Health check](https://github.com/helix-editor/helix/wiki/Healthcheck).
|
||||
|
||||
### Building tree-sitter grammars
|
||||
### Configure the desktop shortcut
|
||||
|
||||
Tree-sitter grammars must be fetched and compiled if not pre-packaged.
|
||||
Fetch grammars with `hx --grammar fetch` (requires `git`) and compile them
|
||||
with `hx --grammar build` (requires a C++ compiler).
|
||||
If your desktop environment supports the
|
||||
[XDG desktop menu](https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html)
|
||||
you can configure Helix to show up in the application menu by copying the
|
||||
provided `.desktop` and icon files to their correct folders:
|
||||
|
||||
### Installing language servers
|
||||
```sh
|
||||
cp contrib/Helix.desktop ~/.local/share/applications
|
||||
cp contrib/helix.png ~/.icons # or ~/.local/share/icons
|
||||
```
|
||||
|
||||
To use another terminal than the system default, you can modify the `.desktop`
|
||||
file. For example, to use `kitty`:
|
||||
|
||||
Language servers can optionally be installed if you want their features (auto-complete, diagnostics etc.).
|
||||
Follow the [instructions on the wiki page](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers) to add your language servers of choice.
|
||||
```sh
|
||||
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
|
||||
```
|
||||
|
Loading…
Reference in New Issue