aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/indent.rs
Commit message (Collapse)AuthorAge
* Fix precedence order of @align captures in indent computation (#8659)Triton1712023-10-29
| | | precedence when multiple occur on the same line in an indent query.
* Implement @align (and @anchor) indent query.Daniel Ebert2023-08-11
|
* Fix YAML auto indentSkyler Hawthorne2023-08-10
| | | | | | | | | YAML indents queries are tweaked to fix auto indent behavior. A new capture type `indent.always` is introduced to address use cases where combining indent captures on a single line is desired. Fixes #6661
* Allow any indent size from 1 to 16 (#7429)Scott Driggers2023-06-23
|
* Fix indentation level calculation for lines mixing tabs and spaces (#6278)Stanisław Borowy2023-03-12
|
* Replace incorrect usages of tab_width with indent_width. (#5918)Triton1712023-02-16
|
* Fix new clippy lints (#5892)Pascal Kuthe2023-02-09
|
* Fix panic from indenting on tree with errorsMichael Davis2022-11-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `deepest_preceding` is known to be a descendant of `node`. Repeated calls of `Node::parent` _should_ eventually turn `deepest_preceding` into `node`, but when the node is errored (the tree contains a syntax error), `Node::parent` returns None. In the typescript case: if(true) &&true // ^ press enter here The tree is: (program [0, 0] - [1, 0] (if_statement [0, 0] - [0, 15] condition: (parenthesized_expression [0, 2] - [0, 8] (true [0, 3] - [0, 7])) consequence: (expression_statement [0, 8] - [0, 15] (binary_expression [0, 8] - [0, 15] left: (identifier [0, 8] - [0, 8]) right: (true [0, 11] - [0, 15]))))) `node` is the `program` node and `deepest_preceding` is the `binary_expression`. The tree is errored on the `binary_expression` node with `(MISSING identifier [0, 8] - [0, 8])`. In the C++ case: ; << // press enter after the ';' The tree is: (translation_unit [0, 0] - [1, 0] (expression_statement [0, 0] - [0, 1]) (ERROR [0, 1] - [0, 4] (identifier [0, 1] - [0, 1]))) `node` is the `translation_unit` and `deepest_preceding` is the `ERROR` node. In both cases, `Node::parent` on the errored node returns None.
* style: Only call extend_nodes when deepest_preceding is SomeMichael Davis2022-11-09
|
* Rename extend indent captures.Daniel Ebert2022-10-11
| | | | Clarify comments in indent code.
* Slightly change the behavior of the `@stop-extend` capture.Daniel Ebert2022-10-11
| | | | This improves the behavior in case of multiple nested extensions.
* Improve code style for tree-sitter indentation.Daniel Ebert2022-10-11
| | | | Split extend logic into a separate file.
* Fix a bug that caused the indent for the line below to also be added in rare ↵Triton1712022-10-11
| | | | cases at the beginning of a file.
* Fix clippy warning.Triton1712022-10-11
|
* Add `extend-indented` and `stop-extend` captures for indent queries.Triton1712022-10-11
| | | | Improve and re-enable python indent queries.
* Fix cargo doc warnings, and add GitHub action to ensure it (#3650)A-Walrus2022-09-03
|
* Fix some typos (#2978)A-Walrus2022-07-06
|
* Indentation rework (#1562)Triton1712022-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * WIP: Rework indentation system * Add ComplexNode for context-aware indentation (including a proof of concept for assignment statements in rust) * Add switch statements to Go indents.toml (fixes the second half of issue #1523) Remove commented-out code * Migrate all existing indentation queries. Add more options to ComplexNode and use them to improve C/C++ indentation. * Add comments & replace Option<Vec<_>> with Vec<_> * Add more detailed documentation for tree-sitter indentation * Improve code style in indent.rs * Use tree-sitter queries for indentation instead of TOML config. Migrate existing indent queries. * Add documentation for the new indent queries. Change xtask docgen to look for indents.scm instead of indents.toml * Improve code style in indent.rs. Fix an issue with the rust indent query. * Move indentation test sources to separate files. Add `#not-kind-eq?`, `#same-line?` and `#not-same-line` custom predicates. Improve the rust and c indent queries. * Fix indent test. Improve rust indent queries. * Move indentation tests to integration test folder. * Improve code style in indent.rs. Reuse tree-sitter cursors for indentation queries. * Migrate HCL indent query * Replace custom loading in indent tests with a designated languages.toml * Update indent query file name for --health command. * Fix single-space formatting in indent queries. * Add explanation for unwrapping. Co-authored-by: Triton171 <triton0171@gmail.com>
* migrate grammar fetching/building code into helix-loader crateMichael Davis2022-03-10
| | | | | | | | | This is a rather large refactor that moves most of the code for loading, fetching, and building grammars into a new helix-loader module. This works well with the [[grammars]] syntax for languages.toml defined earlier: we only have to depend on the types for GrammarConfiguration in helix-loader and can leave all the [[language]] entries for helix-core.
* add 'use-grammars' to languages.tomlMichael Davis2022-03-10
| | | | | | | | The vision with 'use-grammars' is to allow the long-requested feature of being able to declare your own set of grammars that you would like. A simple schema with only/except grammar names controls the list of grammars that is fetched and built. It does not (yet) control which grammars may be loaded at runtime if they already exist.
* rename tree_sitter_library in LanguageConfig to 'grammar'Michael Davis2022-03-10
| | | | | | | | This is not strictly speaking necessary. tree_sitter_library was used by just one grammar: llvm-mir-yaml, which uses the yaml grammar. This will make the language more consistent, though. Each language can explicitly say that they use Some(grammar), defaulting when None to the grammar that has a grammar_id matching the language's language_id.
* add tree-sitter sources to languages.tomlMichael Davis2022-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | Here we add syntax to the languages.toml languge [[grammar]] name = "<name>" source = { .. } Which can be used to specify a tree-sitter grammar separately of the language that defines it, and we make this distinction for two reasons: * In later commits, we will separate this code from helix-core and bring it to a new helix-loader crate. Using separate schemas for language and grammar configurations allows for a nice divide between the types needed to be declared in helix-loader and in helix-core/syntax * Two different languages may use the same grammar. This is currently the case with llvm-mir-yaml and yaml. We could accomplish a config that works for this with just `[[languages]]`, but it gets a bit dicey with languages depending on one another. If you enable llvm-mir-yaml and disable yaml, does helix still need to fetch and build tree-sitter-yaml? It could be a matter of interpretation.
* Configurable auto pairs (#1624)Skyler Hawthorne2022-02-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * impl auto pairs config Implements configuration for which pairs of tokens get auto completed. In order to help with this, the logic for when *not* to auto complete has been generalized from a specific hardcoded list of characters to simply testing if the next/prev char is alphanumeric. It is possible to configure a global list of pairs as well as at the language level. The language config will take precedence over the global config. * rename AutoPair -> Pair * clean up insert_char command * remove Rc * remove some explicit cloning with another impl * fix lint * review comments * global auto-pairs = false takes precedence over language settings * make clippy happy * print out editor config on startup * move auto pairs accessor into Document * rearrange auto pair doc comment * use pattern in Froms
* Merge remote-tracking branch 'origin/master' into debugBlaž Hrastnik2022-02-13
|\
| * Fix Clippy lints in tests (#1563)Omnikar2022-01-23
| | | | | | Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
| * syntax: Split parsing and highlightingBlaž Hrastnik2022-01-23
| |
| * Add llvm-mir highlighting (#1398)Sebastian Neubauer2022-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add injection regex for more languages To support embedding them in other languages like markdown. * Add llvm-mir highlighting LLVM Machine IR is dumped as yaml files that can embed LLVM IR and Machine IR. To support this, add a llvm-mir-yaml language that uses the yaml parser, but uses different injections to highlight IR and MIR. * Update submodule with fixed multiline comments Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
| * Add basic indentation for languages without treesitter-based indentation ↵Triton1712022-01-03
| | | | | | | | | | | | | | rules (always use the indent of the current line for a new line). (#1341) Fix several bugs in the treesitter indentation calculation. Co-authored-by: Triton171 <triton0171@gmail.com>
| * feat(lsp): configurable diagnostic severity (#1325)Matouš Dzivjak2021-12-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * feat(lsp): configurable diagnostic severity Allow severity of diagnostic messages to be configured. E.g. allow turning of Hint level diagnostics. Fixes: https://github.com/helix-editor/helix/issues/1007 * Use language_config() method * Add documentation for diagnostic_severity * Use unreachable for unknown severity level * fix: documentation for diagnostic_severity config
| * Use same name used in config files for langs in docsGokul Soumya2021-12-08
| |
| * Auto generate docs for language supportGokul Soumya2021-12-08
| |
* | Simplify some cases that use return None to use ?Blaž Hrastnik2021-12-02
| |
* | Merge remote-tracking branch 'origin/master' into debugBlaž Hrastnik2021-11-21
|\|
| * Detect filetype from shebang line (#1001)ath32021-11-08
| |
* | Merge branch 'master' into debugBlaž Hrastnik2021-11-06
|\|
| * Add treesitter textobjects (#728)Gokul Soumya2021-10-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add treesitter textobject queries Only for Go, Python and Rust for now. * Add tree-sitter textobjects Only has functions and class objects as of now. * Fix tests * Add docs for tree-sitter textobjects * Add guide for creating new textobject queries * Add parameter textobject Only parameter.inside is implemented now, parameter.around will probably require custom predicates akin to nvim' `make-range` since we want to select a trailing comma too (a comma will be an anonymous node and matching against them doesn't work similar to named nodes) * Simplify TextObject cell init
* | Merge branch 'master' into debugDmitry Sharshakov2021-09-25
|\|
| * Fix broken testBlaž Hrastnik2021-09-16
| |
| * fix: tree-sitter-scopes would infinitely loopBlaž Hrastnik2021-09-06
| |
* | Fix testsDmitry Sharshakov2021-08-25
| |
* | Fix testsDmitry Sharshakov2021-08-23
|/
* Appease clippyBlaž Hrastnik2021-08-13
|
* Add :tree-sitter-scopes, useful when developing indents.tomlBlaž Hrastnik2021-08-13
|
* Move indent-style code into `helix_core::indent`.Nathan Vegdahl2021-07-30
|
* Fix append newline indentIvan Tham2021-07-26
| | | | Fix #492
* Made toggle_comments language dependent (#463)Cor Peters2021-07-18
| | | | | | | | | | | | | * Made toggle_comments language dependent * Fixed Test Cases * Added clippy suggestion * Small Fixes * Clippy Suggestion Co-authored-by: Cor <prive@corpeters.nl>
* Added option to provide a custom config file to the lsp. (#460)Cor Peters2021-07-18
| | | | | | | | | | | | | | | | | * Added option to provide a custom config file to the lsp. * Simplified lsp loading routine with anyhow * Moved config to language.toml * Fixed test case * Cargo fmt * Revert now-useless changes * Renamed custom_config to config Co-authored-by: Cor <prive@corpeters.nl>
* Dynamically load grammar libraries at runtimeBlaž Hrastnik2021-07-14
|
* Fix all remaining warnings in helix-core except for two.Nathan Vegdahl2021-07-02
| | | | | I'm not sure how to address them, because they look like they might be bugs, and code is involved. Will poke the relevant people.
* Remove #[allow(unused)] from helix-core, and fix unused imports.Nathan Vegdahl2021-07-02
| | | | Still a bunch more warnings to fix in core, but it's a start.