mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-12 17:55:41 +08:00
feat(guide): rewrite leader guide in lua
This commit is contained in:
parent
100aa31e52
commit
7e81ce1019
File diff suppressed because it is too large
Load Diff
2
bundle/neodev.nvim/types/nightly/vim.fn.lua
vendored
2
bundle/neodev.nvim/types/nightly/vim.fn.lua
vendored
@ -5655,7 +5655,7 @@ function vim.fn.matchadd(group, pattern, priority, id, dict) end
|
||||
-- ```vim
|
||||
-- GetGroup()->matchaddpos([23, 11])
|
||||
-- ```
|
||||
--- @param pos number
|
||||
--- @param pos number|table
|
||||
--- @param priority? any
|
||||
--- @param id? any
|
||||
--- @param dict? table<string, any>
|
||||
|
@ -23,6 +23,10 @@ function M.getchar(...)
|
||||
end
|
||||
end
|
||||
|
||||
function M.setbufvar(buf, opts)
|
||||
|
||||
end
|
||||
|
||||
function M.getchar2nr(...)
|
||||
local status, ret = pcall(vim.fn.getchar, ...)
|
||||
if not status then
|
||||
|
@ -8,6 +8,10 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.create_buf(listed, scratch)
|
||||
return vim.api.nvim_create_buf(listed, scratch)
|
||||
end
|
||||
|
||||
function M.set_lines(bufnr, startindex, endindex, replacement)
|
||||
if startindex < 0 then
|
||||
startindex = #vim.buffer(bufnr) + 1 + startindex
|
||||
|
@ -1,18 +1,48 @@
|
||||
--!/usr/bin/lua
|
||||
local M = {}
|
||||
|
||||
local specified_keys = {}
|
||||
|
||||
function M.t(str)
|
||||
if vim.api ~= nil and vim.api.nvim_replace_termcodes ~= nil then
|
||||
-- https://github.com/neovim/neovim/issues/17369
|
||||
local ret = vim.api.nvim_replace_termcodes(str, false, true, true):gsub("\128\254X", "\128")
|
||||
return ret
|
||||
if vim.api ~= nil and vim.api.nvim_replace_termcodes ~= nil then
|
||||
-- https://github.com/neovim/neovim/issues/17369
|
||||
local ret = vim.api.nvim_replace_termcodes(str, false, true, true):gsub('\128\254X', '\128')
|
||||
return ret
|
||||
else
|
||||
-- local ret = vim.fn.execute('echon "\\' .. str .. '"')
|
||||
-- ret = ret:gsub('<80>', '\128')
|
||||
-- return ret
|
||||
return vim.eval(string.format('"\\%s"', str))
|
||||
end
|
||||
end
|
||||
|
||||
function M.char2name(c)
|
||||
if #c == 1 then
|
||||
return M.nr2name(vim.fn.char2nr(c))
|
||||
end
|
||||
return specified_keys[c] or c
|
||||
end
|
||||
|
||||
function M.nr2name(nr)
|
||||
if type(nr) == 'number' then
|
||||
if nr == 32 then
|
||||
return 'SPC'
|
||||
elseif nr == 4 then
|
||||
return '<C-d>'
|
||||
elseif nr == 3 then
|
||||
return '<C-c>'
|
||||
elseif nr == 9 then
|
||||
return '<Tab>'
|
||||
elseif nr == 92 then
|
||||
return '<Leader>'
|
||||
elseif nr == 27 then
|
||||
return '<Esc>'
|
||||
else
|
||||
-- local ret = vim.fn.execute('echon "\\' .. str .. '"')
|
||||
-- ret = ret:gsub('<80>', '\128')
|
||||
-- return ret
|
||||
return vim.eval(string.format('"\\%s"', str))
|
||||
return vim.fn.nr2char(nr)
|
||||
end
|
||||
else
|
||||
return specified_keys[nr] or ''
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user