Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite and refactor all documentation #5534

Merged
merged 39 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
421b5eb
Rewrite and refactor all documentation
David-Else Jan 14, 2023
dc6a0e3
Rewrite and refactor the guides
David-Else Jan 14, 2023
d3dfb29
update runtime directory instructions for windows
CptPotato Jan 14, 2023
4224da6
Merge pull request #1 from CptPotato/win-build-docs
David-Else Jan 15, 2023
a6894a1
Update the Ubuntu 3rd party repo section with 22.10
David-Else Jan 16, 2023
227ed34
Merge remote-tracking branch 'upstream/master' into rewrite-and-refac…
David-Else Jan 16, 2023
07cbc54
Merge from upstream
David-Else Jan 16, 2023
3901d60
Rewrite and refactor all documentation
David-Else Jan 28, 2023
d932969
Apply suggestions from code review
David-Else Jan 29, 2023
7c84042
Merge branch 'rewrite-and-refactor-all-documentation' of github.com:D…
David-Else Jan 29, 2023
550273c
Add Windows themes folder
David-Else Feb 1, 2023
0fa91ee
Merge branch 'rewrite-and-refactor-all-documentation' of github.com:D…
David-Else Feb 2, 2023
498be1b
Apply the rest of the suggestions from the code review
David-Else Feb 2, 2023
7cfdd9c
Revert "Apply the rest of the suggestions from the code review"
David-Else Feb 2, 2023
1480e19
Revert "Merge branch 'rewrite-and-refactor-all-documentation' of gith…
the-mikedavis Feb 2, 2023
f5eeac6
Merge branch 'master' into rewrite-and-refactor-all-documentation
the-mikedavis Feb 2, 2023
f92d580
Apply code review suggestions
David-Else Feb 3, 2023
f7ed274
Changes after re-reading all documents
David-Else Feb 3, 2023
a5567a9
Missed a full stop
David-Else Feb 3, 2023
192e891
Code review suggestions and remove macOS and Windows specific sections
David-Else Feb 7, 2023
e01032e
Add OpenBSD to heading
David-Else Feb 7, 2023
445314c
Add back macOS and Windows sections and further simplify and improve
David-Else Feb 8, 2023
47fca79
Change wording to nightly
David-Else Feb 8, 2023
6674a08
Remove README installation section and turn into a link
David-Else Feb 8, 2023
3bd1b23
Simplify building from source and follow code review suggestions
David-Else Feb 8, 2023
99eec65
Code review revisions
David-Else Feb 8, 2023
6b30103
Fix copy paste mistake
David-Else Feb 8, 2023
24fc54a
Apply the latest code review suggestions
David-Else Feb 9, 2023
b3c551e
More small code review items
David-Else Feb 9, 2023
81a95f8
Change minor modes for code review
David-Else Feb 9, 2023
81f9e1b
Fix link and typos
David-Else Feb 9, 2023
b5bd559
Add note that you need a c++ compiler to install the tree-sitter gram…
David-Else Feb 11, 2023
b1372a7
Add pacman example
David-Else Feb 12, 2023
fbaa5d5
Make sure all headings are lower case
David-Else Feb 17, 2023
aa45dc7
Revert to the original passage adding a reference to Windows that was…
David-Else Feb 17, 2023
a5784ed
Merge branch 'master' into rewrite-and-refactor-all-documentation
the-mikedavis Feb 28, 2023
b1d63ea
Update book/src/guides/adding_languages.md
David-Else Mar 1, 2023
07be576
Update book/src/install.md
David-Else Mar 1, 2023
826f470
Remove TOC links to main heading
David-Else Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/src/commands.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Commands

Command mode can be activated by pressing `:`, similar to Vim. Built-in commands:
Command mode, similar to Vim, can be activated by pressing `:`. The built-in commands are:
David-Else marked this conversation as resolved.
Show resolved Hide resolved

{{#include ./generated/typable-cmd.md}}
89 changes: 43 additions & 46 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

To override global configuration parameters, create a `config.toml` file located in your config directory:

* Linux and Mac: `~/.config/helix/config.toml`
* Windows: `%AppData%\helix\config.toml`
- Linux and Mac: `~/.config/helix/config.toml`
- Windows: `%AppData%\helix\config.toml`
David-Else marked this conversation as resolved.
Show resolved Hide resolved

> Hint: You can easily open the config file by typing `:config-open` within Helix normal mode.
> 💡 You can easily open the config file by typing `:config-open` within Helix normal mode.

Example config:

Expand All @@ -25,36 +25,34 @@ select = "underline"
hidden = false
```

You may also specify a file to use for configuration with the `-c` or
`--config` CLI argument: `hx -c path/to/custom-config.toml`.

It is also possible to trigger configuration file reloading by sending the `USR1`
signal to the helix process, e.g. via `pkill -USR1 hx`. This is only supported
on unix operating systems.
You can use a custom configuration file by specifying it with the `-c` or
`--config` command line argument, for example `hx -c path/to/custom-config.toml`.
Additionally, you can reload the configuration file by sending the USR1
signal to the Helix process on Unix operating systems, such as by using the command `pkill -USR1 hx`.

## Editor

### `[editor]` Section

| Key | Description | Default |
|--|--|---------|
| `scrolloff` | Number of lines of padding around the edge of the screen when scrolling. | `5` |
| `mouse` | Enable mouse mode. | `true` |
| `middle-click-paste` | Middle click paste support. | `true` |
| `scroll-lines` | Number of lines to scroll per scroll wheel step. | `3` |
| `shell` | Shell to use when running external commands. | Unix: `["sh", "-c"]`<br/>Windows: `["cmd", "/C"]` |
| `line-number` | Line number display: `absolute` simply shows each line's number, while `relative` shows the distance from the current line. When unfocused or in insert mode, `relative` will still show absolute line numbers. | `absolute` |
| `cursorline` | Highlight all lines with a cursor. | `false` |
| `cursorcolumn` | Highlight all columns with a cursor. | `false` |
| `scrolloff` | Number of lines of padding around the edge of the screen when scrolling | `5` |
| `mouse` | Enable mouse mode | `true` |
| `middle-click-paste` | Middle click paste support | `true` |
| `scroll-lines` | Number of lines to scroll per scroll wheel step | `3` |
| `shell` | Shell to use when running external commands | Unix: `["sh", "-c"]`<br/>Windows: `["cmd", "/C"]` |
| `line-number` | Line number display: `absolute` simply shows each line's number, while `relative` shows the distance from the current line. When unfocused or in insert mode, `relative` will still show absolute line numbers | `absolute` |
| `cursorline` | Highlight all lines with a cursor | `false` |
| `cursorcolumn` | Highlight all columns with a cursor | `false` |
| `gutters` | Gutters to display: Available are `diagnostics` and `diff` and `line-numbers` and `spacer`, note that `diagnostics` also includes other features like breakpoints, 1-width padding will be inserted if gutters is non-empty | `["diagnostics", "spacer", "line-numbers", "spacer", "diff"]` |
| `auto-completion` | Enable automatic pop up of auto-completion. | `true` |
| `auto-format` | Enable automatic formatting on save. | `true` |
| `auto-save` | Enable automatic saving on focus moving away from Helix. Requires [focus event support](https://github.com/helix-editor/helix/wiki/Terminal-Support) from your terminal. | `false` |
| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` |
| `auto-completion` | Enable automatic pop up of auto-completion | `true` |
| `auto-format` | Enable automatic formatting on save | `true` |
| `auto-save` | Enable automatic saving on the focus moving away from Helix. Requires [focus event support](https://github.com/helix-editor/helix/wiki/Terminal-Support) from your terminal | `false` |
| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant | `400` |
| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
| `auto-info` | Whether to display infoboxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |
| `auto-info` | Whether to display info boxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` |
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |

Expand Down Expand Up @@ -123,10 +121,12 @@ The following statusline elements can be configured:

### `[editor.cursor-shape]` Section

Defines the shape of cursor in each mode. Note that due to limitations
of the terminal environment, only the primary cursor can change shape.
Defines the shape of cursor in each mode.
Valid values for these options are `block`, `bar`, `underline`, or `hidden`.

> 💡 Due to limitations of the terminal environment, only the primary cursor can
> change shape.

| Key | Description | Default |
| --- | ----------- | ------- |
| `normal` | Cursor shape in [normal mode][normal mode] | `block` |
Expand All @@ -139,25 +139,22 @@ Valid values for these options are `block`, `bar`, `underline`, or `hidden`.

### `[editor.file-picker]` Section

Sets options for file picker and global search. All but the last key listed in
the default file-picker configuration below are IgnoreOptions: whether hidden
files and files listed within ignore files are ignored by (not visible in) the
helix file picker and global search. There is also one other key, `max-depth`
available, which is not defined by default.
Set options for file picker and global search. Ignoring a file means it is
not visible in the Helix file picker and global search.

All git related options are only enabled in a git repository.

| Key | Description | Default |
|--|--|---------|
|`hidden` | Enables ignoring hidden files. | true
|`hidden` | Enables ignoring hidden files | true
|`follow-links` | Follow symlinks instead of ignoring them | true
|`deduplicate-links` | Ignore symlinks that point at files already shown in the picker | true
|`parents` | Enables reading ignore files from parent directories. | true
|`ignore` | Enables reading `.ignore` files. | true
|`git-ignore` | Enables reading `.gitignore` files. | true
|`git-global` | Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. | true
|`git-exclude` | Enables reading `.git/info/exclude` files. | true
|`max-depth` | Set with an integer value for maximum depth to recurse. | Defaults to `None`.
|`parents` | Enables reading ignore files from parent directories | true
|`ignore` | Enables reading `.ignore` files | true
|`git-ignore` | Enables reading `.gitignore` files | true
|`git-global` | Enables reading global `.gitignore`, whose path is specified in git's config: `core.excludefile` option | true
|`git-exclude` | Enables reading `.git/info/exclude` files | true
|`max-depth` | Set with an integer value for maximum depth to recurse | Defaults to `None`.

### `[editor.auto-pairs]` Section

Expand Down Expand Up @@ -209,7 +206,7 @@ Search specific options.

| Key | Description | Default |
|--|--|---------|
| `smart-case` | Enable smart case regex searching (case insensitive unless pattern contains upper case characters) | `true` |
| `smart-case` | Enable smart case regex searching (case-insensitive unless pattern contains upper case characters) | `true` |
| `wrap-around`| Whether the search should wrap after depleting the matches | `true` |

### `[editor.whitespace]` Section
Expand All @@ -218,7 +215,7 @@ Options for rendering whitespace with visible characters. Use `:set whitespace.r

| Key | Description | Default |
|-----|-------------|---------|
| `render` | Whether to render whitespace. May either be `"all"` or `"none"`, or a table with sub-keys `space`, `nbsp`, `tab`, and `newline`. | `"none"` |
| `render` | Whether to render whitespace. May either be `"all"` or `"none"`, or a table with sub-keys `space`, `nbsp`, `tab`, and `newline` | `"none"` |
| `characters` | Literal characters to use when rendering whitespace. Sub-keys may be any of `tab`, `space`, `nbsp`, `newline` or `tabpad` | See example below |

Example
Expand Down Expand Up @@ -246,7 +243,7 @@ Options for rendering vertical indent guides.

| Key | Description | Default |
| --- | --- | --- |
| `render` | Whether to render indent guides. | `false` |
| `render` | Whether to render indent guides | `false` |
| `character` | Literal character to use for rendering the indent guide | `│` |
| `skip-levels` | Number of indent levels to skip | `0` |

Expand All @@ -271,7 +268,7 @@ gutters = ["diff", "diagnostics", "line-numbers", "spacer"]

To customize the behavior of gutters, the `[editor.gutters]` section must
be used. This section contains top level settings, as well as settings for
specific gutter components as sub-sections.
specific gutter components as subsections.

| Key | Description | Default |
| --- | --- | --- |
Expand Down Expand Up @@ -313,13 +310,13 @@ Currently unused

### `[editor.soft-wrap]` Section

Options for soft wrapping lines that exceed the view width
Options for soft wrapping lines that exceed the view width:

| Key | Description | Default |
| --- | --- | --- |
| `enable` | Whether soft wrapping is enabled. | `false` |
| `max-wrap` | Maximum free space left at the end of the line. | `20` |
| `max-indent-retain` | Maximum indentation to carry over when soft wrapping a line. | `40` |
| `enable` | Whether soft wrapping is enabled | `false` |
| `max-wrap` | Maximum free space left at the end of the line | `20` |
| `max-indent-retain` | Maximum indentation to carry over when soft wrapping a line | `40` |
| `wrap-indicator` | Text inserted before soft wrapped lines, highlighted with `ui.virtual.wrap` | `↪ ` |

Example:
Expand Down
2 changes: 1 addition & 1 deletion book/src/guides/README.md
Original file line number Diff line number Diff line change
@@ -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.
77 changes: 42 additions & 35 deletions book/src/guides/adding_languages.md
Original file line number Diff line number Diff line change
@@ -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)
David-Else marked this conversation as resolved.
Show resolved Hide resolved
> 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/grammar/<name>.so`.
David-Else marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 5 additions & 7 deletions book/src/guides/textobject.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Adding Textobject Queries

Textobjects that are language specific ([like functions, classes, etc][textobjects])
require an accompanying tree-sitter grammar and a `textobjects.scm` query file
Helix supports textobjects that are language specific, such as functions, classes, etc.
These textobjects require an accompanying tree-sitter grammar and a `textobjects.scm` query file
to work properly. Tree-sitter allows us to query the source code syntax tree
and capture specific parts of it. The queries are written in a lisp dialect.
More information on how to write queries can be found in the [official tree-sitter
documentation][tree-sitter-queries].

Query files should be placed in `runtime/queries/{language}/textobjects.scm`
when contributing. Note that to test the query files locally you should put
when contributing to Helix. Note that to test the query files locally you should put
them under your local runtime directory (`~/.config/helix/runtime` on Linux
for example).

Expand All @@ -30,20 +30,18 @@ The following [captures][tree-sitter-captures] are recognized:

## Queries for Textobject Based Navigation

[Tree-sitter based navigation][textobjects-nav] is done using captures in the
Tree-sitter based navigation in Helix is done using captures in the
following order:

- `object.movement`
- `object.around`
- `object.inside`

For example if a `function.around` capture has been already defined for a language
in it's `textobjects.scm` file, function navigation should also work automatically.
in its `textobjects.scm` file, function navigation should also work automatically.
`function.movement` should be defined only if the node captured by `function.around`
doesn't make sense in a navigation context.

[textobjects]: ../usage.md#textobjects
[textobjects-nav]: ../usage.md#tree-sitter-textobject-based-navigation
[tree-sitter-queries]: https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax
[tree-sitter-captures]: https://tree-sitter.github.io/tree-sitter/using-parsers#capturing-nodes
[textobject-examples]: https://github.com/search?q=repo%3Ahelix-editor%2Fhelix+filename%3Atextobjects.scm&type=Code&ref=advsearch&l=&l=
Loading