Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/22.05/.nojekyll b/22.05/.nojekyll new file mode 100644 index 000000000..f17311098 --- /dev/null +++ b/22.05/.nojekyll @@ -0,0 +1 @@ +This file makes sure that Github Pages doesn't process mdBook's output. diff --git a/22.05/404.html b/22.05/404.html new file mode 100644 index 000000000..8a4116191 --- /dev/null +++ b/22.05/404.html @@ -0,0 +1,170 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +Command mode can be activated by pressing :
, similar to vim. Built-in commands:
Name | Description |
---|---|
:quit , :q | Close the current view. |
:quit! , :q! | Close the current view forcefully (ignoring unsaved changes). |
:open , :o | Open a file from disk into the current view. |
:buffer-close , :bc , :bclose | Close the current buffer. |
:buffer-close! , :bc! , :bclose! | Close the current buffer forcefully (ignoring unsaved changes). |
:buffer-close-others , :bco , :bcloseother | Close all buffers but the currently focused one. |
:buffer-close-others! , :bco! , :bcloseother! | Close all buffers but the currently focused one. |
:buffer-close-all , :bca , :bcloseall | Close all buffers, without quitting. |
:buffer-close-all! , :bca! , :bcloseall! | Close all buffers forcefully (ignoring unsaved changes), without quitting. |
:buffer-next , :bn , :bnext | Go to next buffer. |
:buffer-previous , :bp , :bprev | Go to previous buffer. |
:write , :w | Write changes to disk. Accepts an optional path (:write some/path.txt) |
:write! , :w! | Write changes to disk forcefully (creating necessary subdirectories). Accepts an optional path (:write some/path.txt) |
:new , :n | Create a new scratch buffer. |
:format , :fmt | Format the file using the LSP formatter. |
:indent-style | Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.) |
:line-ending | Set the document's default line ending. Options: crlf, lf. |
:earlier , :ear | Jump back to an earlier point in edit history. Accepts a number of steps or a time span. |
:later , :lat | Jump to a later point in edit history. Accepts a number of steps or a time span. |
:write-quit , :wq , :x | Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt) |
:write-quit! , :wq! , :x! | Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt) |
:write-all , :wa | Write changes from all views to disk. |
:write-quit-all , :wqa , :xa | Write changes from all views to disk and close all views. |
:write-quit-all! , :wqa! , :xa! | Write changes from all views to disk and close all views forcefully (ignoring unsaved changes). |
:quit-all , :qa | Close all views. |
:quit-all! , :qa! | Close all views forcefully (ignoring unsaved changes). |
:cquit , :cq | Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2). |
:cquit! , :cq! | Quit with exit code (default 1) forcefully (ignoring unsaved changes). Accepts an optional integer exit code (:cq! 2). |
:theme | Change the editor theme. |
:clipboard-yank | Yank main selection into system clipboard. |
:clipboard-yank-join | Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline. |
:primary-clipboard-yank | Yank main selection into system primary clipboard. |
:primary-clipboard-yank-join | Yank joined selections into system primary clipboard. A separator can be provided as first argument. Default value is newline. |
:clipboard-paste-after | Paste system clipboard after selections. |
:clipboard-paste-before | Paste system clipboard before selections. |
:clipboard-paste-replace | Replace selections with content of system clipboard. |
:primary-clipboard-paste-after | Paste primary clipboard after selections. |
:primary-clipboard-paste-before | Paste primary clipboard before selections. |
:primary-clipboard-paste-replace | Replace selections with content of system primary clipboard. |
:show-clipboard-provider | Show clipboard provider name in status bar. |
:change-current-directory , :cd | Change the current working directory. |
:show-directory , :pwd | Show the current working directory. |
:encoding | Set encoding based on https://encoding.spec.whatwg.org |
:reload | Discard changes and reload from the source file. |
:tree-sitter-scopes | Display tree sitter scopes, primarily for theming and development. |
:debug-start , :dbg | Start a debug session from a given template with given parameters. |
:debug-remote , :dbg-tcp | Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters. |
:debug-eval | Evaluate expression in current debug context. |
:vsplit , :vs | Open the file in a vertical split. |
:vsplit-new , :vnew | Open a scratch buffer in a vertical split. |
:hsplit , :hs , :sp | Open the file in a horizontal split. |
:hsplit-new , :hnew | Open a scratch buffer in a horizontal split. |
:tutor | Open the tutorial. |
:goto , :g | Go to line number. |
:set-language , :lang | Set the language of current buffer. |
:set-option , :set | Set a config option at runtime. For example to disable smart case search, use :set search.smart-case false . |
:get-option , :get | Get the current value of a config option. |
:sort | Sort ranges in selection. |
:rsort | Sort ranges in selection in reverse order. |
:reflow | Hard-wrap the current selection of lines to a given width. |
:tree-sitter-subtree , :ts-subtree | Display tree sitter subtree under cursor, primarily for debugging queries. |
:config-reload | Refreshes helix's config. |
:config-open | Open the helix config.toml file. |
:log-open | Open the helix log file. |
:pipe | Pipe each selection to the shell command. |
:run-shell-command , :sh | Run a shell command |
To override global configuration parameters, create a config.toml
file located in your config directory:
~/.config/helix/config.toml
%AppData%\helix\config.toml
++Hint: You can easily open the config file by typing
+:config-open
within Helix normal mode.
Example config:
+theme = "onedark"
+
+[editor]
+line-number = "relative"
+mouse = false
+
+[editor.cursor-shape]
+insert = "bar"
+normal = "block"
+select = "underline"
+
+[editor.file-picker]
+hidden = false
+
+[editor]
SectionKey | Description | Default |
---|---|---|
scrolloff | Number of lines of padding around the edge of the screen when scrolling. | 3 |
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"] 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 |
gutters | Gutters to display: Available are diagnostics and line-numbers , note that diagnostics also includes other features like breakpoints | ["diagnostics", "line-numbers"] |
auto-completion | Enable automatic pop up of auto-completion. | true |
auto-format | Enable automatic formatting on save. | true |
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. | [] |
[editor.lsp]
SectionKey | Description | Default |
---|---|---|
display-messages | Display LSP progress messages below statusline1 | false |
A progress spinner is always shown in the statusline beside the file path.
+[editor.cursor-shape]
SectionDefines the shape of cursor in each mode. Note that due to limitations
+of the terminal environment, only the primary cursor can change shape.
+Valid values for these options are block
, bar
, underline
, or none
.
Key | Description | Default |
---|---|---|
normal | Cursor shape in normal mode | block |
insert | Cursor shape in insert mode | block |
select | Cursor shape in select mode | block |
[editor.file-picker]
SectionSets 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.
Key | Description | Default |
---|---|---|
hidden | Enables ignoring hidden files. | 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 . |
[editor.auto-pairs]
SectionEnables automatic insertion of pairs to parentheses, brackets, etc. Can be a +simple boolean value, or a specific mapping of pairs of single characters.
+To disable auto-pairs altogether, set auto-pairs
to false
:
[editor]
+auto-pairs = false # defaults to `true`
+
+The default pairs are (){}[]''""``
, but these can be customized by
+setting auto-pairs
to a TOML table:
[editor.auto-pairs]
+'(' = ')'
+'{' = '}'
+'[' = ']'
+'"' = '"'
+'`' = '`'
+'<' = '>'
+
+Additionally, this setting can be used in a language config. Unless
+the editor setting is false
, this will override the editor config in
+documents with this language.
Example languages.toml
that adds <> and removes ''
[[language]]
+name = "rust"
+
+[language.auto-pairs]
+'(' = ')'
+'{' = '}'
+'[' = ']'
+'"' = '"'
+'`' = '`'
+'<' = '>'
+
+[editor.search]
SectionSearch specific options.
+Key | Description | Default |
---|---|---|
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]
SectionOptions for rendering whitespace with visible characters. Use :set whitespace.render all
to temporarily enable visible whitespace.
Key | Description | Default |
---|---|---|
render | Whether to render whitespace. May either be "all" or "none" , or a table with sub-keys space , tab , and newline . | "none" |
characters | Literal characters to use when rendering whitespace. Sub-keys may be any of tab , space , nbsp or newline | See example below |
Example
+[editor.whitespace]
+render = "all"
+# or control each character
+[editor.whitespace.render]
+space = "all"
+tab = "all"
+newline = "none"
+
+[editor.whitespace.characters]
+space = "·"
+nbsp = "⍽"
+tab = "→"
+newline = "⏎"
+
+
+ Helix's editing model is strongly inspired from vim and kakoune, and a notable
+difference from vim (and the most striking similarity to kakoune) is that Helix
+follows the selection → action
model. This means that the whatever you are
+going to act on (a word, a paragraph, a line, etc) is selected first and the
+action itself (delete, change, yank, etc) comes second. A cursor is simply a
+single width selection.
See also Kakoune's Migrating from Vim.
+++ +TODO: Mention texobjects, surround, registers
+
To add a new language, you need to add a language
entry to the
+languages.toml
found in the root of the repository;
+this languages.toml
file is included at compilation time, and is
+distinct from the languages.toml
file in the user's configuration
+directory.
[[language]]
+name = "mylang"
+scope = "scope.mylang"
+injection-regex = "^mylang$"
+file-types = ["mylang", "myl"]
+comment-token = "#"
+indent = { tab-width = 2, unit = " " }
+language-server = { command = "mylang-lsp", args = ["--stdio"] }
+
+These are the available keys and descriptions for the file.
+Key | Description |
---|---|
name | The name of the language |
scope | A string like source.js that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually source.<name> or text.<name> in case of markup languages |
injection-regex | regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential language injection site. |
file-types | The filetypes of the language, for example ["yml", "yaml"] . Extensions and full file names are supported. |
shebangs | The interpreters from the shebang line, for example ["sh", "bash"] |
roots | A set of marker files to look for when trying to find the workspace root. For example Cargo.lock , yarn.lock |
auto-format | Whether to autoformat this language when saving |
diagnostic-severity | Minimal severity of diagnostic for it to be displayed. (Allowed values: Error , Warning , Info , Hint ) |
comment-token | The token to use as a comment-token |
indent | The indent to use. Has sub keys tab-width and unit |
language-server | The Language Server to run. Has sub keys command and args |
config | Language Server configuration |
grammar | The tree-sitter grammar to use (defaults to the value of name ) |
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 docs before creating a pull request.
+When adding a Language Server configuration, be sure to update the
+Language Server Wiki with installation notes.
If a tree-sitter grammar is available for the language, add a new grammar
+entry to languages.toml
.
[[grammar]]
+name = "mylang"
+source = { git = "https://github.com/example/mylang", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
+
+Grammar configuration takes these keys:
+Key | Description |
---|---|
name | The name of the tree-sitter grammar |
source | The method of fetching the grammar - a table with a schema defined below |
Where source
is a table with either these keys when using a grammar from a
+git repository:
Key | Description |
---|---|
git | A git remote URL from which the grammar should be cloned |
rev | The revision (commit hash or tag) which should be fetched |
subpath | A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example tree-sitter-typescript and tree-sitter-ocaml ) in subdirectories. This key is used to point hx --grammar build to the correct path for compilation. When omitted, the root of repository is used |
Or a path
key with an absolute path to a locally available grammar directory.
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
+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 for an example.
+
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
Helix uses tree-sitter to correctly indent new lines. This requires
+a tree-sitter grammar and an indent.scm
query file placed in
+runtime/queries/{language}/indents.scm
. The indentation for a line
+is calculated by traversing the syntax tree from the lowest node at the
+beginning of the new line. Each of these nodes contributes to the total
+indent when it is captured by the query (in what way depends on the name
+of the capture).
Note that it matters where these added indents begin. For example, +multiple indent level increases that start on the same line only increase +the total indent level by 1.
+Added indents don't always apply to the whole node. For example, in most +cases when a node should be indented, we actually only want everything +except for its first line to be indented. For this, there are several +scopes (more scopes may be added in the future if required):
+all
:
+This scope applies to the whole captured node. This is only different from
+tail
when the captured node is the first node on its line.
tail
:
+This scope applies to everything except for the first line of the
+captured node.
Every capture type has a default scope which should do the right thing
+in most situations. When a different scope is required, this can be
+changed by using a #set!
declaration anywhere in the pattern:
(assignment_expression
+ right: (_) @indent
+ (#set! "scope" "all"))
+
+@indent
(default scope tail
):
+Increase the indent level by 1. Multiple occurrences in the same line
+don't stack. If there is at least one @indent
and one @outdent
+capture on the same line, the indent level isn't changed at all.
@outdent
(default scope all
):
+Decrease the indent level by 1. The same rules as for @indent
apply.
In some cases, an S-expression cannot express exactly what pattern should be matched.
+For that, tree-sitter allows for predicates to appear anywhere within a pattern,
+similar to how #set!
declarations work:
(some_kind
+ (child_kind) @indent
+ (#predicate? arg1 arg2 ...)
+)
+
+The number of arguments depends on the predicate that's used.
+Each argument is either a capture (@name
) or a string ("some string"
).
+The following predicates are supported by tree-sitter:
#eq?
/#not-eq?
:
+The first argument (a capture) must/must not be equal to the second argument
+(a capture or a string).
#match?
/#not-match?
:
+The first argument (a capture) must/must not match the regex given in the
+second argument (a string).
Additionally, we support some custom predicates for indent queries:
+#not-kind-eq?
:
+The kind of the first argument (a capture) must not be equal to the second
+argument (a string).
#same-line?
/#not-same-line?
:
+The captures given by the 2 arguments must/must not start on the same line.
This section contains guides for adding new language server configurations, +tree-sitter grammars, textobject queries, etc.
+ +Textobjects that are language specific (like functions, classes, etc)
+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.
Query files should be placed in runtime/queries/{language}/textobjects.scm
+when contributing. Note that to test the query files locally you should put
+them under your local runtime directory (~/.config/helix/runtime
on Linux
+for example).
The following captures are recognized:
+Capture Name |
---|
function.inside |
function.around |
class.inside |
class.around |
parameter.inside |
comment.inside |
comment.around |
Example query files can be found in the helix GitHub repository.
+Tree-sitter based navigation 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.
+function.movement
should be defined only if the node captured by function.around
+doesn't make sense in a navigation context.