summaryrefslogtreecommitdiff
path: root/lua/telescope/builtin
diff options
context:
space:
mode:
authormilanglacier <45728125+milanglacier@users.noreply.github.com>2022-04-30 06:27:16 -0400
committerGitHub <noreply@github.com>2022-04-30 12:27:16 +0200
commit8fe79f9d1df0edca3efa237020bc1f0ff81cb816 (patch)
treee9ccee5ddaeeeda9c859703827b844abddc2d657 /lua/telescope/builtin
parent1b6909cfb322af93506a5187069e8d604d05feb5 (diff)
feat: support for builtin.commands to show buffer commands (#1889)
Diffstat (limited to 'lua/telescope/builtin')
-rw-r--r--lua/telescope/builtin/init.lua1
-rw-r--r--lua/telescope/builtin/internal.lua9
2 files changed, 10 insertions, 0 deletions
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index 84eb18b..b73c970 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -234,6 +234,7 @@ builtin.symbols = require_on_exported_call("telescope.builtin.internal").symbols
--- Lists available plugin/user commands and runs them on `<cr>`
---@param opts table: options to pass to the picker
+---@field show_buf_command boolean: show buf local command (Default: true)
builtin.commands = require_on_exported_call("telescope.builtin.internal").commands
--- Lists items in the quickfix list, jumps to location on `<cr>`
diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua
index 99cc296..122827f 100644
--- a/lua/telescope/builtin/internal.lua
+++ b/lua/telescope/builtin/internal.lua
@@ -318,6 +318,15 @@ internal.commands = function(opts)
table.insert(commands, cmd)
end
+ local need_buf_command = vim.F.if_nil(opts.show_buf_command, true)
+
+ if need_buf_command then
+ local buf_command_iter = vim.api.nvim_buf_get_commands(0, {})
+ buf_command_iter[true] = nil -- remove the redundant entry
+ for _, cmd in pairs(buf_command_iter) do
+ table.insert(commands, cmd)
+ end
+ end
return commands
end)(),