diff --git a/doc/rtp_nvim.txt b/doc/rtp_nvim.txt index 4be05e3..abf1e46 100644 --- a/doc/rtp_nvim.txt +++ b/doc/rtp_nvim.txt @@ -12,4 +12,11 @@ rtp_nvim.source_rtp_dir({dir}) *rtp_nvim.source_rtp_dir* {dir} (string) The runtime directory to source +rtp_nvim.source_after_plugin_dir({dir}) *rtp_nvim.source_after_plugin_dir* + Source the `after` scripts + + Parameters: ~ + {dir} (string) The runtime directory to source + + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/lua/rtp_nvim.lua b/lua/rtp_nvim.lua index a4494a4..3dcff09 100644 --- a/lua/rtp_nvim.lua +++ b/lua/rtp_nvim.lua @@ -23,6 +23,7 @@ local _sourced_ftdetect = {} local RtpSourceDir = { plugin = "plugin", ftdetect = "ftdetect", + after_plugin = vim.fs.joinpath("after", "plugin"), } ---Recursively iterate over a directory's children @@ -77,6 +78,11 @@ local function source_ftdetect(dir) end end +---@param dir string +local function source_after_plugin(dir) + source(RtpSourceDir.after_plugin, dir) +end + ---Source the `plugin` and `ftdetect` directories. ---@param dir string The runtime directory to source function rtp_nvim.source_rtp_dir(dir) @@ -84,4 +90,10 @@ function rtp_nvim.source_rtp_dir(dir) source_ftdetect(dir) end +---Source the `after` scripts +---@param dir string The runtime directory to source +function rtp_nvim.source_after_plugin_dir(dir) + source_after_plugin(dir) +end + return rtp_nvim diff --git a/spec/fixtures/after/plugin/test_after_plugin.lua b/spec/fixtures/after/plugin/test_after_plugin.lua new file mode 100644 index 0000000..815d5c1 --- /dev/null +++ b/spec/fixtures/after/plugin/test_after_plugin.lua @@ -0,0 +1 @@ +vim.g.test_after_plugin = (vim.g.test_after_plugin or 0) + 1 diff --git a/spec/rtp_spec.lua b/spec/rtp_spec.lua index f4fa061..0f2bf78 100644 --- a/spec/rtp_spec.lua +++ b/spec/rtp_spec.lua @@ -4,11 +4,16 @@ describe("rtp_nvim", function() it("sources plugin scripts multiple times and ftdetect scripts once", function() assert.is_nil(vim.g.test_plugin) assert.is_nil(vim.g.test_ftdetect) + assert.is_nil(vim.g.test_after_plugin) rtp.source_rtp_dir(fixture_dir) assert.same(1, vim.g.test_plugin) assert.same(1, vim.g.test_ftdetect) rtp.source_rtp_dir(fixture_dir) assert.same(2, vim.g.test_plugin) assert.same(1, vim.g.test_ftdetect) + rtp.source_after_plugin_dir(fixture_dir) + assert.same(1, vim.g.test_after_plugin) + rtp.source_after_plugin_dir(fixture_dir) + assert.same(2, vim.g.test_after_plugin) end) end)