Commit graph

4814 commits

Author SHA1 Message Date
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.
2023-08-01 09:41:42 -05:00
Skyler Hawthorne
93acb53812 add node boundary movement 2023-08-01 09:41:42 -05:00
Zoey Hewll
1d702ea191
update yanked dependency (#7800) 2023-08-01 22:21:46 +09:00
dependabot[bot]
99413558b9
build(deps): bump serde_json from 1.0.103 to 1.0.104 (#7793)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 02:28:44 +02:00
dependabot[bot]
0eea76c415
build(deps): bump globset from 0.4.11 to 0.4.12 (#7795)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 02:28:25 +02:00
Michael Davis
d4f9716fbc Add yank_to_clipboard commands, bind to <space>y by default
The clipboard special registers are able to retain multiple selections
and also join the value when copying it to the clipboard. So by default
we should yank regularly to the '*' and '+' registers. That will have
the same behavior for the clipboards but will allow pasting multiple
selections if the clipboard doesn't change between yanks.
2023-07-31 15:05:38 +09:00
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.
2023-07-31 15:05:38 +09:00
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`.
2023-07-31 15:05:38 +09:00
Michael Davis
86a1f0177c book: Document default and special registers 2023-07-31 15:05:38 +09:00
Michael Davis
a23b70182c commands: Allow using selected register where hardcoded
These snippets use hardcoded registers but it can be useful to be able
to specify a register for these commands.
2023-07-31 15:05:38 +09:00
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.
2023-07-31 15:05:38 +09:00
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>
2023-07-31 15:05:38 +09:00
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>
2023-07-31 15:05:38 +09:00
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.
2023-07-31 15:05:38 +09:00
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.
2023-07-31 15:05:38 +09:00
lydiandy
57952c46a4
replace new lsp for vlang (#7760)
* fix vlang grammar fetch and build fail

* update highlights.scm for v-analyzer

* Update languages.toml

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

* Update runtime/queries/v/highlights.scm

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

* update scm for new lsp

* gen doc lang-support.md

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-07-31 01:04:55 +02:00
Jesse Luehrs
d5571968fa
add new theme based on the default vim dark theme (#7785) 2023-07-30 16:53:42 +02:00
Mateusz S. Szczygieł
13e7edab19
Register .gltf file type for JSON (#7781) 2023-07-29 18:57:33 +02:00
Matthias Q
224fd5fa29
feat: update prql parser (#7771) 2023-07-28 23:01:06 +02:00
Jummit
9a4890f62b
Add wren support (#7765) 2023-07-28 18:13:51 +02:00
Michael Davis
d6856cfeec
Refactor Nix flake to use crane (#7763)
This resolves a build issue with nci/dream2nix and git dependencies.
We can keep most of the helix-specific parts of the flake, we just need
to switch from configuring nci to calling craneLib functions.

We also switch to flake-utils from flake-parts:

* Using rust-overlay with flake-parts directly is unergonomic
  (see https://github.com/hercules-ci/flake-parts/discussions/83).
* Removing flake-parts reduces the overall dependencies: rust-overlay
  already depends on flake-utils.
2023-07-28 13:30:26 +09:00
Philipp Mildenberger
8a28f30593
Reformat with nightly rustfmt for better let-else formatting (#7721) 2023-07-27 11:57:19 +09:00
Pascal Kuthe
262a595e53
pin TS to unreleased git revision to fix freezes (#7737) 2023-07-27 11:50:40 +09:00
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.
2023-07-27 11:50:19 +09:00
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>
2023-07-27 11:50:19 +09:00
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.
2023-07-27 11:50:19 +09:00
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.
2023-07-27 11:50:19 +09:00
Michael Davis
6a431afc4e
Save an undo checkpoint before accepting completion (#7747) 2023-07-27 11:48:16 +09:00
eh
dea6894f92
Theme Pop-Dark: Increase Diagnostics clarity (#7702) 2023-07-26 22:33:10 +02:00
saltlakrits
5a52897014
Update everforest_dark.toml to add missing color definitions (#7739) 2023-07-26 15:31:35 +02:00
Pham Huy Hoang
75239a938f
fix incorrect predicate in comment highlights (#7732) 2023-07-25 23:56:02 +02:00
Federico Stra
a188282b37
Update soft-wrap indicator in gruvbox themes (#7736) 2023-07-25 23:55:02 +02:00
dependabot[bot]
b266628c17
build(deps): bump signal-hook from 0.3.16 to 0.3.17 (#7728)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-25 03:04:01 +02:00
dependabot[bot]
00dc205108
build(deps): bump thiserror from 1.0.43 to 1.0.44 (#7730)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-25 03:03:50 +02:00
dependabot[bot]
7295340119
build(deps): bump serde from 1.0.171 to 1.0.175 (#7727)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-25 03:03:16 +02:00
dependabot[bot]
46251a1411
build(deps): bump tempfile from 3.6.0 to 3.7.0 (#7726)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-25 03:03:03 +02:00
sigmaSd
5ec126d3e2
Fix docs for default statusline config (#7720) 2023-07-24 08:51:35 -05:00
Ravi Shekhar Jethani
48d57dad47
Fix selection highlighting in remaining gruvbox derived themes (#7717) 2023-07-23 16:45:13 +09:00
Jonas Tepe
505213d41b
Drop mut from variable to silence linter (#7704) 2023-07-22 23:31:24 +09:00
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
2023-07-22 00:21:21 +02:00
sigmaSd
8977123f25
feat: resolve code action (#7677) 2023-07-21 14:50:08 -05:00
Thales Ramos
d52b790379
Add Kaolin Dark, Light and Valley Dark themes (#7151)
Add some missing keys

Inherit themes from kaolin-dark and override diverging keys
2023-07-19 11:14:28 +09:00
Christian Holman
579f68b52d
allow for higher F keys to be used (#7672) 2023-07-19 11:05:32 +09:00
dependabot[bot]
b47519ab11
build(deps): bump signal-hook from 0.3.15 to 0.3.16 (#7664)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-18 10:49:19 +09:00
dependabot[bot]
b87858b7b4
build(deps): bump indoc from 2.0.2 to 2.0.3 (#7663)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-18 10:49:11 +09:00
dependabot[bot]
1478a0d3a6
build(deps): bump anyhow from 1.0.71 to 1.0.72 (#7662)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-18 10:49:03 +09:00
dependabot[bot]
6d4fd77315
build(deps): bump serde_json from 1.0.100 to 1.0.103 (#7661)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-18 10:48:58 +09:00
J. Brock
2fa576b177
Remove snap aliasing instructions (#7657)
The helix snap now gets aliased to hx by default at installation time,
so manual aliasing should no longer be required.

Signed-off-by: Joseph Brock <joseph.brock@protonmail.com>
2023-07-17 09:09:30 -05:00
Jesse Luehrs
e7f60611ac
switch to https://github.com/tree-sitter-perl/tree-sitter-perl (#7644) 2023-07-17 14:09:38 +09:00
Jake Langford
ad2061bab6
Update my name README.md (#7656) 2023-07-17 14:09:19 +09:00