Commit Graph

486 Commits (7b61c63ece4384f75fa41f6c052b3d9e506ff3aa)

Author SHA1 Message Date
Nathan Vegdahl 3fda350494 Fixes for new clippy lints in Rust 1.54. 3 years ago
Blaž Hrastnik 05d20e196f
Merge pull request #376 from cessen/great_line_ending_and_cursor_range_cleanup
The Great Line Ending & Cursor Range Cleanup
3 years ago
Nathan Vegdahl e4d41d06e3 Fix typo in comment. 3 years ago
Gokul Soumya 8a2fa692f2 Refactor case where key event is solely a character 3 years ago
Nathan Vegdahl 285aba2de5 Fix bug with `/` searching after non-ascii characters.
Forgot to convert from char indices to byte indices before passing
to the regex engine.
3 years ago
Nathan Vegdahl cd7302ffd3 Enforce cursor/selection invariants in one place.
Rather than per-command like before.
3 years ago
Nathan Vegdahl a873e719d5 Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Gokul Soumya b90450b9e8 Fix goto line number
Regression from #454. Go to line 10 with `10gg` or `10G`.
3 years ago
Nathan Vegdahl f62ec6e51e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Gokul Soumya 88d6f65239
Allow multi key remappings in config file (#454)
* Use tree like structure to store keymaps

* Allow multi key keymaps in config file

* Allow multi key keymaps in insert mode

* Make keymap state self contained

* Add keymap! macro for ergonomic declaration

* Add descriptions for editor commands

* Allow keymap! to take multiple keys

* Restore infobox display

* Fix keymap merging and add infobox titles

* Fix and add tests for keymaps

* Clean up comments and apply suggestions

* Allow trailing commas in keymap!

* Remove mode suffixes from keymaps

* Preserve order of keys when showing infobox

* Make command descriptions smaller

* Strip infobox title prefix from items

* Strip infobox title prefix from items
3 years ago
Nathan Vegdahl 01247acf0c Start searches at the right side of the block cursor. 3 years ago
Nathan Vegdahl 0883b4fae0 Collect some common patterns into methods on `Range`. 3 years ago
Blaž Hrastnik 63e54e30a7 Implement in-memory prompt history
Implementation is similar to kakoune: we store the entries into
a register.
3 years ago
Gokul Soumya e07e42dcfb fix(term): undo-ing code actions 3 years ago
gbaranski 8da58fe44a fix(term): use existing implementation of edits_to_transaction 3 years ago
Nathan Vegdahl f96b8b769b Switch to a cleaner range-head moving abstraction.
Also fix a bunch of bugs related to it.
3 years ago
Grzegorz Baranski 48e344a2a8
feat: code actions - document edits (#478)
* wip: Code actions

* fix(term): use current macro instead Context::context

* feat(lsp): set code_action capabilities

* feat(term): set SPC-a to code_action

* feat(term): wip on applying code actions

* deps: `cargo update`

* feat(term): applying code actions edits

* fix(term): cleanup of apply_edit

* fix(term): applying edits as a whole thing instead one by one

* refactor(term): move apply_edits below

* fix(term): improve unimplemented messages for further investigation

* fix(term): change code action command comment

Co-authored-by: Ivan Tham <pickfire@riseup.net>

* fix(term): add matching `}`

* fix(term): cleanup, todo!() on workspace edit

* fix(term): remove unrelated workspace_symbol_picker

* fix(term): apply cargo-clippy suggestions

* fix(term): replace todo!'s with editor.set_error

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years ago
Nathan Vegdahl 20723495d3 Fixed find_till_char and find_char commands.
They worked correctly when extending, but not for normal cursor
movement.
3 years ago
Nathan Vegdahl 8f43dc4039 Fix surround replace command replacing the wrong position on the right. 3 years ago
Nathan Vegdahl 43594049dd Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Nathan Vegdahl 427ae6ac6c Put selection in separate variable in commands code. 3 years ago
Nathan Vegdahl ad814b8c2e Fix append mode, and make insertion always happen at head of range. 3 years ago
Nathan Vegdahl 5841954f58 Calculate the line that the range head is on correctly. 3 years ago
Nathan Vegdahl 673338bdb6 Use `Range::line_range()` in some more places I missed. 3 years ago
Ivan Tham eba0bbda2e Resume last picker
Inspired by space ' in doom emacs.
3 years ago
Nathan Vegdahl 7d07704e6f Fix append mode not editing correctly.
This is currently a bit of a hack, and still doesn't behave quite how we
probably want.  Left a TODO.
3 years ago
Nathan Vegdahl 063aa9452d Fix yank not working with internally zero-width ranges. 3 years ago
Nathan Vegdahl c848ed7abc Fixes for misc bugs with view movement. 3 years ago
Nathan Vegdahl 1194fc842a Use new `Range::line_range()` method in more places, as appropriate. 3 years ago
Nathan Vegdahl 1c6b5581f0 Fix various bugs related to goto-end-of-line command.
This also fixes a bug with `Selection::normalize()`, that could
result in an out-of-bounds primary index.
3 years ago
Nathan Vegdahl e8a3980e46 Fix line-wise `p` pasting before the current line instead of after. 3 years ago
Nathan Vegdahl 1792dc6f93 Make search work a little nicer when there are already selections.
Specifically, if you have text like "aaaaaaaaa" and you search
for "a", the new behavior will actually progress through all of the
"a"s, whereas the previous behavior would be stuck on a single one.
3 years ago
Nathan Vegdahl 13b0784009 Fix extend line behavior. 3 years ago
Nathan Vegdahl b0311f4fc2 Fixed primary cursor position calculation to use 1-width semantics.
This had a bunch of knock-on effects that were buggy, such as bracket
match highlighting.
3 years ago
Nathan Vegdahl e462f32723 Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Nathan Vegdahl 6c038bb015 Update word selection/navigation to work with gap indexing.
Also tweaked some of the existing behavior that seemed inconsistent
and/or buggy.  It's mostly identical, just a few corner cases are
different.
3 years ago
Cor Peters cd65a48635
Made toggle_comments language dependent (#463)
* Made toggle_comments language dependent

* Fixed Test Cases

* Added clippy suggestion

* Small Fixes

* Clippy Suggestion

Co-authored-by: Cor <prive@corpeters.nl>
3 years ago
Nathan Vegdahl c2fd55e168 Update extend_line command to work with gap indexing. 3 years ago
Nathan Vegdahl 954314a7c9 Update change-case commands to work with gap indexing. 3 years ago
Nathan Vegdahl a77274e8bb Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Cor Peters 722cfedb38
Added change_case command (#441)
* Added change_case command

* Added switch_to_uppercase and switch_to_lowercase

Renamed change_case to switch_case.

* Updated the Keymap section of the Book

* Use flat_map instead of map + flatten

* Fix switch_to_uppercase using to_lowercase

* Switched 'Alt-`' to uppercase and '`' to lowercase

Co-authored-by: Cor <prive@corpeters.nl>
3 years ago
Blaž Hrastnik 4a5cb0e04b Restore C-w shortcut 3 years ago
Blaž Hrastnik d530d6e39d Further simplify error handling in :commands 3 years ago
Lionel Flandrin 9c02a1b070 Make command implementation return a Result<()>
The error message is displayed with cx.editor.set_error.
3 years ago
Ivan Tham 3e4cd8f8e6 Add infobox for view 3 years ago
Nathan Vegdahl b4c59b444c Update surround commands to work with gap indexing. 3 years ago
Ivan Tham 1c71fced0e Add more modes to infobox 3 years ago
Nathan Vegdahl 85d5b399de Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Blaž Hrastnik a4e28c6927 Implement `X` as extend selection to line bounds 3 years ago
Blaž Hrastnik ebccc96cd4 Factor out goto t/m/b into a single function again 3 years ago
Blaž Hrastnik 6ce303977c Revert back to 'gm'
top / middle / bottom mnemonic.
3 years ago
Ivan Tham bbbbfa9bcf Goto mode use infobox
In the meantime, change gm to gc.
Remove extra space in mode title.
3 years ago
Ivan Tham 5977b07e19 Reduce calculation and improve pattern in infobox
- switch to use static OnceCell to calculate Info once
- pass Vec<(&[KeyEvent], &str)> rather than Vec<(Vec<KeyEvent>, &str)>
- expr -> tt to allow using | as separator, make it more like match
3 years ago
Ivan Tham 64f83dfcbd Support infobox doc gen on stable release 3 years ago
Ivan Tham 61e925cbed Add infobox doc generation and improve ergonomics 3 years ago
Ivan Tham 6710855eac Fix rendering issues for infobox 3 years ago
Ivan Tham 4c190ec9d9 Suggestions for infobox changes
Co-authored-by: Benoît Cortier <benoit.cortier@fried-world.eu>
3 years ago
Ivan Tham 8985c58fd3 Add infobox 3 years ago
Gokul Soumya c68fe1f2a3
Add object selection (textobjects) (#385)
* Add textobjects for word

* Add textobjects for surround characters

* Apply clippy lints

* Remove ThisWordPrevBound in favor of PrevWordEnd

It's the same as PrevWordEnd except for taking the current char
into account, so use a "flag" to capture that usecase

* Add tests for PrevWordEnd movement

* Remove ThisWord* movements

They did not preserve anchor positions and were only used
for textobject boundary search anyway so replace them with
simple position finding functions

* Rewrite tests of word textobject

* Add tests for surround textobject

* Add textobject docs

* Refactor textobject word position functions

* Apply clippy lints on textobject

* Fix overflow error with textobjects
3 years ago
Nathan Vegdahl 28d2d68804 Make horizontal selection movement work properly. 3 years ago
Kirawi c5b2973739
`:reload` (#374)
* reloading functionality

* fn with_newline_eof()

* fmt

* wip

* wip

* wip

* wip

* moved to core, added simd feature for encoding_rs

* wip

* rm

* .gitignore

* wip

* local wip

* wip

* wip

* no features

* wip

* nit

* remove simd

* doc

* clippy

* clippy

* address comments

* add indentation & line ending change
3 years ago
Nathan Vegdahl 2224a1527e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Nathan Vegdahl 0b2d51cf5a Fix unused `Result` warnings in helix-term. 3 years ago
Nathan Vegdahl efa3389b6a Fix unused variable, parameter, and `mut` warnings in helix-term. 3 years ago
Nathan Vegdahl 702a0491db Remove #[allow(unused)] from helix-term, and fix unused imports.
Lots of other warning still left.  Will address in subsequent commits.
3 years ago
Nathan Vegdahl e725957704 Ensure a minimum selection width on commands that need it. 3 years ago
Nathan Vegdahl 7c7be6d583 Make `Selection`'s normalize and transform methods self-consuming only. 3 years ago
Nathan Vegdahl 0ae522f3df Clean up `Selection` to not use so many allocations. 3 years ago
Blaž Hrastnik 2a92dd8d4d If completion arrives after we already stopped editing, ignore it 3 years ago
Joe Neeman b39e452d77 Make set_unmodified an enum. 3 years ago
Joe Neeman 2902a10a3e Make Document's format API a little nicer. 3 years ago
Joe Neeman ffa2f2590b Satisfy clippy. 3 years ago
Joe Neeman d64d75e724 Add some async job infrastructure. 3 years ago
Joe Neeman c9be480bf8 Make formatting happen asynchronously. 3 years ago
PabloMansanet de8745aea7 Incorporate long word commands into keymap 3 years ago
Blaž Hrastnik 6214d707f3 fix: Don't panic on Enter on an empty document.
Refs #386
3 years ago
Blaž Hrastnik 503ca112ae fix: jumping to location did not convert the URI correctly
thus breaking Windows
3 years ago
Keith Simmons 4418e17547
reverse the dependency between helix-tui and helix-view (#366)
* reverse the dependency between helix-tui and helix-view by moving a fiew types to view

* fix tests

* clippy and format fixes

Co-authored-by: Keith Simmons <keithsim@microsoft.com>
3 years ago
Ivan Tham c2b937481f Fix goto line end
Should not goto newline.
3 years ago
Ivan Tham 10548bf0e3 Fix previous broken refactor key into helix-view
Need to be used for autoinfo

Revert "Revert "Refactor key into helix-view""

This reverts commit 10f9f72232.
3 years ago
Kirawi 15ae2e7ef1 Update helix-term/src/commands.rs
Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years ago
Kirawi 7ae21b98ce Update helix-term/src/commands.rs
Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years ago
Shafkath Shuhan 629df6124d Blocking :wq 3 years ago
Nathan Vegdahl 8935e7a879 Fix open-new-line command for CRLF, as well as other bugs.
Fixes #363.

I set out to fix issue #363, but after fixing it discovered some
other things were wrong with the command while testing.  In
summary:
- #363 was because it was still assuming a line ending width
  of 1 char in its indexing calculations, even when actually
  inserting CRLF.
- Aside from #363, it actually needed to set `line_end_index`
  to zero for *all* calculations that use it when line == 0,
  but it was only doing so for a single calculation.
3 years ago
Blaž Hrastnik 0f55e67576 fix: ok, needs to be the end of the previous line 3 years ago
Blaž Hrastnik 7366fe81e0 open: Use the correct function
Still not correct but at least it doesn't append at EOF
3 years ago
Blaž Hrastnik 4ad7b61c69 fix: Better fix that also fixes crashes on `o` 3 years ago
Blaž Hrastnik 655c1aeb73 fix: panic on O at the start of the file (fixes #354) 3 years ago
Shafkath Shuhan fd98e743e8 Handle non-UTF8 files 3 years ago
Nathan Vegdahl 848cc1b438 Fix extend_line() behavior.
It would always extend to the next line if the cursor was at the
end of the current line, even if the current line wasn't fully
selected yet.
3 years ago
Nathan Vegdahl 38bf9c2576 Missed some items in the CRLF PR. 3 years ago
Blaž Hrastnik 7511110d82 Fix build on master 3 years ago
Joe Neeman fd1ae35051 Make the prompt callback take a Context. 3 years ago
Lionel Flandrin 16883e7543 Implement show_current_directory command 3 years ago
Lionel Flandrin b56174d738 Implement change_current_directory command 3 years ago
Blaž Hrastnik 20f33ead67 minor: Remove old TODOs 3 years ago
Gokul Soumya e0fd08d6df Rename surround to match_mode 3 years ago
Gokul Soumya 753ed4cbc5 Add documentation for surround 3 years ago
Gokul Soumya b00e9fc227 Handle line endings correctly in surround 3 years ago
Gokul Soumya b79b5e66f2 Move match_bracket to mm 3 years ago
Gokul Soumya 13648d28b9 Add surround keybinds 3 years ago
Blaž Hrastnik a70de6e980
Merge pull request #224 from helix-editor/line_ending_detection
Line ending detection
3 years ago
Nathan Vegdahl a18d50b777 Add command to set the document's default line ending. 3 years ago
Nathan Vegdahl 7c4fa18764 Fix clippy warnings. 3 years ago
Nathan Vegdahl d33355650f Convert remaining commands to use the document's line ending setting. 3 years ago
Nathan Vegdahl e436c30ed7 Make split_selection_on_newline command handle all line endings. 3 years ago
Nathan Vegdahl 23d6188535 Update `replace` command to use document line ending setting. 3 years ago
Nathan Vegdahl 07e28802f6 Add function to get the line ending of a str slice.
This is needed in some places.
3 years ago
Nathan Vegdahl 714002048c Don't need getters/setters for line_ending property.
It's plain-old-data.  If we want to do fancier things later, it's
easy to switch back.
3 years ago
wojciechkepka cc357d5096 Add progress spinners to status line 3 years ago
Nathan Vegdahl e686c3e462 Merge branch 'master' of github.com:helix-editor/helix into line_ending_detection
Rebasing was making me manually fix conflicts on every commit, so
merging instead.
3 years ago
Nathan Vegdahl 4efd6713c5 Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
3 years ago
Blaž Hrastnik eaf259f8aa Fix build.. 3 years ago
Blaž Hrastnik f41688d960 Merge `x` and `X` 3 years ago
Benoît CORTIER f50261c944 Add mappable commands for system clipboard
System clipboard integration exists now in two favors: typable and
mappable.

Default mappings are:
- SPC p: paste clipboard after
- SPC P: paste clipboard before
- SPC y: join and yank selection to clipboard
- SPC Y: yank main selection to clipboard
- SPC R: replace selections by clipboard contents
3 years ago
Benoît CORTIER a2b8cfca34 Add system clipboard yank and paste commands
This commit adds six new commands to interact with system clipboard:
- clipboard-yank
- clipboard-yank-join
- clipboard-paste-after
- clipboard-paste-before
- clipboard-paste-replace
- show-clipboard-provider

System clipboard provider is detected by checking a few environment
variables and executables. Currently only built-in detection is
supported.

`clipboard-yank` will only yank the "main" selection, which is currently the first
one. This will need to be revisited later.

Closes https://github.com/helix-editor/helix/issues/76
3 years ago
Jan Hrastnik 8634e04a31 added the line_end helper function 3 years ago
Jan Hrastnik 701eb0dd68 changed some hardcoded newlines, removed a else if in line_ending.rs 3 years ago
wojciechkepka 42e13bd542 Add `:theme <name>` command 3 years ago
Blaž Hrastnik 10f9f72232 Revert "Refactor key into helix-view"
Did not use defaults when custom keymap was used

This reverts commit ca806d4f85.
3 years ago
Jan Hrastnik 1e80fbb602 fix merge issue 3 years ago
Jan Hrastnik cdd9347457 Merge remote-tracking branch 'origin/master' into line_ending_detection 3 years ago
Jan Hrastnik 97323dc2f9 ran cargo fmt 3 years ago
Jan Hrastnik ecb884db98 added get_line_ending from pr comment 3 years ago
Ivan Tham ca806d4f85 Refactor key into helix-view
Now also make use of Deserialize for Config.
3 years ago
Gokul Soumya b1cb98283d Fix indent regression issue with o, O
Indents were no longer respected with `o` and `O`. Using counts resulted
in multiple cursors in the same line instead of cursors on each line.

Introduced by 47d2e3ae
3 years ago
wojciechkepka a6d39585d8 Add `work_done_token` as parameter to lsp methods 3 years ago
Wojciech Kępka 41b07486ad
Fix expansion of `~` (#284)
* Fix expansion of `~`, dont use directory relative to cwd.

* Add `expand_tilde`

* Bring back `canonicalize_path`, use `expand_tilde` to `normalize`

* Make `:open ~` completion work

* Fix clippy

* Fold home dir into tilde in Document `realitve_path`
3 years ago
Benoît CORTIER 8664d70e73 Replace `Editor::current` by a macro
This is necessary to workaround ownership issues across function calls.
The issue notably arised when implementing the registers into `Editor`
and I was getting annoyed again when implementing copy/pasting into
system clipboard.
The problem is addressed by using macro calls instead of function calls.
There is no notable side effect.
3 years ago
Jan Hrastnik 8bccd6df30 applied changes from pr review 3 years ago
PabloMansanet f7e00cf720
Configurable keys 2 (Mapping keys to commands) (#268)
* Add convenience/clarity wrapper for Range initialization

* Add keycode parse and display methods

* Add remapping functions and tests

* Implement key remapping

* Add remapping book entry

* Use raw string literal for toml

* Add command constants

* Make command functions private

* Map directly to commands

* Match key parsing/displaying to Kakoune

* Formatting pass

* Update documentation

* Formatting

* Fix example in the book

* Refactor into single config file

* Formatting

* Refactor configuration and add keymap newtype wrappers

* Address first batch of PR comments

* Replace FromStr with custom deserialize
3 years ago
Gokul Soumya 47d2e3aefa Let o, O take counts for multiple cursors 3 years ago
Gokul Soumya 20d6b202d5 Fix cursor position bugs related to o and O
- `O` at the beginning of file didn't move cursor
- `o` and `O` messed up cursor position with multiple cursors

Fixes #127
3 years ago
Jan Hrastnik 9c3eadb2e4 fixed some problems from rebasing 3 years ago
Jan Hrastnik 7cf0fa05a4 doc.line_ending() now returns &'static str 3 years ago
Jan Hrastnik a4f5a0134e trying out line ending helper functions in commands.rs 3 years ago
Benoît CORTIER 6bdf609caa Remove RwLock for registers
Registers are stored inside `Editor` and accessed without `RwLock`.
To work around ownership, I added a sister method to `Editor::current`:
`Editor::current_with_context`. I tried to modify `Editor::current`
directly but it's used at a lot of places so I reverted into this for
now at least.
3 years ago
Benoît CORTIER 6fb2d2679d Use `_impl` suffix instead of `_` prefix
Helpers / internal implementations where using the `_` prefix.
However, this prefix also suppress unused warnings.
I suggest we use the `_impl` suffix instead.
3 years ago
Ivan Tham 05ed3e8fb8 Remove unused variables 3 years ago
Nathan Vegdahl 7c2fb92c91 Report indent style when calling indent-style with no arguments.
Also print an error message when the argument is malformed.
3 years ago
Nathan Vegdahl d415a666fe Address PR comments.
* Clean up "indent-style" command argument parsing.
* Adjust command's name to match the style of other commands.
* Add a "0" alias to the command, for tabs indent style.
3 years ago
Nathan Vegdahl 358ea6a37c Implement command to change the indent-style setting of a document. 3 years ago
Blaž Hrastnik e819121f6e fix: wq/wqa functions need to wait for save to finish before closing 3 years ago
Andreas Liljeqvist 5d23667a26 fix offset by one problem in replace_with_yanked 3 years ago
Wojciech Kępka df217f71c1 Fix `wq` 3 years ago
Wojciech Kępka b9100fbd44 Fix clippy 3 years ago
Wojciech Kępka 52d3c29244 Deduplicate code 3 years ago
Wojciech Kępka 17c9a8499e Add `qa` and `qa!` 3 years ago
Wojciech Kępka 62e6232a32 Update write_all 3 years ago
Wojciech Kępka d8b5d1181f Add `Copy` derive to `PromptEvent` 3 years ago