1use nvim_oxi::api::StringOrFunction;
7use nvim_oxi::api::opts::CreateCommandOpts;
8use nvim_oxi::api::opts::CreateCommandOptsBuilder;
9use nvim_oxi::api::types::CommandArgs;
10
11const USER_CMDS: [(&str, &str, &str); 6] = [
12 ("CopyAll", "Copy all", ":%y+"),
13 ("Highlights", "FzfHighlights", ":FzfLua highlights"),
14 ("LazyProfile", "Lazy profile", ":Lazy profile"),
15 ("LazyUpdate", "Lazy update", ":Lazy update"),
16 ("SelectAll", "Select all", "normal! ggVG"),
17 (
18 "Fkr",
19 "Gen string with fkr",
20 ":lua require('nvrim').fkr.insert_string()",
21 ),
22];
23
24pub fn create() {
26 for (cmd_name, desc, cmd) in USER_CMDS {
27 create_user_cmd(cmd_name, cmd, &CreateCommandOptsBuilder::default().desc(desc).build());
28 }
29}
30
31fn create_user_cmd<Cmd>(name: &str, command: Cmd, opts: &CreateCommandOpts)
33where
34 Cmd: StringOrFunction<CommandArgs, ()>,
35{
36 if let Err(err) = nvim_oxi::api::create_user_command(name, command, opts) {
37 ytil_noxi::notify::error(format!(
38 "error creating user command | name={name:?} opts={opts:#?} error={err:#?}"
39 ));
40 }
41}