Commit Graph

769 Commits (afd292e3b9616ea9098ca3a7d24a730508b84809)

Author SHA1 Message Date
PiergiorgioZagaria 219d2c2515
Change default formatter for any language (#2942)
* Change default formatter for any language

* Fix clippy error

* Close stdin for Stdio formatters

* Better indentation and pattern matching

* Return Result<Option<...>> for fn format instead of Option

* Remove unwrap for stdin

* Handle FormatterErrors instead of Result<Option<...>>

* Use Transaction instead of LspFormatting

* Use Transaction directly in Document::format

* Perform stdin type formatting asynchronously

* Rename formatter.type values to kebab-case

* Debug format for displaying io::ErrorKind (msrv fix)

* Solve conflict?

* Use only stdio type formatters

* Remove FormatterType enum

* Remove old comment

* Check if the formatter exited correctly

* Add formatter configuration to the book

* Avoid allocations when writing to stdin and formatting errors

* Remove unused import

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
2 years ago
A-Walrus c15b494288
Fix align_selection behaviour with tabs (#3276) 2 years ago
MilanVasko 9a49623721
Use OR of all selections in search_selection command (#3138)
Closes #2312
2 years ago
Gokul Soumya de8ade8967
Shorten embedded command descriptions (#3070)
* Shorten embedded command descriptions

- Compact descriptions in command palette and infobox

* Shorten typed command descriptions

* Fix typo in decrement command description
2 years ago
Houkime 52bb1103f8
Auto pair-removal (#2940)
* auto pair-removal

Fixes https://github.com/helix-editor/helix/issues/1673

* autopairs removal: use doc autopairs

* autopairs-removal: limit to one-char selections

* use single_grapheme() to check if range is one char

* fix errouneous deletes of " and other symmetric autopairs when at buffer start

Co-authored-by: Houkime <>
2 years ago
Robin 19b7864062
keep jump/file history when using :split (#3031)
* keep jump/file history when using :split

* move history cloning into the switch function

Co-authored-by: Robin <robinvandijk@klippa.com>
2 years ago
Bob 2f53644c6d
jumplist picker (#3033)
* jumplist picker

* remove jumps slicing

Co-authored-by: Benoît Cortier <bcortier@proton.me>

* remove unnecessary deref format! parameter

Co-authored-by: Benoît Cortier <bcortier@proton.me>

Co-authored-by: Benoît Cortier <bcortier@proton.me>
2 years ago
Gokul Soumya 791bf7e50a
Add lsp signature help (#1755)
* Add lsp signature help

* Do not move signature help popup on multiple triggers

* Highlight current parameter in signature help

* Auto close signature help

* Position signature help above to not block completion

* Update signature help on backspace/insert mode delete

* Add lsp.auto-signature-help config option

* Add serde default annotation for LspConfig

* Show LSP inactive message only if signature help is invoked manually

* Do not assume valid signature help response from LSP

Malformed LSP responses are common, and these should not crash the
editor.

* Check signature help capability before sending request

* Reuse Open enum for PositionBias in popup

* Close signature popup and exit insert mode on escape

* Add config to control signature help docs display

* Use new Margin api in signature help

* Invoke signature help on changing to insert mode
2 years ago
Bob 4418924ec3
respect count for selecting next/previous match (#3056) 2 years ago
Bob e6a6e251c5
respect count for repeating motion (#3057) 2 years ago
Slug e109022bfd
fix: error that caused usize to overflow (#3024)
* fix: error that caused usize to overflow

* update: changed check_sub to saturating_sub
2 years ago
A-Walrus 2ac1de305e
Fix backwards selection duplication widening bug (#2945)
* Fix backwards selection duplication widening bug

* Add integration tests

* Make tests line-ending agnostic

Make tests line-ending agnostic

Use indoc to fix tests

Fix line-ending on test input
2 years ago
Gokul Soumya 6e2aaed5c2
Reuse menu::Item trait in picker (#2814)
* Refactor menu::Item to accomodate external state

Will be useful for storing editor state when reused by pickers.

* Add some type aliases for readability

* Reuse menu::Item trait in picker

This opens the way for merging the menu and picker code in the
future, since a picker is essentially a menu + prompt. More
excitingly, this change will also allow aligning items in the
picker, which would be useful (for example) in the command palette
for aligning the descriptions to the left and the keybinds to
the right in two separate columns.

The item formatting of each picker has been kept as is, even though
there is room for improvement now that we can format the data into
columns, since that is better tackled in a separate PR.

* Rename menu::Item::EditorData to Data

* Call and inline filter_text() in sort_text() completion

* Rename diagnostic picker's Item::Data
2 years ago
Sora edee2f4c34
Fix backwards character deletion on other whitespaces (#2855)
* delete_backwards_char accepts any type of whitespace

* Fix inconsistency, where unicode whitespaces are treated as normal whitespaces

* Changed back to direct whitespace match

* Only accept explicit whitespace / tabs

Co-authored-by: s0LA1337 <dreamer@neoncity.dev>
2 years ago
Falco Hirschenberger ed89f8897e
Add workspace and document diagnostics picker (#2013)
* Add workspace and document diagnostics picker

fixes #1891

* Fix some of @archseer's annotations

* Add From<&Spans> impl for String

* More descriptive parameter names.

* Adding From<Cow<str>> impls for Span and Spans

* Add new keymap entries to docs

* Avoid some clones

* Fix api change

* Update helix-term/src/application.rs

Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>

* Fix a clippy hint

* Sort diagnostics first by URL and then by severity.

* Sort diagnostics first by URL and then by severity.

* Ignore missing lsp severity entries

* Add truncated filepath

* Typo

* Strip cwd from paths and use url-path without schema

* Make tests a doctest

* Better variable names

Co-authored-by: Falco Hirschenberger <falco.hirschenberger@itwm.fraunhofer.de>
Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>
2 years ago
PabloMansanet 030de46e6b
Fix recursive macro crash and empty macro lockout (#2902) 2 years ago
lazytanuki 096abdd19b
feat: highlight / select symbol under cursor using LSP textDocument/documentHighlight (#2738)
* feat: highlight symbol under cursor using LSP textDocument/documentHighlight

* fix: please clippy

* fix: shorter description and code style
2 years ago
farwyler 886cff3bcc
Redetect indent and line endings after language server replaces documents (#2778)
* redetect indent and line endings after language server replaces document

* removes nested if

* always redetect indent and line endings after format

This reverts commit 764d14f55894dc7213e48022dfa0f91829b8ef59.
2 years ago
Blaž Hrastnik 23b5b1e25a Remove a couple more unwraps 2 years ago
Blaž Hrastnik 19dccade7c
Merge pull request #2359 from dead10ck/test-harness
Integration testing harness
2 years ago
Termina94 a17626a822
add history suggest to global search (#2717)
Co-authored-by: Dean Revell <revell@gmail.com>
2 years ago
Gokul Soumya 8b67acf130
Format keys identically in statusline and command palette (#2790)
The command palette previously used + as a delimiter for denoting
a single key in a key sequence, (like C+w). This was at odds with
how the statusline displayed them with pending keys (like <C-w>).
This patch changes the palette formatting to the statusline formatting
2 years ago
Blaž Hrastnik 458b89e21d
Merge branch 'master' into test-harness 2 years ago
Matthew Toohey 6a3f7f2c39
feat: make `move_vertically` aware of tabs and wide characters (#2620)
* feat: make `move_vertically` aware of tabs and wide characters

* refactor: replace unnecessary checked_sub with comparison

* refactor: leave pos_at_coords unchanged and introduce separate pos_at_visual_coords

* style: include comment to explain `pos_at_visual_coords` breaking condition

* refactor: use `pos_at_visual_coords` in `text_pos_at_screen_coords`

* feat: make `copy_selection_on_line` aware of wide characters
2 years ago
Connor Lay (Clay) 67f6c85792 text-objects: add test capture & elixir queries 2 years ago
Skyler Hawthorne 652cdda833 use test terminal backend for integration tests 2 years ago
Skyler Hawthorne ed950fcc56 Add more context; Editor::open doesn't need to own path 2 years ago
Skyler Hawthorne 0f3c10a021 Fix initial selection of Document in new view
When a new View of a Document is created, a default cursor of 0, 0 is
created, and it does not get normalized to a single width cursor until
at least one movement of the cursor happens. This appears to have no
practical negative effect that I could find, but it makes tests difficult
to work with, since the initial selection is not what you expect it to be.

This changes the initial selection of a new View to be the width of the
first grapheme in the text.
2 years ago
Ryang Sohn 3bd5545577
Add a check to prevent re-selecting same range (#2760) 2 years ago
Blaž Hrastnik 26dbdb70fb
Refactor push_jump so we're not needlessly fetching doc twice 2 years ago
Blaž Hrastnik b14c258a2c
prompt: If submitting empty prompt, use default (last used) 2 years ago
gavynriebau b2bd87df81
Fix crash due to cycles when replaying macros (#2647)
In certain circumstances it was possible to get into an infinite loop
when replaying macros such as when different macros attempt to replay
each other.

This commit adds changes to track which macros are currently being
replayed and prevent getting into infinite loops.
2 years ago
Ryan Russell ae12c58f0f
Improve Readability (#2639) 2 years ago
Andrey Tkachenko fa2eeccc57
Fix unwrap error when undo after `shell_append_output` (#2625) 2 years ago
Daniel S Poulin 0c05447d49
Add shrink equivalent of extend_to_line_bounds (#2450)
* Add shrink equivalent of extend_to_line_bounds

* Add a check for being past rope end in end position calc

* Include the EOL character in calculations

* Bind to `A-x` for now

* Document new keybind
2 years ago
Roland Kovacs 3f10473d30 Implement view swapping
* add Tree::swap_split_in_direction()
* add swap_view_{left,down,up,right} commands, bound to H,J,K,L
  respectively in the Window menu(s)
* add test for view swapping
2 years ago
Michael Davis e04bb8b891
address rust 1.61.0 clippy lints (#2514) 2 years ago
Roland Kovacs 8958bf0a92
Implement view transpose (#2461)
Change the layout of existing split view from horizontal to vertical and
vica-versa. It only effects the focused view and its siblings, i.e. not
recursive.

Command is mapped to 't' or 'C-t' under the Window menus.
2 years ago
Ivan Tham 0477d02894
Exclude cursor when doing ctrl-w (#2431)
Currently ctrl-w in insert mode deletes the cursor which results in
unexpected behavior. The patch also reduces the selection to cursor before
performing prev word to remove the behavior of removing unnecessary text
when nothing should be removed.

1. `::#(|)#::` after `ctrl-w` should be `#(|)#::`, previously `#(|)#:`
2. `#(|::)#` after `ctrl-w` should be `#(|::)#`, previously `#(|)#`

Fix #2390
2 years ago
Michael Davis e0b5cdfb47
prevent selection collapse when inserting a newline (#2414)
Inserting a newline currently collapses any connected selections when inserting
or appending. It's happening because we're reducing the selections down to
their cursors (`let selection = ..` line) and then computing the new selection
based on the cursor. We're discarding the original head and anchor information
which are necessary to emulate Kakoune's behavior.

In Kakoune, inserting a newline retains the existing selection and _slides_
it (moves head and anchor by the same amount) forward by the newline and
indentation amount. Appending a newline extends the selection to include the
newline and any new indentation.

With the implementation of insert_newline here, we slide by adding the global
and local offsets to both head and anchor. We extend by adding the global
offset to both head and anchor but the local offset only to the head.
2 years ago
Matouš Dzivjak d2b1add1f4
feat(term): wrap command palette in overlay (#2378)
Looks better and is consistent with the rest, nothing else.
2 years ago
AntonioLucibello ac2ea800ce
Add undo checkpoint command (#2115)
* added undo checkpoint command

* changed add_undo_checkpoint to commit_undo_checkpoint

* mapped commit_undo_checkpoint to Alt-u

* Update default.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Gokul Soumya 76175dbd6d Support m in surround delete and replace 2 years ago
Gokul Soumya de15d70171 Add `m` textobject to select closest surround pair 2 years ago
CossonLeo 477b88e99c
Wrap current directory picker with overlay widget (#2308) 2 years ago
chunghha 3a398eec56
fix typos (#2304) 2 years ago
Matouš Dzivjak 52f5a4228a
feat(commands): better handling of buffer-close (#1397)
* feat(commands): better handling of buffer-close

Previously, when closing buffer, you would loose cursor position in other docs.
Also, all splits where the buffer was open would be closed.

This PR changes the behavior, if the view has also other buffer
previously viewed it switches back to the last one instead of the view
being closed. As a side effect, since the views are persisted,
 the cursor history is persisted as well.

Fixes: https://github.com/helix-editor/helix/issues/1186

* Adjust buffer close behavior

* Remove closed documents from jump history

* Fix after rebase
2 years ago
Michael Davis 3f2bd7770e
Rename paragraph motion commands from move to goto (#2226)
* fix command name for next/prev paragraph motion

* rename move_next/prev_paragraph to goto_next/prev_paragraph
2 years ago
Ivan Tham c1d3d49f3f
Fix ctrl-u on insert behavior (#1957)
* Fix ctrl-u on insert behavior

Now should follow vim behavior more
- no longer remove text on cursor
- no longer remove selected text while inserting
- first kill to start non-whitespace, start, previous new line

* Add comment for c-u parts
2 years ago
Ivan Tham 2a853cd41d
Fix open on multiline selection (#2161)
Select multiple line and open should be based on the whole selection
and not just the line of the cursor, which causes weird behavior like
opening in the middle of the selection which user might not expect.
2 years ago