From 4997cc9704883b7833372386b71ddc8bbb177a56 Mon Sep 17 00:00:00 2001 From: HumanEntity Date: Mon, 25 Dec 2023 12:54:37 +0100 Subject: Little restructurization and cmd update --- lua/denote/cmd.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lua/denote/cmd.lua') diff --git a/lua/denote/cmd.lua b/lua/denote/cmd.lua index aa93637..9b8d9e6 100644 --- a/lua/denote/cmd.lua +++ b/lua/denote/cmd.lua @@ -1,17 +1,25 @@ -local M = {} +local M = { + commands = { "note", "search" }, +} local api = require("denote.api") function M.load_cmd() vim.api.nvim_create_user_command("Denote", function(opts) - if opts.fargs[1] == "note" then - api.note() - elseif opts.fargs[1] == "search" then - api.search() + if opts.fargs[1] then + if opts.fargs[1] == "note" then + api.note() + elseif opts.fargs[1] == "search" then + api.search() + else + error("Unsupported operation " .. opts.fargs[1]) + end else - error("Unsupported operation " .. opts.fargs[1]) + vim.ui.select(M.commands, { prompt = "Command: " }, function(choice) + api[choice]() + end) end end, { - nargs = 1, + -- nargs = 1, complete = function() return { "note", "search" } end, -- cgit v1.2.3