From 515e62e98222a3cf57e0200f04990fd4388b08a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 12 May 2022 21:12:01 +0200 Subject: [PATCH] Add descriptions to all nvim_create_user_command --- symlinks/config/nvim/after/plugin/testing.lua | 8 +-- .../nvim/lua/esensar/lsp/diagnostic.lua | 14 ++++-- .../esensar/vim_rest_console_extensions.lua | 2 +- symlinks/config/nvim/plugin/dap.lua | 6 +-- symlinks/config/nvim/plugin/local_vimrc.lua | 2 +- symlinks/config/nvim/plugin/luapopup.lua | 8 +-- symlinks/config/nvim/plugin/popupterm.lua | 50 ------------------- symlinks/config/nvim/plugin/rest.lua | 8 +-- symlinks/config/nvim/plugin/ui.lua | 2 +- symlinks/config/nvim/plugin/vimconf_utils.lua | 12 +++-- symlinks/tool-versions | 1 + 11 files changed, 39 insertions(+), 74 deletions(-) delete mode 100644 symlinks/config/nvim/plugin/popupterm.lua diff --git a/symlinks/config/nvim/after/plugin/testing.lua b/symlinks/config/nvim/after/plugin/testing.lua index 3cc0938..dbc7670 100644 --- a/symlinks/config/nvim/after/plugin/testing.lua +++ b/symlinks/config/nvim/after/plugin/testing.lua @@ -30,13 +30,13 @@ vim.api.nvim_create_user_command("PlenaryTestFile", function() last_path = vim.fn.expand("%:p") require("plenary.test_harness").test_directory(last_path, get_plenary_test_opts()) -end, {}) +end, { desc = "Test current file using plenary.nvim" }) vim.api.nvim_create_user_command("PlenaryTestSuite", function() last_path = vim.fn["projectionist#path"]() require("plenary.test_harness").test_directory(last_path, get_plenary_test_opts()) -end, {}) +end, { desc = "Run all tests using plenary.nvim" }) vim.api.nvim_create_user_command("PlenaryTestLast", function() if not last_path then @@ -44,7 +44,7 @@ vim.api.nvim_create_user_command("PlenaryTestLast", function() return end require("plenary.test_harness").test_directory(last_path, get_plenary_test_opts()) -end, {}) +end, { desc = "Run last run test using plenary.nvim" }) vim.api.nvim_create_user_command("PlenaryVisitLastTest", function() if not last_path then @@ -52,7 +52,7 @@ vim.api.nvim_create_user_command("PlenaryVisitLastTest", function() return end vim.cmd("edit " .. last_path) -end, {}) +end, { desc = "Visit latest run test using plenary.nvim" }) local au_id = vim.api.nvim_create_augroup("plenary_test_group", {}) vim.api.nvim_create_autocmd("FileType", { diff --git a/symlinks/config/nvim/lua/esensar/lsp/diagnostic.lua b/symlinks/config/nvim/lua/esensar/lsp/diagnostic.lua index 14a8749..bf2a8b9 100644 --- a/symlinks/config/nvim/lua/esensar/lsp/diagnostic.lua +++ b/symlinks/config/nvim/lua/esensar/lsp/diagnostic.lua @@ -62,6 +62,14 @@ null_ls.setup({ vim.keymap.set("n", "]w", vim.diagnostic.goto_next) vim.keymap.set("n", "[w", vim.diagnostic.goto_prev) -vim.api.nvim_create_user_command("Warnings", vim.diagnostic.setqflist, {}) -vim.api.nvim_create_user_command("WarningsLoc", vim.diagnostic.setloclist, {}) -vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {}) +vim.api.nvim_create_user_command( + "Warnings", + vim.diagnostic.setqflist, + { desc = "Show all LSP project warning in a quickfix list" } +) +vim.api.nvim_create_user_command( + "WarningsLoc", + vim.diagnostic.setloclist, + { desc = "Show LSP buffer warnings in a location list" } +) +vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, { desc = "Format current buffer using LSP" }) diff --git a/symlinks/config/nvim/lua/esensar/vim_rest_console_extensions.lua b/symlinks/config/nvim/lua/esensar/vim_rest_console_extensions.lua index 53f7641..6a514f5 100644 --- a/symlinks/config/nvim/lua/esensar/vim_rest_console_extensions.lua +++ b/symlinks/config/nvim/lua/esensar/vim_rest_console_extensions.lua @@ -44,7 +44,7 @@ end -- Opens up a rest console which can be saved -- cached by name function M.open_cached_rest_console(args) local name = args[0] or args[1] - if not name then + if string.len(name) == 0 then name = require("esensar.common.projects").get_project_id() end open_cached_rest_console(name) diff --git a/symlinks/config/nvim/plugin/dap.lua b/symlinks/config/nvim/plugin/dap.lua index 0d4f538..26cf347 100644 --- a/symlinks/config/nvim/plugin/dap.lua +++ b/symlinks/config/nvim/plugin/dap.lua @@ -23,15 +23,15 @@ vim.keymap.set("n", "dsi", dap.step_into) -- Neovim Lua debugging vim.api.nvim_create_user_command("NeovimDebugStart", function() require("osv").launch() -end, {}) +end, { desc = "Start debugging neovim" }) vim.api.nvim_create_user_command("NeovimDebugThis", function() require("osv").run_this() -end, {}) +end, { desc = "Start debugging this neovim lua script" }) -- Vscode launch.json support vim.api.nvim_create_user_command("DapLoadVsCodeLaunch", function(args) require("dap.ext.vscode").load_launchjs(args.args) -end, {}) +end, { desc = "Load VsCode launch.json for DAP" }) -- Nvim DAP UI local dapui = require("dapui") diff --git a/symlinks/config/nvim/plugin/local_vimrc.lua b/symlinks/config/nvim/plugin/local_vimrc.lua index 087275d..03f0d57 100644 --- a/symlinks/config/nvim/plugin/local_vimrc.lua +++ b/symlinks/config/nvim/plugin/local_vimrc.lua @@ -4,4 +4,4 @@ vim.api.nvim_create_user_command("EditLocalVimrc", function(_) require("esensar.direnv_vimrc_local").open_local_vimrc() -end, { nargs = 0 }) +end, { nargs = 0, desc = "Open or create project local .vimrc file" }) diff --git a/symlinks/config/nvim/plugin/luapopup.lua b/symlinks/config/nvim/plugin/luapopup.lua index 80dfcce..0b2d042 100644 --- a/symlinks/config/nvim/plugin/luapopup.lua +++ b/symlinks/config/nvim/plugin/luapopup.lua @@ -117,7 +117,7 @@ end vim.api.nvim_create_user_command("LuaPopup", function() popup_and_run(popup_type.lua) -end, {}) +end, { desc = "Show a popup for writing lua code that will be executed after closing" }) vim.api.nvim_create_user_command("LuaPopupRestore", function() if get_last_win(popup_type.lua) then @@ -125,11 +125,11 @@ vim.api.nvim_create_user_command("LuaPopupRestore", function() else vim.notify("No popup to restore! Use :LuaPopup first!", vim.log.levels.WARN) end -end, {}) +end, { desc = "Restore last popup displayed with LuaPopup command" }) vim.api.nvim_create_user_command("FennelPopup", function() popup_and_run(popup_type.fennel) -end, {}) +end, { desc = "Show a popup for writing fennel code that will be executed after closing" }) vim.api.nvim_create_user_command("FennelPopupRestore", function() if get_last_win(popup_type.fennel) then @@ -137,4 +137,4 @@ vim.api.nvim_create_user_command("FennelPopupRestore", function() else vim.notify("No popup to restore! Use :FennelPopup first!", vim.log.levels.WARN) end -end, {}) +end, { desc = "Restore last popup displayed with FennelPopup command" }) diff --git a/symlinks/config/nvim/plugin/popupterm.lua b/symlinks/config/nvim/plugin/popupterm.lua deleted file mode 100644 index d119878..0000000 --- a/symlinks/config/nvim/plugin/popupterm.lua +++ /dev/null @@ -1,50 +0,0 @@ --- Popupterm - get a popup with terminal buffer -local popup = require("nui.popup") -local event = require("nui.utils.autocmd").event - -local last_term_win - -local function popup_terminal() - if last_term_win then - last_term_win:show() - return - end - - local win = popup({ - enter = true, - focusable = true, - border = { - style = "rounded", - }, - position = "50%", - size = { - width = "80%", - height = "60%", - }, - }) - - -- mount/open the component - win:mount() - - vim.cmd("edit term://" .. vim.env.SHELL) - - -- map keys - win:map("n", "", function(_) - win:hide() - end, { noremap = true }) - - -- unmount component when cursor leaves buffer - win:on(event.BufLeave, function() - win:hide() - end) - - win:on(event.BufDelete, function() - last_term_win = nil - end) - - last_term_win = win -end - -vim.api.nvim_create_user_command("PopupTerm", function() - popup_terminal() -end, {}) diff --git a/symlinks/config/nvim/plugin/rest.lua b/symlinks/config/nvim/plugin/rest.lua index feb83eb..3e5b050 100644 --- a/symlinks/config/nvim/plugin/rest.lua +++ b/symlinks/config/nvim/plugin/rest.lua @@ -6,14 +6,14 @@ local vim_rest_console_extensions = require("esensar.vim_rest_console_extensions vim.api.nvim_create_user_command( "ScratchRestConsole", vim_rest_console_extensions.open_scratch_rest_console, - { nargs = 0 } + { nargs = 0, desc = "Open scratch RestConsole file - for testing HTTP calls" } ) vim.api.nvim_create_user_command("RestConsole", function(args) vim_rest_console_extensions.open_cached_rest_console(args.fargs) -end, { nargs = "?" }) +end, { nargs = "?", desc = "Opens up a rest console which can be saved -- cached by name or project" }) vim.api.nvim_create_user_command("RestConsoleLocal", function(args) vim_rest_console_extensions.open_local_rest_console(args.fargs) -end, { nargs = "?" }) +end, { nargs = "?", desc = "Opens up a rest console based on local file path" }) vim.api.nvim_create_user_command("RestConsoleCached", function(args) vim_rest_console_extensions.open_named_cached_rest_console(args.fargs[0] or args.fargs[1]) -end, { nargs = 1 }) +end, { nargs = 1, desc = "Opens up a rest console which can be saved -- cached by name and project" }) diff --git a/symlinks/config/nvim/plugin/ui.lua b/symlinks/config/nvim/plugin/ui.lua index 5f24e60..24e083a 100644 --- a/symlinks/config/nvim/plugin/ui.lua +++ b/symlinks/config/nvim/plugin/ui.lua @@ -85,4 +85,4 @@ end vim.api.nvim_create_user_command("BottomTerminal", function() require("esensar.ui").new_bottom_split({}) vim.fn.termopen(os.getenv("SHELL")) -end, {}) +end, { desc = "Open a terminal buffer at the bottom of the editor" }) diff --git a/symlinks/config/nvim/plugin/vimconf_utils.lua b/symlinks/config/nvim/plugin/vimconf_utils.lua index 7609d60..4553902 100644 --- a/symlinks/config/nvim/plugin/vimconf_utils.lua +++ b/symlinks/config/nvim/plugin/vimconf_utils.lua @@ -1,3 +1,5 @@ +-- Vim configuration utility commands + local function edit_vim_config() vim.cmd("edit $VIMHOME/init.lua") end @@ -11,9 +13,13 @@ local function reload_vim_config() vim.cmd("source $MYVIMRC") end -vim.api.nvim_create_user_command("EditVimConfig", edit_vim_config, {}) -vim.api.nvim_create_user_command("EditVimPlugins", edit_vim_plugins, {}) -vim.api.nvim_create_user_command("ReloadVimConfig", reload_vim_config, {}) +vim.api.nvim_create_user_command( + "EditVimConfig", + edit_vim_config, + { desc = "Edit vim configuration ($MYVIMRC - init.lua)" } +) +vim.api.nvim_create_user_command("EditVimPlugins", edit_vim_plugins, { desc = "Edit plugin list file" }) +vim.api.nvim_create_user_command("ReloadVimConfig", reload_vim_config, { desc = "Reload init.lua and all lua files" }) vim.keymap.set("n", "vec", edit_vim_config) vim.keymap.set("n", "vep", edit_vim_plugins) diff --git a/symlinks/tool-versions b/symlinks/tool-versions index 1cedc18..506f74d 100644 --- a/symlinks/tool-versions +++ b/symlinks/tool-versions @@ -11,3 +11,4 @@ lua 5.4.4 actionlint 1.6.12 act 0.2.26 shellcheck 0.8.0 +cmake 3.22.3