mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 23:00:04 +08:00
feat(recordkey): support nvim 0.10.0
This commit is contained in:
parent
f07c2e3e31
commit
f6e07c5659
@ -122,6 +122,8 @@ function! s:fix_colorschem_in_SpaceVim() abort
|
|||||||
hi VertSplit guibg=#282828 guifg=#181A1F
|
hi VertSplit guibg=#282828 guifg=#181A1F
|
||||||
elseif g:colors_name ==# 'one'
|
elseif g:colors_name ==# 'one'
|
||||||
hi VertSplit guibg=#282c34 guifg=#181A1F
|
hi VertSplit guibg=#282c34 guifg=#181A1F
|
||||||
|
hi SPCFloatBorder guibg=#282c34 guifg=#181A1F
|
||||||
|
hi SPCNormalFloat guifg=#abb2bf guibg=#282c34
|
||||||
elseif g:colors_name ==# 'jellybeans'
|
elseif g:colors_name ==# 'jellybeans'
|
||||||
hi VertSplit guibg=#151515 guifg=#080808
|
hi VertSplit guibg=#151515 guifg=#080808
|
||||||
elseif g:colors_name ==# 'nord'
|
elseif g:colors_name ==# 'nord'
|
||||||
|
@ -185,7 +185,8 @@ function! SpaceVim#layers#telescope#config() abort
|
|||||||
" https://github.com/nvim-telescope/telescope.nvim/issues/161
|
" https://github.com/nvim-telescope/telescope.nvim/issues/161
|
||||||
autocmd FileType TelescopePrompt call deoplete#custom#buffer_option('auto_complete', v:false)
|
autocmd FileType TelescopePrompt call deoplete#custom#buffer_option('auto_complete', v:false)
|
||||||
endif
|
endif
|
||||||
autocmd FileType TelescopePrompt iunmap <buffer> jk
|
" @fixme 无法移除 jk 映射
|
||||||
|
" autocmd FileType TelescopePrompt iunmap <buffer> jk
|
||||||
augroup END
|
augroup END
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -1,89 +1,108 @@
|
|||||||
--=============================================================================
|
--=============================================================================
|
||||||
-- record-key.lua --- record key for nvim
|
-- record-key.lua --- record key for nvim
|
||||||
-- Copyright (c) 2016-2022 Wang Shidong & Contributors
|
-- Copyright (c) 2016-2022 Wang Shidong & Contributors
|
||||||
-- Author: Wang Shidong < wsdjeg@outlook.com >
|
-- Author: Wang Shidong < wsdjeg@outlook.com >
|
||||||
-- URL: https://spacevim.org
|
-- URL: https://spacevim.org
|
||||||
-- License: GPLv3
|
-- License: GPLv3
|
||||||
--=============================================================================
|
--=============================================================================
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local timeout = 3000
|
local timeout = 3000
|
||||||
|
|
||||||
local max_count = 5
|
local max_count = 5
|
||||||
|
|
||||||
local keys = {}
|
local keys = {}
|
||||||
|
|
||||||
local pos = 0
|
local pos = 0
|
||||||
|
|
||||||
local enabled = false
|
local enabled = false
|
||||||
local ns_is = vim.api.nvim_create_namespace('record-key')
|
local ns_is = vim.api.nvim_create_namespace('record-key')
|
||||||
|
|
||||||
local function show_key(key)
|
local function show_key(key)
|
||||||
local save_ei = vim.o.eventignore
|
local save_ei = vim.o.eventignore
|
||||||
vim.o.eventignore = 'all'
|
vim.o.eventignore = 'all'
|
||||||
local buf = vim.api.nvim_create_buf(false, true)
|
local buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { string.format('%8s', key) })
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { string.format('%8s', key) })
|
||||||
|
|
||||||
local winid = vim.api.nvim_open_win(buf, false, {
|
local w = 8
|
||||||
relative = 'editor',
|
|
||||||
width = 8,
|
if vim.fn.strdisplaywidth(key) > 8 then
|
||||||
height = 1,
|
w = vim.fn.strdisplaywidth(key) + 2
|
||||||
row = vim.o.lines - 10 - pos * 3,
|
end
|
||||||
col = vim.o.columns - 25,
|
|
||||||
focusable = false,
|
local winid = vim.api.nvim_open_win(buf, false, {
|
||||||
noautocmd = true,
|
relative = 'editor',
|
||||||
border = "single"
|
width = w,
|
||||||
})
|
height = 1,
|
||||||
vim.fn.setbufvar(buf, '&number', 0)
|
row = vim.o.lines - w - 2 - pos * 3,
|
||||||
vim.fn.setbufvar(buf, '&relativenumber', 0)
|
col = vim.o.columns - 25,
|
||||||
vim.fn.setbufvar(buf, '&cursorline', 0)
|
focusable = false,
|
||||||
vim.fn.setbufvar(buf, '&bufhidden', 'wipe')
|
noautocmd = true,
|
||||||
vim.api.nvim_win_set_option(winid, 'winhighlight', 'NormalFloat:Normal')
|
border = 'single',
|
||||||
vim.fn.timer_start(timeout, function()
|
})
|
||||||
local ei = vim.o.eventignore
|
vim.fn.setbufvar(buf, '&number', 0)
|
||||||
vim.o.eventignore = 'all'
|
vim.fn.setbufvar(buf, '&relativenumber', 0)
|
||||||
if vim.api.nvim_win_is_valid(winid) then
|
vim.fn.setbufvar(buf, '&cursorline', 0)
|
||||||
vim.api.nvim_win_close(winid, true)
|
vim.fn.setbufvar(buf, '&bufhidden', 'wipe')
|
||||||
end
|
vim.api.nvim_win_set_option(winid, 'winhighlight', 'NormalFloat:Normal,FloatBorder:WinSeparator')
|
||||||
vim.o.eventignore = ei
|
vim.fn.timer_start(timeout, function()
|
||||||
end, { ['repeat'] = 1 })
|
local ei = vim.o.eventignore
|
||||||
vim.o.eventignore = save_ei
|
vim.o.eventignore = 'all'
|
||||||
end
|
if vim.api.nvim_win_is_valid(winid) then
|
||||||
|
vim.api.nvim_win_close(winid, true)
|
||||||
local function display()
|
end
|
||||||
pos = 0
|
vim.o.eventignore = ei
|
||||||
if #keys > max_count then
|
end, { ['repeat'] = 1 })
|
||||||
for i = 1, max_count, 1 do
|
vim.o.eventignore = save_ei
|
||||||
show_key(keys[#keys - i + 1])
|
end
|
||||||
pos = pos + 1
|
|
||||||
end
|
local function display()
|
||||||
else
|
pos = 0
|
||||||
for i = 1, #keys, 1 do
|
if #keys > max_count then
|
||||||
show_key(keys[#keys - i + 1])
|
for i = 1, max_count, 1 do
|
||||||
pos = pos + 1
|
show_key(keys[#keys - i + 1])
|
||||||
end
|
pos = pos + 1
|
||||||
end
|
end
|
||||||
end
|
else
|
||||||
|
for i = 1, #keys, 1 do
|
||||||
local function on_key(key)
|
show_key(keys[#keys - i + 1])
|
||||||
table.insert(keys, vim.fn.keytrans(key))
|
pos = pos + 1
|
||||||
vim.fn.timer_start(timeout, function()
|
end
|
||||||
if #keys > 0 then
|
end
|
||||||
table.remove(keys, 1)
|
end
|
||||||
end
|
|
||||||
end, { ['repeat'] = 1 })
|
local function on_key(oldkey, key)
|
||||||
display()
|
if not key then
|
||||||
end
|
table.insert(keys, vim.fn.keytrans(oldkey))
|
||||||
|
vim.fn.timer_start(timeout, function()
|
||||||
function M.toggle()
|
if #keys > 0 then
|
||||||
if enabled then
|
table.remove(keys, 1)
|
||||||
vim.on_key(nil, ns_is)
|
end
|
||||||
enabled = false
|
end, { ['repeat'] = 1 })
|
||||||
else
|
display()
|
||||||
vim.on_key(on_key, ns_is)
|
else
|
||||||
enabled = true
|
if #key == 0 then
|
||||||
end
|
return
|
||||||
end
|
end
|
||||||
|
table.insert(keys, vim.fn.keytrans(key))
|
||||||
return M
|
vim.fn.timer_start(timeout, function()
|
||||||
|
if #keys > 0 then
|
||||||
|
table.remove(keys, 1)
|
||||||
|
end
|
||||||
|
end, { ['repeat'] = 1 })
|
||||||
|
display()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.toggle()
|
||||||
|
if enabled then
|
||||||
|
vim.on_key(nil, ns_is)
|
||||||
|
enabled = false
|
||||||
|
else
|
||||||
|
vim.on_key(on_key, ns_is)
|
||||||
|
enabled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
Loading…
Reference in New Issue
Block a user