The update to the grammar itself covers the case where the document
is a single expression without a trailing newline such as "min(A, B)".
A small change to the parser now parses these expressions correctly
which improves the display of the function head in the signature
help popup.
The update to the queries marks 'andalso', 'orelse', 'not', etc. as
`@keyword.operator` which improves the look - it looks odd to see
operators that are words highlighted the same as tokens like '->'
or '=:='.
* str, list, etc. handled as @function.builtin and @type.builtin
* None and non-conforming type indentifiers as @type in type hints
* class identifiers treated as @type
* @constructor used for constructor definitions and calls rather than
as a catch-all for type-like things
* Parameters highlighted
* self and cls as @variable.builtin
* improved decorator highlighting as part of @function
Re-ordering of some statements to give more accurate priority.
* log textobject query construction errors
The current behavior is that invalid queries are discarded silently
which makes it difficult to debug invalid textobjects (either invalid
syntax or an update may have come through that changed the valid set
of nodes).
* fix golang textobject query
`method_spec_list` used to be a named node but was removed (I think
for Helix, it was when updated to pull in the support for generics).
Instead of a named node for the list of method specs we have a bunch
of `method_spec` children nodes now. We can match on the set of them
with a `+` wildcard.
Example go for this query:
type Shape interface {
area() float64
perimeter() float64
}
Which is parsed as:
(source_file
(type_declaration
(type_spec
name: (type_identifier)
type: (interface_type
(method_spec
name: (field_identifier)
parameters: (parameter_list)
result: (type_identifier))
(method_spec
name: (field_identifier)
parameters: (parameter_list)
result: (type_identifier))))))
HEEx is a templating engine on top of Elixir's EEx templating
language specific to HTML that is included in Phoenix.LiveView
(though I think the plan is to eventually include it in base
Phoenix). It's a superset of EEx with some additional features
like components and slots.
The injections don't work perfectly because the Elixir grammar is
newline sensitive (the _terminator rule). See
https://github.com/elixir-lang/tree-sitter-elixir/issues/24
for more information.
This will become more important with the HEEx grammar being added.
Error highlighting with the Elixir grammar is a bit jumpy because
in some scenarios, a bit of missing syntax can force tree-sitter to
give up on error recovery and mark the entire tree as an error.
This ends up looking bad when editing. We don't typically highlight
error nodes so I'm inclined to leave it out of the highlights here.
After the incremental parsing rewrite for injections (which was released
in 22.03 https://helix-editor.com/news/release-22-03-highlights/#incremental-injection-parsing-rewrite),
we can now do combined injections which lets us pull in some templating
grammars. The most notable of those is embedded-template - a pretty
straightforward grammar that covers ERB and EJS.
The grammar and highlights queries are shared between the two but they have
different injections.
It looks like a24fb17b2a (and
855e438f55) broke the typescript
highlights because typescript
; inherits: javascript
but it doesn't have those named nodes in its grammar.
So instead we can separate out JSX into its own language and copy
over everything from javascript and supplement it with the new
JSX highlights. Luckily there isn't too much duplication, just the
language configuration parts - we can re-use the parser with the
languages.toml `grammar` key and most of the queries with `inherits`.
* 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>
news:
- tree-sitter-elixir now powers Elixir syntax highlighting on github.com
- GitHub now supports code-navigation for Elixir repos via
tree-sitter-elixir
changes:
- modules now use the `@module` highlight, which was added upstream to
tree-sitter
- it seems appropriate to use `@namespace` to follow helix convention
- added nullary range operator (e.g. `Enum.to_list(..) == []`), a new syntax
for elixir 1.14
- a fix for stab clause nodes mis-highlighting when the right hand side of
the stab clause contained multiple simple expressions
changes:
- typed fields within records which do not declare a default
value are now correctly highlighted as record fields
- the EEP49 'maybe' form is now parsed
- fixes for highlights for 'begin' and 'after' tokens
changes:
- any text following a (scissors) is now contained in one (message)
- this vastly improves performance on large verbose commits:
no more slowness on huge commits
* Add kotlin language
Queries taken from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/kotlin seem to work well enough for my needs though I don't use kotlin heavily.
* Update lang-support doc
* Updates the kotlin highlight query to use helixs scopes
* Updates the queries from PR feedback
* Adds 'shallow = true' to gitmodules
* Removes kotlin locals.scm
* Remove blank line
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Add tree-sitter-twig grammer and highlights
The gammar itself is quite basic, but is much better than nothing
for working with real files consisting mostly of html.
* Docgen for newly added grammar
* Add Graphql language support
* Fix docs gen
* Add JS Graphql injection query
* Updates based on PR feedback
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* tree sitter comments injections
* trailing newlines & julia fix
* Update runtime/queries/julia/injections.scm
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
* Add experimental tree-sitter-lean
* Run docgen
* Copy over the queries from lean.nvim
* Update .gitmodules
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Update lean highlights and run docgen
* Update runtime/queries/lean/injections.scm
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
* Lean: Move variable matcher to bottom
* Update runtime/queries/lean/locals.scm
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
* add tree-sitter-regex
* adapt regex highlights from upstream
* inject regex into elixir sigil_r/2 and sigil_R/2
* generate lang-support docs
* capture interesting nodes in character-ranges
* make $.character_class captures more consistent
* fix fallthrough behavior for character classes
* capture pattern characters as 'string'
* use latest tree-sitter-regex
* set elixir regex injections as combined
* add link to upstream queries
* inject regex in rust into 'Regex::new' raw string literals
Indentation of single line statements doesn't work, i.e.
for (;;)<hit enter>
leads to
for(;;)
<cursor here>
Only blocks with curly braces are indented.
* 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 a tree-sitter grammar and highlights for TableGen files.
TableGen and its grammar are described here:
https://llvm.org/docs/TableGen/index.html
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* add submodule on tree-sitter-rebase, add to languages
* add basic highlights query
* inject bash in execute statements
* update tree-sitter-rebase
* tree-sitter-rebase->tree-sitter-git-rebase
* get injection working with tree-sitter-git-commit
* set scope under source.gitrebase
* unset include-children on commit message injections
* Revert "unset include-children on commit message injections"
This reverts commit 2ecee155ea8e229651920b291062c2ee84b47944.
* fix generated language docs
* use rebase_command scopes from tree-sitter-git-commit
* add submodule on tree-sitter-git-diff
* add git-diff highlights
* inject git-diff into git-commit
* update tree-sitter-git-commit with fix for bad diff case
* add git-diff to language support docs
* include-children in diff injections
This ensures that children nodes of $.message are included in the
injection, such as $.user or issue/pr numbers. Without this change,
diffs containing '#' or '@' characters can trip up the injection and
be parsed separately.
See https://github.com/helix-editor/helix/pull/1373#issuecomment-1001215629
* set diff language's scope as source.diff
* Improve llvm highlighting and queries
The llvm tree-sitter parser was updated to support scopes and more
accurate highlighting.
* Group highlight expressions better
- Differentiates between `as` keyword as a binary type cast
operator and import renamer.
- `mod` and `use` are now under `@keyword.control.import`,
but `mod` is a `@keyword` if used as `mod name;`.
* allow language.config (in languages.toml) to be passed in as a toml object
* Change config field for languages from json string to toml object
* remove indents on languages.toml config
* fix: remove patch version from serde_json import in helix-core
* Use same tree-sitter-zig as upstream/master
* fix(completion_popup): Fixes#1256
* Update helix-term/src/ui/completion.rs
* feat(languages): Add support for `Dockerfile`s
* docs(cargo-xtask-docgen):
* improvement(langs-dockerfile): Add `injection-regex` to `languages.toml` for
`Dockerfile`
* improvement(langs-dockerfile): Add injections.scm
* Update .gitmodules
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
- Rename markup.underline.link to markup.link.url
- Add markup.link.label
- Add markup.quote
(The constructor theme scope was missing from the
docs, so unrelated to this commit).
* Add language: dart
The setup requires that dart be in the users path, such as:
```
export PATH="$HOME/Android/flutter/bin/cache/dart-sdk/bin/:$PATH"
```
Refactor the dart highlights
* lang: dart: add indents and locals
* lang: dart: corrections to local scope
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* 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
* add submodule on tree-sitter/tree-sitter-tsq
mark tsq submodule as shallow
* add tree-sitter-tsq to languages
* add highlight queries for tsq
* Update .gitmodules
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Can't do it via a scm query nicely because it returns an iterator over
all the matches, whereas we want to traverse the tree ourselves.
Can't extract the pattern data from a parsed query either.
Oh well, toml files for now.