diff --git a/lua/catppuccino/core/list_cs.lua b/lua/catppuccino/core/list_cs.lua new file mode 100644 index 0000000..7d3be0a --- /dev/null +++ b/lua/catppuccino/core/list_cs.lua @@ -0,0 +1,4 @@ +return { + ["catppuccino"] = "catppuccino", + ["neon_latte"] = "neon_latte" +} diff --git a/lua/catppuccino/utils/cli_completion.lua b/lua/catppuccino/utils/cli_completion.lua new file mode 100644 index 0000000..6e906dd --- /dev/null +++ b/lua/catppuccino/utils/cli_completion.lua @@ -0,0 +1,7 @@ +local M = {} + +function M.available_commands() + return vim.tbl_keys(require("catppuccino.core.list_cs")) +end + +return M diff --git a/plugin/cpcmds.vim b/plugin/cpcmds.vim index 18b29f8..871efbe 100644 --- a/plugin/cpcmds.vim +++ b/plugin/cpcmds.vim @@ -6,8 +6,27 @@ if exists('g:loaded_catppuccino') | finish | endif let s:save_cpo = &cpo " save user coptions 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 {{{ -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()) " }}} let &cpo = s:save_cpo " restore after