Commit Graph

976 Commits (aca1b0e2f06e0f1b2e14c2e90b92745bccd379c9)

Author SHA1 Message Date
Nik Revenco aca1b0e2f0 chore: Do not expose `Syntax.inner` and `Document.syn_loader`
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-06-17 15:05:37 +01:00
Nik Revenco bdd953e5b1 chore: Use `&[T]` instead of `&Vec<T>`
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-06-17 15:05:37 +01:00
Nik Revenco a2841103a1 style: `cargo fmt` 2025-06-17 12:04:20 +01:00
Nik Revenco f8d1f943e8 Merge branch 'master' into determine-comment-tokens 2025-06-17 11:33:54 +01:00
Pascal Kuthe 205e7ece70
update imara-diff (#13722) 2025-06-14 16:14:27 -04:00
Michael Davis f4b488e380
Remove unused `helix_core::graphemes::is_grapheme_boundary`
This function was never used and will be superseded by
`RopeSliceExt::is_grapheme_boundary` (which accepts a byte index rather
than a character index) once we transition to Ropey v2. In the meantime
any callers should convert to byte index and use the `RopeSliceExt`
extension rather than form new dependencies on this.
2025-06-06 18:24:44 -04:00
Michael Davis 7410fe35a3
Update tree-house and bindings to v0.2.0 2025-06-06 17:14:08 -04:00
Michael Davis b1f4717356
Allow multiple `#not-kind-eq?` predicates in indent queries
This fixes a regression from the switch to tree-house with one of the
custom predicates in indent queries: `#not-kind-eq?`. This predicate
should be allowed to be written multiple times in a pattern. For example
in the Go indents:

    ; Switches and selects aren't indented, only their case bodies are.
    ; Outdent all closing braces except those closing switches or selects.
    (
        (_ "}" @outdent) @outer
        (#not-kind-eq? @outer "select_statement")
        (#not-kind-eq? @outer "type_switch_statement")
        (#not-kind-eq? @outer "expression_switch_statement")
    )

So instead of an `Option<T>` of one we need a `Vec<T>` and we need to
check that all of these predicates are individually satisfied (basically
`iter().all(/* node kind is not expected kind for that capture */)`).
2025-06-06 12:14:43 -04:00
Michael Davis 8961ae1dc6
Consistently use `helix_core::config::default_{lang,config}_loader`
This avoids using any custom configuration in a user-defined
`languages.toml` config for the syntax test cases. The test cases should
only use the builtin `languages.toml` config.

Also the xtask crate reimplemented `default_lang_loader` and
`default_lang_config`. These functions are replaced with calls into
`helix_core`.
2025-05-29 09:55:26 -04:00
Nik Revenco 76687f5389 refactor: Rename varibles + Remove accidentally commited files 2025-05-25 00:57:00 +01:00
Michael Davis 5a1dcc2429
syntax: Reset query cursor byte range for textobjects
`InactiveQueryCursor::new` might reuse a query cursor from a
thread-local cache if one is available, rather than create a new cursor.
Currently tree-house does not reset cached cursors back to defaults
(i.e. byte range and match limit). For now we can patch around this here
but eventually this should be fixed in `tree-house` upstream. Then this
patch can be reverted.

In practice this caused textobjects like `]f` to get "stuck" trying to
move to the next function if it was out of the current view. This is
because the highlight query cursor sets the range of the cursor to the
current viewport. We can reset the byte range to defaults to fix the
textobject behavior.
2025-05-17 10:30:30 -04:00
Nik Revenco c7dd5c1ad9 chore: move comment to a doc comment 2025-05-15 17:18:59 +01:00
Nik Revenco 600bdae69f chore: update to new version of my PR to tree-sitter 2025-05-15 17:18:13 +01:00
Michael Davis 09bc67ad6d
syntax: Fix language detection by shebang
The switch to tree-house accidentally dropped some shebang parsing code
from the loader's function to detect by shebang. This change restores
that. The new code is slightly different as it's using a `regex_cursor`
regex on the Rope rather than eagerly converting the text to a
`Cow<str>` and running a regular regex across it.
2025-05-14 16:30:29 -04:00
Nik Revenco f07e6973fe fix: do not consider languages that do not have comment tokens 2025-05-14 19:41:18 +01:00
Nik Revenco 77a74feb24 feat: solve merge conflicts and make tests more modular 2025-05-14 18:33:05 +01:00
Nik Revenco d0ca96c566 Merge branch 'master' into determine-comment-tokens 2025-05-14 17:07:54 +01:00
Michael Davis aea53523dd
Replace tree-sitter with tree-house 2025-05-13 18:43:43 -04:00
Michael Davis 24e3ccc31b
Add the `syn_loader` to `Document`
This type also exists on `Editor`. This change brings it to the
`Document` as well because the replacement for `Syntax` in the child
commits will eliminate `Syntax`'s copy of `syn_loader`. `Syntax` will
also be responsible for returning the highlighter and query iterators
(which will borrow the loader), so the loader must be separated from
that type.

In the long run, when we make a larger refactor to have
`Document::apply` be a function of the `Editor` instead of the
`Document`, we will be able to drop this field on `Document` - it is
currently only necessary for `Document::apply`. Once we make that
refactor, we will be able to eliminate the surrounding `Arc` in
`Arc<ArcSwap<syntax::Loader>>` and use the `ArcSwap` directly instead.
2025-05-13 18:30:21 -04:00
Michael Davis c94fde8d1c
syntax: Move config types to a separate module 2025-05-13 18:30:21 -04:00
dependabot[bot] 447a6d3299
build(deps): bump the rust-dependencies group with 6 updates (#13518)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-13 08:26:46 -05:00
Joffrey Bluthé 949d9e4433
feat: give formatters access to filename (#13429)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-04-28 17:34:05 -05:00
dependabot[bot] 5d16aae58e
build(deps): bump the rust-dependencies group across 1 directory with 5 updates (#13301)
Bumps the rust-dependencies group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [smallvec](https://github.com/servo/rust-smallvec) | `1.14.0` | `1.15.0` |
| [tokio](https://github.com/tokio-rs/tokio) | `1.44.1` | `1.44.2` |
| [rustix](https://github.com/bytecodealliance/rustix) | `1.0.3` | `1.0.5` |
| [indexmap](https://github.com/indexmap-rs/indexmap) | `2.8.0` | `2.9.0` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.17` | `1.2.18` |



Updates `smallvec` from 1.14.0 to 1.15.0
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.14.0...v1.15.0)

Updates `tokio` from 1.44.1 to 1.44.2
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.44.1...tokio-1.44.2)

Updates `rustix` from 1.0.3 to 1.0.5
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Changelog](https://github.com/bytecodealliance/rustix/blob/main/CHANGES.md)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v1.0.3...v1.0.5)

Updates `indexmap` from 2.8.0 to 2.9.0
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/main/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.8.0...2.9.0)

Updates `cc` from 1.2.17 to 1.2.18
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.17...cc-v1.2.18)

---
updated-dependencies:
- dependency-name: smallvec
  dependency-version: 1.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: tokio
  dependency-version: 1.44.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: rustix
  dependency-version: 1.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: indexmap
  dependency-version: 2.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: cc
  dependency-version: 1.2.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-07 21:33:46 -05:00
Rolo 5b72b59448 perf: use `next_back` on `DoubleEndedIterator` 2025-04-06 12:03:14 -05:00
Nikita Revenco f18a2d7c5a refactor: do not use pointless assertion 2025-03-25 14:41:27 +00:00
Nikita Revenco a07819b497 refactor: remove `pub`, use a getter instead 2025-03-25 14:41:27 +00:00
Nikita Revenco ec94fbdf3b refactor: collapse 2 `map` intoa a single `map` 2025-03-25 14:41:27 +00:00
Nikita Revenco 18aaf93da0 chore: remove Clone derive from Syntax 2025-03-25 14:41:27 +00:00
Nikita Revenco c72755437a feat: continue comment uses injected comment tokens 2025-03-25 14:41:27 +00:00
Nikita Revenco 37f8cbed3c feat: upgrade `tree-sitter-injection` to show injections for entire file 2025-03-25 14:41:27 +00:00
Nikita Revenco 56dedd10a7 fix: add `regex` to ignored layer configs 2025-03-25 14:41:27 +00:00
Nikita Revenco d451077978 feat: add typable command to get injection layer for current range 2025-03-25 14:41:27 +00:00
Nikita Revenco 99d16170dc fix: commenting full lines 2025-03-25 14:41:27 +00:00
Nikita Revenco e9683381b6 refactor: extract a separate toggle_comment_impl function 2025-03-25 14:41:27 +00:00
Nikita Revenco 093805b62c perf: get rid of a `.clone()` 2025-03-25 14:41:27 +00:00
Nikita Revenco 63fb49c1b4 chore: clean up code
chore: remove comment
2025-03-25 14:41:27 +00:00
Nikita Revenco 13b52e9d97 refactor: rename variables ,use iterator methods, separate vars for added and removed chars 2025-03-25 14:41:27 +00:00
Nikita Revenco 7a39fb8164 refactor: rename variable 2025-03-25 14:41:27 +00:00
Nikita Revenco bbd7cb7bfb fix: incorrect order of index additions 2025-03-25 14:41:27 +00:00
Nikita Revenco 76b3e6778d chore: remove log statement 2025-03-25 14:41:27 +00:00
Nikita Revenco 31e2f739ee fix: panic as no ranges were inserted 2025-03-25 14:41:27 +00:00
Nikita Revenco b94d3a70e7 fix: multiple selections having incorrect range and not properly accounting for comment tokens 2025-03-25 14:41:27 +00:00
Nikita Revenco 0a882107ed fix: restore selections when created comment 2025-03-25 14:41:27 +00:00
Nikita Revenco de7884c7dd test: uncomment previosly skipped tests 2025-03-25 14:41:27 +00:00
Nikita Revenco 371dec3774 feat: block comment toggle and single line comment toggle 2025-03-25 14:41:27 +00:00
Nikita Revenco 544e460ac4 feat: implement toggle comment funcitonality for multiple comment tokens 2025-03-25 14:41:27 +00:00
Nikita Revenco 29e0a00eb0 feat: implement toggle comment for the simplest case 2025-03-25 14:41:27 +00:00
Nikita Revenco d719f1572b feat: gain access to injection-specific line and block comment tokens 2025-03-25 14:41:27 +00:00
Nikita Revenco b10fc21169 chore: clean up code 2025-03-25 14:41:27 +00:00
Nikita Revenco 8fe3f90cbb feat: use FnMut 2025-03-25 14:41:27 +00:00