Commit Graph

822 Commits (main)

Author SHA1 Message Date
Em Zhan 7090555dab
Add `insert-final-newline` config option (#8157)
Co-authored-by: Xalfer <64538944+Xalfer@users.noreply.github.com>
8 months ago
Blaž Hrastnik 060e73a711
Lower idle-timeout to 250ms
The aim is to make it slow enough it only triggers during a typing
pause, but not too slow. Initial value was chosen as a safe slow
default but I've been using 250 for a while.
8 months ago
Alexis Mousset 83ac53a109
Fix various typos (#8233) 8 months ago
Luke Halasy b959162ceb
Add tree-sitter-highlight-name command (#8170)
* adds treesitter-highlight-name command

* commit documentation changes

* moves the get_highlight_name function into core/syntax

* rename get_highlight_name function to get_highlight_for_node_at_position

* addresses pr comments: moves fn into helper fn, simplifies a lot

* commit updated documentation changes

* changes scope method to return &str so that callers can decide whether or not to own
8 months ago
Jonathan LEI 8778083b5a
Detect tmux clipboard provider on macOS (#8182) 8 months ago
Ezekiel Warren 6bef982f2d
use which on formatter command (#8064) 8 months ago
chtenb 7fffc0a5d1
Rename reset to default (#8114)
Use `default` instead of `reset`, as this is the conventional name for ANSI codes 39/49. The word `reset` should be reserved for ANSI code `0`, which resets both fg and bg colors at once, while also removing all modifiers. While the code uses the value name `Reset`, this is misleading and should not leak into the user space.
8 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>
8 months ago
West 82cd445715
add `reset` to the color palette (#8083) 8 months ago
Michael Davis 050c019ccb Translate new ScrollLeft/ScrollRight crossterm mouse events 9 months ago
dependabot[bot] c3442f3a18 build(deps): bump crossterm from 0.26.1 to 0.27.0
Bumps [crossterm](https://github.com/crossterm-rs/crossterm) from 0.26.1 to 0.27.0.
- [Release notes](https://github.com/crossterm-rs/crossterm/releases)
- [Changelog](https://github.com/crossterm-rs/crossterm/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossterm-rs/crossterm/compare/0.26.1...0.27.0)

---
updated-dependencies:
- dependency-name: crossterm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
9 months ago
Pascal Kuthe e5f8d8ef04
create separate timer for redraw requests (#8023)
* create separate timer for redraw requests

* Update helix-view/src/editor.rs

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

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.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
dependabot[bot] e9a807a48f
build(deps): bump bitflags from 2.3.3 to 2.4.0 (#7943)
Bumps [bitflags](https://github.com/bitflags/bitflags) from 2.3.3 to 2.4.0.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/2.3.3...2.4.0)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
9 months ago
Jonathan LEI 3a162e2bef
Make editor remember the latest search register (#5244) 9 months ago
theteachr d6bb1092c7 Update stale comments
Obsoleted by https://github.com/helix-editor/helix/pull/4731
9 months ago
Michael Davis f01ca107fb
Detect non-existent files as non-readonly (#7875) 9 months ago
woojiq aa4d84a0b3
Align view for background buffer opened with `alt-ret` (#7691)
* fix(picker): `alt-ret' changes cursor pos of current file, not new one

Closes #7673

* fix other pickers

* symbol pickers
* diagnostick pickers

This is done using the already patched `jump_to_location` method.

* fix global and jumplist pickers

* use `view` as old_id; make `align_view` method of `Action`

* test(picker): basic <alt-ret> functionality

* fix: picker integrational test

* fix nit

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

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
9 months ago
Connortsui20 fcbac485f8
Show whether file readonly in statusline (#7740) 9 months ago
Anshul Dalal c7e9e94f00
Skip rendering gutters when gutter width exceeds view width (#7821) 9 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.
9 months ago
Michael Davis 4555a6b433 Reimplement clipboard commands in terms of special regs
Since the clipboard provider now lives on the Registers type, we want
to eliminate it from the Editor. We can do that and clean up the
commands that interact with the clipboard by calling regular yank,
paste and replace impls on the clipboard special registers.

Eventually the clipboard commands could be removed once macro keybinding
is supported.
9 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`.
9 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.
9 months ago
Michael Davis 0f19f282cf Add system & primary clipboards as special registers
These special registers join and copy the values to the clipboards with
'*' corresponding to the system clipboard and '+' to the primary as
they are in Vim. This also uses the trick from PR6889 to save the values
in the register and re-use them without joining into one value when
pasting a value which was yanked and not changed.

These registers are not implemented in Kakoune but Kakoune also does
not have a built-in clipboard integration.

Co-authored-by: CcydtN <51289140+CcydtN@users.noreply.github.com>
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
9 months ago
Michael Davis 32d071a392 Add the '%' (current filename) register
This register also comes from Kakoune. It's read-only and produces the
current document's name, defaulting to the scratch buffer name
constant.

(Also see PR5577.)

Co-authored-by: Ivan Tham <pickfire@riseup.net>
9 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.
9 months ago
Michael Davis 5eb1a25d8a Refactor Registers to take Editor
This sets up a new Registers type that will allow us to expand support
for special registers. (See the child commits.)

We start simple with the regular (`Vec<String>`) registers and the
simplest special register, the black hole. In the child commits we
will expand these match arms with more special registers.

The upcoming special registers will need a few things that aren't
possible with the current Registers type in helix-core:

* Access to the `Editor`. This is only necessary when reading from
  registers, so the `&Editor` parameter is only added to
  `Registers::read`.
* Returning owned values. Registers in helix-core returns references
  to the values backed by the `Vec<String>` but future special registers
  will need to return owned values. We refactor the return value of the
  read operations to give `Cow<str>`s and iterators over those.
* Returning a `Result` for write/push functions. This will be used by
  the clipboard special registers.
9 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>
9 months ago
Ryan Fowler 5c41f22c2a
Add support for LSP DidChangeWatchedFiles (#7665)
* Add initial support for LSP DidChangeWatchedFiles

* Move file event Handler to helix-lsp

* Simplify file event handling

* Refactor file event handling

* Block on future within LSP file event handler

* Fully qualify uses of the file_event::Handler type

* Rename ops field to options

* Revert newline removal from helix-view/Cargo.toml

* Ensure file event Handler is cleaned up when lsp client is shutdown
10 months ago
Christian Holman 579f68b52d
allow for higher F keys to be used (#7672) 10 months ago
Gabriel Hansson c1488267e5
(Updated) Apply motion API refinements (#6078)
* _apply_motion generalization where possible

API encourages users to not forget setting `editor.last_motion` when
applying a motion. But also not setting `last_motion` without applying a
motion first.

* (rename) will_find_char -> find_char

method name makes it sound like it would be returning a boolean.

* use _apply_motion in find_char

Feature that falls out from this is that repetitions of t,T,f,F are
saved with the context extention/move and count. (Not defaulting to extend
by 1 count).

* Finalize apply_motion API

last_motion is now a private field and can only be set by calling
Editor.apply_motion(). Removing need (and possibility) of writing:

`motion(editor); editor.last_motion = motion`

Now it's just: `editor.apply_motion(motion)`

* editor.last_message: rm Box wrap around Arc

* Use pre-existing `Direction` rather than custom `SearchDirection`.

* `LastMotion` type alias for `Option<Arc<dyn Fn(&mut Editor)>>`

* Take motion rather than cloning it.

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

* last_motion as Option<Motion>.

* Use `Box` over `Arc` for `last_motion`.

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
10 months ago
Pascal Kuthe 618620b369
use redraw handle for debouncing LSP messages (#7538) 10 months ago
Tom Taylor dc50263ed0
Fix incorrect gutter bail message (#7534) 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>
10 months ago
Michael Davis 636c91c76b
Mark buffers created from stdin as modified (#7431)
This resolves some confusing behavior where a scratch document created
by piping into hx is discarded when navigating away from that document.

We discard any scratch documents that are not modified and the original
`Editor::new_file_from_stdin` would create unmodified documents. We
refactor this function to create an empty document first and then to
apply the text from stdin as a change.
11 months ago
Blaž Hrastnik 8d39a81aa8 fix: Regression from d491e234f4 11 months ago
Pascal Kuthe d491e234f4 map positions through changes in O(N) 11 months ago
tomleb 29638babea
Allow ANSI colors in themes (#5119) 11 months ago
Alex d5af6031f6
Use default line ending in open command (#7357) 11 months ago
Alex 3fb9fafb2a
Add config for default line ending (#5621) 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>
11 months ago
spectre256 00b152facd
Add register statusline element (#7222) 11 months ago
gibbz00 3d0bc72099 Place `Info::from_keymap()` contents in `keymap.infobox()`:
This makes it easier later control the order in which the key events
are presented.
11 months ago
gibbz00 19326d23d1 Keymap infobox: Idiomatic body tuple.
Does not change any behavior other than making the tuple slightly
more idiomatic.  Keymap infobox shows key events, then the respective
description. This commit makes sure that order is used from the get go,
rather than flipping it midway.
11 months ago
dependabot[bot] 6deb0e4ef7
build(deps): bump once_cell from 1.17.2 to 1.18.0 (#7248)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
11 months ago
dependabot[bot] 6043c3c3db
build(deps): bump bitflags from 2.2.1 to 2.3.1 (#7117)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
12 months ago
Philipp Mildenberger f45bbf165e Apply all review suggestions (doc_id -> id, error message, unnecessary if)
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
12 months ago
Philipp Mildenberger 656ee24966 Simplify gutter diagnostics rendering by using partition_point instead of binary search
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
12 months ago
Philipp Mildenberger 2b746ea6fa Some minor clarity/cosmetic improvements
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
12 months ago