Skip to content

Commit

Permalink
Add generate_helptags (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizamiza authored Apr 1, 2024
1 parent 3beab3e commit 80bc407
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ luac.out
*.x86_64
*.hex

# Helptags
doc/tags
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 14 additions & 7 deletions doc/rpm.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*rpm.txt* A Rudimentary Plugin Manager for NeoVim
*rpm* A Rudimentary Plugin Manager for NeoVim

================================================================================
INTRODUCTION **rpm**
Expand Down Expand Up @@ -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:

Expand Down
6 changes: 5 additions & 1 deletion lua/rpm/autocomplete.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
17 changes: 17 additions & 0 deletions lua/rpm/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
}
7 changes: 6 additions & 1 deletion lua/rpm/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local Rpm = require("rpm.interface")
local core = require("rpm.core")
local plugin_list = require("rpm.plugin_list")

Expand Down Expand Up @@ -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
Expand All @@ -37,4 +43,3 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
coroutine.resume(init_routine)
end
})

38 changes: 37 additions & 1 deletion lua/rpm/interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit 80bc407

Please sign in to comment.