Commit Graph

262 Commits (13ed4f6c4748019787d24c2b686d417b71604242)

Author SHA1 Message Date
Skyler Hawthorne a494f47a5d
Configurable auto pairs (#1624)
* impl auto pairs config

Implements configuration for which pairs of tokens get auto completed.

In order to help with this, the logic for when *not* to auto complete
has been generalized from a specific hardcoded list of characters to
simply testing if the next/prev char is alphanumeric.

It is possible to configure a global list of pairs as well as at the
language level. The language config will take precedence over the
global config.

* rename AutoPair -> Pair

* clean up insert_char command

* remove Rc

* remove some explicit cloning with another impl

* fix lint

* review comments

* global auto-pairs = false takes precedence over language settings

* make clippy happy

* print out editor config on startup

* move auto pairs accessor into Document

* rearrange auto pair doc comment

* use pattern in Froms
2 years ago
Blaž Hrastnik a449156702 Extract a lsp position helper 2 years ago
Gokul Soumya 59b5bf3178 Refactor document methods 2 years ago
Blaž Hrastnik e2d2f19fd0
Merge pull request #1154 from sudormrfbin/cursor-shape-new
Change cursor shape on mode change
2 years ago
Blaž Hrastnik 4080341977 cargo fmt + clippy lint 2 years ago
Blaž Hrastnik 53d881f172 Store theme scopes on the loader, this way theme isn't passed around 2 years ago
Blaž Hrastnik 6728e44490 syntax: Split parsing and highlighting 2 years ago
Kevin Sjöberg 3a34036310
Use the correct language ID for JavaScript & TypeScript (#1466)
* Use correct language ID for JavaScript/TypeScript

* Add missing slash

* Only calculate fallback when needed
2 years ago
Gokul Soumya 449624965b Merge branch 'master' into cursor-shape-new 3 years ago
Matouš Dzivjak 4b0b1a5657
feat(ui): file encoding in statusline (#1355)
* feat(ui): file encoding in statusline

Display file encoding in statusline if the encoding
isn't UTF-8.

* Re-export encoding_rs from core

From there it can be imported by other mods
that rely on it.
3 years ago
WindSoilder 600ce70cf6
Improve dedent behavior (#1232)
* tmp add code for dedent

* finish normal_mode with dedent behavior

* use function pointer

* rebase from origin

* check dedent condition inside normal_mode implementation

* using if let...

* fix check

* using char_is_whitespace instead of ch.is_whitespace

* fix clippy

* abstract restore_indent function
3 years ago
Gokul Soumya d4fb1d0633 Merge branch 'master' into cursor-shape-new 3 years ago
Gokul Soumya 016640f4fb Remove ui.cursor.primary and hashmap lookups 3 years ago
Ivan Tham e2b428cc2d
Add last modified file (gm) (#1093) 3 years ago
ath3 35c974c9c4
Implement "Goto last modification" command (#1067) 3 years ago
Cole Helbling b824e091a9
helix-term/commands: move SCRATCH_BUFFER_NAME to helix-view/document (#1091)
This way, the name is accessible everywhere `Document` and related types
are.
3 years ago
Ivan Tham 9d591427be
Fix earlier/later missing changeset update (#1069)
Fix #1059
3 years ago
Blaž Hrastnik 549cdee561 Refactor shebang detection to reuse the loaded buffer 3 years ago
ath3 77dbbc73f9
Detect filetype from shebang line (#1001) 3 years ago
Blaž Hrastnik e80708eba7 Make sure document diagnostics are sorted 3 years ago
Omnikar 51b4d35dce
Inform when reaching undo/redo bounds (#981)
* Inform when reaching undo/redo bounds

* `Already at oldest change` when undo fails
* `Already at newest change` when redo fails

* Add missing `the`
3 years ago
Kirawi cec0cfdaec
Uncomment mapping LSP diagnostics through changes (#925) 3 years ago
Blaž Hrastnik c1e5831b21 set_path: Pass in the function directly 3 years ago
Blaž Hrastnik 3e69a4852e Simplify set_path 3 years ago
Omnikar e2ed691537
Implement `hx --tutor` and `:tutor` to load `tutor.txt` (#898)
* Implement `hx --tutor` and `:tutor` to load `tutor.txt`

* Document `hx --tutor` and `:tutor`

* Change `Document::set_path` to take an `Option`

* `Document::set_path` accepts an `Option<&Path>` instead of `&Path`.
* Remove `Editor::open_tutor` and make tutor-open functionality use
  `Editor::open` and `Document::set_path`.

* Use `PathBuf::join`

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

* Add comments explaining unsetting tutor path

Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years ago
Blaž Hrastnik e36ad8b4ed minor: Further simplify take_with 3 years ago
Blaž Hrastnik 3edca7854e completion: fully revert state before apply & insertText common prefix 3 years ago
Blaž Hrastnik c913bade0a fix: Indentation used different default on `hx` vs `hx new_file.txt` 3 years ago
Blaž Hrastnik 0b1bc566e4 fix: lsp: Regression with textDocument/didSave not getting sent 3 years ago
Blaž Hrastnik 64099af3f1 Don't panic on save if language_server isn't initialized 3 years ago
Blaž Hrastnik 37606bad47 lsp: doc.language_server() is None until initialize completes 3 years ago
Blaž Hrastnik 10b690b5bd Drop some &mut bounds where & would have sufficed 3 years ago
Blaž Hrastnik 800d79b584 ls: Refactor textDocument/didSave in a similar vein 3 years ago
Blaž Hrastnik 184637c55a lsp: refactor format so we stop cloning the language_server 3 years ago
Blaž Hrastnik 57ed5180e0 lsp: Improve line ending handling when generating TextEdit 3 years ago
Brian Shu fa4caf7e3d remove unsafe 3 years ago
Kirawi b99db7c687
Move path util functions from helix-term to helix-core (#650) 3 years ago
Blaž Hrastnik 1d45f50781 fix: Don't internally use relative paths in the buffer picker
Fixes #619
3 years ago
Kirawi 16bf8e1e6b
Document more of document.rs (#562) 3 years ago
Gokul Soumya d84f8b5fde
Show file preview in split pane in fuzzy finder (#534)
* Add preview pane for fuzzy finder

* Fix picker preview lag by caching

* Add picker preview for document symbols

* Cache picker preview per document instead of view

* Use line instead of range for preview doc

* Add picker preview for buffer picker

* Fix render bug and refactor picker

* Refactor picker preview rendering

* Split picker and preview and compose

The current selected item is cloned on every event, which is
undesirable

* Refactor out clones in previewed picker

* Retrieve doc from editor if possible in filepicker

* Disable syntax highlight for picker preview

Files already loaded in memory have syntax highlighting enabled

* Ignore directory symlinks in file picker

* Cleanup unnecessary pubs and derives

* Remove unnecessary highlight from file picker

* Reorganize buffer rendering

* Use normal picker for code actions

* Remove unnecessary generics and trait impls

* Remove prepare_for_render and make render mutable

* Skip picker preview if screen small, less padding
3 years ago
Blaž Hrastnik f0eb6ed96a Resolve a couple TODOs 3 years ago
Blaž Hrastnik 557c63033c fix: Map all selections on transaction.apply 3 years ago
Nathan Vegdahl f88d4c1e20 Move indent-style code into `helix_core::indent`. 3 years ago
Nathan Vegdahl e191a75e33 Give default document a single line ending. 3 years ago
Nathan Vegdahl cd7302ffd3 Enforce cursor/selection invariants in one place.
Rather than per-command like before.
3 years ago
Nathan Vegdahl 43594049dd Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Shafkath Shuhan 25103833b2 mark reloaded buffers as unchanged 3 years ago
Nathan Vegdahl 198fe40951 Don't insert a final line ending on file load/reload. 3 years ago
Nathan Vegdahl a77274e8bb Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Kirawi 0b1ed8656d
Fix #442 (#446)
* fix #442

fix #442

fmt

* create Rope from default line ending

* Fix use of encoding in Document::open()
3 years ago
Nathan Vegdahl 85d5b399de Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Blaž Hrastnik fc34efea12 appease clippy 3 years ago
Blaž Hrastnik 48481db8ca fix: Make path absolute before normalizing
:open ../file.txt failed before because .. would be stripped
3 years ago
Blaž Hrastnik b72c6204e5 fix: When calculating relative path, expand tilde last 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 28627f97e9 Fix empty document test. 3 years ago
Nathan Vegdahl 7961a13007 Make new documents empty, rather than starting with a line ending. 3 years ago
Nathan Vegdahl 22dca3b111 Allow last line in file to lack a line break character. 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
Joe Neeman 2902a10a3e Make Document's format API a little nicer. 3 years ago
Joe Neeman c9be480bf8 Make formatting happen asynchronously. 3 years ago
Nathan Vegdahl d534d6470f Detect file language before file indent style.
Fixes #378.  The issue was that because indent style detection
ran before language detection, there was no language indent
style to fall back on if indent style detection failed, so it
would just default to 2 spaces.
3 years ago
teenjuna c688288881
Move helix-view/tests/*txt files to txts subdirectory (#372)
* Move helix-view/tests/*txt files to txts subdirectory

* Rename tests/txts to tests/encoding
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
Shafkath Shuhan 6564257a7b add missing doc 3 years ago
Shafkath Shuhan fd98e743e8 Handle non-UTF8 files 3 years ago
Nathan Vegdahl 0cbaa998ce Fix flipped condition where Helix adds a line ending on open. 3 years ago
Gokul Soumya 13648d28b9 Add surround keybinds 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
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
Ivan Tham 985625763a Fix doc warnings 3 years ago
Nathan Vegdahl 5d22e3c4e5 Misc fixes and clean up of line ending detect code. 3 years ago
Jan Hrastnik 701eb0dd68 changed some hardcoded newlines, removed a else if in line_ending.rs 3 years ago
wojciechkepka ce97a2f05f Add ability to change theme on editor 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 cdd9347457 Merge remote-tracking branch 'origin/master' into line_ending_detection 3 years ago
Ivan Tham ca806d4f85 Refactor key into helix-view
Now also make use of Deserialize for Config.
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
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
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
Jan Hrastnik a9a718c3ca added some tests and a line_ending helper function in document.rs 3 years ago
Jan Hrastnik 9c419fe05c added more changes from pr review for line_ending_detection 3 years ago
Jan Hrastnik 5eb6918392 resolved conflict in rebase 3 years ago
Jan Hrastnik 17f69a03e0 ran cargo clippy and cargo fmt 3 years ago
Jan Hrastnik 3756c21bae rebase on branch line_ending_detection 3 years ago
Nathan Vegdahl ecb39da3e0 Cosmetic changes and better comments for the indent auto-detect code. 3 years ago
Nathan Vegdahl 0a5580aa21 Address PR comments.
- Move char functions into their own module under helix_core.
- Use matches!() macro where appropriate.
- Use a static lifetime on indent_unit() now that we can.
3 years ago
Nathan Vegdahl 8648e483f7 Render indent-style status in status line.
Also cleaned up the status line code a little.
3 years ago
Nathan Vegdahl 5ca043c17a Fix clippy warnings. 3 years ago
Nathan Vegdahl 2329512122 Attempt to auto-detect indentation style on document load.
This also moves the primary indentation-style setting into Document.
3 years ago
Wojciech Kępka d008e86037 `Document::is_modified` should not check if path is set
If there is a new document we still want to know if there are unsaved changes
3 years ago
Jakub Bartodziej 69fe46a122
Add :earlier and :later commands that can be used to navigate the full edit history. (#194)
* Disable deleting from an empty buffer which can cause a crash.

* Improve on the fix for deleting from the end of the buffer.

* Clean up leftover log.

* Avoid theoretical underflow.

* Implement :before which accepts a time interval and moves the editor to
the closest history state to the commit of the current time minus that
interval. Current time is now by default, or the commit time if :before
has just been used.

* Add :earlier an :later commands that can move through
the edit history and retrieve changes hidded by undoing
and commiting new changes. The commands accept a number
of steps or a time period relative to the currrent change.

* Fix clippy lint error.

* Remove the dependency on parse_duration, add a custom parser instead.

* Fix clippy errors.

* Make helix_core::history a public module.

* Use the helper for getting the current document and view.

* Handled some PR comments.

* Fix the logic in :later n.

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

* Add an alias for :earlier.

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

* Add an alias for later.

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

* Run cargo fmt.

* Add some tests for earlier and later.

* Add more tests and restore the fix for later that diappeared somehow.

* Use ? instead of a match on an option.

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

* Rename to UndoKind.

* Remove the leftover match.

* Handle a bunch of review comments.

* More systemd.time compliant time units and additional description for the new commands.

* A more concise rewrite of the time span parser using ideas from PR discussion.

* Replace a match with map_err().

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

Co-authored-by: Jakub Bartodziej <jqb@google.com>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years ago
Ivan Tham 7cc13fefe9 Derive debug without feature
Note that this also removed those `finish_non_exhaustive()`.
3 years ago
notoria 1a3a924634 Implement Debug for data structure as a feature 3 years ago
Kevin Sjöberg 7ef0e2cab6 Don't panic on empty document 3 years ago
Ivan Tham 82fdfdc38e Add missing newline to end of file on load
Fix #152
3 years ago
Wojciech Kępka 16b1cfa3be Add diagnostics keybindings 3 years ago
Wojciech Kępka bcb1afeb4c Add a comment to `canonicalize_path` 3 years ago
Wojciech Kępka de946d2357 Add a TODO 3 years ago
Wojciech Kępka 14f511da93 Create document if it doesn't exist on save 3 years ago
Blaž Hrastnik 06d8d3f55f Try to detect language when document file path is set
Fixes #91
3 years ago
Ivan Tham e6132f0acd Fix undo redo
I missed the fast return.

Fix #89
3 years ago
Jakub Bartodziej 3c5dfb0633 Improve on the fix for deleting from the end of the buffer. 3 years ago
Jakub Bartodziej 6cbc0aea92 Disable deleting from an empty buffer which can cause a crash. 3 years ago
Ivan Tham f5f46b1fed Separate document history into Cell
As history is used separately from the rest of the edits, separating it
can avoid needless borrowing and cloning. But one need to be aware later.
3 years ago
Blaž Hrastnik ce25aa951e Allow setting a filepath on :write 3 years ago
Blaž Hrastnik 2c48d65b15 Format document on save 3 years ago
Blaž Hrastnik 4a9d1163e0 Hacky way to specify indent scopes per language via toml configs.
Can't do it via a scm query nicely because it returns an iterator over
all the matches, whereas we want to traverse the tree ourselves.

Can't extract the pattern data from a parsed query either.

Oh well, toml files for now.
3 years ago
Blaž Hrastnik 355ad3cb82 Tokio migration. 3 years ago
Blaž Hrastnik b0bdcab970 doc: Note about diagnostic mapping. 3 years ago
Blaž Hrastnik 28c167d71d doc: Be smarter about calculating modified status.
This way edit -> undo will properly show up as unmodified.
3 years ago
Blaž Hrastnik 3e5f24a9d5 lsp: support both utf-8 and utf-16 offsets.
Still need to implement the clangd encoding negotiation, but it's
a start. Should also manually override to utf8 for pyls.
3 years ago
Blaž Hrastnik cf7b19d711 Always update selection: Empty transactions can still change selections. 3 years ago
Blaž Hrastnik ceea5eacd8 clippy lint 3 years ago
Blaž Hrastnik 15c9a33ebc Drop doc.state. Use doc.text + doc.selections. 3 years ago
Blaž Hrastnik 6c4093c946 Weave through view_id references so that views into one file have independent selects. 3 years ago
Blaž Hrastnik 9eaef6e333 Fully drop State references. 3 years ago
Blaž Hrastnik 1b5316ea74 Track document modified state. 3 years ago
Blaž Hrastnik 742b3a709f Store intra-files jumps (goto) on the jumplist. 3 years ago
Blaž Hrastnik c1f2a14453 view: document.rs cleanup 3 years ago
Blaž Hrastnik aefafc25cd Replace Mode::Goto with just using on_next_key. 3 years ago
Blaž Hrastnik e3c4edae32 Add the machinery to load syntax config from TOML.
It's embedded into the binary at build time for now, but it's progress.
3 years ago
Blaž Hrastnik 8328fe926d Drop refcell use, make view simply ref doc.id. 3 years ago
Blaž Hrastnik 5e6716c89c Add tab_width and indent_unit config. 3 years ago
Blaž Hrastnik c331721565 Finish hiding doc.state / State as an implementation detail. 3 years ago
Blaž Hrastnik 8ba1e15d29 Expose doc.syntax() via accessor. 3 years ago
Blaž Hrastnik 2b64f49f2c Document::new should just take a rope. 3 years ago
Blaž Hrastnik e261f3c50d Expose doc.language_server as an accessor. 3 years ago
Blaž Hrastnik 59e6024186 Remove State from a few more signatures. 3 years ago
Blaž Hrastnik 8eaf9a432d Make Transaction::change only rely on the rope. 3 years ago
Blaž Hrastnik 143cfe13e0 minor: TODO comment cleanup 3 years ago
Blaž Hrastnik bb87b08fc9 Configure language servers via LanguageConfiguration. 3 years ago
Blaž Hrastnik 6cbfb050e2 lsp: Emit didSave notifications. 3 years ago
Blaž Hrastnik ec4dd0a176 Add a selection mode again. 3 years ago
Blaž Hrastnik 87a6d4e736 minor: Simplify some code. 3 years ago
Blaž Hrastnik 8b9b02f08b minor 3 years ago
Blaž Hrastnik 3b6c9648f3 fix clippy lint 3 years ago
Blaž Hrastnik 9132c6a591 Make some Document fields read-only. 3 years ago
Blaž Hrastnik d5f9622e2e lsp: edit events change ranges need to affect each other. 3 years ago
Blaž Hrastnik 1ffd1e7633 Send updates to the lsp on undo/redo. 3 years ago
Blaž Hrastnik b7da7f83c3 lsp: Test changeset_to_changes. 3 years ago
Blaž Hrastnik 777a80917d Address clippy lints. 4 years ago
Blaž Hrastnik 3cbab20908 lsp: Fix pos_to_lsp_pos calculation. 4 years ago