Commit Graph

688 Commits (main)

Author SHA1 Message Date
Alexis Mousset 83ac53a109
Fix various typos (#8233) 8 months ago
Pascal Kuthe e6cdc5f9d3
Don't use word splitting during fuzzy matching (#8192) 9 months ago
Pascal Kuthe 0cb595e226
transition to nucleo for fuzzy matching (#7814)
* transition to nucleo for fuzzy matching

* drop flakey test case

since the picker streams in results now any test that relies
on the picker containing results is potentially flakely

* use crates.io version of nucleo

* Fix typo in commands.rs

Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>

---------

Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>
9 months ago
nkitsaini 22f4f313f1
Remove unnecessary `Err` from `get_canonicalized_path` (#8009)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
9 months ago
Michael Davis 01a1e5ec2a
Update tree-sitter to latest master (#7998) 9 months ago
Dillard Robertson 01776e6851
Prevent GraphemeStrs created from Strings from leaking (#7920) 9 months ago
Daniel Ebert eab0d4fa4b Implement @align (and @anchor) indent query. 9 months ago
Skyler Hawthorne 7078e84007 Fix YAML auto indent
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
9 months ago
Skyler Hawthorne 93acb53812 add node boundary movement 10 months ago
Michael Davis baceb02a09 Use refactored Registers type
This is an unfortunately noisy change: we need to update virtually all
callsites that access the registers. For reads this means passing in the
Editor and for writes this means handling potential failure when we
can't write to a clipboard register.
10 months ago
Michael Davis da2afe7353 Add '#' and '.' special registers
These come from Kakoune:

* '#' is the selection index register. It's read-only and produces the
  selection index numbers, 1-indexed.
* '.' is the selection contents register. It is also read-only and
  mirrors the contents of the current selections when read.

We switch the iterators returned from Selection's `fragments` and
`slices` methods to ExactSizeIterators because:

* The selection contents register can simply return the fragments
  iterator.
* ExactSizeIterator is already implemented for iterators over Vecs, so
  it's essentially free.
* The `len` method can be useful on its own.
10 months ago
Philipp Mildenberger 8a28f30593
Reformat with nightly rustfmt for better let-else formatting (#7721) 10 months ago
Michael Davis 98ef05d768 Prefer RopeSlice to &Rope in helix_core::syntax
Pascal and I discussed this and we think it's generally better to
take a 'RopeSlice' rather than a '&Rope'. The code block rendering
function in the markdown component module is a good example for how
this can be useful: we can remove an allocation of a rope and instead
directly turn a '&str' into a 'RopeSlice' which is very cheap.

A change to prefer 'RopeSlice' to '&Rope' whenever the rope isn't
modified would be nice, but it would be a very large diff (around 500+
500-). Starting off with just the syntax functions seems like a nice
middle-ground, and we can remove a Rope allocation because of it.

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
10 months ago
Pascal Kuthe 68a98ac36b use a single query for injections
In the past we used two separate queries for combined and normal injections. There was no real reason for this (except historical/slightly easier implementation). Instead, we now use a single query and simply check if an injection corresponds to a combined injection or not.
10 months ago
Pascal Kuthe 2d5ff9ec8f fix crash when encountering overlapping injections 10 months ago
Yomain 8afc0282f2
Fix crash when cwd is deleted (#7185) 10 months ago
Pascal Kuthe 1adb19464f
search buffer contents during global search (#5652) 10 months ago
Pascal Kuthe 4a2337d828
correctly map unsorted positions (#7471)
* correctly map unsorted positions

* Fix typo

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
11 months ago
Pascal Kuthe b33516fb16 move normalize fastpath into normalize function 11 months ago
Pascal Kuthe d491e234f4 map positions through changes in O(N) 11 months ago
Scott Driggers 93ac706844
Allow any indent size from 1 to 16 (#7429) 11 months ago
Pascal Kuthe a0359f7f22 make TS matching fallback to plaintext 11 months ago
Pascal Kuthe 5dba649d81 Avoid false positives in non-fuzzy bracket match 11 months ago
Pascal Kuthe 37058e0401 match pairs which don't form a standalone TS node 11 months ago
A-Walrus eb81cf3c01
Fix tree sitter chunking (#7417)
Call as bytes before slicing, that way you can take bytes that aren't
aligned to chars. Should technically also be slightly faster since you
don't have to check alignment...
11 months ago
Alex 3fb9fafb2a
Add config for default line ending (#5621) 11 months ago
A-Walrus a4a86120e8
Fix next/prev tree-sitter inconsistency (#7332)
* Fix next/prev tree-sitter inconsistency

Before there where different results going to next or previous due to
sorting not dealing with multiple captures that start/end at the same
pos. I chose to prefer longer matches.

* Revert unnecessary change
11 months ago
vwkd 352d1574a6
add move_prev_long_word_end and extend_prev_long_word_end (#6905) 12 months ago
Ilya Sovtsov 77e9a22aff
Add check for a non-zero value for tab width (#7178) 12 months ago
Alex Vinyals a2b8cfdb8c
feat(core): add plaintext matching fallback to tree-sitter matching (#4288) 12 months ago
Ikko Eltociear Ashimine 349e2b5f0e
Fix typo in syntax.rs (#7114)
seperator -> separator
12 months ago
Szabin 70e4cdbd8e
Add command to merge non-consecutive ranges (#7053)
* Add command for merging non-consecutive ranges

* Add `merge_selections` command to book

* Simplify `merge_ranges`

Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.

* Clarify doc comment of `merge_ranges`
1 year ago
Philipp Mildenberger 2eeac10755 Refactor doc language servers to a HashMap, and the config to use a Vec to retain order 1 year ago
Philipp Mildenberger ec2f9091a0 Simplify Display implementation for LanguageServerFeature 1 year ago
Philipp Mildenberger 76b5cab524 Refactored doc.language_servers and doc.language_servers_with_feature to return an iterator and refactor LanguageServerFeature handling to a HashMap (language server name maps to features)
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
1 year ago
Philipp Mildenberger 19f88fc577 Simplify Display implementation of LanguageServerFeature
Co-authored-by: Ivan Tham <pickfire@riseup.net>
1 year ago
Philipp Mildenberger 71551d395b Adds support for multiple language servers per language.
Language Servers are now configured in a separate table in `languages.toml`:

```toml
[langauge-server.mylang-lsp]
command = "mylang-lsp"
args = ["--stdio"]
config = { provideFormatter = true }

[language-server.efm-lsp-prettier]
command = "efm-langserver"

[language-server.efm-lsp-prettier.config]
documentFormatting = true
languages = { typescript = [ { formatCommand ="prettier --stdin-filepath ${INPUT}", formatStdin = true } ] }
```

The language server for a language is configured like this (`typescript-language-server` is configured by default):

```toml
[[language]]
name = "typescript"
language-servers = [ { name = "efm-lsp-prettier", only-features = [ "format" ] }, "typescript-language-server" ]
```

or equivalent:

```toml
[[language]]
name = "typescript"
language-servers = [ { name = "typescript-language-server", except-features = [ "format" ] }, "efm-lsp-prettier" ]
```

Each requested LSP feature is priorized in the order of the `language-servers` array.
For example the first `goto-definition` supported language server (in this case `typescript-language-server`) will be taken for the relevant LSP request (command `goto_definition`).

If no `except-features` or `only-features` is given all features for the language server are enabled, as long as the language server supports these. If it doesn't the next language server which supports the feature is tried.

The list of supported features are:

- `format`
- `goto-definition`
- `goto-declaration`
- `goto-type-definition`
- `goto-reference`
- `goto-implementation`
- `signature-help`
- `hover`
- `document-highlight`
- `completion`
- `code-action`
- `workspace-command`
- `document-symbols`
- `workspace-symbols`
- `diagnostics`
- `rename-symbol`
- `inlay-hints`

Another side-effect/difference that comes with this PR, is that only one language server instance is started if different languages use the same language server.
1 year ago
Pascal Kuthe b0705337be automatically disable TS when parsing takes longer than 500ms 1 year ago
Pascal Kuthe 25d4ebe30d don't move cursor while forward deleting in append mode
Currently, when forward deleting (`delete_char_forward` bound to `del`,
`delete_word_forward`, `kill_to_line_end`) the cursor is moved to the
left in append mode (or generally when the cursor is at the end of the
selection). For example in a document `|abc|def`  (|indicates selection)
if enter append mode the cursor is moved to `c` and the selection
becomes: `|abcd|ef`. When deleting forward (`del`) `d` is deleted. The
expectation would be that the selection doesn't shrink so that `del`
again deletes `e` and then `f`. This would look as follows:

`|abcd|ef`
`|abce|f`
`|abcf|`
`|abc |`

This is inline with how other editors like kakoune work.
However, helix currently moves the selection backwards leading to the
following behavior:

`|abcd|ef`
`|abc|ef`
`|ab|ef`
`ef`

This means that `delete_char_forward` essentially acts like
`delete_char_backward` after deleting the first character in append
mode.

To fix the problem the cursor must be moved to the right while deleting
forward (first fix in this commit). Furthermore, when the EOF char is
reached a newline char must be inserted (just like when entering
appendmode) to prevent the cursor from moving to the right
1 year ago
Pascal Kuthe f8225ed921 fix panic when deleting overlapping ranges
Some deletion operations (especially those that use indentation)
can generate overlapping deletion ranges when using multiple cursors.
To fix that problem a new `Transaction::delete` and
`Transaction:delete_by_selection` function were added. These functions
merge overlapping deletion ranges instead of generating an invalid
transaction. This merging of changes is only possible for deletions
and not for other changes and therefore require its own function.

The function has been used in all commands that currently delete
text by using `Transaction::change_by_selection`.
1 year ago
ZJPzjp 3b8c15618f
Fix warnings from clippy (#7013)
* Fix warnings from clippy

* revert MAIN_SEPARATOR_STR
1 year ago
Timothy DeHerrera 9c6c63a2be
inject language based on file extension & shebang (#3970)
* inject language based on file extension

Nodes can now be captured with "injection.filename". If this capture
contains a valid file extension known to Helix, then the content will
be highlighted as that language.

* inject language by shebang

Nodes can now be captured with "injection.shebang". If this capture
contains a valid shebang line known to Helix, then the content will
be highlighted as the language the shebang calls for.

* add documentation for language injection

* nix: fix highlights

The `@` is now highlighted properly on either side of the function arg.

Also, extending the phases with `buildPhase = prev.buildPhase + ''''`
is now highlighted properly.

Fix highlighting of `''$` style escapes (requires tree-sitter-nix bump)

Fix `inherit` highlighting.

* simplify injection_for_match

Split out injection pair logic into its own method to make the overall
flow easier to follow.

Also transform the top-level function into a method on a
HighlightConfiguration.

* markdown: add shebang injection query
1 year ago
jorge 204d1eba4b
feat(commands): add clear-register typable command (#5695)
Co-authored-by: Jorge <chorcheus@tutanota.com>
1 year ago
ymgyt 61ff2bc094
return early if soft wrap is invalid (#6856) 1 year ago
Blaž Hrastnik 58e457a4e1
Revert "Fix #6605: Remove soft-wrap.enable option wrapping. (#6656)"
This caused a bug that would ignore the global config.

This reverts commit af88a3c15c.
1 year ago
gibbz00 af88a3c15c
Fix #6605: Remove soft-wrap.enable option wrapping. (#6656)
Co-authored-by: gibbz00 <gabrielhansson@gmail.com>
1 year ago
Daniel Sedlak e856906f76
Fix typos (#6643) 1 year ago
jazzfool d04288e0f3
Canonicalize paths before stripping current dir as prefix (#6290)
Co-authored-by: jazzfool <shamoslover69@gmail.com>
1 year ago
Pascal Kuthe 2d10a429eb add workspace config and manual LSP root management
fixup documentation

Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>

fixup typo

Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>
1 year ago
Philipp Mildenberger 198ff2c3f9
Fix clippy lints (#6454) 1 year ago