forked from nvim-lua/kickstart.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepeatable.lua
More file actions
49 lines (47 loc) · 1.07 KB
/
repeatable.lua
File metadata and controls
49 lines (47 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
safestate = false
lastmode = ''
function start_repatable()
register()
vim.api.nvim_create_autocmd('SafeState', {
group = vim.api.nvim_create_augroup('auto_repeat', { clear = true }),
callback = function()
safestate = true
if tablelength(storage) > 1 then
local command = table.concat(storage)
if string.find(command, '@') then
storage = {}
return
end
print(command)
vim.fn.setreg('w', command)
end
storage = {}
-- local mode = vim.fn.mode()
-- if lastmode == mode then
-- return
-- end
-- lastmode = mode
-- print(mode)
-- if vim.fn.mode() then
-- retu
-- end
end,
})
end
storage = {}
local ns_id = vim.api.nvim_create_namespace 'auto_repeat'
function register()
print 'register'
vim.on_key(function(key, typed)
table.insert(storage, key)
end, ns_id, {})
end
start_repatable()
function tablelength(T)
local count = 0
for _ in pairs(T) do
count = count + 1
end
return count
end
-- ssdf asdf asa asdf dafsfasddfg