feat(vim): update selection mode to normal (while inclusive doesn't work) and add cut operations for word navigation
This commit is contained in:
		
							parent
							
								
									f9f57a6616
								
							
						
					
					
						commit
						87fb11eaa1
					
				
					 2 changed files with 42 additions and 18 deletions
				
			
		|  | @ -9,7 +9,7 @@ | ||||||
|         "name": "NORMAL", |         "name": "NORMAL", | ||||||
|         "line_numbers": "relative", |         "line_numbers": "relative", | ||||||
|         "cursor": "block", |         "cursor": "block", | ||||||
|         "selection": "inclusive", |         "selection": "normal", | ||||||
|         "press": [ |         "press": [ | ||||||
|             ["b", "move_word_left_vim"], |             ["b", "move_word_left_vim"], | ||||||
|             ["w", "move_word_right_vim"], |             ["w", "move_word_right_vim"], | ||||||
|  | @ -32,15 +32,15 @@ | ||||||
|             ["O", ["smart_insert_line_before"], ["enter_mode", "insert"]], |             ["O", ["smart_insert_line_before"], ["enter_mode", "insert"]], | ||||||
| 
 | 
 | ||||||
|             ["v", "enter_mode", "visual"], |             ["v", "enter_mode", "visual"], | ||||||
|  |             ["V", ["move_begin"], ["enter_mode", "visual"], ["select_end"]], | ||||||
| 
 | 
 | ||||||
|             ["/", "find"], |  | ||||||
|             ["n", "goto_next_match"], |             ["n", "goto_next_match"], | ||||||
|             ["0", "move_begin"], |             ["0", "move_begin"], | ||||||
|  |             ["^", "smart_move_begin"], | ||||||
|             ["$", "move_end"], |             ["$", "move_end"], | ||||||
|             [":", "open_command_palette"], |             [":", "open_command_palette"], | ||||||
|             ["p", "paste"], |             ["p", "paste"], | ||||||
| 
 | 
 | ||||||
|             ["gd", "goto_definition"], |  | ||||||
|             ["gi", "goto_implementation"], |             ["gi", "goto_implementation"], | ||||||
|             ["gy", "goto_type_definition"], |             ["gy", "goto_type_definition"], | ||||||
|             ["gg", "move_buffer_begin"], |             ["gg", "move_buffer_begin"], | ||||||
|  | @ -49,6 +49,8 @@ | ||||||
|             ["G", "move_buffer_end"], |             ["G", "move_buffer_end"], | ||||||
| 
 | 
 | ||||||
|             ["d$", "delete_to_end"], |             ["d$", "delete_to_end"], | ||||||
|  |             ["dw", "cut_word_right_vim"], | ||||||
|  |             ["db", "cut_word_left_vim"], | ||||||
|             ["dd", "cut_internal"], |             ["dd", "cut_internal"], | ||||||
|             ["\"_dd", "delete_line"], |             ["\"_dd", "delete_line"], | ||||||
| 
 | 
 | ||||||
|  | @ -62,10 +64,12 @@ | ||||||
|             ["<C-i>", "jump_forward"], |             ["<C-i>", "jump_forward"], | ||||||
|             ["<C-y>", "redo"], |             ["<C-y>", "redo"], | ||||||
| 
 | 
 | ||||||
|  |             ["/", "find"], | ||||||
|  | 
 | ||||||
|             ["<C-k>", "TODO"], |             ["<C-k>", "TODO"], | ||||||
| 
 | 
 | ||||||
|             ["<C-CR>", "smart_insert_line_after"], |             ["<C-CR>", ["move_down"], ["move_begin"]], | ||||||
|             ["<CR>", "smart_insert_line"] |             ["<CR>", ["move_down"], ["move_begin"]] | ||||||
|         ] |         ] | ||||||
|     }, |     }, | ||||||
|     "visual": { |     "visual": { | ||||||
|  | @ -73,8 +77,8 @@ | ||||||
|         "on_match_failure": "ignore", |         "on_match_failure": "ignore", | ||||||
|         "name": "VISUAL", |         "name": "VISUAL", | ||||||
|         "line_numbers": "relative", |         "line_numbers": "relative", | ||||||
|         "cursor": "underline", |         "cursor": "block", | ||||||
|         "selection": "inclusive", |         "selection": "normal", | ||||||
|         "press": [ |         "press": [ | ||||||
|             ["<Esc>", "enter_mode", "normal"], |             ["<Esc>", "enter_mode", "normal"], | ||||||
|             ["k", "select_up"], |             ["k", "select_up"], | ||||||
|  | @ -97,7 +101,10 @@ | ||||||
|             ["<Esc>", "enter_mode", "normal"], |             ["<Esc>", "enter_mode", "normal"], | ||||||
|             ["<Del>", "delete_forward"], |             ["<Del>", "delete_forward"], | ||||||
|             ["<BS>", "delete_backward"], |             ["<BS>", "delete_backward"], | ||||||
|             ["<CR>", "insert_line_after"] |             ["<CR>", "smart_insert_line"], | ||||||
|  | 
 | ||||||
|  |             ["<C-BS>", "delete_word_left"], | ||||||
|  |             ["<C-Del", "delete_word_right"] | ||||||
|         ] |         ] | ||||||
|     }, |     }, | ||||||
|     "home": { |     "home": { | ||||||
|  |  | ||||||
|  | @ -2421,7 +2421,6 @@ pub const Editor = struct { | ||||||
|         var all_stop = true; |         var all_stop = true; | ||||||
|         var root = root_; |         var root = root_; | ||||||
| 
 | 
 | ||||||
|         // For each cursor, collect what would be deleted |  | ||||||
|         var text = std.ArrayList(u8).init(self.allocator); |         var text = std.ArrayList(u8).init(self.allocator); | ||||||
|         var first = true; |         var first = true; | ||||||
|         for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { |         for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { | ||||||
|  | @ -2587,14 +2586,6 @@ pub const Editor = struct { | ||||||
|     } |     } | ||||||
|     pub const delete_forward_meta = .{ .description = "Delete next character" }; |     pub const delete_forward_meta = .{ .description = "Delete next character" }; | ||||||
| 
 | 
 | ||||||
|     pub fn delete_backward(self: *Self, _: Context) Result { |  | ||||||
|         const b = try self.buf_for_update(); |  | ||||||
|         const root = try self.delete_to(move_cursor_left, b.root, b.allocator); |  | ||||||
|         try self.update_buf(root); |  | ||||||
|         self.clamp(); |  | ||||||
|     } |  | ||||||
|     pub const delete_backward_meta = .{ .description = "Delete previous character" }; |  | ||||||
| 
 |  | ||||||
|     pub fn cut_forward_internal(self: *Self, _: Context) Result { |     pub fn cut_forward_internal(self: *Self, _: Context) Result { | ||||||
|         const b = try self.buf_for_update(); |         const b = try self.buf_for_update(); | ||||||
|         const text, const root= try self.cut_to(move_cursor_right, b.root); |         const text, const root= try self.cut_to(move_cursor_right, b.root); | ||||||
|  | @ -2602,7 +2593,15 @@ pub const Editor = struct { | ||||||
|         try self.update_buf(root); |         try self.update_buf(root); | ||||||
|         self.clamp(); |         self.clamp(); | ||||||
|     } |     } | ||||||
|     pub const cut_forward_internal_meta = .{ .description = "Cut next character" }; |     pub const cut_forward_internal_meta = .{ .description = "Cut next character to internal clipboard" }; | ||||||
|  | 
 | ||||||
|  |     pub fn delete_backward(self: *Self, _: Context) Result { | ||||||
|  |         const b = try self.buf_for_update(); | ||||||
|  |         const root = try self.delete_to(move_cursor_left, b.root, b.allocator); | ||||||
|  |         try self.update_buf(root); | ||||||
|  |         self.clamp(); | ||||||
|  |     } | ||||||
|  |     pub const delete_backward_meta = .{ .description = "Delete previous character" }; | ||||||
| 
 | 
 | ||||||
|     pub fn delete_word_left(self: *Self, _: Context) Result { |     pub fn delete_word_left(self: *Self, _: Context) Result { | ||||||
|         const b = try self.buf_for_update(); |         const b = try self.buf_for_update(); | ||||||
|  | @ -2612,6 +2611,15 @@ pub const Editor = struct { | ||||||
|     } |     } | ||||||
|     pub const delete_word_left_meta = .{ .description = "Delete previous word" }; |     pub const delete_word_left_meta = .{ .description = "Delete previous word" }; | ||||||
| 
 | 
 | ||||||
|  |     pub fn cut_word_left_vim(self: *Self, _: Context) Result { | ||||||
|  |         const b = try self.buf_for_update(); | ||||||
|  |         const text, const root= try self.cut_to(move_cursor_word_left_vim, b.root); | ||||||
|  |         self.set_clipboard_internal(text); | ||||||
|  |         try self.update_buf(root); | ||||||
|  |         self.clamp(); | ||||||
|  |     } | ||||||
|  |     pub const cut_word_left_vim_meta = .{ .description = "Cut next character to internal clipboard" }; | ||||||
|  | 
 | ||||||
|     pub fn delete_word_right(self: *Self, _: Context) Result { |     pub fn delete_word_right(self: *Self, _: Context) Result { | ||||||
|         const b = try self.buf_for_update(); |         const b = try self.buf_for_update(); | ||||||
|         const root = try self.delete_to(move_cursor_word_right_space, b.root, b.allocator); |         const root = try self.delete_to(move_cursor_word_right_space, b.root, b.allocator); | ||||||
|  | @ -2620,6 +2628,15 @@ pub const Editor = struct { | ||||||
|     } |     } | ||||||
|     pub const delete_word_right_meta = .{ .description = "Delete next word" }; |     pub const delete_word_right_meta = .{ .description = "Delete next word" }; | ||||||
| 
 | 
 | ||||||
|  |     pub fn cut_word_right_vim(self: *Self, _: Context) Result { | ||||||
|  |         const b = try self.buf_for_update(); | ||||||
|  |         const text, const root= try self.cut_to(move_cursor_word_right_vim, b.root); | ||||||
|  |         self.set_clipboard_internal(text); | ||||||
|  |         try self.update_buf(root); | ||||||
|  |         self.clamp(); | ||||||
|  |     } | ||||||
|  |     pub const cut_word_right_vim_meta = .{ .description = "Cut next character to internal clipboard" }; | ||||||
|  | 
 | ||||||
|     pub fn delete_to_begin(self: *Self, _: Context) Result { |     pub fn delete_to_begin(self: *Self, _: Context) Result { | ||||||
|         const b = try self.buf_for_update(); |         const b = try self.buf_for_update(); | ||||||
|         const root = try self.delete_to(move_cursor_begin, b.root, b.allocator); |         const root = try self.delete_to(move_cursor_begin, b.root, b.allocator); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 lulvz
						lulvz