Skip to content

Commit

Permalink
Merge branch 'master' into md/lsp-show-document
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Jan 17, 2024
2 parents f7cd43c + dcdecaa commit 7ccc16c
Show file tree
Hide file tree
Showing 32 changed files with 757 additions and 315 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cachix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
uses: actions/checkout@v4

- name: Install nix
uses: cachix/install-nix-action@v24
uses: cachix/install-nix-action@v25

- name: Authenticate with Cachix
uses: cachix/cachix-action@v13
uses: cachix/cachix-action@v14
with:
name: helix
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
Expand Down
2 changes: 0 additions & 2 deletions .ignore

This file was deleted.

75 changes: 38 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package.helix-tui.opt-level = 2
package.helix-term.opt-level = 2

[workspace.dependencies]
tree-sitter = { version = "0.20", git = "https://github.com/tree-sitter/tree-sitter", rev = "ab09ae20d640711174b8da8a654f6b3dec93da1a" }
tree-sitter = { version = "0.20", git = "https://github.com/helix-editor/tree-sitter", rev = "660481dbf71413eba5a928b0b0ab8da50c1109e0" }
nucleo = "0.2.0"

[workspace.package]
Expand Down
6 changes: 5 additions & 1 deletion book/src/guides/indent.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ The first argument (a capture) must/must not be equal to the second argument
The first argument (a capture) must/must not match the regex given in the
second argument (a string).

- `#any-of?`/`#not-any-of?`:
The first argument (a capture) must/must not be one of the other arguments
(strings).

Additionally, we support some custom predicates for indent queries:

- `#not-kind-eq?`:
Expand Down Expand Up @@ -366,4 +370,4 @@ Everything up to and including the closing brace gets an indent level of 1.
Then, on the closing brace, we encounter an outdent with a scope of "all", which
means the first line is included, and the indent level is cancelled out on this
line. (Note these scopes are the defaults for `@indent` and `@outdent`—they are
written explicitly for demonstration.)
written explicitly for demonstration.)
3 changes: 3 additions & 0 deletions book/src/guides/injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ The first argument (a capture) must be equal to the second argument
The first argument (a capture) must match the regex given in the
second argument (a string).

- `#any-of?` (standard):
The first argument (a capture) must be one of the other arguments (strings).

[upstream-docs]: http://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
4 changes: 2 additions & 2 deletions book/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ RUSTFLAGS="-C target-feature=-crt-static"

#### Linux and macOS

The **runtime** directory is one below the Helix source, so either set a
The **runtime** directory is one below the Helix source, so either export a
`HELIX_RUNTIME` environment variable to point to that directory and add it to
your `~/.bashrc` or equivalent:

```sh
HELIX_RUNTIME=~/src/helix/runtime
export HELIX_RUNTIME=~/src/helix/runtime
```

Or, create a symbolic link:
Expand Down
12 changes: 11 additions & 1 deletion grammars.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@
owner = builtins.elemAt match 0;
repo = builtins.elemAt match 1;
};
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
# If `use-grammars.only` is set, use only those grammars.
# If `use-grammars.except` is set, use all other grammars.
# Otherwise use all grammars.
useGrammar = grammar:
if languagesConfig?use-grammars.only then
builtins.elem grammar.name languagesConfig.use-grammars.only
else if languagesConfig?use-grammars.except then
!(builtins.elem grammar.name languagesConfig.use-grammars.except)
else true;
grammarsToUse = builtins.filter useGrammar languagesConfig.grammar;
gitGrammars = builtins.filter isGitGrammar grammarsToUse;
buildGrammar = grammar: let
gh = toGitHubFetcher grammar.source.git;
sourceGit = builtins.fetchTree {
Expand Down
3 changes: 2 additions & 1 deletion helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ integration = []
helix-loader = { path = "../helix-loader" }

ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
smallvec = "1.11"
smallvec = "1.12"
smartstring = "1.0.1"
unicode-segmentation = "1.10"
unicode-width = "0.1"
Expand Down Expand Up @@ -55,3 +55,4 @@ parking_lot = "0.12"
[dev-dependencies]
quickcheck = { version = "1", default-features = false }
indoc = "2.0.4"
tempfile = "3.9"
2 changes: 1 addition & 1 deletion helix-core/src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ fn query_indents<'a>(
// The row/column position of the optional anchor in this query
let mut anchor: Option<tree_sitter::Node> = None;
for capture in m.captures {
let capture_name = query.capture_names()[capture.index as usize].as_str();
let capture_name = query.capture_names()[capture.index as usize];
let capture_type = match capture_name {
"indent" => IndentCaptureType::Indent,
"indent.always" => IndentCaptureType::IndentAlways,
Expand Down
14 changes: 11 additions & 3 deletions helix-core/src/match_brackets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn find_pair(
let tree = syntax.tree();
let pos = doc.char_to_byte(pos_);

let mut node = tree.root_node().descendant_for_byte_range(pos, pos)?;
let mut node = tree.root_node().descendant_for_byte_range(pos, pos + 1)?;

loop {
if node.is_named() {
Expand Down Expand Up @@ -118,7 +118,9 @@ fn find_pair(
};
node = parent;
}
let node = tree.root_node().named_descendant_for_byte_range(pos, pos)?;
let node = tree
.root_node()
.named_descendant_for_byte_range(pos, pos + 1)?;
if node.child_count() != 0 {
return None;
}
Expand All @@ -141,7 +143,7 @@ fn find_pair(
#[must_use]
pub fn find_matching_bracket_plaintext(doc: RopeSlice, cursor_pos: usize) -> Option<usize> {
// Don't do anything when the cursor is not on top of a bracket.
let bracket = doc.char(cursor_pos);
let bracket = doc.get_char(cursor_pos)?;
if !is_valid_bracket(bracket) {
return None;
}
Expand Down Expand Up @@ -265,6 +267,12 @@ fn as_char(doc: RopeSlice, node: &Node) -> Option<(usize, char)> {
mod tests {
use super::*;

#[test]
fn find_matching_bracket_empty_file() {
let actual = find_matching_bracket_plaintext("".into(), 0);
assert_eq!(actual, None);
}

#[test]
fn test_find_matching_bracket_current_line_plaintext() {
let assert = |input: &str, pos, expected| {
Expand Down
Loading

0 comments on commit 7ccc16c

Please sign in to comment.