aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2021-04-05 17:01:32 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2021-04-05 17:01:32 +0200
commit80fb59c73f4754aa145d6bee9235395ef6b6f3a7 (patch)
tree71da530e53338a0e2ab600b7a94d1aa8f9cfa4f1
parent6113c7b38e49b6e8943cc23fc3d4e8ccf87c5630 (diff)
downloadlite-xl-vim-mode.tar.gz
lite-xl-vim-mode.zip
Implement vim . commandvim-mode
-rw-r--r--data/core/vim.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/data/core/vim.lua b/data/core/vim.lua
index a15e61c3..148ec0e8 100644
--- a/data/core/vim.lua
+++ b/data/core/vim.lua
@@ -3,10 +3,10 @@ local command = require "core.command"
local vim = {}
-local command_buffer = {verb = '.', mult_accu = '', inside = ''}
+local command_buffer = {verb = '', mult_accu = '', inside = ''}
function command_buffer:reset()
- self.verb = '.'
+ self.verb = ''
self.mult_accu = ''
self.inside = ''
end
@@ -49,13 +49,16 @@ local inside_delims = {
["'"] = {"'", "'"},
}
+local vim_previous_command
+
local function doc_command(action, command)
return 'doc:' .. action .. '-' .. command
end
local function vim_execute(mode, verb, mult, object)
+ vim_previous_command = {verb, mult, object}
local action = (mode == 'command' and 'move-to' or 'select-to')
- if verb == '.' then
+ if verb == '' then
if object == '$' then
command.perform_many(mult - 1, doc_command(action, 'next-line'))
command.perform(doc_command(action, 'end-of-line'))
@@ -160,12 +163,17 @@ function vim.on_text_input(mode, text_raw, stroke)
command_buffer:reset()
return true
end
- elseif command_buffer.verb == '.' and table_find(verbs_imm, text) then
+ elseif text == '.' then
+ if vim_previous_command then
+ vim_execute(mode, unpack(vim_previous_command))
+ return true
+ end
+ elseif command_buffer.verb == '' and table_find(verbs_imm, text) then
-- execute immediate vim command
vim_execute(mode, text, command_buffer:mult())
command_buffer:reset()
return true
- elseif command_buffer.verb == '.' and table_find(verbs_obj, text) then
+ elseif command_buffer.verb == '' and table_find(verbs_obj, text) then
-- vim command that takes an object
if mode == 'command' then
-- store the command without executing