Skip to content

Commit

Permalink
Fix module search to include runtime (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
undyamon authored Dec 30, 2023
1 parent f2cbe8f commit 2730051
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lua/tasks/utils.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local scandir = require('plenary.scandir')
local Path = require('plenary.path')
local utils = {}

local args_regex = vim.regex([[\s\%(\%([^'"]*\(['"]\)[^'"]*\1\)*[^'"]*$\)\@=]])
Expand Down Expand Up @@ -60,14 +58,11 @@ end

---@return table
function utils.get_module_names()
local module_dir = Path:new(debug.getinfo(1).source:sub(2)):parent() / 'module'

local modules = {}
for _, entry in ipairs(scandir.scan_dir(module_dir.filename, { depth = 1 })) do
-- Strip full path and extension
local extension_len = 4
local parent_offset = 2
table.insert(modules, entry:sub(#Path:new(entry):parent().filename + parent_offset, #entry - extension_len))

local runtime_files = vim.api.nvim_get_runtime_file('lua/tasks/module/*.lua', true)
for _, file in ipairs(runtime_files) do
table.insert(modules, vim.fn.fnamemodify(file, ':t:r'))
end

return modules
Expand Down

0 comments on commit 2730051

Please sign in to comment.