Commit Graph

145 Commits (c6bd105484fbaf35812dddc41b8fb32cb054fc54)

Author SHA1 Message Date
Gokul Soumya 2b0835b295
Refactor :set to parse by deserializing values (#1799)
* Refactor :set to parse by deserializing values

* Implement serialize for idle_timeout config
2 years ago
Michael Davis 7044d7d804 rename '--fetch/build-grammars' flags into '--grammar fetch/build'
The old flags were a bit long. --grammar is also aliased to -g to make
it even easier.
2 years ago
Michael Davis 4fc991fdec migrate grammar fetching/building code into helix-loader crate
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.
2 years ago
Michael Davis 08ee949dcb add 'use-grammars' to languages.toml
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.
2 years ago
Michael Davis db3470d973 ensure rust grammar is available in CI 2 years ago
Michael Davis c1f677ff75 rename tree_sitter_library in LanguageConfig to 'grammar'
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.
2 years ago
Michael Davis eeb3f8e963 migrate helix-syntax crate into helix-core and helix-term
helix-syntax mostly existed for the sake of the build task which
checks and compiles the submodules. Since we won't be relying on
that process anymore, it doesn't end up making much sense to have
a very thin crate just for some functions that we could port to
helix-core.

The remaining build-related code is moved to helix-term which will
be able to provide grammar builds through the --build-grammars CLI
flag.
2 years ago
Michael Davis c1f90a127b add tree-sitter sources to languages.toml
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.
2 years ago
Gokul Soumya 194b09fbc1
Add --health command for troubleshooting (#1669)
* Move runtime file location definitions to core

* Add basic --health command

* Add language specific --health

* Show summary for all langs with bare --health

* Use TsFeature from xtask for --health

* cargo fmt

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Gokul Soumya e83cdf3fd3 Ensure non empty grouped nodes in textobject queries 2 years ago
Gokul Soumya e6c36e82cf Allow capturing multiple nodes in textobject queries
Treesitter captures can contain multiple nodes like so:

```
(line_comment)+ @comment
```

This would match each line in a comment as a separate
`@comment` capture when what we actually want is the
whole set of contiguous `line_comment` nodes to be
captured under the `@comment` capture. This commit enables
this behaviour.
2 years ago
Skyler Hawthorne a494f47a5d
Configurable auto pairs (#1624)
* 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
2 years ago
Gokul Soumya ab2a0f325b Add object.movement for tree-sitter navigation 2 years ago
Blaž Hrastnik bd549d8a20 Merge remote-tracking branch 'origin/master' into debug 2 years ago
Blaž Hrastnik 4080341977 cargo fmt + clippy lint 2 years ago
Blaž Hrastnik 7c9ebd05b8 Remove some TODOs 2 years ago
Blaž Hrastnik 66a8612351 cleanup 2 years ago
Blaž Hrastnik 9d41113ae0 Make Layer::parse take &mut tree_sitter::Parser 2 years ago
Blaž Hrastnik e22dbf102f Use filter_map rather than flat_map 2 years ago
Blaž Hrastnik 2f4a9fea03 Set byte range on cursor again 2 years ago
Blaž Hrastnik 24314bd844 Only call scopes.load() once 2 years ago
Blaž Hrastnik 4b0205f690 Resolve some outdated comments 2 years ago
Blaž Hrastnik 9508684031 fix: Skip modifying the root layer range, it always covers 0..max 2 years ago
Blaž Hrastnik 7315f6f3e4 Update range markers so we can determine which layers can be reused 2 years ago
Blaž Hrastnik 8a53e34e66 Try to reuse an existing layer based on layer.ranges 2 years ago
Blaž Hrastnik 72eb2ce1f1 Ignore layers without highlight captures, avoid cloning ranges 2 years ago
Blaž Hrastnik 5135fa37eb Reuse the source slice between layers 2 years ago
Blaž Hrastnik 53d881f172 Store theme scopes on the loader, this way theme isn't passed around 2 years ago
Blaž Hrastnik 6728e44490 syntax: Split parsing and highlighting 2 years ago
Kevin Sjöberg 3a34036310
Use the correct language ID for JavaScript & TypeScript (#1466)
* Use correct language ID for JavaScript/TypeScript

* Add missing slash

* Only calculate fallback when needed
2 years ago
Sebastian Neubauer 641255ccc8
Add llvm-mir highlighting (#1398)
* 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>
3 years ago
Matouš Dzivjak 0e7d757869
feat(lsp): configurable diagnostic severity (#1325)
* 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
3 years ago
Gokul Soumya d08bdfa838 Use same name used in config files for langs in docs 3 years ago
Gokul Soumya a78b789406 Auto generate docs for language support 3 years ago
ath3 70c62530ee
Support env flags in shebang (#1224) 3 years ago
Blaž Hrastnik 2dbf966293 dap: Start working on runInTerminal support 3 years ago
Blaž Hrastnik d1854d8e6a Merge remote-tracking branch 'origin/master' into debug 3 years ago
Omnikar a424ef4e20
Use default `languages.toml` if user's is invalid (#994) 3 years ago
Blaž Hrastnik f804ed3192 Make shebangs optional, they don't make sense outside of scripts 3 years ago
Blaž Hrastnik 549cdee561 Refactor shebang detection to reuse the loaded buffer 3 years ago
ath3 77dbbc73f9
Detect filetype from shebang line (#1001) 3 years ago
Blaž Hrastnik f2b709a3c3 Merge branch 'master' into debug 3 years ago
Gygaxis Vainhardt 0a38983ee3
Remove three transmutes from helix-core syntax.rs (#923) 3 years ago
Dmitry Sharshakov 6aa9838ea6
dap: support arrays as arguments 3 years ago
Kirawi 0cb5e0b2ca
log syntax highlighting init errors (#895) 3 years ago
Gokul Soumya 4ee92cad19
Add treesitter textobjects (#728)
* 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
3 years ago
Michael Davis 1766bdb9d4
clean up combined-injections comment (#880) 3 years ago
Blaž Hrastnik 83a8167402 Invert core -> dap dependency 3 years ago
Blaž Hrastnik 0a6b60085a Merge branch 'master' into debug 3 years ago
Midnight Exigent eedcea7e6b
Allow `language.config` (in languages.toml) to be passed in as a toml object (#807)
* 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
3 years ago