Commit Graph

800 Commits (main)

Author SHA1 Message Date
Pascal Kuthe eb9c37844c
fix syntax highlights in dynamic picker (#8206) 8 months ago
Michael Davis c0fd8bc61b
Fix Clone definition for Injector (#8194) 9 months ago
Pascal Kuthe e6cdc5f9d3
Don't use word splitting during fuzzy matching (#8192) 9 months ago
Pascal Kuthe 0cfd46c14f
Do not show (running) when opening picker (#8148)
* only stream from background thread if necessary

If the file transversal is longer shorter 30ms it will now be performed
on the main thread. Spawning a thread can take a while (or rather it
takes a while until that thread is scheduled) so the files can actually
take a while to show up. This prevents the `(running)` indicator from
briefly showing up when opening the file picker in a small directory.

* run partial cargo update
9 months ago
Pascal Kuthe a38ec6d6ca
avoid excessive memory consumption in picker (#8127)
* avoid excessive memory consumption from file picker

* fix typos

Co-authored-by: Chris <75008413+cd-a@users.noreply.github.com>

---------

Co-authored-by: Chris <75008413+cd-a@users.noreply.github.com>
9 months ago
Michael Davis 48373d4a2b
Clear completion when switching windows via click (#8118)
The completion component assumes that it operates on the same View but
it's possible to break this assumption by switching windows through
left-clicking. I believe we should clear the completion menu when
switching windows to fix this.

This change fixes a panic for this scenario:

* Open a buffer with LSP completion available
* Split the window (for example '<C-w>v')
* Enter insert mode and trigger the completion menu
* Select a completion candidate (for example with '<C-n>')
* Switch to the original window by left-clicking in its area
* Enter insert mode and make edits (for example 'o<backspace>')

This will trip the 'assert_eq' in Document::restore.
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
woojiq b67d2c3a68
fix: line numbers remain relative when helix loses focus (#7955)
* fix: line numbers remain relative when helix loses focus

If `line number = relative` and a new window is opened in helix, lines inside unfocused windows will be `absolute`. This commit adds the same thing when helix becomes unfocused in a terminal emulator.

* partial rebase
9 months ago
nkitsaini 22f4f313f1
Remove unnecessary `Err` from `get_canonicalized_path` (#8009)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
9 months ago
quantonganh 085706e0cd
Include completions for git-ignored files in debugger prompt (#7936) 9 months ago
Connortsui20 fcbac485f8
Show whether file readonly in statusline (#7740) 10 months ago
Jesse Luehrs a7a145ad3d
Center the picker preview selection using visual lines (#7837)
this way the preview always shows the selection even if lines were
wrapped
10 months ago
Anshul Dalal c7e9e94f00
Skip rendering gutters when gutter width exceeds view width (#7821) 10 months ago
Skyler Hawthorne 15e07d4db8 feat: smart_tab
Implement `smart_tab`, which optionally makes the tab key run the
`move_parent_node_start` command when the cursor has non- whitespace to
its left.
10 months ago
Michael Davis 2d838d729c Preview the latest value for regular registers
This fixes a discrepancy between regular registers which are used for
yanking multiple values (for example via `"ay`) and regular registers
that store a history of values (for example `"a*`).

Previously, the preview shown in `select_register`'s infobox would show
the oldest value in history. It's intuitive and useful to see the most
recent value pushed to the history though.

We cannot simply switch the preview line from `values.first()`
to `values.last()`: that would fix the preview for registers
used for history but break the preview for registers used to yank
multiple values. We could push to the beginning of the values with
`Registers::push` but this is wasteful from a performance perspective.
Instead we can have `Registers::read` return an iterator that
returns elements in the reverse order and reverse the values in
`Register::write`. This effectively means that `push` adds elements to
the beginning of the register's values. For the sake of the preview, we
can switch to `values.last()` and that is then correct for both usage-
styles. This also needs a change to call-sites that read the latest
history value to switch from `last` to `first`.
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
Philipp Mildenberger 8a28f30593
Reformat with nightly rustfmt for better let-else formatting (#7721) 10 months ago
Michael Davis 953073a679 highlighted_code_block: Take input text as &str
This removes a handful of allocations for functions calling into the
function, which is nice because the prompt may call this function on
every keypress.
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
Michael Davis f0b877e258 Tune regex highlights for usage in prompts
Since regex is almost always injected into other languages,
`pattern_character`s will inherit the highlight for the structure that
injects them (for example `/foo/` in JavaScript or `~r/foo/` in Elixir).
This removes the string highlight when used in the prompt.

We also add `ERROR` node highlighting so that errors in regex syntax
appear in the prompt. This resolves a TODO in the `regex_prompt`
function about highlighting errors in the regex.
10 months ago
Michael Davis 0dc3753eb2 Syntax-highlight regex prompts
We can use tree-sitter-regex highlighting in prompts for entering
regexes, like `search` or `global_search`. The `highlighted_code_block`
function from the markdown component makes this a very small change.

This could be improved in the future by leaving the parsed syntax tree
on the prompt, allowing incremental updates. Prompt lines are usually so
short though and tree-sitter-regex is rather small and uncomplicated,
so that improvement probably wouldn't make a big difference.
10 months ago
Michael Davis 6a431afc4e
Save an undo checkpoint before accepting completion (#7747) 10 months ago
Pascal Kuthe 8f1c6456f3
Clear statusline while prompt is visible (#7646) 10 months ago
Yomain 8afc0282f2
Fix crash when cwd is deleted (#7185) 10 months ago
Pascal Kuthe a0359f7f22 make TS matching fallback to plaintext 11 months ago
Michael Davis 9690e0b733
Fix Component implementations for Picker (#7382) 11 months ago
Gokul Soumya f18acadbd0
Completely remove old Picker and rename FilePicker to Picker 11 months ago
Michael Davis 545acfda88
Make file preview callback optional
When Picker and FilePicker are merged, not all Pickers will be able to
show a preview.

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
11 months ago
Gokul Soumya fc111213b5
Move FilePicker struct def closer to impl block 11 months ago
Gokul Soumya 15cc09fc81
Render the preview in FilePicker 11 months ago
Gokul Soumya 34c8f9ab73
Move Picker::render into FilePicker::render 11 months ago
Gokul Soumya 49fbf8df53
Move Component methods except render() to FilePicker 11 months ago
Gokul Soumya 1e66e9198c
Move handle_event methods from Picker to FilePicker 11 months ago
Gokul Soumya 8516f43837
Move navigation methods from Picker to FilePicker 11 months ago
Gokul Soumya 7a058c7361
Move scoring functions from Picker to FilePicker 11 months ago
Gokul Soumya 104036bd7f
Copy struct fields and new() from Picker to FilePicker 11 months ago
Gokul Soumya 40916dff63
Move FilePicker::render from Component impl to normal impl
Merges the code for the Picker and FilePicker into a single Picker that
can show a file preview if a preview callback is provided. This change
was mainly made to facilitate refactoring out a simple skeleton of a
picker that does not do any filtering to be reused in a normal Picker
and a DynamicPicker (see #5714; in particular [mikes-comment] and
[gokuls-comment]).

The crux of the issue is that a picker maintains a list of predefined
options (eg. list of files in the directory) and (re-)filters them every
time the picker prompt changes, while a dynamic picker (eg. interactive
global search, #4687) recalculates the full list of options on every
prompt change. Using a filtering picker to drive a dynamic picker hence
does duplicate work of filtering thousands of matches for no reason. It
could also cause problems like interfering with the regex pattern in the
global search.

I tried to directly extract a PickerBase to be reused in Picker and
FilePicker and DynamicPicker, but the problem is that DynamicPicker is
actually a DynamicFilePicker (i.e. it can preview file contents) which
means we would need PickerBase, Picker, FilePicker, DynamicPicker and
DynamicFilePicker and then another way of sharing the previewing code
between a FilePicker and a DynamicFilePicker. By merging Picker and
FilePicker into Picker, we only need PickerBase, Picker and
DynamicPicker.

[gokuls-comment]: https://github.com/helix-editor/helix/issues/5714#issuecomment-1410949578
[mikes-comment]: https://github.com/helix-editor/helix/issues/5714#issuecomment-1407451963
11 months ago
Philipp Mildenberger 2a11fb485d
Fix underflow when repeating a completion that has a negative shift position (#7322) 11 months ago
Luca Schlecker dbd248fdfa add config option for instant completion entry preview (defaulting to true).
Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
12 months ago
spectre256 00b152facd
Add register statusline element (#7222) 12 months ago
Michael Davis 0e083497a5 Persist register selection in pending keymaps
Previously the register selection (via `"`) would be lost in the middle
of any key sequence longer than one key. For example, `<space>f` would
clear the register selection after the `<space>` making it inaccessible
for the `file_picker` command.

This behavior does not currently have any effect in the default keymap
but might affect custom keymaps. This change aligns the behavior of the
register with count. Making this change allows propagating the register
to the `command_palette` (see the child commit) or other pickers should
we decide to use registers in those in the future. (Interactive global
search for example.)
12 months ago
Poliorcetics 8e2660b5cc
Update diagnostics correctly on LSP exit (#7111)
* chore: avoid format! call with argument when useless

* feat: also clear diagnostics for unopened documents when exiting an LSP

* feat: we already worked on `self.editor.diagnostics` no need to redo the checks
1 year ago
Philipp Mildenberger 2a512f7c48 Rebase cleanup/fixes and use lsp::CompletionItem in item_to_transaction directly 1 year ago
Philipp Mildenberger f45bbf165e Apply all review suggestions (doc_id -> id, error message, unnecessary if)
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
1 year ago
Philipp Mildenberger 39b9a4bba2 Add function `Editor::language_server_by_id` and refactor/simplify related code, also don't 'crash' in completion menu if language_server somehow disappeared 1 year ago
Philipp Mildenberger ff26208427 Filter language servers also by capabilities in `doc.language_servers_with_feature`
* Add `helix_lsp::client::Client::supports_feature(&self, LanguageServerFeature)`
* Extend `doc.language_servers_with_feature` to use this method as filter as well
* Add macro `language_server_with_feature!` to reduce boilerplate for non-mergeable language server requests (like goto-definition)
* Refactored most of the `find_map` code to use the either the macro or filter directly via `doc.language_servers_with_feature`
1 year ago
Philipp Mildenberger 1d5d5dab47 Remove offset_encoding in CompletionItem 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 f9b08656f4 Fix sorting issues of the editor wide diagnostics and apply diagnostics related review suggestions
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
1 year ago
Philipp Mildenberger b6c60beb2d Remove unnecessary completion support check (likely an artifact) 1 year ago