diff --git a/.gitignore b/.gitignore index 6fd0a37..6c52ca7 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ luac.out *.x86_64 *.hex +# Helptags +doc/tags diff --git a/README.md b/README.md index e3e3e8c..68a0cdf 100644 --- a/README.md +++ b/README.md @@ -94,18 +94,25 @@ require("rpm") 4. Alternatively, run `:Rpm install_all` to install all plugins in the `lua/plugins/` directory. -5. Run `:Rpm list` to see a list of installed plugins. +5. Run `:Rpm generate_helptags` to generate helptags for a plugin. By default, + RPM runs the help tag generation command for each plugin after it is + installed. You can run this command manually if you need to regenerate the + helptags. -6. Run `:Rpm update` to update a specific plugin. +6. Run `:Rpm list` to see a list of installed plugins. -7. Run `:Rpm update_all` to update all plugins. +7. Run `:Rpm update` to update a specific plugin. -8. Run `:Rpm clean` to remove all plugins that are not defined in the +8. Run `:Rpm update_all` to update all plugins. + +9. Run `:Rpm clean` to remove all plugins that are not defined in the `lua/plugins/` directory. -9. Run `:Rpm delete` to remove a specific plugin. +10. Run `:Rpm delete` to remove a specific plugin. + +11. Run `:Rpm delete_all` to remove all plugins. -10. Run `:Rpm delete_all` to remove all plugins. +You can run `:Run help` to see a list of available commands. ## Remarks diff --git a/doc/rpm.txt b/doc/rpm.txt index 4a2a80e..9bd1cae 100644 --- a/doc/rpm.txt +++ b/doc/rpm.txt @@ -1,4 +1,4 @@ -*rpm.txt* A Rudimentary Plugin Manager for NeoVim +*rpm* A Rudimentary Plugin Manager for NeoVim ================================================================================ INTRODUCTION **rpm** @@ -70,18 +70,25 @@ Getting Started: 4. Alternatively, run `:Rpm install_all` to install all plugins in the `lua/plugins/` directory. -5. Run `:Rpm list` to see a list of installed plugins. +5. Run `:Rpm generate_helptags` to generate helptags for a plugin. By default, + RPM runs the help tag generation command for each plugin after it is + installed. You can run this command manually if you need to regenerate the + helptags. -6. Run `:Rpm update` to update a specific plugin. +6. Run `:Rpm list` to see a list of installed plugins. -7. Run `:Rpm update_all` to update all plugins. +7. Run `:Rpm update` to update a specific plugin. -8. Run `:Rpm clean` to remove all plugins that are not defined in the +8. Run `:Rpm update_all` to update all plugins. + +9. Run `:Rpm clean` to remove all plugins that are not defined in the `lua/plugins/` directory. -9. Run `:Rpm delete` to remove a specific plugin. +10. Run `:Rpm delete` to remove a specific plugin. + +11. Run `:Rpm delete_all` to remove all plugins. -10. Run `:Rpm delete_all` to remove all plugins. +You can run `:Run help` to see a list of available commands. Remarks: diff --git a/lua/rpm/autocomplete.lua b/lua/rpm/autocomplete.lua index d4b474c..0ed540e 100644 --- a/lua/rpm/autocomplete.lua +++ b/lua/rpm/autocomplete.lua @@ -38,7 +38,11 @@ local commands = { clean = { desc = "Delete plugins that don't have a config file", nargs = 0 - } + }, + generate_helptags = { + desc = "Generate helptags for a plugin", + nargs = 1 + }, } local command_names = {} diff --git a/lua/rpm/core.lua b/lua/rpm/core.lua index fb5a161..57d93ad 100644 --- a/lua/rpm/core.lua +++ b/lua/rpm/core.lua @@ -61,6 +61,19 @@ local function is_plugin_installed(path, silent) return true end +local function generate_helptags(path, silent) + local info = get_plugin_info(path) + local doc_dir = info.install_path .. "/doc" + + if vim.fn.isdirectory(doc_dir) == 1 then + silent_print("Generating help tags for " .. info.name .. "...", silent) + + vim.cmd("helptags " .. doc_dir) + + silent_print("Help tags for " .. info.name .. " have been generated!", silent) + end +end + local function install_plugin(path, silent) local paths = coerce_to_table(path) @@ -77,6 +90,8 @@ local function install_plugin(path, silent) vim.fn.system({ "git", "clone", url, info.install_path }) + generate_helptags(p, silent) + silent_print("Dependency " .. info.name .. " has been installed!", silent) ::continue:: end @@ -160,5 +175,7 @@ return { get_plugin_info = get_plugin_info, install_plugin = install_plugin, is_plugin_installed = is_plugin_installed, + parse_input_answer = parse_input_answer, + generate_helptags = generate_helptags, update_plugin = update_plugin } diff --git a/lua/rpm/init.lua b/lua/rpm/init.lua index 90551ff..ae7b5d5 100644 --- a/lua/rpm/init.lua +++ b/lua/rpm/init.lua @@ -1,3 +1,4 @@ +local Rpm = require("rpm.interface") local core = require("rpm.core") local plugin_list = require("rpm.plugin_list") @@ -25,6 +26,11 @@ local function init_plugins() end print("Plugins initialized.") + + if Rpm.after_init then + Rpm.after_init(plugin_list) + end + return true end) end @@ -37,4 +43,3 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, { coroutine.resume(init_routine) end }) - diff --git a/lua/rpm/interface.lua b/lua/rpm/interface.lua index 5eff2b6..399924d 100644 --- a/lua/rpm/interface.lua +++ b/lua/rpm/interface.lua @@ -51,6 +51,16 @@ Rpm.help = function(command_name) end end +Rpm.generate_helptags = function(plugin_name) + local plugin = get_plugin(plugin_name) + + if not plugin then + return + end + + core.generate_helptags(plugin.path) +end + Rpm.info = function(plugin_name) local plugin = get_plugin(plugin_name) @@ -101,6 +111,20 @@ Rpm.delete = function(plugin_name, silent) return end + local is_rpm = plugin_name == "rpm" + + if is_rpm then + silent = true + + local answer = vim.fn.input( + "Are you sure you want to delete RPM? This is your plugin manager :D (y/n): " + ) + + if not core.parse_input_answer(answer) then + return + end + end + core.delete_plugin(plugin.path, silent) end @@ -134,10 +158,14 @@ Rpm.delete_all = function() print("\n") use_plugin_list_op_with_routines(function(name) + if name == "rpm" then + return + end + Rpm.delete(name, true) end) - print("All plugins have been deleted.") + print("All plugins (except for RPM) have been deleted.") end Rpm.clean = function() @@ -173,4 +201,12 @@ Rpm.clean = function() print("Deleted " .. delete_count .. " plugins.\n") end +Rpm.setup = function(opts) + opts = opts or {} + + if opts.after_init and type(opts.after_init) == "function" then + Rpm.after_init = opts.after_init + end +end + return Rpm