feat(commands): include buffer local commands (closes #445)

This commit is contained in:
bhagwan 2022-06-12 10:06:39 -07:00
parent 179162abe0
commit 844718eb5a

View File

@ -12,7 +12,9 @@ M.commands = function(opts)
opts = config.normalize_opts(opts, config.globals.nvim.commands)
if not opts then return end
local commands = vim.api.nvim_get_commands {}
local global_commands = vim.api.nvim_get_commands {}
local buf_commands = vim.api.nvim_buf_get_commands(0, {})
local commands = vim.tbl_extend('force', {}, global_commands, buf_commands)
local prev_act = shell.action(function (args)
local cmd = args[1]
@ -23,10 +25,16 @@ M.commands = function(opts)
end, nil, opts.debug)
local entries = {}
for k, _ in pairs(commands) do
for k, _ in pairs(global_commands) do
table.insert(entries, utils.ansi_codes.magenta(k))
end
for k, v in pairs(buf_commands) do
if type(v) == 'table' then
table.insert(entries, utils.ansi_codes.green(k))
end
end
table.sort(entries, function(a, b) return a<b end)
opts.fzf_opts['--no-multi'] = ''