diff options
| author | Raphael <glepnir@gopherhub.org> | 2021-01-31 19:21:25 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-31 19:21:25 +0800 |
| commit | 689dd12385f6689bb8d413945558c455379e2738 (patch) | |
| tree | 3ceaad13a998983311b415ad9dc785cd8a51256e /lua/telescope | |
| parent | 1ca1e7ccba203752f7b7f89c2bd3aca13586d460 (diff) | |
support custom table type keyword (#450)
* support custom table type keyword
* remove custom split function use vim.split
* remove unused varable fix test
* rewrite get extensions subcommand
* add comment
* remove blankline
* check the param in default options
* revert
* add register keyword function
Diffstat (limited to 'lua/telescope')
| -rw-r--r-- | lua/telescope/command.lua | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/lua/telescope/command.lua b/lua/telescope/command.lua index c8d7336..d28f540 100644 --- a/lua/telescope/command.lua +++ b/lua/telescope/command.lua @@ -66,7 +66,7 @@ end -- opts = { -- cwd = '***', -- } -function command.run_command(args) +local function run_command(args) local user_opts = args or {} if next(user_opts) == nil and not user_opts.cmd then print('[Telescope] your command miss args') @@ -101,4 +101,56 @@ function command.run_command(args) end end +-- @Summary get extensions sub command +-- register extensions dap gh etc. +-- input in command line `Telescope gh <TAB>` +-- It will show a list that all extensions sub command list +-- ['commands','list_breakpoints','variables','issues','gist','pull_request'] +function command.get_extensions_subcommand() + local exts = require('telescope._extensions').manager + local complete_ext_table = {} + for _,value in pairs(exts) do + if type(value) == "table" then + for key,_ in pairs(value) do + table.insert(complete_ext_table,key) + end + end + end + return complete_ext_table +end + +local split_keywords = { + ['find_command'] = true, + ['vimgrep_arguments'] = true, + ['sections'] = true +} + +function command.register_keyword(keyword) + split_keywords[keyword] = true +end + +function command.load_command(cmd,...) + local args = {...} + local user_opts = {} + user_opts['cmd'] = cmd + user_opts.opts = {} + + for _,arg in ipairs(args) do + if arg:find('=',1) == nil then + user_opts['extension_type'] = arg + else + local param = vim.split(arg,'=') + if param[1] == 'theme' then + user_opts['theme'] = param[2] + elseif split_keywords[param[1]] then + user_opts.opts[param[1]] = vim.split(param[2],',') + else + user_opts.opts[param[1]] = param[2] + end + end + end + + run_command(user_opts) +end + return command |
