From 689dd12385f6689bb8d413945558c455379e2738 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 31 Jan 2021 19:21:25 +0800 Subject: 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 --- plugin/telescope.vim | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) (limited to 'plugin') diff --git a/plugin/telescope.vim b/plugin/telescope.vim index 8317cfa..b3668d9 100644 --- a/plugin/telescope.vim +++ b/plugin/telescope.vim @@ -60,16 +60,7 @@ function! s:telescope_complete(arg,line,pos) let l:builtin_list = luaeval('vim.tbl_keys(require("telescope.builtin"))') let l:extensions_list = luaeval('vim.tbl_keys(require("telescope._extensions").manager)') let l:options_list = luaeval('vim.tbl_keys(require("telescope.config").values)') - let ext_type = v:lua.require('telescope._extensions').manager - let l:ext_type_list = [] - - if !empty(ext_type) - for val in values(ext_type) - if type(val) == 3 - call extend(l:ext_type_list,keys(val)) - endif - endfor - endif + let l:extensions_subcommand_list = luaeval('require("telescope.command").get_extensions_subcommand()') let list = [extend(l:builtin_list,l:extensions_list),l:options_list] let l = split(a:line[:a:pos-1], '\%(\%(\%(^\|[^\\]\)\\\)\@= 0 - return join(l:ext_type_list,"\n") + return join(l:extensions_subcommand_list,"\n") endif return join(list[1],"\n") endif @@ -91,32 +82,5 @@ function! s:telescope_complete(arg,line,pos) endif endfunction -function! s:load_command(builtin,...) abort - let user_opts = {} - let user_opts.cmd = a:builtin - let user_opts.opts = {} - - " range command args - " if arg in lua code is table type,we split command string by `,` to vimscript - " list type. - for arg in a:000 - if stridx(arg,'=') < 0 - let user_opts.extension_type = arg - continue - endif - " split args by = - let arg_list = split(arg,'=') - if arg_list[0] == 'find_command' || arg_list[0] == 'vimgrep_arguments' - let user_opts.opts[arg_list[0]] = split(arg_list[1],',') - elseif arg_list[0] == 'theme' - let user_opts.theme = arg_list[1] - else - let user_opts.opts[arg_list[0]] = arg_list[1] - endif - endfor - - call v:lua.require('telescope.command').run_command(user_opts) -endfunction - " Telescope Commands with complete -command! -nargs=+ -complete=custom,s:telescope_complete Telescope call s:load_command() +command! -nargs=+ -complete=custom,s:telescope_complete Telescope lua require('telescope.command').load_command() -- cgit v1.2.3