mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-13 23:07:59 +08:00
feat(nvim-plug): support on_map
opt
This commit is contained in:
parent
8368712a5e
commit
c21cea3595
@ -321,3 +321,10 @@
|
||||
[bundle-vim-zettelkasten-nvim.options.env]
|
||||
VIM = 'D:\Scoop\apps\neovim\current\share\nvim'
|
||||
VIMRUNTIME = 'D:\Scoop\apps\neovim\current\share\nvim\runtime'
|
||||
[bundle-nvim-plug]
|
||||
command = 'wt.exe'
|
||||
args = ['-d', 'C:\Users\wsdjeg\.SpaceVim\bundle\nvim-plug', 'D:\Scoop\apps\neovim\current\bin\nvim.exe', '-Nu', 'test/init.lua']
|
||||
isBackground = true
|
||||
[bundle-nvim-plug.options.env]
|
||||
VIM = 'D:\Scoop\apps\neovim\current\share\nvim'
|
||||
VIMRUNTIME = 'D:\Scoop\apps\neovim\current\share\nvim\runtime'
|
||||
|
17
bundle/nvim-plug/README.md
vendored
17
bundle/nvim-plug/README.md
vendored
@ -44,14 +44,15 @@ require('plug').add({
|
||||
|
||||
## Plugin Spec
|
||||
|
||||
| name | description |
|
||||
| --------- | --------------------------------------------------------------------------------------------------- |
|
||||
| `[1]` | `string`, plugin repo short name, `wsdjeg/flygrep.nvim` |
|
||||
| `cmds` | `table<string>`, commands lazy loading |
|
||||
| `events` | `table<string>`, events lazy loading |
|
||||
| `on_ft` | `table<string>`, filetypes lazy loading |
|
||||
| `type` | `string`, plugin type including `color`, `plugin` |
|
||||
| `build` | `string` or `table<string>`, executed by [job](https://spacevim.org/api/job/) api |
|
||||
| name | description |
|
||||
| --------- | --------------------------------------------------------------------------------------- |
|
||||
| `[1]` | `string`, plugin repo short name, `wsdjeg/flygrep.nvim` |
|
||||
| `cmds` | `table<string>`, commands lazy loading |
|
||||
| `events` | `table<string>`, events lazy loading |
|
||||
| `on_ft` | `table<string>`, filetypes lazy loading |
|
||||
| `on_map` | `table<string>`, key bindings lazy loading |
|
||||
| `type` | `string`, plugin type including `color`, `plugin` |
|
||||
| `build` | `string` or `table<string>`, executed by [job](https://spacevim.org/api/job/) api |
|
||||
| `enabled` | `boolean` or `function` evaluated when startup, when it is false, plugin will be skiped |
|
||||
|
||||
## Commands
|
||||
|
35
bundle/nvim-plug/lua/plug/hooks.lua
vendored
35
bundle/nvim-plug/lua/plug/hooks.lua
vendored
@ -53,4 +53,39 @@ function M.on_ft(fts, plugSpec)
|
||||
})
|
||||
end
|
||||
|
||||
function M.on_map(maps, plugSpec)
|
||||
for _, lhs in ipairs(maps) do
|
||||
vim.keymap.set('n', lhs, function()
|
||||
for _, v in ipairs(plugSpec.on_map) do
|
||||
vim.keymap.del('n', v, {})
|
||||
end
|
||||
plugin_loader.load(plugSpec)
|
||||
|
||||
local termstr = '<M-_>'
|
||||
local input = ''
|
||||
|
||||
vim.fn.feedkeys(termstr, 'n')
|
||||
|
||||
while true do
|
||||
local char = vim.fn.getchar()
|
||||
if type(char) == 'number' then
|
||||
input = input .. vim.fn.nr2char(char)
|
||||
else
|
||||
input = input .. char
|
||||
end
|
||||
local idx = vim.fn.stridx(input, termstr)
|
||||
if idx >= 1 then
|
||||
input = string.sub(input, 1, idx)
|
||||
break
|
||||
elseif idx == 0 then
|
||||
input = ''
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
vim.fn.feedkeys(lhs .. input, 'm')
|
||||
end, {})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
6
bundle/nvim-plug/lua/plug/init.lua
vendored
6
bundle/nvim-plug/lua/plug/init.lua
vendored
@ -36,7 +36,11 @@ function M.add(plugins)
|
||||
hooks.on_ft(plug.on_ft, plug)
|
||||
end
|
||||
|
||||
if not plug.events and not plug.cmds and not plug.on_ft then
|
||||
if plug.on_map then
|
||||
hooks.on_map(plug.on_map, plug)
|
||||
end
|
||||
|
||||
if not plug.events and not plug.cmds and not plug.on_ft and not plug.on_map then
|
||||
loader.load(plug)
|
||||
end
|
||||
::continue::
|
||||
|
4
bundle/nvim-plug/lua/plug/loader.lua
vendored
4
bundle/nvim-plug/lua/plug/loader.lua
vendored
@ -31,7 +31,7 @@ local function is_local_plugin(plugSpec)
|
||||
end
|
||||
|
||||
local function unique_name(plugSpec)
|
||||
local s = vim.split(plugSpec, '/')
|
||||
local s = vim.split(plugSpec[1], '/')
|
||||
return s[#s]
|
||||
end
|
||||
|
||||
@ -90,7 +90,7 @@ function M.load(plugSpec)
|
||||
if vim.fn.isdirectory(plugSpec.rtp) == 1 then
|
||||
vim.opt.runtimepath:append(plugSpec.rtp)
|
||||
if vim.fn.has('vim_starting') ~= 1 then
|
||||
local plugin_directory_files = vim.fn.globpath(plugSpec.rtp, 'plugin/*.{lua,vim}')
|
||||
local plugin_directory_files = vim.fn.globpath(plugSpec.rtp, "plugin/*.{lua,vim}", 0, 1)
|
||||
for _, f in ipairs(plugin_directory_files) do
|
||||
vim.cmd.source(f)
|
||||
end
|
||||
|
29
bundle/nvim-plug/test/init.lua
vendored
29
bundle/nvim-plug/test/init.lua
vendored
@ -11,21 +11,24 @@ vim.opt.runtimepath:append('~/.SpaceVim')
|
||||
require('plug').setup({
|
||||
|
||||
bundle_dir = 'D:/bundle_dir',
|
||||
|
||||
})
|
||||
|
||||
require("plug").add({
|
||||
{
|
||||
"wsdjeg/scrollbar.vim",
|
||||
events = { "VimEnter" },
|
||||
config = function()
|
||||
end
|
||||
},
|
||||
{
|
||||
"wsdjeg/flygrep.nvim",
|
||||
cmds = { "FlyGrep" },
|
||||
require('plug').add({
|
||||
{
|
||||
'wsdjeg/scrollbar.vim',
|
||||
events = { 'VimEnter' },
|
||||
config = function() end,
|
||||
},
|
||||
{
|
||||
'wsdjeg/flygrep.nvim',
|
||||
cmds = { 'FlyGrep' },
|
||||
config = function()
|
||||
require('flygrep').setup()
|
||||
end
|
||||
},
|
||||
end,
|
||||
},
|
||||
{
|
||||
'rhysd/clever-f.vim',
|
||||
on_map = { '<Plug>(clever-f' },
|
||||
},
|
||||
})
|
||||
vim.cmd('nmap f <Plug>(clever-f-f)')
|
||||
|
Loading…
Reference in New Issue
Block a user