feat: cli completion

dev-assets
Pocco81 3 years ago
parent 6c0bad9846
commit e0d2a052c6

@ -0,0 +1,4 @@
return {
["catppuccino"] = "catppuccino",
["neon_latte"] = "neon_latte"
}

@ -0,0 +1,7 @@
local M = {}
function M.available_commands()
return vim.tbl_keys(require("catppuccino.core.list_cs"))
end
return M

@ -6,8 +6,27 @@ if exists('g:loaded_catppuccino') | finish | endif
let s:save_cpo = &cpo " save user coptions let s:save_cpo = &cpo " save user coptions
set cpo&vim " reset them to defaults set cpo&vim " reset them to defaults
" Utils {{{
function! cpcmds#get_first_arg(...)
return "".get(a:, 1, 1).""
endfunction
" }}}
" Test Availability {{{
" aa = available arguments
function! cpcmds#available_args_flavors() abort
return luaeval('require("catppuccino.utils.cli_completion").available_commands()')
endfunction
" }}}
" Tab Completion {{{
function! s:complete_args_flavors(arg, line, pos) abort
return join(cpcmds#available_args_flavors(), "\n")
endfunction
" }}}
" Interface {{{ " Interface {{{
command! CPLoad lua require'catppuccino.main'.main('load') command! -nargs=+ -complete=custom,s:complete_args_flavors CPLoad call v:lua.require'catppuccino.main'.main('load',cpcmds#get_first_arg(<f-args>))
" }}} " }}}
let &cpo = s:save_cpo " restore after let &cpo = s:save_cpo " restore after

Loading…
Cancel
Save