added 'packadd' provider (closes issue #64)

main
bhagwan 3 years ago
parent 757d6392f0
commit ac99206c13

@ -176,6 +176,7 @@ nnoremap <c-P> <cmd>lua require('fzf-lua').files()<CR>
|`spell_suggest`|spelling suggestions|
|`tags`|project tags|
|`btags`|buffer tags|
|`packadd`|:packadd <package>|
## Customization

@ -25,7 +25,8 @@ M.act = function(actions, selected)
-- the table will contain the results directly
-- otherwise 'selected[1]` will contain the keybind
-- empty string in selected[1] represents default
if #selected>1 and #selected[1]>0 then action = selected[1] end
if actions and utils.tbl_length(actions) > 1 and
#selected>1 and #selected[1]>0 then action = selected[1] end
if actions[action] then
actions[action](selected)
end
@ -167,6 +168,13 @@ M.spell_apply = function(selected)
vim.cmd("stopinsert")
end
M.packadd = function(selected)
if not selected then return end
for i = 1, #selected do
vim.cmd("packadd " .. selected[i])
end
end
M.help = function(selected)
local vimcmd = "help"
M.vimcmd(vimcmd, selected)

@ -417,6 +417,12 @@ M.globals.nvim = {
["default"] = actions.spell_apply,
},
},
packadd = {
prompt = 'packadd> ',
actions = {
["default"] = actions.packadd,
},
},
}
M.globals.file_icon_colors = {
["lua"] = "blue",

@ -78,6 +78,7 @@ M.commands = require'fzf-lua.providers.nvim'.commands
M.command_history = require'fzf-lua.providers.nvim'.command_history
M.search_history = require'fzf-lua.providers.nvim'.search_history
M.spell_suggest = require'fzf-lua.providers.nvim'.spell_suggest
M.packadd = require'fzf-lua.providers.nvim'.packadd
M.lsp_typedefs = require'fzf-lua.providers.lsp'.typedefs
M.lsp_references = require'fzf-lua.providers.lsp'.references

@ -252,4 +252,28 @@ M.spell_suggest = function(opts)
end
M.packadd = function(opts)
opts = config.normalize_opts(opts, config.globals.nvim.packadd)
coroutine.wrap(function ()
local entries = vim.fn.getcompletion('', 'packadd')
if vim.tbl_isempty(entries) then return end
opts.nomulti = false
opts.preview = nil
opts.preview_window = 'hidden:down:0'
local selected = core.fzf(opts, entries)
if not selected then return end
actions.act(opts.actions, selected)
end)()
end
return M

Loading…
Cancel
Save