~unwox/awm-fuzzy

ee1ec58c13f8d57002a1b11f0b9c5157208b4b79 — Vladislav Gorenkin 4 years ago 1589433
Exclude duplicates from path source
1 files changed, 11 insertions(+), 6 deletions(-)

M source.lua
M source.lua => source.lua +11 -6
@@ 24,15 24,20 @@ function sources.path()
  end

  local output = {}
  local hash = {}

  for path_dir in string.gmatch(os.getenv("PATH"), "[^%:]+") do
    for _, file in pairs(get_files(path_dir)) do
      table.insert(output, {
        title = file,
        description = path_dir .. "/" .. file,
        value = file,
        data = {},
      })
      if not hash[file] then
        hash[file] = true

        table.insert(output, {
          title = file,
          description = path_dir .. "/" .. file,
          value = file,
          data = {},
        })
      end
    end
  end