Commit graph

251 commits

Author SHA1 Message Date
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.
2021-03-25 15:26:25 +09:00
Blaž Hrastnik
9a36d2c2a8 wip: Hooks & trigger characters for completion/signature_help. 2021-03-24 18:17:00 +09:00
Blaž Hrastnik
06aca7691c clippy lint 2021-03-24 14:58:01 +09:00
Blaž Hrastnik
d0530fb839 Fix a scrolling crash where it would jump past the end of the buffer. 2021-03-22 18:06:52 +09:00
Blaž Hrastnik
73c92a0bc1 Implement m / match_brackets (using tree sitter). 2021-03-22 17:58:49 +09:00
Blaž Hrastnik
bd607b4cbd Provide a capacity on Selection::new's normalize. 2021-03-22 14:50:08 +09:00
Blaž Hrastnik
5e6716c89c Add tab_width and indent_unit config. 2021-03-22 13:53:36 +09:00
Blaž Hrastnik
cbcacb1063 Merge some imports. 2021-03-22 12:40:07 +09:00
Blaž Hrastnik
c4792efead clippy lints 2021-03-22 12:29:55 +09:00
Blaž Hrastnik
798dbd27c5 Selection: fail early if new() is called with no ranges. 2021-03-22 12:22:33 +09:00
Blaž Hrastnik
71999cce43 Implement auto-pairs behavior for open and close. 2021-03-22 12:22:33 +09:00
Blaž Hrastnik
f29f01858d Implement iter() and len() directly on Selection. 2021-03-19 11:14:13 +09:00
Blaž Hrastnik
c331721565 Finish hiding doc.state / State as an implementation detail. 2021-03-18 15:07:02 +09:00
Blaž Hrastnik
59e6024186 Remove State from a few more signatures. 2021-03-18 14:17:32 +09:00
Blaž Hrastnik
dbcc099f48 Move things out of state.rs. 2021-03-18 14:07:53 +09:00
Blaž Hrastnik
8eaf9a432d Make Transaction::change only rely on the rope. 2021-03-18 13:39:56 +09:00
Blaž Hrastnik
4f77d80e74 Clippy lint 2021-03-16 13:51:35 +09:00
Blaž Hrastnik
081e0ae8ae syntax: highlight_iter always returns Ok() 2021-03-16 13:51:35 +09:00
Blaž Hrastnik
71f899cb5b syntax: Highlight using ropes, avoiding dumping whole doc to string. 2021-03-16 13:47:06 +09:00
Blaž Hrastnik
dd91090a1a Implement keep_selections (filter selections on regex). 2021-03-15 17:09:18 +09:00
Blaž Hrastnik
87e3cd3df2 ui: Render diagnostic errors in sideline. 2021-03-15 16:19:31 +09:00
Blaž Hrastnik
9c55b3e306 state.rs cleanup 2021-03-15 14:45:09 +09:00
Blaž Hrastnik
bb87b08fc9 Configure language servers via LanguageConfiguration. 2021-03-14 17:14:34 +09:00
Blaž Hrastnik
1cf887dea9 Cleanup: use doc.selection() instead of doc.state.selection(). 2021-03-14 17:14:34 +09:00
Blaž Hrastnik
3445abf88e syntax: Hide the TSParser internally, borrowing when needed. 2021-03-13 11:06:02 +09:00
Blaž Hrastnik
b7dd7310c4 syntax: Reuse parser instances. highlight_iter() no longer needs &mut. 2021-03-12 14:46:23 +09:00
Blaž Hrastnik
9dcfe25e4a Use diagnostic.severity to distinguish between error colors. 2021-03-11 16:31:49 +09:00
Blaž Hrastnik
4acf301022 Implement the f/t/F/T find/till family of commands. 2021-03-11 16:15:27 +09:00
Blaž Hrastnik
62c991230f find-till (f) prototype, on_next_key mode implementation. 2021-03-11 10:44:38 +09:00
Blaž Hrastnik
90f9cd6d62 search: draft f/t 2021-03-10 17:50:46 +09:00
Blaž Hrastnik
a16c6e2585 clippy lints 2021-03-01 17:37:31 +09:00
Blaž Hrastnik
2c9b02039b commands: Implement join_selections. 2021-02-26 17:21:59 +09:00
Blaž Hrastnik
ad58286dc7 graphemes: fix nth_prev_grapheme_boundary calculation. 2021-02-26 15:53:01 +09:00
Blaž Hrastnik
01907b3497 commands: Implement count for a few more commands. 2021-02-25 16:49:30 +09:00
Blaž Hrastnik
6bd16a7320 graphemes: Optimize nth_next/nth_prev operation.
It's used a lot more than it used to in position calculation. Instead of
throwing away state between boundary calculation, reuse it.
2021-02-24 17:12:44 +09:00
Blaž Hrastnik
f118e7580f Improve coords_at_pos & pos_at_coords, test with graphemes. 2021-02-24 16:08:17 +09:00
Blaž Hrastnik
87a6d4e736 minor: Simplify some code. 2021-02-24 16:07:39 +09:00
Blaž Hrastnik
6cfb1acb9d commands: Implement expand_selection. 2021-02-22 17:02:32 +09:00
Blaž Hrastnik
33c67f1388 commands: add * as selection search. 2021-02-22 15:14:02 +09:00
Blaž Hrastnik
9132c6a591 Make some Document fields read-only. 2021-02-21 19:47:21 +09:00
Blaž Hrastnik
8c82f8f140 indent: use_list indentation, fix indentation bug on open_below
use std::{
  time::Duration // <- pressing `o` here would use }'s indent instead of prev line
}
2021-02-19 14:55:53 +09:00
Blaž Hrastnik
7a1ff5e45f commands: Wire up toggle comments as ctrl-c 2021-02-19 13:59:24 +09:00
Blaž Hrastnik
4ab5631d65 more lints 2021-02-18 18:45:41 +09:00
Blaž Hrastnik
d0791e0f98 core: Implement comment toggling module. 2021-02-18 18:35:39 +09:00
Blaž Hrastnik
c9dd1c930e treewide: &RopeSlice -> RopeSlice. It's Copy so no reason to pass by ref 2021-02-18 18:34:22 +09:00
Blaž Hrastnik
af55ebd002 transaction: Also modify map_pos to work with insert|delete order. 2021-02-18 12:17:33 +09:00
Blaž Hrastnik
9cac44c7c0 minor changes 2021-02-17 17:26:27 +09:00
Blaž Hrastnik
d8bc19f715 Update deps, switch tendril over to crates.io 2021-02-16 18:11:17 +09:00
Blaž Hrastnik
9821c4dd3b Optimize Changeset::is_empty()
Checked the ASM output for these three options:

pub enum Operation {
    /// Move cursor by n characters.
    Retain(usize),
    /// Delete n characters.
    Delete(usize),
    /// Insert text at position.
    Insert(String),
}

pub struct A {
    changes: Vec<Operation>,
    len: usize,
}

impl A {
    pub fn is_empty1(&self) -> bool {
        match self.changes.as_slice() {
            [] => true,
            [Operation::Retain(_)] => true,
            _ => false,
        }
    }

    /// `true` when the set is empty.
    pub fn is_empty2(&self) -> bool {
        let len = self.changes.len();
        len == 0
        || (
            len == 1
            && self.changes[0] == Operation::Retain(self.len)
        )

    }

    pub fn is_empty3(&self) -> bool {
        match self.changes.as_slice() {
            [] | [Operation::Retain(_)] => true,
            _ => false
        }
    }

}
2021-02-16 13:39:04 +09:00
Blaž Hrastnik
b0b5451c38 Since insert preceedes deletes, follow that ordering in Transaction::changes.
Produces the same output but will take the happy path.
2021-02-16 11:09:05 +09:00
Blaž Hrastnik
b4312c9492 transaction: Use builder methods to generate compact changesets. 2021-02-16 11:03:36 +09:00
Blaž Hrastnik
19fb4ed835 transaction: Merge consecutive inserts on compose. 2021-02-16 00:15:49 +09:00
Blaž Hrastnik
65893a2cbc fix test 2021-02-16 00:15:38 +09:00
Blaž Hrastnik
239db79834 Finally: Retain horizontal position when moving vertically. 2021-02-12 16:49:24 +09:00
Blaž Hrastnik
a924ad2885 simplify. 2021-02-05 16:06:48 +09:00
Blaž Hrastnik
2bea5db7bd commands: Implement select_on_matches. 2021-01-22 17:13:14 +09:00
Blaž Hrastnik
7c99ff58fd nix: include rust-src so rust-analyzer works correctly. 2021-01-19 16:16:15 +09:00
Blaž Hrastnik
22e1692adc indent: Fix edge cases, refactor test. 2021-01-10 23:46:18 +09:00
Blaž Hrastnik
777a80917d Address clippy lints. 2021-01-08 16:37:36 +09:00
Blaž Hrastnik
7d41550a23 indent: refactor logic to be more correct.
Thanks to atom-sane-indentation, nvim-treesitter and tree-sitter-indent.el
for inspiration.
2021-01-08 16:15:12 +09:00
Blaž Hrastnik
a7869c728c wip 2020-12-03 13:12:07 +09:00
Blaž Hrastnik
cc6bdf8f66 Text change generation, RPC call handling. 2020-12-03 13:10:35 +09:00
Blaž Hrastnik
f5981f72c2 Introduce Selection::point. 2020-12-03 13:10:35 +09:00
Blaž Hrastnik
efc5aa2016 Simplify old_state handling. 2020-12-03 13:10:35 +09:00
Blaž Hrastnik
c0e17dd324 Fix undo/redo not updating the syntax tree. 2020-12-03 13:10:35 +09:00
Blaž Hrastnik
b39849dde1 Refactor: Document type as a wrapper around barebones State. 2020-12-03 13:10:35 +09:00
Blaž Hrastnik
ef5e5f9296 state.version tracking 2020-12-03 13:10:34 +09:00
Blaž Hrastnik
49254d7180 Total mess but it works: diagnostic marking. 2020-12-03 13:10:34 +09:00
Blaž Hrastnik
f9bfba4d96 Reroute LSP notification events into the main app event loop. 2020-12-03 13:10:32 +09:00
Blaž Hrastnik
64b5b23315 Move theme from view to editor, support multiple views in editor. 2020-12-03 13:07:55 +09:00
Blaž Hrastnik
bc2c652fe8 Bugfix 2020-10-16 16:58:26 +09:00
Jan Hrastnik
7d58378374 added move left&right, delete char 2020-10-16 12:01:21 +09:00
Jan Hrastnik
ed03ec92a8 moved prompt command matching to prompt.rs 2020-10-16 12:00:28 +09:00
Jan Hrastnik
0c0c2c7103 modified editor.render() to prepare for command mode rendering 2020-10-16 11:53:31 +09:00
Blaž Hrastnik
16828d322a wip 2020-10-15 23:31:37 +09:00
Blaž Hrastnik
6e658aae1c Auto-indent on enter based on tree-sitter scopes. 2020-10-14 18:07:42 +09:00
Blaž Hrastnik
d64f4beede Share tab width definitions. 2020-10-14 13:35:54 +09:00
Blaž Hrastnik
0b74d423d0 Validate compose len after applying a is same as before applying b. 2020-10-14 13:35:54 +09:00
Blaž Hrastnik
7fcc6f8f1b Fix overlapping (insert | delete) compose 2020-10-14 11:48:01 +09:00
Blaž Hrastnik
94f9603c74 Fix compose not merging certain changesets correctly. 2020-10-14 09:38:52 +09:00
Blaž Hrastnik
00e661f600 Indent draft, linewise paste 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
4a648555ed Don't try to compose zero-width deletes. 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
490e23b645 Simplify changeset tracking. 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
8098279676 Cleanup 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
1dba0f2b1c Simple yank/paste registers. 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
eba5b1ef33 Fix changeset composition, lengths don't have to match. 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
b765c17896 Hacky undo/redo integration. 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
04b1546634 history.redo() 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
8c7bc71ede Split on matches off by one, breaks tests again. 2020-10-13 23:13:56 +09:00
Blaž Hrastnik
fd311fb8ad Undo tree draft.
We keep a tree of transactions. This allows for persistent undo by
simply serializing the changesets.
2020-10-13 23:13:56 +09:00
Blaž Hrastnik
5392b48268 Drop Coords. 2020-10-07 13:59:19 +09:00
Jan Hrastnik
038201647c started work on goto mode 2020-10-04 23:47:37 +02:00
Blaž Hrastnik
883b77bd24 Fix transaction.invert()/.apply() using byte counts instead of char counts. 2020-10-04 17:37:46 +09:00
Blaž Hrastnik
aa077a07f3 Implement Transaction::invert. 2020-10-02 18:16:26 +09:00
Blaž Hrastnik
5945815d97 Fix cursor rendering & placement on append mode. 2020-10-01 18:44:12 +09:00
Blaž Hrastnik
e39bd211d1 argh -> clap to speed up compilation (no syn/proc_macro) 2020-10-01 12:25:03 +09:00
Blaž Hrastnik
592c5b0af2 Fix test, break split + append 2020-09-29 18:13:19 +09:00
Blaž Hrastnik
3feb00283d clippy warnings 2020-09-29 18:07:05 +09:00
Blaž Hrastnik
1bb01d27ae Simplify line ending calculation. 2020-09-29 17:49:19 +09:00
Blaž Hrastnik
13d1ea542e Clamp character movement to line. 2020-09-29 01:11:17 +09:00
Blaž Hrastnik
36e7e2133f Split selection on regex, fix InputEdit generation. 2020-09-29 01:01:27 +09:00
Blaž Hrastnik
3020077da8 Extend selection commands. 2020-09-29 01:00:35 +09:00
Blaž Hrastnik
e0785aabe7 Move-by-word commands: w, b, e. 2020-09-24 19:16:35 +09:00
Blaž Hrastnik
eb639eb2e4 More robust syntax detection/grammar loading. 2020-09-22 18:27:37 +09:00
Blaž Hrastnik
935cfeae57 Split parts of helix-term into helix-view.
It still largely depends on term for some types but I plan to change
that later.
2020-09-21 18:24:16 +09:00
Blaž Hrastnik
48330ddb5f Command needs access to view information for certain changes. 2020-09-19 23:16:00 +09:00
Blaž Hrastnik
b120515613 Range based highlight_iter. Only works on limiting the start right now 2020-09-19 11:58:08 +09:00
Blaž Hrastnik
3859f6963d More work on the UI. 2020-09-19 11:58:08 +09:00
Blaž Hrastnik
088f8a82af Incremental parsing: rough draft. 2020-09-17 16:32:40 +09:00
Blaž Hrastnik
31999d6528 Make state fields read-only from outside the crate. 2020-09-14 19:50:46 +09:00
Blaž Hrastnik
96db02742e Simplify some more code. 2020-09-13 23:40:11 +09:00
Blaž Hrastnik
0427acd18c Avoid collect() by accepting iterators into Transaction::change. 2020-09-13 23:12:14 +09:00
Blaž Hrastnik
2027f69eae Deduplicate some code. 2020-09-13 20:11:29 +09:00
Blaž Hrastnik
b827b41efe Address clippy lint. 2020-09-13 20:06:53 +09:00
Blaž Hrastnik
b08278807e Add 'A', 'I' commands. 2020-09-13 20:04:16 +09:00
Blaž Hrastnik
fb0f56b747 Add 'o' command. 2020-09-13 19:51:42 +09:00
Blaž Hrastnik
22cb7b3338 Change -> Operation, Change2 -> Change 2020-09-13 19:18:05 +09:00
Blaž Hrastnik
d86f0feafc Abstract Transaction::change from change_by_selection. 2020-09-13 15:48:15 +09:00
Blaž Hrastnik
593f33dca6 Fix clippy warnings. 2020-09-13 11:36:48 +09:00
Blaž Hrastnik
d466882d04 Abstract Transaction::change_by_selection, working del/backspace. 2020-09-13 11:32:37 +09:00
Blaž Hrastnik
f098166571 Get rid of a bunch of clones. 2020-09-12 23:52:38 +09:00
Blaž Hrastnik
9546164dc8 cargo fmt & clippy lint 2020-09-12 19:38:30 +09:00
Blaž Hrastnik
a106be94f1 Refactor a little bit. 2020-09-12 17:44:57 +09:00
Blaž Hrastnik
b17a77b8b8 cleanup: Import tree-sitter-highlight so we can cache trees. 2020-09-11 14:14:44 +09:00
Blaž Hrastnik
b647c7a773 tree-sitter based syntax highlighting draft 2020-09-10 18:19:59 +09:00
Blaž Hrastnik
25b3f98e3d draft: tree-sitter highlighting 2020-09-09 15:48:25 +09:00
Blaž Hrastnik
563e094916 Fix double must_use. 2020-09-08 21:06:39 +09:00
Blaž Hrastnik
67017e5336 append mode 2020-09-07 17:17:14 +09:00
Blaž Hrastnik
dd749bb284 Expand transaction API. 2020-09-07 17:08:28 +09:00
Blaž Hrastnik
8b3e152126 cleanup: Make Buffer just a part of State. 2020-09-07 11:28:52 +09:00
Blaž Hrastnik
579b6899f1 Work on insert mode. 2020-09-07 11:21:26 +09:00
Blaž Hrastnik
e806446379 Fix position coordinate calculation. 2020-09-04 18:18:59 +09:00
Jan Hrastnik
6ba082697d added cursor rendering 2020-06-24 20:59:35 +02:00
Jan Hrastnik
e93b15cef3 created view struct 2020-06-19 02:14:29 +02:00
Jan Hrastnik
8958f06f08 added file rendering 2020-06-16 22:46:27 +02:00
Blaž Hrastnik
073fe61264 Use ropey 1.2.0 2020-06-15 13:51:59 +09:00
Blaž Hrastnik
f8fe273a2e Fix build. 2020-06-08 00:41:37 +09:00
Blaž Hrastnik
e98cdebf1e Add a command module. 2020-06-08 00:15:39 +09:00
Blaž Hrastnik
195aad4675 Fix coord mapping, add vertical move. 2020-06-08 00:08:51 +09:00
Blaž Hrastnik
10d53f3ef0 Add primitives for converting between char offset indices and coords. 2020-06-05 14:04:30 +09:00
Blaž Hrastnik
387fb57c94 Allow unused code for the time being. 2020-06-02 10:59:02 +09:00
Blaž Hrastnik
3848058472 clippy lint 2020-06-02 10:49:28 +09:00
Blaž Hrastnik
d232000c54 Fix compilation. 2020-06-02 10:34:55 +09:00
Blaž Hrastnik
613d06dfb0 wip: importing to github 2020-06-01 17:42:28 +09:00
Blaž Hrastnik
6905ff03c2 Start swapping from termwiz to crossterm + async. 2020-05-28 17:47:35 +09:00
Blaž Hrastnik
1984410ac9 Selection mapping over changesets. 2020-05-28 14:59:50 +09:00
Blaž Hrastnik
e52e848fd7 changeset: Introduce map_pos. 2020-05-28 14:48:34 +09:00
Blaž Hrastnik
b5c38812e9 address clippy warnings 2020-05-28 14:45:44 +09:00
Blaž Hrastnik
23109f1512 OT: changeset: Implement compose and apply. 2020-05-26 18:11:11 +09:00
Blaž Hrastnik
44ff4d3c1f Implement a new core based on CodeMirror. 2020-05-25 13:02:21 +09:00