File size: 204,291 Bytes
2c916e8
 
 
1
2
3
4
{"repo_name": "fyler.nvim", "file_name": "/fyler.nvim/lua/fyler/views/explorer/init.lua", "inference_info": {"prefix_code": "local FSItem = require(\"fyler.views.explorer.struct\")\nlocal Win = require(\"fyler.lib.win\")\nlocal a = require(\"fyler.lib.async\")\nlocal config = require(\"fyler.config\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal store = require(\"fyler.views.explorer.store\")\n\nlocal fn = vim.fn\nlocal api = vim.api\n\n---@class FylerExplorerView\n---@field cwd     string      - Directory path which act as a root\n---@field fs_root FylerFSItem - Root |FylerFSItem| instance\n---@field win     FylerWin    - Window instance\nlocal ExplorerView = {}\nExplorerView.__index = ExplorerView\n\n", "suffix_code": "\n\nExplorerView.open = a.async(function(self, opts)\n  local mappings = config.get_reverse_mappings(\"explorer\")\n  local view = config.get_view(\"explorer\")\n\n  -- stylua: ignore start\n  self.win = Win {\n    border   = view.border,\n    buf_opts = view.buf_opts,\n    bufname  = string.format(\"fyler://%s\", self.cwd),\n    enter    = opts.enter,\n    height   = view.height,\n    kind     = opts.kind or view.kind,\n    name     = \"explorer\",\n    width    = view.width,\n    win_opts = view.win_opts,\n    mappings = {\n      n = {\n        [mappings[\"Select\"]]    = self:_action(\"n_select\"),\n        [mappings[\"CloseView\"]] = self:_action(\"n_close_view\"),\n      },\n    },\n    autocmds = {\n      [\"BufReadCmd\"]   = self:_action(\"refreshview\"),\n      [\"BufWriteCmd\"]  = self:_action(\"synchronize\"),\n      [\"CursorMoved\"]  = self:_action(\"constrain_cursor\"),\n      [\"CursorMovedI\"] = self:_action(\"constrain_cursor\"),\n      [\"WinClosed\"]    = self:_action(\"n_close_view\"),\n    },\n    user_autocmds = {\n      [\"RefreshView\"] = self:_action(\"refreshview\"),\n      [\"Synchronize\"] = self:_action(\"synchronize\"),\n    },\n    render = self:_action(\"refreshview\"),\n  }\n  -- stylua: ignore end\n\n  require(\"fyler.cache\").set_entry(\"recent_win\", api.nvim_get_current_win())\n\n  self.win:show()\nend)\n\n---@param ... any\nfunction ExplorerView:_action(name, ...)\n  local action = require(\"fyler.views.explorer.actions\")[name]\n\n  assert(action, string.format(\"%s action is not available\", name))\n\n  return action(self, ...)\nend\n\nlocal M = {\n  instance = nil, ---@type FylerExplorerView\n}\n\n---@param opts { cwd?: string, kind?: FylerWinKind }\n---@return FylerExplorerView\nfunction M.get_instance(opts)\n  if (not M.instance) or (M.instance.cwd ~= opts.cwd) then\n    M.instance = ExplorerView.new {\n      cwd = opts.cwd,\n      kind = opts.kind,\n    }\n  end\n\n  return M.instance\nend\n\n---@param opts? { enter?: boolean, cwd?: string, kind?: FylerWinKind }\nfunction M.open(opts)\n  opts = opts or {}\n  opts.enter = opts.enter == nil and true or opts.enter\n  opts.cwd = opts.cwd or fs.getcwd()\n  opts.kind = opts.kind or config.get_view(\"explorer\").kind\n\n  if M.instance and fn.winbufnr(M.instance.win.winid) == M.instance.win.bufnr then\n    M.instance.win:hide()\n  end\n\n  M.get_instance(opts):open(opts)\nend\n\nreturn M\n", "middle_code": "function ExplorerView.new(opts)\n  local fs_root = FSItem(store.set {\n    name = fn.fnamemodify(opts.cwd, \":t\"),\n    type = \"directory\",\n    path = opts.cwd,\n  })\n  fs_root:toggle()\n  local instance = {\n    cwd = opts.cwd,\n    fs_root = fs_root,\n    kind = opts.kind,\n  }\n  setmetatable(instance, ExplorerView)\n  return instance\nend", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "lua", "sub_task_type": null}, "context_code": [["/fyler.nvim/lua/fyler/views/confirm/init.lua", "local Win = require(\"fyler.lib.win\")\nlocal config = require(\"fyler.config\")\nlocal ui = require(\"fyler.views.confirm.ui\")\n\n---@class FylerConfirmView\n---@field win FylerWin\nlocal FylerConfirmView = {}\nFylerConfirmView.__index = FylerConfirmView\n\n---@param msg { str: string, hl: string }[]\n---@param chs string\n---@param cb fun(c: boolean)\nfunction FylerConfirmView:open(msg, chs, cb)\n  local mappings = config.get_reverse_mappings(\"confirm\")\n  local view = config.get_view(\"confirm\")\n\n  --stylua: ignore start\n  self.win = Win {\n    border   = view.border,\n    buf_opts = view.buf_opts,\n    bufname  = \"confirm\",\n    enter    = true,\n    height   = view.height,\n    kind     = view.kind,\n    name     = \"confirm\",\n    title    = string.format(\" Confirm %s \", chs),\n    width    = view.width,\n    win_opts = view.win_opts,\n    mappings = {\n      n = {\n        [mappings[\"Confirm\"]] = self:_action(\"n_confirm\", cb),\n        [mappings[\"Discard\"]] = self:_action(\"n_discard\", cb),\n      },\n    },\n    autocmds = {\n      [\"QuitPre\"] = self:_action(\"n_close_view\", cb),\n    },\n    render = function()\n      self.win.ui:render({ ui_lines = ui.Confirm(msg) })\n    end,\n  }\n  --stylua: ignore end\n\n  self.win:show()\nend\n\nfunction FylerConfirmView:close()\n  self.win:hide()\nend\n\n---@param name string\nfunction FylerConfirmView:_action(name, ...)\n  local action = require(\"fyler.views.confirm.actions\")[name]\n\n  assert(action, string.format(\"%s action is not available\", name))\n\n  return action(self, ...)\nend\n\nlocal M = {}\n\n---@param msg { str: string, hl: string }[]\n---@param chs string\n---@param cb fun(c: boolean)\nM.open = vim.schedule_wrap(function(msg, chs, cb)\n  if not M.instance then\n    M.instance = setmetatable({}, FylerConfirmView)\n  end\n\n  if M.instance.win and M.instance.win:has_valid_winid() then\n    M.instance:close()\n  end\n\n  M.instance:open(msg, chs, cb)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/win.lua", "local Ui = require(\"fyler.lib.ui\")\n\nlocal api = vim.api\n\n---@alias FylerWinKind\n---| \"float\"\n---| \"split:left\"\n---| \"split:above\"\n---| \"split:right\"\n---| \"split:below\"\n---| \"split:leftmost\"\n---| \"split:abovemost\"\n---| \"split:rightmost\"\n---| \"split:belowmost\"\n\n---@class FylerWin\n---@field augroup       string          - Autogroup associated with window instance\n---@field autocmds      table           - Autocommands locally associated with window instance\n---@field border        string|string[] - Border format - read ':winborder' for more info\n---@field bufname       string          - Builtin way to name neovim buffers\n---@field bufnr?        integer         - Buffer number associated with window instance\n---@field buf_opts      table           - Buffer local options\n---@field enter         boolean         - whether to enter in the window on open\n---@field footer?       any             - Footer content\n---@field footer_pos?   string          - Footer alignment\n---@field height        number          - Height of window\n---@field kind          FylerWinKind    - Decides launch behaviour of window instance\n---@field mappings      table           - Kemaps local to the window instance\n---@field name          string          - Also know as `view_name` which helps to get specific config from user end\n---@field namespace     integer         - Namespace associated with window instance\n---@field render?       function        - Defines what to render on the screen on open\n---@field title?        any             - Title content\n---@field title_pos?    string          - Title alignment\n---@field ui            FylerUi         - Ui responsible to render lines return from corresponding render function\n---@field user_autocmds table           - User autocommands associated with window instance\n---@field width         number          - Width of window\n---@field winid?        integer         - Window id associated with window instance\n---@field win_opts      table           - Window local options\nlocal Win = {}\nWin.__index = Win\n\n-- Prepares namespace ID by attaching buffer's given name\n---@param name string\nlocal function get_namespace(name)\n  return api.nvim_create_namespace(\"Fyler\" .. name)\nend\n\n-- Prepares autogroup ID by attaching buffer's given name\n---@param name string\nlocal function get_augroup(name)\n  return api.nvim_create_augroup(\"Fyler\" .. name, { clear = true })\nend\n\nlocal M = setmetatable({}, {\n  ---@return FylerWin\n  __call = function(_, opts)\n    opts = opts or {}\n\n    assert(opts.name, \"name is required field\")\n    assert(opts.bufname, \"bufname is required field\")\n\n    -- stylua: ignore start\n    local instance = {\n      augroup       = get_augroup(opts.name),\n      autocmds      = opts.autocmds or {},\n      border        = opts.border,\n      bufname       = opts.bufname,\n      buf_opts      = opts.buf_opts or {},\n      enter         = opts.enter,\n      footer        = opts.footer,\n      footer_pos    = opts.footer_pos,\n      height        = opts.height,\n      kind          = opts.kind or \"float\",\n      mappings      = opts.mappings or {},\n      name          = opts.name or \"\",\n      namespace     = get_namespace(opts.name),\n      render        = opts.render,\n      title         = opts.title,\n      title_pos     = opts.title_pos,\n      user_autocmds = opts.user_autocmds or {},\n      width         = opts.width,\n      win_opts      = opts.win_opts or {},\n    }\n    -- stylua: ignore end\n\n    instance.ui = Ui(instance)\n    setmetatable(instance, Win)\n\n    return instance\n  end,\n})\n\n-- Determine whether the `Win` has valid buffer\n---@return boolean\nfunction Win:has_valid_bufnr()\n  return type(self.bufnr) == \"number\" and api.nvim_buf_is_valid(self.bufnr)\nend\n\n-- Determine whether the `Win` has valid window\n---@return boolean\nfunction Win:has_valid_winid()\n  return type(self.winid) == \"number\" and api.nvim_win_is_valid(self.winid)\nend\n\n---@return boolean\nfunction Win:is_visible()\n  return self:has_valid_bufnr() and self:has_valid_winid()\nend\n\n-- Construct respective window config in vim understandable format\n---@return vim.api.keyset.win_config\nfunction Win:config()\n  local winconfig = {\n    style = \"minimal\",\n    noautocmd = true,\n    title = self.title,\n    title_pos = self.title_pos,\n    footer = self.footer,\n    footer_pos = self.footer_pos,\n  }\n\n  if self.kind:match(\"^split:\") then\n    winconfig.split = self.kind:match(\"^split:(.*)\")\n    winconfig.title = nil\n    winconfig.title_pos = nil\n    winconfig.footer = nil\n    winconfig.footer_pos = nil\n  end\n\n  if self.kind == \"float\" then\n    winconfig.relative = \"editor\"\n    winconfig.border = self.border\n    winconfig.col = math.floor((1 - self.width) * 0.5 * vim.o.columns)\n    winconfig.row = math.floor((1 - self.height) * 0.5 * vim.o.lines)\n  end\n\n  winconfig.width = math.ceil(self.width * vim.o.columns)\n  winconfig.height = math.ceil(self.height * vim.o.lines)\n\n  return winconfig\nend\n\nfunction Win:show()\n  if self:has_valid_winid() then\n    return\n  end\n\n  local recent_win = api.nvim_get_current_win()\n  local win_config = self:config()\n\n  self.bufnr = api.nvim_create_buf(false, true)\n  if self.render then\n    self.render()\n  end\n\n  api.nvim_buf_set_name(self.bufnr, self.bufname)\n\n  if win_config.split and win_config.split:match(\"^%w+most$\") then\n    if win_config.split == \"leftmost\" then\n      api.nvim_command(string.format(\"topleft %dvsplit\", win_config.width))\n    elseif win_config.split == \"abovemost\" then\n      api.nvim_command(string.format(\"topleft %dsplit\", win_config.height))\n    elseif win_config.split == \"rightmost\" then\n      api.nvim_command(string.format(\"botright %dvsplit\", win_config.width))\n    elseif win_config.split == \"belowmost\" then\n      api.nvim_command(string.format(\"botright %dsplit\", win_config.height))\n    else\n      error(string.format(\"Invalid window kind `%s`\", win_config.split))\n    end\n\n    self.winid = api.nvim_get_current_win()\n\n    if not self.enter then\n      api.nvim_set_current_win(recent_win)\n    end\n\n    api.nvim_win_set_buf(self.winid, self.bufnr)\n  else\n    self.winid = api.nvim_open_win(self.bufnr, self.enter, win_config)\n  end\n\n  api.nvim_exec_autocmds(\"BufEnter\", {})\n\n  for mode, map in pairs(self.mappings) do\n    for key, val in pairs(map) do\n      vim.keymap.set(mode, key, val, { buffer = self.bufnr, silent = true, noremap = true })\n    end\n  end\n\n  for option, value in pairs(self.win_opts) do\n    vim.w[self.winid][option] = vim.wo[self.winid][option]\n    vim.wo[self.winid][option] = value\n  end\n\n  for option, value in pairs(self.buf_opts) do\n    vim.bo[self.bufnr][option] = value\n  end\n\n  for event, callback in pairs(self.autocmds) do\n    api.nvim_create_autocmd(event, {\n      group = self.augroup,\n      buffer = self.bufnr,\n      callback = callback,\n    })\n  end\n\n  for event, callback in pairs(self.user_autocmds) do\n    api.nvim_create_autocmd(\"User\", {\n      pattern = event,\n      group = self.augroup,\n      callback = callback,\n    })\n  end\nend\n\nfunction Win:hide()\n  if self:has_valid_winid() then\n    api.nvim_win_close(self.winid, true)\n  end\n\n  if self:has_valid_bufnr() then\n    api.nvim_buf_delete(self.bufnr, { force = true })\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/actions.lua", "local a = require(\"fyler.lib.async\")\nlocal algos = require(\"fyler.views.explorer.algos\")\nlocal cache = require(\"fyler.cache\")\nlocal config = require(\"fyler.config\")\nlocal confirm_view = require(\"fyler.views.confirm\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal regex = require(\"fyler.views.explorer.regex\")\nlocal store = require(\"fyler.views.explorer.store\")\nlocal ui = require(\"fyler.views.explorer.ui\")\n\nlocal M = {}\n\nlocal fn = vim.fn\nlocal api = vim.api\n\n---@param view table\nfunction M.n_close_view(view)\n  return function()\n    local success = pcall(api.nvim_win_close, view.win.winid, true)\n    if not success then\n      api.nvim_win_set_buf(view.win.winid, fn.bufnr(\"#\", true))\n    end\n\n    pcall(api.nvim_buf_delete, view.win.bufnr, { force = true })\n  end\nend\n\n---@param view FylerExplorerView\nfunction M.n_select(view)\n  return function()\n    local key = regex.match_meta(api.nvim_get_current_line())\n    if not key then\n      return\n    end\n\n    local meta_data = store.get(key)\n    if meta_data:is_directory() then\n      view.fs_root:find(key):toggle()\n      api.nvim_exec_autocmds(\"User\", { pattern = \"RefreshView\" })\n    else\n      local recent_win = cache.get_entry(\"recent_win\")\n\n      if recent_win and api.nvim_win_is_valid(recent_win) then\n        fn.win_execute(recent_win, string.format(\"edit %s\", meta_data:resolved_path()))\n        fn.win_gotoid(recent_win)\n\n        if config.values.close_on_select then\n          view.win:hide()\n        end\n      end\n    end\n  end\nend\n\n---@param tbl table\n---@return table\nlocal function get_tbl(tbl)\n  local lines = { { { str = \"\", hl = \"\" } } }\n  if not vim.tbl_isempty(tbl.create) then\n    table.insert(lines, { { str = \"# Creation\", hl = \"FylerConfirmGreen\" } })\n    for _, change in ipairs(tbl.create) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  if not vim.tbl_isempty(tbl.delete) then\n    table.insert(lines, { { str = \"# Deletion\", hl = \"FylerConfirmRed\" } })\n    for _, change in ipairs(tbl.delete) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  if not vim.tbl_isempty(tbl.move) then\n    table.insert(lines, { { str = \"# Migration\", hl = \"FylerConfirmYellow\" } })\n    for _, change in ipairs(tbl.move) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change.src), hl = \"FylerConfirmGrey\" },\n        { str = \" > \" },\n        { str = fs.relpath(fs.getcwd(), change.dst), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  return lines\nend\n\n---@param changes table\n---@return boolean\nlocal function can_bypass(changes)\n  if not vim.tbl_isempty(changes.delete) then\n    return false\n  end\n\n  if #changes.move > 1 then\n    return false\n  end\n\n  if #changes.create > 5 then\n    return false\n  end\n\n  return true\nend\n\n---@param view FylerExplorerView\nfunction M.synchronize(view)\n  return a.async(function()\n    local changes = algos.get_diff(view)\n    local can_sync = (function()\n      if #changes.create == 0 and #changes.delete == 0 and #changes.move == 0 then\n        return true\n      end\n\n      if not config.values.auto_confirm_simple_edits then\n        return a.await(confirm_view.open, get_tbl(changes), \"(y/n)\")\n      end\n\n      if can_bypass(changes) then\n        return true\n      end\n\n      return a.await(confirm_view.open, get_tbl(changes), \"(y/n)\")\n    end)()\n\n    if can_sync then\n      for _, change in ipairs(changes.create) do\n        local err, success = a.await(fs.create, change)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n\n      for _, change in ipairs(changes.delete) do\n        local err, success = a.await(fs.delete, change)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n\n      for _, change in ipairs(changes.move) do\n        local err, success = a.await(fs.move, change.src, change.dst)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n    end\n\n    vim.schedule(function()\n      api.nvim_exec_autocmds(\"User\", { pattern = \"RefreshView\" })\n    end)\n  end)\nend\n\n---@param view FylerExplorerView\n---@param on_render function\nfunction M.refreshview(view, on_render)\n  return a.async(function()\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    a.await(view.fs_root.update, view.fs_root)\n\n    vim.bo[view.win.bufnr].undolevels = -1\n\n    view.win.ui:render {\n      ui_lines = a.await(ui.Explorer, algos.tree_table_from_node(view).children),\n      on_render = function()\n        if on_render then\n          on_render()\n        end\n\n        M.draw_indentscope(view)()\n\n        if not view.win:has_valid_bufnr() then\n          return\n        end\n\n        vim.bo[view.win.bufnr].undolevels = vim.go.undolevels\n      end,\n    }\n\n    vim.bo[view.win.bufnr].syntax = \"fyler\"\n    vim.bo[view.win.bufnr].filetype = \"fyler\"\n  end)\nend\n\nfunction M.constrain_cursor(view)\n  return function()\n    local cur = api.nvim_get_current_line()\n    local meta = regex.match_meta(cur)\n    if not meta then\n      return\n    end\n\n    local _, ub = string.find(cur, meta)\n    if not view.win:has_valid_winid() then\n      return\n    end\n\n    local row, col = unpack(api.nvim_win_get_cursor(view.win.winid))\n    if col <= ub then\n      api.nvim_win_set_cursor(view.win.winid, { row, ub + 1 })\n    end\n  end\nend\n\n---@param view FylerExplorerView\nfunction M.try_focus_buffer(view)\n  return a.schedule_async(function(arg)\n    local explorer = require(\"fyler.views.explorer\")\n\n    if not view.win:is_visible() then\n      return\n    end\n\n    if arg.file == \"\" then\n      return\n    end\n\n    if string.match(arg.file, \"^fyler://*\") then\n      local recent_win = cache.get_entry(\"recent_win\")\n      if (type(recent_win) ~= \"number\") or (not api.nvim_win_is_valid(recent_win)) then\n        return\n      end\n\n      local recent_bufname = fn.bufname(api.nvim_win_get_buf(recent_win))\n      if recent_bufname == \"\" or string.match(recent_bufname, \"^fyler://*\") then\n        return\n      end\n\n      arg.file = fs.abspath(recent_bufname)\n    end\n\n    if not vim.startswith(arg.file, view.cwd) then\n      explorer.open {\n        enter = fn.bufname(\"%\") == view.win.bufname,\n        cwd = fn.fnamemodify(arg.file, \":h\"),\n      }\n    end\n\n    local relpath = fs.relpath(view.cwd, arg.file)\n    if not relpath then\n      return\n    end\n\n    local focused_node = view.fs_root\n    local last_visit = 0\n    local parts = vim.split(relpath, \"/\")\n\n    a.await(focused_node.update, focused_node)\n\n    for i, part in ipairs(parts) do\n      local child = vim.iter(focused_node.children):find(function(child)\n        return store.get(child.meta).name == part\n      end)\n\n      if not child then\n        break\n      end\n\n      if store.get(child.meta):is_directory() then\n        child.open = true\n        a.await(child.update, child)\n      end\n\n      focused_node, last_visit = child, i\n    end\n\n    if last_visit ~= #parts then\n      return\n    end\n\n    M.refreshview(view, function()\n      if not view.win:has_valid_winid() then\n        return\n      end\n\n      local buf_lines = api.nvim_buf_get_lines(view.win.bufnr, 0, -1, false)\n      for ln, buf_line in ipairs(buf_lines) do\n        if buf_line:find(focused_node.meta) then\n          api.nvim_win_set_cursor(view.win.winid, { ln, 0 })\n        end\n      end\n    end)()\n  end)\nend\n\nlocal extmark_namespace = api.nvim_create_namespace(\"FylerIndentScope\")\n\n---@param view FylerExplorerView\nfunction M.draw_indentscope(view)\n  local function draw_line(ln)\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    local cur_line = unpack(api.nvim_buf_get_lines(view.win.bufnr, ln - 1, ln, false))\n    local cur_indent = #regex.match_indent(cur_line)\n    if cur_indent == 0 then\n      return\n    end\n\n    local indent_depth = math.floor(cur_indent * 0.5)\n    for i = 1, indent_depth do\n      api.nvim_buf_set_extmark(view.win.bufnr, extmark_namespace, ln - 1, 0, {\n        hl_mode = \"combine\",\n        virt_text = {\n          {\n            config.values.indentscope.marker,\n            config.values.indentscope.group,\n          },\n        },\n        virt_text_pos = \"overlay\",\n        virt_text_win_col = (i - 1) * 2,\n      })\n    end\n  end\n\n  return function()\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    if not config.values.indentscope.enabled then\n      return\n    end\n\n    api.nvim_buf_clear_namespace(view.win.bufnr, extmark_namespace, 0, -1)\n    for i = 1, api.nvim_buf_line_count(view.win.bufnr) do\n      draw_line(i)\n    end\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/autocmds.lua", "local M = {}\n\nlocal api = vim.api\nlocal uv = vim.uv or vim.loop\n\nlocal augroup = api.nvim_create_augroup(\"Fyler\", { clear = true })\n\nfunction M.setup(opts)\n  opts = opts or {}\n\n  api.nvim_create_autocmd(\"ColorScheme\", {\n    group = augroup,\n    callback = function()\n      require(\"fyler.lib.hls\").setup()\n    end,\n  })\n\n  api.nvim_create_autocmd(\"BufEnter\", {\n    group = augroup,\n    callback = function(...)\n      local cur_instance = require(\"fyler.views.explorer\").instance\n      if cur_instance then\n        cur_instance:_action(\"try_focus_buffer\")(...)\n      end\n    end,\n  })\n\n  api.nvim_create_autocmd(\"BufEnter\", {\n    group = augroup,\n    callback = vim.schedule_wrap(function(arg)\n      local explorer = require(\"fyler.views.explorer\").instance\n      if not explorer then\n        return\n      end\n\n      if vim.fn.bufname(arg.buf) == explorer.win.bufname then\n        return\n      end\n\n      if api.nvim_get_current_win() == explorer.win.winid then\n        for option, _ in pairs(require(\"fyler.config\").get_view(\"explorer\").win_opts) do\n          if not explorer.win:has_valid_winid() then\n            return\n          end\n\n          vim.wo[explorer.win.winid][option] = vim.w[explorer.win.winid][option]\n        end\n      end\n    end),\n  })\n\n  if opts.values.default_explorer then\n    api.nvim_create_autocmd(\"BufEnter\", {\n      group = augroup,\n      callback = function(arg)\n        local stats = uv.fs_stat(arg.file)\n\n        if stats and stats.type == \"directory\" then\n          local cur_buf = api.nvim_get_current_buf()\n\n          if api.nvim_buf_is_valid(cur_buf) then\n            api.nvim_buf_delete(cur_buf, { force = true })\n          end\n\n          require(\"fyler\").open { cwd = arg.file }\n        end\n      end,\n    })\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/config.lua", "---@class FylerConfigView\n---@field width  number\n---@field height number\n---@field kind   FylerWinKind\n---@field border string|string[]\n\n---@class FylerConfig\n---@field auto_confirm_simple_edits? boolean\n---@field close_on_select?           boolean\n---@field default_explorer?          boolean\n---@field git_status                 boolean\n---@field icon_provider?             string|fun(type: string, name: string): string, string\n---@field indentscope                { enabled: boolean, group: string, marker: string }\n---@field on_highlights              fun(hl_groups: table, palette: table): nil\n---@field views?                     table<string, FylerConfigView>\n---@field mappings?                  table<string, table<\"n\"|\"i\", table<string, string>>>\n\nlocal M = {}\n\nlocal defaults = {\n  auto_confirm_simple_edits = false,\n  close_on_select = true,\n  default_explorer = false,\n  git_status = true,\n  icon_provider = \"mini-icons\",\n  on_highlights = nil,\n  indentscope = {\n    enabled = true,\n    group = \"FylerIndentMarker\",\n    marker = \"\",\n  },\n  mappings = {\n    confirm = {\n      n = {\n        [\"y\"] = \"Confirm\",\n        [\"n\"] = \"Discard\",\n      },\n    },\n    explorer = {\n      n = {\n        [\"q\"] = \"CloseView\",\n        [\"<CR>\"] = \"Select\",\n      },\n    },\n  },\n  views = {\n    confirm = {\n      width = 0.5,\n      height = 0.4,\n      kind = \"float\",\n      border = \"single\",\n      buf_opts = {\n        buflisted = false,\n        modifiable = false,\n      },\n      win_opts = {\n        winhighlight = \"Normal:Normal,FloatBorder:FloatBorder,FloatTitle:FloatTitle\",\n        wrap = false,\n      },\n    },\n    explorer = {\n      width = 0.8,\n      height = 0.8,\n      kind = \"float\",\n      border = \"single\",\n      buf_opts = {\n        buflisted = false,\n        buftype = \"acwrite\",\n        filetype = \"fyler\",\n        syntax = \"fyler\",\n      },\n      win_opts = {\n        concealcursor = \"nvic\",\n        conceallevel = 3,\n        cursorline = true,\n        number = true,\n        relativenumber = true,\n        winhighlight = \"Normal:Normal,FloatBorder:FloatBorder,FloatTitle:FloatTitle\",\n        wrap = false,\n      },\n    },\n  },\n}\n\n---@param name string\nfunction M.get_view(name)\n  assert(name, \"name is required\")\n\n  return M.values.views[name]\nend\n\n---@param name string\nfunction M.get_mappings(name)\n  assert(name, \"name is required\")\n\n  return M.values.mappings[name]\nend\n\n---@param name string\nfunction M.get_reverse_mappings(name)\n  assert(name, \"name is required\")\n\n  local mappings = M.get_mappings(name)\n  local reverse_mappings = {}\n\n  for _, map in pairs(mappings) do\n    for key, val in pairs(map) do\n      reverse_mappings[val] = key\n    end\n  end\n\n  return reverse_mappings\nend\n\n---@param opts? FylerConfig\nfunction M.setup(opts)\n  opts = opts or {}\n  M.values = vim.tbl_deep_extend(\"force\", defaults, opts)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler.lua", "local M = {}\n\nlocal did_setup = false\n\nlocal api = vim.api\nlocal fn = vim.fn\n\n---@param opts FylerConfig\nfunction M.setup(opts)\n  if fn.has(\"nvim-0.11\") ~= 1 then\n    return vim.notify(\"Fyler requires at least NVIM 0.11\")\n  end\n\n  if did_setup then\n    return\n  end\n\n  require(\"fyler.config\").setup(opts)\n  require(\"fyler.lib.hls\").setup(require(\"fyler.config\"))\n  require(\"fyler.autocmds\").setup(require(\"fyler.config\"))\n\n  if require(\"fyler.config\").values.default_explorer then\n    vim.g.loaded_netrw = 1\n    vim.g.loaded_netrwPlugin = 1\n    if fn.exists(\"#FileExplorer\") then\n      api.nvim_create_augroup(\"FileExplorer\", { clear = true })\n    end\n\n    if vim.v.vim_did_enter == 0 then\n      local arg_path = fn.argv(0)\n      local first_arg = type(arg_path) == \"string\" and arg_path or arg_path[1]\n      if fn.isdirectory(first_arg) == 0 then\n        return\n      end\n\n      local current_bufnr = api.nvim_get_current_buf()\n      if api.nvim_buf_is_valid(current_bufnr) then\n        api.nvim_buf_delete(current_bufnr, { force = true })\n      end\n\n      M.open { cwd = arg_path }\n    end\n  end\n\n  did_setup = true\nend\n\nM.open = vim.schedule_wrap(function(opts)\n  opts = opts or {}\n\n  require(\"fyler.views.explorer\").open {\n    cwd = opts.cwd,\n    kind = opts.kind,\n  }\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/algos.lua", "local fs = require(\"fyler.lib.fs\")\nlocal regex = require(\"fyler.views.explorer.regex\")\nlocal store = require(\"fyler.views.explorer.store\")\nlocal M = {}\n\nlocal api = vim.api\n\n---@param view FylerExplorerView\n---@return table\nfunction M.tree_table_from_node(view)\n  ---@param node FylerFSItem\n  local function get_tbl(node)\n    local sub_tbl = store.get(node.meta)\n    sub_tbl.meta = node.meta\n\n    if sub_tbl:is_directory() then\n      sub_tbl.children = {}\n    end\n\n    if not node.open then\n      return sub_tbl\n    end\n\n    for _, child in ipairs(node.children) do\n      table.insert(sub_tbl.children, get_tbl(child))\n    end\n\n    return sub_tbl\n  end\n\n  return get_tbl(view.fs_root)\nend\n\n---@param view FylerExplorerView\n---@return table\nfunction M.tree_table_from_buffer(view)\n  if not view.win:has_valid_bufnr() then\n    return {}\n  end\n\n  local buf_lines = vim\n    .iter(api.nvim_buf_get_lines(view.win.bufnr, 0, -1, false))\n    :filter(function(buf_line)\n      return buf_line ~= \"\"\n    end)\n    :totable()\n\n  local root = vim.tbl_deep_extend(\"force\", store.get(view.fs_root.meta), {\n    meta = view.fs_root.meta,\n    children = {},\n  })\n\n  local stack = {\n    { node = root, indent = -1 },\n  }\n\n  for _, buf_line in ipairs(buf_lines) do\n    local meta = regex.match_meta(buf_line)\n    local name = regex.match_name(buf_line)\n    local indent = regex.match_indent(buf_line)\n    local metadata = meta and store.get(meta)\n\n    while #stack > 1 and #stack[#stack].indent >= #indent do\n      table.remove(stack)\n    end\n\n    local parent = stack[#stack].node\n    local path = fs.joinpath(parent.path, name)\n    local new_node = {\n      meta = meta,\n      name = name,\n      type = (metadata or {}).type or \"\",\n      path = path,\n    }\n\n    table.insert(parent.children, new_node)\n    if metadata and metadata:is_directory() then\n      new_node.children = {}\n      table.insert(stack, { node = new_node, indent = indent })\n    end\n  end\n\n  return root\nend\n\n---@param view FylerExplorerView\n---@return table\nfunction M.get_diff(view)\n  local recent_tree_hash = {}\n\n  local function save_hash(root)\n    recent_tree_hash[root.meta] = root.path\n    for _, child in ipairs(root.children or {}) do\n      save_hash(child)\n    end\n  end\n\n  save_hash(M.tree_table_from_node(view))\n\n  local fs_actions = {\n    create = {},\n    delete = {},\n    move = {},\n  }\n\n  local function calculate_fs_actions(root)\n    if not root.meta then\n      table.insert(fs_actions.create, root.path)\n    else\n      if recent_tree_hash[root.meta] ~= root.path then\n        table.insert(fs_actions.move, { src = recent_tree_hash[root.meta], dst = root.path })\n      end\n\n      recent_tree_hash[root.meta] = nil\n    end\n\n    for _, child in ipairs(root.children or {}) do\n      calculate_fs_actions(child)\n    end\n  end\n\n  calculate_fs_actions(M.tree_table_from_buffer(view))\n\n  for _, v in pairs(recent_tree_hash) do\n    if v then\n      table.insert(fs_actions.delete, v)\n    end\n  end\n\n  return fs_actions\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/ui/init.lua", "local api = vim.api\n\n---@class FylerUi\n---@field win FylerWin\nlocal Ui = {}\nUi.__index = Ui\n\nlocal M = setmetatable({}, {\n  ---@param win FylerWin\n  ---@return FylerUi\n  __call = function(_, win)\n    assert(win, \"win is required\")\n\n    return setmetatable({ win = win }, Ui)\n  end,\n})\n\n---@param align FylerUiLineAlign\n---@param line string\n---@return string\nlocal function get_margin(width, align, line)\n  if align == \"center\" then\n    return string.rep(\" \", math.floor((width - #line) * 0.5))\n  elseif align == \"end\" then\n    return string.rep(\" \", math.floor((width - #line)))\n  else\n    return \"\"\n  end\nend\n\n---@param ui_lines FylerUiLine[]\nfunction Ui:_render(ui_lines)\n  if not self.win:has_valid_bufnr() then\n    return\n  end\n\n  local was_modifiable = vim.bo[self.win.bufnr].modifiable\n  local win_width = api.nvim_win_get_width(self.win.winid)\n  local buf_lines = {}\n\n  vim.bo[self.win.bufnr].modifiable = true\n\n  for _, line in ipairs(ui_lines) do\n    local line_text = table.concat(vim.tbl_map(function(word)\n      return word.str\n    end, line.words))\n\n    local margin = get_margin(win_width, line.align, line_text)\n\n    table.insert(line.words, 1, {\n      str = margin,\n    })\n\n    table.insert(buf_lines, margin .. line_text)\n  end\n\n  api.nvim_buf_set_lines(self.win.bufnr, 0, -1, false, buf_lines)\n  api.nvim_buf_clear_namespace(self.win.bufnr, self.win.namespace, 0, -1)\n\n  for i, line in ipairs(ui_lines) do\n    local offset = 0\n\n    for _, word in ipairs(line.words) do\n      api.nvim_buf_set_extmark(self.win.bufnr, self.win.namespace, i - 1, offset, {\n        end_col = offset + #word.str,\n        hl_group = word.hl or \"\",\n      })\n\n      offset = offset + #word.str\n    end\n\n    for _, mark in pairs(line.marks) do\n      api.nvim_buf_set_extmark(self.win.bufnr, self.win.namespace, i - 1, 0, {\n        virt_text = { { mark.str, mark.hl or \"\" } },\n        virt_text_pos = \"eol\",\n        hl_mode = \"combine\",\n      })\n    end\n  end\n\n  if not was_modifiable then\n    vim.bo[self.win.bufnr].modifiable = false\n  end\n\n  vim.bo[self.win.bufnr].modified = false\nend\n\nfunction Ui:render(opts)\n  opts = opts or {}\n\n  vim.schedule(function()\n    self:_render(opts.ui_lines)\n    if opts.on_render then\n      opts.on_render()\n    end\n  end)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/hls.lua", "local api = vim.api\n\nlocal M = {}\n\n---@param dec integer\nlocal function to_hex(dec)\n  return string.format(\"%06X\", math.max(0, math.min(0xFFFFFF, math.floor(dec))))\nend\n\n-- https://github.com/NeogitOrg/neogit\n---@param name string\n---@return string|nil\nlocal function get_fg(name)\n  local color = api.nvim_get_hl(0, { name = name })\n  if color[\"link\"] then\n    return get_fg(color[\"link\"])\n  elseif color[\"reverse\"] and color[\"bg\"] then\n    return \"#\" .. to_hex(color[\"bg\"])\n  elseif color[\"fg\"] then\n    return \"#\" .. to_hex(color[\"fg\"])\n  end\nend\n\n-- https://github.com/NeogitOrg/neogit\n---@param name string\n---@return string|nil\nlocal function get_bg(name)\n  local color = api.nvim_get_hl(0, { name = name })\n  if color[\"link\"] then\n    return get_bg(color[\"link\"])\n  elseif color[\"reverse\"] and color[\"fg\"] then\n    return \"#\" .. to_hex(color[\"fg\"])\n  elseif color[\"bg\"] then\n    return \"#\" .. to_hex(color[\"bg\"])\n  end\nend\n\nlocal function build_palette()\n  -- stylua: ignore start\n  return {\n    black     = \"#000000\",\n    white     = \"#ffffff\",\n\n    bg        = get_bg(\"Normal\"),\n    blue      = get_fg(\"Directory\"),\n    cyan      = get_fg(\"Operator\"),\n    dark_grey = get_fg(\"WhiteSpace\"),\n    fg        = get_fg(\"Normal\"),\n    green     = get_fg(\"String\"),\n    grey      = get_fg(\"Comment\"),\n    orange    = get_fg(\"SpecialChar\"),\n    red       = get_fg(\"Error\"),\n    yellow    = get_fg(\"WarningMsg\"),\n  }\n  -- stylua: ignore end\nend\n\n---@param opts? FylerConfig\nfunction M.setup(opts)\n  opts = opts or {}\n\n  local palette = build_palette()\n\n  -- stylua: ignore start\n  local hl_groups = {\n    FylerConfirmGreen  = { fg = palette.green },\n    FylerConfirmGrey   = { fg = palette.grey },\n    FylerConfirmRed    = { fg = palette.red },\n    FylerConfirmYellow = { fg = palette.yellow },\n    FylerFSDirectory   = { fg = palette.blue },\n    FylerFSFile        = { fg = palette.white },\n    FylerFSLink        = { fg = palette.grey },\n    FylerGitAdded      = { fg = palette.green },\n    FylerGitConflict   = { fg = palette.red },\n    FylerGitDeleted    = { fg = palette.red },\n    FylerGitIgnored    = { fg = palette.red },\n    FylerGitModified   = { fg = palette.yellow },\n    FylerGitRenamed    = { fg = palette.yellow },\n    FylerGitStaged     = { fg = palette.green },\n    FylerGitUnstaged   = { fg = palette.orange },\n    FylerGitUntracked  = { fg = palette.cyan },\n    FylerIndentMarker  = { fg = palette.dark_grey },\n  }\n  -- stylua: ignore end\n\n  if opts.on_highlights then\n    opts.on_highlights(hl_groups, palette)\n  end\n\n  for key, val in pairs(hl_groups) do\n    api.nvim_set_hl(0, key, val)\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/struct.lua", "local a = require(\"fyler.lib.async\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal store = require(\"fyler.views.explorer.store\")\n\n---@class FylerFSItem\n---@field meta string\n---@field open boolean\n---@field children FylerFSItem[]\nlocal FSItem = {}\nFSItem.__index = FSItem\n\nlocal M = setmetatable({}, {\n  ---@param meta string\n  ---@return FylerFSItem\n  __call = function(_, meta)\n    local instance = {\n      meta = meta,\n      open = false,\n      children = {},\n    }\n\n    return setmetatable(instance, FSItem)\n  end,\n})\n\nfunction FSItem:toggle()\n  self.open = not self.open\nend\n\n---@param addr string\n---@param meta string\nfunction FSItem:add_child(addr, meta)\n  local target_node = self:find(addr)\n  if target_node then\n    table.insert(target_node.children, M(meta))\n  end\nend\n\n---@param addr string\n---@return FylerFSItem?\nfunction FSItem:find(addr)\n  if self.meta == addr then\n    return self\n  end\n\n  for _, child in ipairs(self.children) do\n    local found = child:find(addr)\n    if found then\n      return found\n    end\n  end\n\n  return nil\nend\n\nFSItem.update = a.async(function(self, cb)\n  if not self.open then\n    return cb()\n  end\n\n  local meta_data = store.get(self.meta)\n  local err, items = a.await(fs.ls, meta_data.path)\n  if err then\n    return cb()\n  end\n\n  self.children = vim\n    .iter(self.children)\n    :filter(function(child) ---@param child FylerFSItem\n      return vim.iter(items):any(function(item)\n        return item.path == store.get(child.meta).path and item.type == store.get(child.meta).type\n      end)\n    end)\n    :totable()\n\n  for _, item in ipairs(items) do\n    if\n      not vim.iter(self.children):any(function(child) ---@param child FylerFSItem\n        return store.get(child.meta).path == item.path and store.get(child.meta).type == item.type\n      end)\n    then\n      self:add_child(self.meta, store.set(item))\n    end\n  end\n\n  for _, child in ipairs(self.children) do\n    a.await(child.update, child)\n  end\n\n  return cb()\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/ui.lua", "local a = require(\"fyler.lib.async\")\nlocal components = require(\"fyler.lib.ui.components\")\nlocal config = require(\"fyler.config\")\nlocal git = require(\"fyler.lib.git\")\n\nlocal icon_provider = (function()\n  if type(config.values.icon_provider) == \"function\" then\n    return config.values.icon_provider\n  else\n    return require(\"fyler.integrations.icon\")[config.values.icon_provider]\n  end\nend)()\n\nlocal Line = components.Line\n\nlocal M = {}\n\n-- stylua: ignore start\nlocal git_status_hl = setmetatable({\n  [\"  \"] = \"FylerGitAdded\",\n  [\"UU\"] = \"FylerGitConflict\",\n  [\" D\"] = \"FylerGitDeleted\",\n  [\"!!\"] = \"FylerGitIgnored\",\n  [\" M\"] = \"FylerGitModified\",\n  [\"R \"] = \"FylerGitRenamed\",\n  [\"M \"] = \"FylerGitStaged\",\n  [\"??\"] = \"FylerGitUntracked\",\n  [\"MM\"] = \"FylerGitUnstaged\",\n}, {\n  __index = function()\n    return \"\"\n  end,\n})\n-- stylua: ignore end\n\nlocal function get_sorted(tbl)\n  table.sort(tbl, function(x, y)\n    if x:is_directory() and not y:is_directory() then\n      return true\n    elseif not x:is_directory() and y:is_directory() then\n      return false\n    else\n      return x.name < y.name\n    end\n  end)\n\n  return tbl\nend\n\nlocal TREE_STRUCTURE\n---@param tbl table\n---@param status_map? table\n---@param cb fun(lines: FylerUiLine[])\nTREE_STRUCTURE = a.async(function(tbl, status_map, depth, cb)\n  depth = depth or 0\n  if not tbl then\n    return cb {}\n  end\n\n  local lines = {}\n  for _, item in ipairs(get_sorted(tbl)) do\n    local icon, hl = (function()\n      if item.type == \"directory\" then\n        return icon_provider(item.type, item.name)\n      elseif item.type == \"link\" then\n        return icon_provider(item.link_type, item.name)\n      else\n        return icon_provider(item.type, item.name)\n      end\n    end)()\n\n    local git_symbol = (function()\n      if not status_map then\n        return nil\n      end\n\n      if status_map[item.path] then\n        return status_map[item.path]\n      end\n\n      return nil\n    end)()\n\n    table.insert(\n      lines,\n      Line {\n        words = {\n          { str = string.rep(\"  \", depth) },\n          {\n            str = icon,\n            hl = (function()\n              if item.type == \"directory\" then\n                return \"FylerFSDirectory\"\n              elseif item.link_type == \"directory\" then\n                return \"FylerFSDirectory\"\n              else\n                return hl\n              end\n            end)(),\n          },\n          {\n            str = git_symbol and string.format(\" %s \", git_symbol) or \" \",\n            hl = git_status_hl[git_symbol],\n          },\n          { str = string.format(\"/%s\", item.meta) },\n          {\n            str = string.format(\" %s\", item.name),\n            hl = (function()\n              if git_symbol then\n                return git_status_hl[git_symbol]\n              elseif item.type == \"directory\" then\n                return \"FylerFSDirectory\"\n              elseif item.link_type == \"directory\" then\n                return \"FylerFSDirectory\"\n              else\n                return \"\"\n              end\n            end)(),\n          },\n        },\n        marks = (function()\n          local line = {}\n          if item.type == \"link\" then\n            table.insert(line, {\n              hl = \"FylerFSLink\",\n              str = string.format(\" %s\", item.link_path),\n            })\n          end\n\n          return line\n        end)(),\n      }\n    )\n\n    if item.children then\n      for _, line in ipairs(a.await(TREE_STRUCTURE, item.children, status_map, depth + 1)) do\n        table.insert(lines, line)\n      end\n    end\n  end\n\n  return cb(lines)\nend)\n\nM.Explorer = a.async(function(tbl, cb)\n  return cb(a.await(TREE_STRUCTURE, tbl, config.values.git_status and a.await(git.status_map) or {}, 0))\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/fs.lua", "local List = require(\"fyler.lib.structs.list\")\nlocal Stack = require(\"fyler.lib.structs.stack\")\n\nlocal a = require(\"fyler.lib.async\")\n\nlocal M = {}\n\nlocal api = vim.api\n\nlocal uv = vim.uv or vim.loop\nlocal fn = vim.fn\n\n---@return string\nfunction M.getcwd()\n  return uv.cwd() or fn.getcwd(0)\nend\n\n---@param path string\n---@return string\nfunction M.normalize(path)\n  return vim.fs.normalize(path)\nend\n\n---@return string\nfunction M.joinpath(...)\n  return vim.fs.joinpath(...)\nend\n\n---@param path string\n---@return string\nfunction M.abspath(path)\n  return vim.fs.abspath(path)\nend\n\n---@param path string\nfunction M.relpath(base, path)\n  return vim.fs.relpath(base, path)\nend\n\n---@param path string\n---@return string?, string?\nfunction M.resolve_link(path)\n  local res_path = nil\n  local res_type = nil\n  while true do\n    local stat = uv.fs_stat(path)\n    if not stat then\n      break\n    end\n\n    local linkdata = uv.fs_readlink(path)\n    if not linkdata then\n      res_path = path\n      res_type = stat.type\n      break\n    end\n\n    path = linkdata\n  end\n\n  return res_path, res_type\nend\n\n---@param path string\n---@param cb fun(err?: string, items: table)\nM.ls = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, {})\n  end\n\n  ---@diagnostic disable-next-line: param-type-mismatch\n  local dir = uv.fs_opendir(path, nil, 1000)\n  local items = {}\n\n  while true do\n    local _, entries = a.await(uv.fs_readdir, dir)\n    if not entries then\n      break\n    end\n\n    items = vim.list_extend(\n      items,\n      vim\n        .iter(entries)\n        :map(function(entry)\n          local link_path, link_type = M.resolve_link(M.joinpath(path, entry.name))\n          return {\n            name = entry.name,\n            type = entry.type,\n            path = M.joinpath(path, entry.name),\n            link_path = link_path,\n            link_type = link_type,\n          }\n        end)\n        :totable()\n    )\n  end\n\n  return cb(nil, items)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.touch = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if stat then\n    return cb(stat_err, false)\n  end\n\n  local fd_err, fd = a.await(uv.fs_open, path, \"a\", 420)\n  if not fd then\n    return cb(fd_err, false)\n  end\n\n  return cb(a.await(uv.fs_close, fd))\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rm = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat or stat.type == \"directory\" then\n    return cb(stat_err, false)\n  end\n\n  local unlink_err, success = a.await(uv.fs_unlink, path)\n  if not success then\n    return cb(unlink_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rm_r = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, false)\n  end\n\n  local stk, lst = Stack(), List()\n\n  stk:push { path = path, type = stat.type }\n\n  while not stk:is_empty() do\n    local cur_entry = stk:pop()\n\n    lst:insert(1, cur_entry)\n\n    if cur_entry.type == \"directory\" then\n      local ls_err, entries = a.await(M.ls, cur_entry.path)\n      if ls_err then\n        return cb(ls_err, false)\n      end\n\n      for _, entry in ipairs(entries) do\n        stk:push(entry)\n      end\n    end\n  end\n\n  for _, entry in ipairs(lst:totable()) do\n    if entry.type == \"directory\" then\n      local rmdir_err, rmdir_success = a.await(M.rmdir, entry.path)\n      if not rmdir_success then\n        return cb(rmdir_err, false)\n      end\n    else\n      local rm_err, rm_success = a.await(M.rm, entry.path)\n      if not rm_success then\n        return cb(rm_err, false)\n      end\n    end\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.mkdir = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if stat and stat.type == \"directory\" then\n    return cb(stat_err, false)\n  end\n\n  local mkdir_err, success = a.await(uv.fs_mkdir, path, 493)\n  if not success then\n    return cb(mkdir_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.mkdir_p = a.async(function(path, cb)\n  local parts = vim\n    .iter(vim.split(path, \"/\"))\n    :filter(function(part)\n      return part ~= \"\"\n    end)\n    :totable()\n\n  local is_win = fn.has(\"win32\") == 1 or fn.has(\"win64\") == 1\n\n  local dir = is_win and parts[1] or \"\"\n\n  local start_idx = is_win and 2 or 1\n  for i = start_idx, #parts do\n    dir = dir .. string.format(\"/%s\", parts[i])\n\n    local _, stat = a.await(uv.fs_stat, dir)\n    if not stat then\n      local mkdir_err, mkdir_success = a.await(M.mkdir, dir)\n      if not mkdir_success then\n        return cb(mkdir_err, false)\n      end\n    end\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rmdir = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, false)\n  end\n\n  local rmdir_err, success = a.await(uv.fs_rmdir, path)\n  if not success then\n    return cb(rmdir_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param src_path string\n---@param dst_path string\n---@param cb fun(err?: string, success: boolean)\nM.mv = a.async(function(src_path, dst_path, cb)\n  local stat_err, src_stat = a.await(uv.fs_stat, src_path)\n  if not src_stat then\n    return cb(stat_err, false)\n  end\n\n  local _, dst_stat = a.await(uv.fs_stat, dst_path)\n  if dst_stat then\n    return cb(\"Destination path already exists\", false)\n  end\n\n  local rename_err, rename_success = a.await(uv.fs_rename, src_path, dst_path)\n  if not rename_success then\n    return cb(rename_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.create = a.async(function(path, cb)\n  local mkdirp_err, mkdirp_success =\n    a.await(M.mkdir_p, fn.fnamemodify(path, vim.endswith(path, \"/\") and \":h:h\" or \":h\"))\n  if not mkdirp_success then\n    return cb(mkdirp_err, false)\n  end\n\n  if vim.endswith(path, \"/\") then\n    local mkdir_err, mkdir_success = a.await(M.mkdir, path)\n    if not mkdir_success then\n      return cb(mkdir_err, false)\n    end\n  else\n    local touch_err, touch_success = a.await(M.touch, path)\n    if not touch_success then\n      return cb(touch_err, false)\n    end\n  end\n\n  return cb(nil, true)\nend)\n\nlocal function get_alt_buf(for_buf)\n  for _, buf in ipairs(api.nvim_list_bufs()) do\n    if api.nvim_buf_is_valid(buf) and buf ~= for_buf then\n      return buf\n    end\n  end\n\n  return api.nvim_create_buf(false, true)\nend\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.delete = a.async(function(path, cb)\n  local rm_r_err, rm_r_success = a.await(M.rm_r, path)\n  if not rm_r_success then\n    return cb(rm_r_err, false)\n  end\n\n  local buf = fn.bufnr(path)\n  if buf == -1 then\n    return cb(\"Unable to find buffer to delete\", true)\n  end\n\n  local alt = get_alt_buf(buf)\n  for _, win in ipairs(api.nvim_list_wins()) do\n    if api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) == buf then\n      if alt < 1 or alt == buf then\n        alt = api.nvim_create_buf(true, false)\n      end\n\n      api.nvim_win_set_buf(win, alt)\n    end\n  end\n\n  local success, msg = pcall(api.nvim_buf_delete, buf, { force = true })\n  if not success then\n    return cb(msg, true)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param src_path string\n---@param dst_path string\n---@param cb fun(err?: string, success: boolean)\nM.move = a.async(function(src_path, dst_path, cb)\n  local mkdirp_err, mkdirp_success = a.await(M.mkdir_p, fn.fnamemodify(dst_path, \":h\"))\n  if not mkdirp_success then\n    return cb(mkdirp_err, false)\n  end\n\n  local mv_err, mv_success = a.await(M.mv, src_path, dst_path)\n  if not mv_success then\n    return cb(mv_err, false)\n  end\n\n  local src_buf = fn.bufnr(src_path)\n  if src_buf == -1 then\n    return cb(\"unable to find moved buffer\", true)\n  end\n\n  local dst_buf = fn.bufadd(dst_path)\n  fn.bufload(dst_buf)\n  vim.bo[dst_buf].buflisted = true\n\n  for _, win in ipairs(api.nvim_list_wins()) do\n    if api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) == src_buf then\n      api.nvim_win_set_buf(win, dst_buf)\n    end\n  end\n\n  local success, msg = pcall(api.nvim_buf_delete, src_buf, { force = true })\n  if not success then\n    return cb(msg, true)\n  end\n\n  return cb(nil, true)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/ui/components.lua", "---@alias FylerUiLineAlign\n---| \"end\"\n---| \"start\"\n---| \"center\"\n\n---@alias FylerUiWord { str: string, hl?: string }\n---@alias FylerUiMark { str: string, hl?: string, id: string }\n\n---@class FylerUiLine\n---@field align FylerUiLineAlign\n---@field words FylerUiWord[]\n---@field marks FylerUiMark[]\nlocal Line = {}\nLine.__index = Line\n\nreturn {\n  Line = setmetatable({}, {\n    ---@param opts { words: FylerUiWord[], marks: FylerUiMark[], align?: FylerUiLineAlign }\n    ---@return FylerUiLine\n    __call = function(_, opts)\n      local instance = {\n        words = opts.words or {},\n        align = opts.align or \"start\",\n        marks = opts.marks or {},\n      }\n\n      setmetatable(instance, Line)\n\n      return instance\n    end,\n  }),\n}\n"], ["/fyler.nvim/plugin/fyler.lua", "vim.api.nvim_create_user_command(\"Fyler\", function(args)\n  local opts = {}\n  for _, farg in ipairs(args.fargs) do\n    local key, value = unpack(vim.split(farg, \"=\"))\n    opts[key] = value\n  end\n\n  require(\"fyler\").open(opts)\nend, {\n  nargs = \"*\",\n  complete = function(arglead, cmdline)\n    if arglead:find(\"^kind=\") then\n      return {\n        \"kind=float\",\n        \"kind=split:left\",\n        \"kind=split:above\",\n        \"kind=split:right\",\n        \"kind=split:below\",\n        \"kind=split:leftmost\",\n        \"kind=split:abovemost\",\n        \"kind=split:rightmost\",\n        \"kind=split:belowmost\",\n      }\n    end\n\n    if arglead:find(\"^cwd=\") then\n      return {\n        \"cwd=\" .. (vim.uv or vim.loop).cwd(),\n      }\n    end\n\n    return vim.tbl_filter(function(arg)\n      return cmdline:match(arg) == nil\n    end, {\n      \"kind=\",\n      \"cwd=\",\n    })\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/git.lua", "local a = require(\"fyler.lib.async\")\nlocal fs = require(\"fyler.lib.fs\")\n\nlocal M = {}\n\n---@param cb fun(result: boolean)\nlocal is_git_repo = a.async(function(cb)\n  local out = a.await(vim.system, { \"git\", \"rev-parse\", \"--is-inside-work-tree\" }, nil) ---@type vim.SystemCompleted\n  return cb(string.match(out.stdout, \"^(.*)\\n$\") == \"true\")\nend)\n\n---@param cb fun(status?: string)\nlocal git_status = a.async(function(cb)\n  if not a.await(is_git_repo) then\n    return cb(nil)\n  end\n\n  local out = a.await(vim.system, { \"git\", \"status\", \"--porcelain\", \"-z\" }, nil) ---@type vim.SystemCompleted\n  if not out.stdout then\n    return cb(nil)\n  end\n\n  return cb(out.stdout)\nend)\n\n---@param cb fun(path?: string)\nlocal git_toplevel = a.async(function(cb)\n  local out = a.await(vim.system, { \"git\", \"rev-parse\", \"--show-toplevel\" }, nil) ---@type vim.SystemCompleted\n  if not out.stdout then\n    return cb(nil)\n  end\n\n  return cb(string.match(out.stdout, \"^(.*)\\n$\"))\nend)\n\n---@param cb fun(status_map?: table)\nM.status_map = a.async(function(cb)\n  local status_str = a.await(git_status)\n  if not status_str then\n    return cb(nil)\n  end\n\n  local statuses = vim\n    .iter(vim.split(status_str, \"\\0\"))\n    :filter(function(status)\n      if status == \"\" then\n        return false\n      end\n\n      return true\n    end)\n    :totable()\n\n  local toplevel = a.await(git_toplevel)\n  if not toplevel then\n    return cb(nil)\n  end\n\n  local status_map = {}\n  for _, status in ipairs(statuses) do\n    local symbol, path = (function()\n      if string.match(status, \"^.*%s.*$\") then\n        return string.match(status, \"^(.*)%s(.*)$\")\n      else\n        return nil, status\n      end\n    end)()\n\n    status_map[fs.joinpath(toplevel, fs.normalize(path))] = symbol\n  end\n\n  return cb(status_map)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/structs/list.lua", "---@class FylerLinkedList\n---@field node FylerLinkedListNode\nlocal LinkedList = {}\nLinkedList.__index = LinkedList\n\n---@class FylerLinkedListNode\n---@field next? FylerLinkedListNode\n---@field data  any\nlocal LinkedListNode = {}\nLinkedListNode.__index = LinkedListNode\n\n---@return integer\nfunction LinkedList:len()\n  local count = 0\n  local current = self.node\n  while current do\n    count = count + 1\n    current = current.next\n  end\n\n  return count\nend\n\n---@param fn fun(node: FylerLinkedListNode)\nfunction LinkedList:each(fn)\n  local start = self.node\n  while start do\n    fn(start.data)\n    start = start.next\n  end\nend\n\n---@param pos integer\n---@param data any\nfunction LinkedList:insert(pos, data)\n  local newNode = setmetatable({ data = data }, LinkedListNode)\n  if pos == 1 then\n    newNode.next = self.node\n    self.node = newNode\n    return\n  end\n\n  local start = self.node\n  for _ = 1, pos - 2 do\n    if not start then\n      error(\"position is out of bound\")\n    end\n    start = start.next\n  end\n\n  if not start then\n    error(\"position is out of bound\")\n  end\n\n  newNode.next = start.next\n  start.next = newNode\nend\n\n---@param pos integer\nfunction LinkedList:erase(pos)\n  assert(pos >= 1, \"position must be 1 or greater\")\n\n  if not self.node then\n    error(\"list is empty\")\n  end\n\n  if pos == 1 then\n    self.node = self.node.next\n    return\n  end\n\n  local start = self.node\n  for _ = 1, pos - 2 do\n    if not start or not start.next then\n      error(\"position is out of bound\")\n    end\n\n    start = start.next\n  end\n\n  if not start or not start.next then\n    error(\"position is out of bound\")\n  end\n\n  start.next = start.next.next\nend\n\n---@return table\nfunction LinkedList:totable()\n  local tbl = {}\n  self:each(function(item)\n    table.insert(tbl, item)\n  end)\n\n  return tbl\nend\n\nreturn setmetatable({}, {\n  ---@return FylerLinkedList\n  __call = function()\n    return setmetatable({}, LinkedList)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/structs/queue.lua", "local List = require(\"fyler.lib.structs.list\")\n\n---@class FylerQueue\n---@field items FylerLinkedList\nlocal Queue = {}\nQueue.__index = Queue\n\n---@param data any\nfunction Queue:enqueue(data)\n  self.items:insert(self.items:len() + 1, data)\nend\n\n---@return any\nfunction Queue:dequeue()\n  assert(not self:is_empty(), \"Queue is empty\")\n\n  local data = self.items.node.data\n  self.items:erase(1)\n  return data\nend\n\n---@return any\nfunction Queue:front()\n  assert(self.items.node, \"Queue is empty\")\n  return self.items.node.data\nend\n\n---@return boolean\nfunction Queue:is_empty()\n  return self.items:len() == 0\nend\n\nreturn setmetatable({}, {\n  ---@return FylerQueue\n  __call = function()\n    return setmetatable({ items = List() }, Queue)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/structs/stack.lua", "local List = require(\"fyler.lib.structs.list\")\n\n---@class FylerStack\n---@field items FylerLinkedList\nlocal Stack = {}\nStack.__index = Stack\n\n---@param data any\nfunction Stack:push(data)\n  self.items:insert(1, data)\nend\n\nfunction Stack:pop()\n  assert(not self:is_empty(), \"stack is empty\")\n\n  local data = self.items.node.data\n  self.items:erase(1)\n  return data\nend\n\n---@return any\nfunction Stack:top()\n  assert(self.items.node, \"stack is empty\")\n  return self.items.node.data\nend\n\n---@return boolean\nfunction Stack:is_empty()\n  return self.items:len() == 0\nend\n\nreturn setmetatable({}, {\n  ---@return FylerStack\n  __call = function()\n    return setmetatable({ items = List() }, Stack)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/async.lua", "local M = {}\n\nlocal queue = require(\"fyler.lib.structs.queue\")() ---@type FylerQueue\nlocal is_loop_running = false\n\n---@param co thread\n---@param ... any\nlocal function schedule(co, ...)\n  queue:enqueue {\n    args = { ... },\n    co = co,\n    started = false,\n  }\n\n  if is_loop_running then\n    return\n  end\n\n  is_loop_running = true\n\n  local function loop()\n    if queue:is_empty() then\n      is_loop_running = false\n      return\n    end\n\n    local front = queue:front()\n    local status = coroutine.status(front.co)\n\n    if status == \"dead\" then\n      queue:dequeue()\n\n      vim.defer_fn(loop, 0)\n    elseif status == \"suspended\" and front.started == false then\n      local success = coroutine.resume(front.co, unpack(front.args))\n      if not success then\n        queue:dequeue()\n      end\n\n      front.started = true\n\n      vim.defer_fn(loop, 0)\n    else\n      vim.defer_fn(loop, 10)\n    end\n  end\n\n  vim.defer_fn(loop, 0)\nend\n\nfunction M.schedule_async(async_fn)\n  return function(...)\n    schedule(coroutine.create(async_fn), ...)\n  end\nend\n\nfunction M.async(async_fn)\n  return function(...)\n    local ok, err = coroutine.resume(coroutine.create(async_fn), ...)\n    if not ok then\n      error(err)\n    end\n  end\nend\n\nfunction M.await(fn, ...)\n  local thread = coroutine.running()\n  local args = { ... }\n\n  table.insert(\n    args,\n    vim.schedule_wrap(function(...)\n      if not thread then\n        return error(\"no coroutine is running\")\n      end\n\n      coroutine.resume(thread, ...)\n    end)\n  )\n\n  fn(unpack(args))\n\n  return coroutine.yield()\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/store.lua", "local M = {}\n\nlocal count = 0\nlocal store = {}\n\nlocal Metadata = {}\nMetadata.__index = Metadata\n\nfunction Metadata:is_directory()\n  return self.type == \"directory\" or (self.type == \"link\" and self.link_type == \"directory\")\nend\n\nfunction Metadata:resolved_path()\n  return self.type == \"link\" and self.link_path or self.path\nend\n\n---@param key string\nfunction M.get(key)\n  return setmetatable(vim.deepcopy(store[key]), Metadata)\nend\n\n---@param tbl table\n---@return string\nfunction M.set(tbl)\n  count = count + 1\n  local meta = string.format(\"%05d\", count)\n  store[meta] = tbl\n  return meta\nend\n\nfunction M.debug()\n  for k, v in pairs(store) do\n    print(k, vim.inspect(v))\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/integrations/icon/init.lua", "---@param type string\n---@param _ string\n---@return string?, string?\nlocal function default_icon_provider(type, _)\n  if type == \"directory\" then\n    return \"D\", \"FylerFSDirectory\"\n  elseif type == \"file\" then\n    return \"F\", \"FylerFSFile\"\n  else\n    return \"*\", \"\"\n  end\nend\n\nreturn setmetatable({}, {\n  __index = function(_, key)\n    local status, icon_provider = pcall(require, string.format(\"fyler.integrations.icon.%s\", key))\n    if not status then\n      return default_icon_provider\n    end\n\n    return function(...)\n      local success, icon, hl = pcall(icon_provider.get_icon, ...)\n      if not success then\n        return default_icon_provider(...)\n      end\n\n      return icon, hl\n    end\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/integrations/icon/nvim-web-devicons.lua", "local M = {}\n\nlocal fn = vim.fn\n\n---@param type string\n---@param name string\n---@return string?, string?\nfunction M.get_icon(type, name)\n  local success, devicons = pcall(require, \"nvim-web-devicons\")\n  if not success then\n    return nil, nil\n  end\n\n  local icon, hl = devicons.get_icon(name, fn.fnamemodify(name, \":e\"))\n  icon = (type == \"directory\" and \"\" or (icon or \"\"))\n  hl = hl or (type == \"directory\" and \"Fylerblue\" or \"\")\n  return icon, hl\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/actions.lua", "local M = {}\n\n---@param view table\nfunction M.n_close_view(view, cb)\n  return function()\n    cb(false)\n    view:close()\n  end\nend\n\nfunction M.n_confirm(view, cb)\n  return function()\n    cb(true)\n    view:close()\n  end\nend\n\nfunction M.n_discard(view, cb)\n  return function()\n    cb(false)\n    view:close()\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/ui.lua", "local components = require(\"fyler.lib.ui.components\")\n\nlocal Line = components.Line\n\nlocal function MESSAGE(tbl)\n  local lines = {}\n  for _, line in ipairs(tbl or {}) do\n    table.insert(lines, Line { words = line })\n  end\n\n  return lines\nend\n\nlocal M = {}\n\n---@param tbl table\nfunction M.Confirm(tbl)\n  if not tbl then\n    return {}\n  end\n\n  return MESSAGE(tbl)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/regex.lua", "local M = {}\n\n---@param str string\n---@return string\nfunction M.match_meta(str)\n  assert(str, \"str is required\")\n  return str:match(\" /(%d%d%d%d%d)\")\nend\n\n---@param str string\n---@return string\nfunction M.match_indent(str)\n  assert(str, \"str is required\")\n  return str:match(\"^(%s*)\")\nend\n\n---@param str string\n---@return string\nfunction M.match_name(str)\n  assert(str, \"str is required\")\n  if str:match(\"/%d%d%d%d%d\") then\n    return str:match(\"/%d%d%d%d%d (.*)$\")\n  else\n    return str:gsub(\"^%s*\", \"\"):match(\".*\")\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/integrations/icon/mini-icons.lua", "local M = {}\n\n---@param type string\n---@param name string\n---@return string?, string?\nfunction M.get_icon(type, name)\n  local success, miniicons = pcall(require, \"mini.icons\")\n  if not success then\n    return nil, nil\n  end\n\n  return miniicons.get(type, name)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/cache.lua", "local M = {}\n\nlocal cache_table = {}\n\n---@param entry_key string\n---@param val any\nfunction M.set_entry(entry_key, val)\n  cache_table[entry_key] = val\nend\n\n---@param entry_key string\n---@return any\nfunction M.get_entry(entry_key)\n  return vim.deepcopy(cache_table[entry_key])\nend\n\nreturn M\n"], ["/fyler.nvim/syntax/fyler.lua", "if vim.b.current_syntax then\n  return\nend\n\nvim.cmd([[\n  syntax match FylerMetaKey /\\/\\d\\d\\d\\d\\d / conceal\n]])\n\nvim.b.current_syntax = \"fyler\"\n"]], "task_instance_info": {"created_time": "2025-08-21 00:45:12", "created_task_model": "DeepSeek-R1", "code_description": "This code segment functions to: Initialize a new instance of a component that manages directory-based content by setting up a root structure, configuring instance properties, and establishing inheritance for method access."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```lua\n[TASK_BEGIN]\nfunction ExplorerView.new(opts)\n  opts = opts or {}\n  local self = setmetatable({}, ExplorerView)\n  self.cwd = opts.cwd or fs.getcwd()\n  self.fs_root = FSItem.new(self.cwd)\n  self.win = nil\n  return self\nend\n[TASK_END]\n```", "inference_time": "2025-08-21 00-45-24"}, "editdistance_info": {"edit_distance": 24.4444, "calculate_time": "2025-08-21 00:45:24", "true_code_clean": "function ExplorerView.new(opts)\n  local fs_root = FSItem(store.set {\n    name = fn.fnamemodify(opts.cwd, \":t\"),\n    type = \"directory\",\n    path = opts.cwd,\n  })\n  fs_root:toggle()\n  local instance = {\n    cwd = opts.cwd,\n    fs_root = fs_root,\n    kind = opts.kind,\n  }\n  setmetatable(instance, ExplorerView)\n  return instance\nend", "predict_code_clean": "function ExplorerView.new(opts)\n  opts = opts or {}\n  local self = setmetatable({}, ExplorerView)\n  self.cwd = opts.cwd or fs.getcwd()\n  self.fs_root = FSItem.new(self.cwd)\n  self.win = nil\n  return self\nend"}}
{"repo_name": "fyler.nvim", "file_name": "/fyler.nvim/lua/fyler/config.lua", "inference_info": {"prefix_code": "---@class FylerConfigView\n---@field width  number\n---@field height number\n---@field kind   FylerWinKind\n---@field border string|string[]\n\n---@class FylerConfig\n---@field auto_confirm_simple_edits? boolean\n---@field close_on_select?           boolean\n---@field default_explorer?          boolean\n---@field git_status                 boolean\n---@field icon_provider?             string|fun(type: string, name: string): string, string\n---@field indentscope                { enabled: boolean, group: string, marker: string }\n---@field on_highlights              fun(hl_groups: table, palette: table): nil\n---@field views?                     table<string, FylerConfigView>\n---@field mappings?                  table<string, table<\"n\"|\"i\", table<string, string>>>\n\nlocal M = {}\n\nlocal defaults = {\n  auto_confirm_simple_edits = false,\n  close_on_select = true,\n  default_explorer = false,\n  git_status = true,\n  icon_provider = \"mini-icons\",\n  on_highlights = nil,\n  indentscope = {\n    enabled = true,\n    group = \"FylerIndentMarker\",\n    marker = \"\",\n  },\n  mappings = {\n    confirm = {\n      n = {\n        [\"y\"] = \"Confirm\",\n        [\"n\"] = \"Discard\",\n      },\n    },\n    explorer = {\n      n = {\n        [\"q\"] = \"CloseView\",\n        [\"<CR>\"] = \"Select\",\n      },\n    },\n  },\n  views = {\n    confirm = {\n      width = 0.5,\n      height = 0.4,\n      kind = \"float\",\n      border = \"single\",\n      buf_opts = {\n        buflisted = false,\n        modifiable = false,\n      },\n      win_opts = {\n        winhighlight = \"Normal:Normal,FloatBorder:FloatBorder,FloatTitle:FloatTitle\",\n        wrap = false,\n      },\n    },\n    explorer = {\n      width = 0.8,\n      height = 0.8,\n      kind = \"float\",\n      border = \"single\",\n      buf_opts = {\n        buflisted = false,\n        buftype = \"acwrite\",\n        filetype = \"fyler\",\n        syntax = \"fyler\",\n      },\n      win_opts = {\n        concealcursor = \"nvic\",\n        conceallevel = 3,\n        cursorline = true,\n        number = true,\n        relativenumber = true,\n        winhighlight = \"Normal:Normal,FloatBorder:FloatBorder,FloatTitle:FloatTitle\",\n        wrap = false,\n      },\n    },\n  },\n}\n\n---@param name string\nfunction M.get_view(name)\n  assert(name, \"name is required\")\n\n  return M.values.views[name]\nend\n\n---@param name string\nfunction M.get_mappings(name)\n  assert(name, \"name is required\")\n\n  return M.values.mappings[name]\nend\n\n---@param name string\n", "suffix_code": "\n\n---@param opts? FylerConfig\nfunction M.setup(opts)\n  opts = opts or {}\n  M.values = vim.tbl_deep_extend(\"force\", defaults, opts)\nend\n\nreturn M\n", "middle_code": "function M.get_reverse_mappings(name)\n  assert(name, \"name is required\")\n  local mappings = M.get_mappings(name)\n  local reverse_mappings = {}\n  for _, map in pairs(mappings) do\n    for key, val in pairs(map) do\n      reverse_mappings[val] = key\n    end\n  end\n  return reverse_mappings\nend", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "lua", "sub_task_type": null}, "context_code": [["/fyler.nvim/lua/fyler/views/explorer/init.lua", "local FSItem = require(\"fyler.views.explorer.struct\")\nlocal Win = require(\"fyler.lib.win\")\nlocal a = require(\"fyler.lib.async\")\nlocal config = require(\"fyler.config\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal store = require(\"fyler.views.explorer.store\")\n\nlocal fn = vim.fn\nlocal api = vim.api\n\n---@class FylerExplorerView\n---@field cwd     string      - Directory path which act as a root\n---@field fs_root FylerFSItem - Root |FylerFSItem| instance\n---@field win     FylerWin    - Window instance\nlocal ExplorerView = {}\nExplorerView.__index = ExplorerView\n\nfunction ExplorerView.new(opts)\n  local fs_root = FSItem(store.set {\n    name = fn.fnamemodify(opts.cwd, \":t\"),\n    type = \"directory\",\n    path = opts.cwd,\n  })\n\n  fs_root:toggle()\n\n  local instance = {\n    cwd = opts.cwd,\n    fs_root = fs_root,\n    kind = opts.kind,\n  }\n\n  setmetatable(instance, ExplorerView)\n\n  return instance\nend\n\nExplorerView.open = a.async(function(self, opts)\n  local mappings = config.get_reverse_mappings(\"explorer\")\n  local view = config.get_view(\"explorer\")\n\n  -- stylua: ignore start\n  self.win = Win {\n    border   = view.border,\n    buf_opts = view.buf_opts,\n    bufname  = string.format(\"fyler://%s\", self.cwd),\n    enter    = opts.enter,\n    height   = view.height,\n    kind     = opts.kind or view.kind,\n    name     = \"explorer\",\n    width    = view.width,\n    win_opts = view.win_opts,\n    mappings = {\n      n = {\n        [mappings[\"Select\"]]    = self:_action(\"n_select\"),\n        [mappings[\"CloseView\"]] = self:_action(\"n_close_view\"),\n      },\n    },\n    autocmds = {\n      [\"BufReadCmd\"]   = self:_action(\"refreshview\"),\n      [\"BufWriteCmd\"]  = self:_action(\"synchronize\"),\n      [\"CursorMoved\"]  = self:_action(\"constrain_cursor\"),\n      [\"CursorMovedI\"] = self:_action(\"constrain_cursor\"),\n      [\"WinClosed\"]    = self:_action(\"n_close_view\"),\n    },\n    user_autocmds = {\n      [\"RefreshView\"] = self:_action(\"refreshview\"),\n      [\"Synchronize\"] = self:_action(\"synchronize\"),\n    },\n    render = self:_action(\"refreshview\"),\n  }\n  -- stylua: ignore end\n\n  require(\"fyler.cache\").set_entry(\"recent_win\", api.nvim_get_current_win())\n\n  self.win:show()\nend)\n\n---@param ... any\nfunction ExplorerView:_action(name, ...)\n  local action = require(\"fyler.views.explorer.actions\")[name]\n\n  assert(action, string.format(\"%s action is not available\", name))\n\n  return action(self, ...)\nend\n\nlocal M = {\n  instance = nil, ---@type FylerExplorerView\n}\n\n---@param opts { cwd?: string, kind?: FylerWinKind }\n---@return FylerExplorerView\nfunction M.get_instance(opts)\n  if (not M.instance) or (M.instance.cwd ~= opts.cwd) then\n    M.instance = ExplorerView.new {\n      cwd = opts.cwd,\n      kind = opts.kind,\n    }\n  end\n\n  return M.instance\nend\n\n---@param opts? { enter?: boolean, cwd?: string, kind?: FylerWinKind }\nfunction M.open(opts)\n  opts = opts or {}\n  opts.enter = opts.enter == nil and true or opts.enter\n  opts.cwd = opts.cwd or fs.getcwd()\n  opts.kind = opts.kind or config.get_view(\"explorer\").kind\n\n  if M.instance and fn.winbufnr(M.instance.win.winid) == M.instance.win.bufnr then\n    M.instance.win:hide()\n  end\n\n  M.get_instance(opts):open(opts)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/init.lua", "local Win = require(\"fyler.lib.win\")\nlocal config = require(\"fyler.config\")\nlocal ui = require(\"fyler.views.confirm.ui\")\n\n---@class FylerConfirmView\n---@field win FylerWin\nlocal FylerConfirmView = {}\nFylerConfirmView.__index = FylerConfirmView\n\n---@param msg { str: string, hl: string }[]\n---@param chs string\n---@param cb fun(c: boolean)\nfunction FylerConfirmView:open(msg, chs, cb)\n  local mappings = config.get_reverse_mappings(\"confirm\")\n  local view = config.get_view(\"confirm\")\n\n  --stylua: ignore start\n  self.win = Win {\n    border   = view.border,\n    buf_opts = view.buf_opts,\n    bufname  = \"confirm\",\n    enter    = true,\n    height   = view.height,\n    kind     = view.kind,\n    name     = \"confirm\",\n    title    = string.format(\" Confirm %s \", chs),\n    width    = view.width,\n    win_opts = view.win_opts,\n    mappings = {\n      n = {\n        [mappings[\"Confirm\"]] = self:_action(\"n_confirm\", cb),\n        [mappings[\"Discard\"]] = self:_action(\"n_discard\", cb),\n      },\n    },\n    autocmds = {\n      [\"QuitPre\"] = self:_action(\"n_close_view\", cb),\n    },\n    render = function()\n      self.win.ui:render({ ui_lines = ui.Confirm(msg) })\n    end,\n  }\n  --stylua: ignore end\n\n  self.win:show()\nend\n\nfunction FylerConfirmView:close()\n  self.win:hide()\nend\n\n---@param name string\nfunction FylerConfirmView:_action(name, ...)\n  local action = require(\"fyler.views.confirm.actions\")[name]\n\n  assert(action, string.format(\"%s action is not available\", name))\n\n  return action(self, ...)\nend\n\nlocal M = {}\n\n---@param msg { str: string, hl: string }[]\n---@param chs string\n---@param cb fun(c: boolean)\nM.open = vim.schedule_wrap(function(msg, chs, cb)\n  if not M.instance then\n    M.instance = setmetatable({}, FylerConfirmView)\n  end\n\n  if M.instance.win and M.instance.win:has_valid_winid() then\n    M.instance:close()\n  end\n\n  M.instance:open(msg, chs, cb)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/win.lua", "local Ui = require(\"fyler.lib.ui\")\n\nlocal api = vim.api\n\n---@alias FylerWinKind\n---| \"float\"\n---| \"split:left\"\n---| \"split:above\"\n---| \"split:right\"\n---| \"split:below\"\n---| \"split:leftmost\"\n---| \"split:abovemost\"\n---| \"split:rightmost\"\n---| \"split:belowmost\"\n\n---@class FylerWin\n---@field augroup       string          - Autogroup associated with window instance\n---@field autocmds      table           - Autocommands locally associated with window instance\n---@field border        string|string[] - Border format - read ':winborder' for more info\n---@field bufname       string          - Builtin way to name neovim buffers\n---@field bufnr?        integer         - Buffer number associated with window instance\n---@field buf_opts      table           - Buffer local options\n---@field enter         boolean         - whether to enter in the window on open\n---@field footer?       any             - Footer content\n---@field footer_pos?   string          - Footer alignment\n---@field height        number          - Height of window\n---@field kind          FylerWinKind    - Decides launch behaviour of window instance\n---@field mappings      table           - Kemaps local to the window instance\n---@field name          string          - Also know as `view_name` which helps to get specific config from user end\n---@field namespace     integer         - Namespace associated with window instance\n---@field render?       function        - Defines what to render on the screen on open\n---@field title?        any             - Title content\n---@field title_pos?    string          - Title alignment\n---@field ui            FylerUi         - Ui responsible to render lines return from corresponding render function\n---@field user_autocmds table           - User autocommands associated with window instance\n---@field width         number          - Width of window\n---@field winid?        integer         - Window id associated with window instance\n---@field win_opts      table           - Window local options\nlocal Win = {}\nWin.__index = Win\n\n-- Prepares namespace ID by attaching buffer's given name\n---@param name string\nlocal function get_namespace(name)\n  return api.nvim_create_namespace(\"Fyler\" .. name)\nend\n\n-- Prepares autogroup ID by attaching buffer's given name\n---@param name string\nlocal function get_augroup(name)\n  return api.nvim_create_augroup(\"Fyler\" .. name, { clear = true })\nend\n\nlocal M = setmetatable({}, {\n  ---@return FylerWin\n  __call = function(_, opts)\n    opts = opts or {}\n\n    assert(opts.name, \"name is required field\")\n    assert(opts.bufname, \"bufname is required field\")\n\n    -- stylua: ignore start\n    local instance = {\n      augroup       = get_augroup(opts.name),\n      autocmds      = opts.autocmds or {},\n      border        = opts.border,\n      bufname       = opts.bufname,\n      buf_opts      = opts.buf_opts or {},\n      enter         = opts.enter,\n      footer        = opts.footer,\n      footer_pos    = opts.footer_pos,\n      height        = opts.height,\n      kind          = opts.kind or \"float\",\n      mappings      = opts.mappings or {},\n      name          = opts.name or \"\",\n      namespace     = get_namespace(opts.name),\n      render        = opts.render,\n      title         = opts.title,\n      title_pos     = opts.title_pos,\n      user_autocmds = opts.user_autocmds or {},\n      width         = opts.width,\n      win_opts      = opts.win_opts or {},\n    }\n    -- stylua: ignore end\n\n    instance.ui = Ui(instance)\n    setmetatable(instance, Win)\n\n    return instance\n  end,\n})\n\n-- Determine whether the `Win` has valid buffer\n---@return boolean\nfunction Win:has_valid_bufnr()\n  return type(self.bufnr) == \"number\" and api.nvim_buf_is_valid(self.bufnr)\nend\n\n-- Determine whether the `Win` has valid window\n---@return boolean\nfunction Win:has_valid_winid()\n  return type(self.winid) == \"number\" and api.nvim_win_is_valid(self.winid)\nend\n\n---@return boolean\nfunction Win:is_visible()\n  return self:has_valid_bufnr() and self:has_valid_winid()\nend\n\n-- Construct respective window config in vim understandable format\n---@return vim.api.keyset.win_config\nfunction Win:config()\n  local winconfig = {\n    style = \"minimal\",\n    noautocmd = true,\n    title = self.title,\n    title_pos = self.title_pos,\n    footer = self.footer,\n    footer_pos = self.footer_pos,\n  }\n\n  if self.kind:match(\"^split:\") then\n    winconfig.split = self.kind:match(\"^split:(.*)\")\n    winconfig.title = nil\n    winconfig.title_pos = nil\n    winconfig.footer = nil\n    winconfig.footer_pos = nil\n  end\n\n  if self.kind == \"float\" then\n    winconfig.relative = \"editor\"\n    winconfig.border = self.border\n    winconfig.col = math.floor((1 - self.width) * 0.5 * vim.o.columns)\n    winconfig.row = math.floor((1 - self.height) * 0.5 * vim.o.lines)\n  end\n\n  winconfig.width = math.ceil(self.width * vim.o.columns)\n  winconfig.height = math.ceil(self.height * vim.o.lines)\n\n  return winconfig\nend\n\nfunction Win:show()\n  if self:has_valid_winid() then\n    return\n  end\n\n  local recent_win = api.nvim_get_current_win()\n  local win_config = self:config()\n\n  self.bufnr = api.nvim_create_buf(false, true)\n  if self.render then\n    self.render()\n  end\n\n  api.nvim_buf_set_name(self.bufnr, self.bufname)\n\n  if win_config.split and win_config.split:match(\"^%w+most$\") then\n    if win_config.split == \"leftmost\" then\n      api.nvim_command(string.format(\"topleft %dvsplit\", win_config.width))\n    elseif win_config.split == \"abovemost\" then\n      api.nvim_command(string.format(\"topleft %dsplit\", win_config.height))\n    elseif win_config.split == \"rightmost\" then\n      api.nvim_command(string.format(\"botright %dvsplit\", win_config.width))\n    elseif win_config.split == \"belowmost\" then\n      api.nvim_command(string.format(\"botright %dsplit\", win_config.height))\n    else\n      error(string.format(\"Invalid window kind `%s`\", win_config.split))\n    end\n\n    self.winid = api.nvim_get_current_win()\n\n    if not self.enter then\n      api.nvim_set_current_win(recent_win)\n    end\n\n    api.nvim_win_set_buf(self.winid, self.bufnr)\n  else\n    self.winid = api.nvim_open_win(self.bufnr, self.enter, win_config)\n  end\n\n  api.nvim_exec_autocmds(\"BufEnter\", {})\n\n  for mode, map in pairs(self.mappings) do\n    for key, val in pairs(map) do\n      vim.keymap.set(mode, key, val, { buffer = self.bufnr, silent = true, noremap = true })\n    end\n  end\n\n  for option, value in pairs(self.win_opts) do\n    vim.w[self.winid][option] = vim.wo[self.winid][option]\n    vim.wo[self.winid][option] = value\n  end\n\n  for option, value in pairs(self.buf_opts) do\n    vim.bo[self.bufnr][option] = value\n  end\n\n  for event, callback in pairs(self.autocmds) do\n    api.nvim_create_autocmd(event, {\n      group = self.augroup,\n      buffer = self.bufnr,\n      callback = callback,\n    })\n  end\n\n  for event, callback in pairs(self.user_autocmds) do\n    api.nvim_create_autocmd(\"User\", {\n      pattern = event,\n      group = self.augroup,\n      callback = callback,\n    })\n  end\nend\n\nfunction Win:hide()\n  if self:has_valid_winid() then\n    api.nvim_win_close(self.winid, true)\n  end\n\n  if self:has_valid_bufnr() then\n    api.nvim_buf_delete(self.bufnr, { force = true })\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/ui.lua", "local a = require(\"fyler.lib.async\")\nlocal components = require(\"fyler.lib.ui.components\")\nlocal config = require(\"fyler.config\")\nlocal git = require(\"fyler.lib.git\")\n\nlocal icon_provider = (function()\n  if type(config.values.icon_provider) == \"function\" then\n    return config.values.icon_provider\n  else\n    return require(\"fyler.integrations.icon\")[config.values.icon_provider]\n  end\nend)()\n\nlocal Line = components.Line\n\nlocal M = {}\n\n-- stylua: ignore start\nlocal git_status_hl = setmetatable({\n  [\"  \"] = \"FylerGitAdded\",\n  [\"UU\"] = \"FylerGitConflict\",\n  [\" D\"] = \"FylerGitDeleted\",\n  [\"!!\"] = \"FylerGitIgnored\",\n  [\" M\"] = \"FylerGitModified\",\n  [\"R \"] = \"FylerGitRenamed\",\n  [\"M \"] = \"FylerGitStaged\",\n  [\"??\"] = \"FylerGitUntracked\",\n  [\"MM\"] = \"FylerGitUnstaged\",\n}, {\n  __index = function()\n    return \"\"\n  end,\n})\n-- stylua: ignore end\n\nlocal function get_sorted(tbl)\n  table.sort(tbl, function(x, y)\n    if x:is_directory() and not y:is_directory() then\n      return true\n    elseif not x:is_directory() and y:is_directory() then\n      return false\n    else\n      return x.name < y.name\n    end\n  end)\n\n  return tbl\nend\n\nlocal TREE_STRUCTURE\n---@param tbl table\n---@param status_map? table\n---@param cb fun(lines: FylerUiLine[])\nTREE_STRUCTURE = a.async(function(tbl, status_map, depth, cb)\n  depth = depth or 0\n  if not tbl then\n    return cb {}\n  end\n\n  local lines = {}\n  for _, item in ipairs(get_sorted(tbl)) do\n    local icon, hl = (function()\n      if item.type == \"directory\" then\n        return icon_provider(item.type, item.name)\n      elseif item.type == \"link\" then\n        return icon_provider(item.link_type, item.name)\n      else\n        return icon_provider(item.type, item.name)\n      end\n    end)()\n\n    local git_symbol = (function()\n      if not status_map then\n        return nil\n      end\n\n      if status_map[item.path] then\n        return status_map[item.path]\n      end\n\n      return nil\n    end)()\n\n    table.insert(\n      lines,\n      Line {\n        words = {\n          { str = string.rep(\"  \", depth) },\n          {\n            str = icon,\n            hl = (function()\n              if item.type == \"directory\" then\n                return \"FylerFSDirectory\"\n              elseif item.link_type == \"directory\" then\n                return \"FylerFSDirectory\"\n              else\n                return hl\n              end\n            end)(),\n          },\n          {\n            str = git_symbol and string.format(\" %s \", git_symbol) or \" \",\n            hl = git_status_hl[git_symbol],\n          },\n          { str = string.format(\"/%s\", item.meta) },\n          {\n            str = string.format(\" %s\", item.name),\n            hl = (function()\n              if git_symbol then\n                return git_status_hl[git_symbol]\n              elseif item.type == \"directory\" then\n                return \"FylerFSDirectory\"\n              elseif item.link_type == \"directory\" then\n                return \"FylerFSDirectory\"\n              else\n                return \"\"\n              end\n            end)(),\n          },\n        },\n        marks = (function()\n          local line = {}\n          if item.type == \"link\" then\n            table.insert(line, {\n              hl = \"FylerFSLink\",\n              str = string.format(\" %s\", item.link_path),\n            })\n          end\n\n          return line\n        end)(),\n      }\n    )\n\n    if item.children then\n      for _, line in ipairs(a.await(TREE_STRUCTURE, item.children, status_map, depth + 1)) do\n        table.insert(lines, line)\n      end\n    end\n  end\n\n  return cb(lines)\nend)\n\nM.Explorer = a.async(function(tbl, cb)\n  return cb(a.await(TREE_STRUCTURE, tbl, config.values.git_status and a.await(git.status_map) or {}, 0))\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/actions.lua", "local a = require(\"fyler.lib.async\")\nlocal algos = require(\"fyler.views.explorer.algos\")\nlocal cache = require(\"fyler.cache\")\nlocal config = require(\"fyler.config\")\nlocal confirm_view = require(\"fyler.views.confirm\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal regex = require(\"fyler.views.explorer.regex\")\nlocal store = require(\"fyler.views.explorer.store\")\nlocal ui = require(\"fyler.views.explorer.ui\")\n\nlocal M = {}\n\nlocal fn = vim.fn\nlocal api = vim.api\n\n---@param view table\nfunction M.n_close_view(view)\n  return function()\n    local success = pcall(api.nvim_win_close, view.win.winid, true)\n    if not success then\n      api.nvim_win_set_buf(view.win.winid, fn.bufnr(\"#\", true))\n    end\n\n    pcall(api.nvim_buf_delete, view.win.bufnr, { force = true })\n  end\nend\n\n---@param view FylerExplorerView\nfunction M.n_select(view)\n  return function()\n    local key = regex.match_meta(api.nvim_get_current_line())\n    if not key then\n      return\n    end\n\n    local meta_data = store.get(key)\n    if meta_data:is_directory() then\n      view.fs_root:find(key):toggle()\n      api.nvim_exec_autocmds(\"User\", { pattern = \"RefreshView\" })\n    else\n      local recent_win = cache.get_entry(\"recent_win\")\n\n      if recent_win and api.nvim_win_is_valid(recent_win) then\n        fn.win_execute(recent_win, string.format(\"edit %s\", meta_data:resolved_path()))\n        fn.win_gotoid(recent_win)\n\n        if config.values.close_on_select then\n          view.win:hide()\n        end\n      end\n    end\n  end\nend\n\n---@param tbl table\n---@return table\nlocal function get_tbl(tbl)\n  local lines = { { { str = \"\", hl = \"\" } } }\n  if not vim.tbl_isempty(tbl.create) then\n    table.insert(lines, { { str = \"# Creation\", hl = \"FylerConfirmGreen\" } })\n    for _, change in ipairs(tbl.create) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  if not vim.tbl_isempty(tbl.delete) then\n    table.insert(lines, { { str = \"# Deletion\", hl = \"FylerConfirmRed\" } })\n    for _, change in ipairs(tbl.delete) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  if not vim.tbl_isempty(tbl.move) then\n    table.insert(lines, { { str = \"# Migration\", hl = \"FylerConfirmYellow\" } })\n    for _, change in ipairs(tbl.move) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change.src), hl = \"FylerConfirmGrey\" },\n        { str = \" > \" },\n        { str = fs.relpath(fs.getcwd(), change.dst), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  return lines\nend\n\n---@param changes table\n---@return boolean\nlocal function can_bypass(changes)\n  if not vim.tbl_isempty(changes.delete) then\n    return false\n  end\n\n  if #changes.move > 1 then\n    return false\n  end\n\n  if #changes.create > 5 then\n    return false\n  end\n\n  return true\nend\n\n---@param view FylerExplorerView\nfunction M.synchronize(view)\n  return a.async(function()\n    local changes = algos.get_diff(view)\n    local can_sync = (function()\n      if #changes.create == 0 and #changes.delete == 0 and #changes.move == 0 then\n        return true\n      end\n\n      if not config.values.auto_confirm_simple_edits then\n        return a.await(confirm_view.open, get_tbl(changes), \"(y/n)\")\n      end\n\n      if can_bypass(changes) then\n        return true\n      end\n\n      return a.await(confirm_view.open, get_tbl(changes), \"(y/n)\")\n    end)()\n\n    if can_sync then\n      for _, change in ipairs(changes.create) do\n        local err, success = a.await(fs.create, change)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n\n      for _, change in ipairs(changes.delete) do\n        local err, success = a.await(fs.delete, change)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n\n      for _, change in ipairs(changes.move) do\n        local err, success = a.await(fs.move, change.src, change.dst)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n    end\n\n    vim.schedule(function()\n      api.nvim_exec_autocmds(\"User\", { pattern = \"RefreshView\" })\n    end)\n  end)\nend\n\n---@param view FylerExplorerView\n---@param on_render function\nfunction M.refreshview(view, on_render)\n  return a.async(function()\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    a.await(view.fs_root.update, view.fs_root)\n\n    vim.bo[view.win.bufnr].undolevels = -1\n\n    view.win.ui:render {\n      ui_lines = a.await(ui.Explorer, algos.tree_table_from_node(view).children),\n      on_render = function()\n        if on_render then\n          on_render()\n        end\n\n        M.draw_indentscope(view)()\n\n        if not view.win:has_valid_bufnr() then\n          return\n        end\n\n        vim.bo[view.win.bufnr].undolevels = vim.go.undolevels\n      end,\n    }\n\n    vim.bo[view.win.bufnr].syntax = \"fyler\"\n    vim.bo[view.win.bufnr].filetype = \"fyler\"\n  end)\nend\n\nfunction M.constrain_cursor(view)\n  return function()\n    local cur = api.nvim_get_current_line()\n    local meta = regex.match_meta(cur)\n    if not meta then\n      return\n    end\n\n    local _, ub = string.find(cur, meta)\n    if not view.win:has_valid_winid() then\n      return\n    end\n\n    local row, col = unpack(api.nvim_win_get_cursor(view.win.winid))\n    if col <= ub then\n      api.nvim_win_set_cursor(view.win.winid, { row, ub + 1 })\n    end\n  end\nend\n\n---@param view FylerExplorerView\nfunction M.try_focus_buffer(view)\n  return a.schedule_async(function(arg)\n    local explorer = require(\"fyler.views.explorer\")\n\n    if not view.win:is_visible() then\n      return\n    end\n\n    if arg.file == \"\" then\n      return\n    end\n\n    if string.match(arg.file, \"^fyler://*\") then\n      local recent_win = cache.get_entry(\"recent_win\")\n      if (type(recent_win) ~= \"number\") or (not api.nvim_win_is_valid(recent_win)) then\n        return\n      end\n\n      local recent_bufname = fn.bufname(api.nvim_win_get_buf(recent_win))\n      if recent_bufname == \"\" or string.match(recent_bufname, \"^fyler://*\") then\n        return\n      end\n\n      arg.file = fs.abspath(recent_bufname)\n    end\n\n    if not vim.startswith(arg.file, view.cwd) then\n      explorer.open {\n        enter = fn.bufname(\"%\") == view.win.bufname,\n        cwd = fn.fnamemodify(arg.file, \":h\"),\n      }\n    end\n\n    local relpath = fs.relpath(view.cwd, arg.file)\n    if not relpath then\n      return\n    end\n\n    local focused_node = view.fs_root\n    local last_visit = 0\n    local parts = vim.split(relpath, \"/\")\n\n    a.await(focused_node.update, focused_node)\n\n    for i, part in ipairs(parts) do\n      local child = vim.iter(focused_node.children):find(function(child)\n        return store.get(child.meta).name == part\n      end)\n\n      if not child then\n        break\n      end\n\n      if store.get(child.meta):is_directory() then\n        child.open = true\n        a.await(child.update, child)\n      end\n\n      focused_node, last_visit = child, i\n    end\n\n    if last_visit ~= #parts then\n      return\n    end\n\n    M.refreshview(view, function()\n      if not view.win:has_valid_winid() then\n        return\n      end\n\n      local buf_lines = api.nvim_buf_get_lines(view.win.bufnr, 0, -1, false)\n      for ln, buf_line in ipairs(buf_lines) do\n        if buf_line:find(focused_node.meta) then\n          api.nvim_win_set_cursor(view.win.winid, { ln, 0 })\n        end\n      end\n    end)()\n  end)\nend\n\nlocal extmark_namespace = api.nvim_create_namespace(\"FylerIndentScope\")\n\n---@param view FylerExplorerView\nfunction M.draw_indentscope(view)\n  local function draw_line(ln)\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    local cur_line = unpack(api.nvim_buf_get_lines(view.win.bufnr, ln - 1, ln, false))\n    local cur_indent = #regex.match_indent(cur_line)\n    if cur_indent == 0 then\n      return\n    end\n\n    local indent_depth = math.floor(cur_indent * 0.5)\n    for i = 1, indent_depth do\n      api.nvim_buf_set_extmark(view.win.bufnr, extmark_namespace, ln - 1, 0, {\n        hl_mode = \"combine\",\n        virt_text = {\n          {\n            config.values.indentscope.marker,\n            config.values.indentscope.group,\n          },\n        },\n        virt_text_pos = \"overlay\",\n        virt_text_win_col = (i - 1) * 2,\n      })\n    end\n  end\n\n  return function()\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    if not config.values.indentscope.enabled then\n      return\n    end\n\n    api.nvim_buf_clear_namespace(view.win.bufnr, extmark_namespace, 0, -1)\n    for i = 1, api.nvim_buf_line_count(view.win.bufnr) do\n      draw_line(i)\n    end\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/hls.lua", "local api = vim.api\n\nlocal M = {}\n\n---@param dec integer\nlocal function to_hex(dec)\n  return string.format(\"%06X\", math.max(0, math.min(0xFFFFFF, math.floor(dec))))\nend\n\n-- https://github.com/NeogitOrg/neogit\n---@param name string\n---@return string|nil\nlocal function get_fg(name)\n  local color = api.nvim_get_hl(0, { name = name })\n  if color[\"link\"] then\n    return get_fg(color[\"link\"])\n  elseif color[\"reverse\"] and color[\"bg\"] then\n    return \"#\" .. to_hex(color[\"bg\"])\n  elseif color[\"fg\"] then\n    return \"#\" .. to_hex(color[\"fg\"])\n  end\nend\n\n-- https://github.com/NeogitOrg/neogit\n---@param name string\n---@return string|nil\nlocal function get_bg(name)\n  local color = api.nvim_get_hl(0, { name = name })\n  if color[\"link\"] then\n    return get_bg(color[\"link\"])\n  elseif color[\"reverse\"] and color[\"fg\"] then\n    return \"#\" .. to_hex(color[\"fg\"])\n  elseif color[\"bg\"] then\n    return \"#\" .. to_hex(color[\"bg\"])\n  end\nend\n\nlocal function build_palette()\n  -- stylua: ignore start\n  return {\n    black     = \"#000000\",\n    white     = \"#ffffff\",\n\n    bg        = get_bg(\"Normal\"),\n    blue      = get_fg(\"Directory\"),\n    cyan      = get_fg(\"Operator\"),\n    dark_grey = get_fg(\"WhiteSpace\"),\n    fg        = get_fg(\"Normal\"),\n    green     = get_fg(\"String\"),\n    grey      = get_fg(\"Comment\"),\n    orange    = get_fg(\"SpecialChar\"),\n    red       = get_fg(\"Error\"),\n    yellow    = get_fg(\"WarningMsg\"),\n  }\n  -- stylua: ignore end\nend\n\n---@param opts? FylerConfig\nfunction M.setup(opts)\n  opts = opts or {}\n\n  local palette = build_palette()\n\n  -- stylua: ignore start\n  local hl_groups = {\n    FylerConfirmGreen  = { fg = palette.green },\n    FylerConfirmGrey   = { fg = palette.grey },\n    FylerConfirmRed    = { fg = palette.red },\n    FylerConfirmYellow = { fg = palette.yellow },\n    FylerFSDirectory   = { fg = palette.blue },\n    FylerFSFile        = { fg = palette.white },\n    FylerFSLink        = { fg = palette.grey },\n    FylerGitAdded      = { fg = palette.green },\n    FylerGitConflict   = { fg = palette.red },\n    FylerGitDeleted    = { fg = palette.red },\n    FylerGitIgnored    = { fg = palette.red },\n    FylerGitModified   = { fg = palette.yellow },\n    FylerGitRenamed    = { fg = palette.yellow },\n    FylerGitStaged     = { fg = palette.green },\n    FylerGitUnstaged   = { fg = palette.orange },\n    FylerGitUntracked  = { fg = palette.cyan },\n    FylerIndentMarker  = { fg = palette.dark_grey },\n  }\n  -- stylua: ignore end\n\n  if opts.on_highlights then\n    opts.on_highlights(hl_groups, palette)\n  end\n\n  for key, val in pairs(hl_groups) do\n    api.nvim_set_hl(0, key, val)\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/ui/init.lua", "local api = vim.api\n\n---@class FylerUi\n---@field win FylerWin\nlocal Ui = {}\nUi.__index = Ui\n\nlocal M = setmetatable({}, {\n  ---@param win FylerWin\n  ---@return FylerUi\n  __call = function(_, win)\n    assert(win, \"win is required\")\n\n    return setmetatable({ win = win }, Ui)\n  end,\n})\n\n---@param align FylerUiLineAlign\n---@param line string\n---@return string\nlocal function get_margin(width, align, line)\n  if align == \"center\" then\n    return string.rep(\" \", math.floor((width - #line) * 0.5))\n  elseif align == \"end\" then\n    return string.rep(\" \", math.floor((width - #line)))\n  else\n    return \"\"\n  end\nend\n\n---@param ui_lines FylerUiLine[]\nfunction Ui:_render(ui_lines)\n  if not self.win:has_valid_bufnr() then\n    return\n  end\n\n  local was_modifiable = vim.bo[self.win.bufnr].modifiable\n  local win_width = api.nvim_win_get_width(self.win.winid)\n  local buf_lines = {}\n\n  vim.bo[self.win.bufnr].modifiable = true\n\n  for _, line in ipairs(ui_lines) do\n    local line_text = table.concat(vim.tbl_map(function(word)\n      return word.str\n    end, line.words))\n\n    local margin = get_margin(win_width, line.align, line_text)\n\n    table.insert(line.words, 1, {\n      str = margin,\n    })\n\n    table.insert(buf_lines, margin .. line_text)\n  end\n\n  api.nvim_buf_set_lines(self.win.bufnr, 0, -1, false, buf_lines)\n  api.nvim_buf_clear_namespace(self.win.bufnr, self.win.namespace, 0, -1)\n\n  for i, line in ipairs(ui_lines) do\n    local offset = 0\n\n    for _, word in ipairs(line.words) do\n      api.nvim_buf_set_extmark(self.win.bufnr, self.win.namespace, i - 1, offset, {\n        end_col = offset + #word.str,\n        hl_group = word.hl or \"\",\n      })\n\n      offset = offset + #word.str\n    end\n\n    for _, mark in pairs(line.marks) do\n      api.nvim_buf_set_extmark(self.win.bufnr, self.win.namespace, i - 1, 0, {\n        virt_text = { { mark.str, mark.hl or \"\" } },\n        virt_text_pos = \"eol\",\n        hl_mode = \"combine\",\n      })\n    end\n  end\n\n  if not was_modifiable then\n    vim.bo[self.win.bufnr].modifiable = false\n  end\n\n  vim.bo[self.win.bufnr].modified = false\nend\n\nfunction Ui:render(opts)\n  opts = opts or {}\n\n  vim.schedule(function()\n    self:_render(opts.ui_lines)\n    if opts.on_render then\n      opts.on_render()\n    end\n  end)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/autocmds.lua", "local M = {}\n\nlocal api = vim.api\nlocal uv = vim.uv or vim.loop\n\nlocal augroup = api.nvim_create_augroup(\"Fyler\", { clear = true })\n\nfunction M.setup(opts)\n  opts = opts or {}\n\n  api.nvim_create_autocmd(\"ColorScheme\", {\n    group = augroup,\n    callback = function()\n      require(\"fyler.lib.hls\").setup()\n    end,\n  })\n\n  api.nvim_create_autocmd(\"BufEnter\", {\n    group = augroup,\n    callback = function(...)\n      local cur_instance = require(\"fyler.views.explorer\").instance\n      if cur_instance then\n        cur_instance:_action(\"try_focus_buffer\")(...)\n      end\n    end,\n  })\n\n  api.nvim_create_autocmd(\"BufEnter\", {\n    group = augroup,\n    callback = vim.schedule_wrap(function(arg)\n      local explorer = require(\"fyler.views.explorer\").instance\n      if not explorer then\n        return\n      end\n\n      if vim.fn.bufname(arg.buf) == explorer.win.bufname then\n        return\n      end\n\n      if api.nvim_get_current_win() == explorer.win.winid then\n        for option, _ in pairs(require(\"fyler.config\").get_view(\"explorer\").win_opts) do\n          if not explorer.win:has_valid_winid() then\n            return\n          end\n\n          vim.wo[explorer.win.winid][option] = vim.w[explorer.win.winid][option]\n        end\n      end\n    end),\n  })\n\n  if opts.values.default_explorer then\n    api.nvim_create_autocmd(\"BufEnter\", {\n      group = augroup,\n      callback = function(arg)\n        local stats = uv.fs_stat(arg.file)\n\n        if stats and stats.type == \"directory\" then\n          local cur_buf = api.nvim_get_current_buf()\n\n          if api.nvim_buf_is_valid(cur_buf) then\n            api.nvim_buf_delete(cur_buf, { force = true })\n          end\n\n          require(\"fyler\").open { cwd = arg.file }\n        end\n      end,\n    })\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/ui/components.lua", "---@alias FylerUiLineAlign\n---| \"end\"\n---| \"start\"\n---| \"center\"\n\n---@alias FylerUiWord { str: string, hl?: string }\n---@alias FylerUiMark { str: string, hl?: string, id: string }\n\n---@class FylerUiLine\n---@field align FylerUiLineAlign\n---@field words FylerUiWord[]\n---@field marks FylerUiMark[]\nlocal Line = {}\nLine.__index = Line\n\nreturn {\n  Line = setmetatable({}, {\n    ---@param opts { words: FylerUiWord[], marks: FylerUiMark[], align?: FylerUiLineAlign }\n    ---@return FylerUiLine\n    __call = function(_, opts)\n      local instance = {\n        words = opts.words or {},\n        align = opts.align or \"start\",\n        marks = opts.marks or {},\n      }\n\n      setmetatable(instance, Line)\n\n      return instance\n    end,\n  }),\n}\n"], ["/fyler.nvim/lua/fyler/views/explorer/struct.lua", "local a = require(\"fyler.lib.async\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal store = require(\"fyler.views.explorer.store\")\n\n---@class FylerFSItem\n---@field meta string\n---@field open boolean\n---@field children FylerFSItem[]\nlocal FSItem = {}\nFSItem.__index = FSItem\n\nlocal M = setmetatable({}, {\n  ---@param meta string\n  ---@return FylerFSItem\n  __call = function(_, meta)\n    local instance = {\n      meta = meta,\n      open = false,\n      children = {},\n    }\n\n    return setmetatable(instance, FSItem)\n  end,\n})\n\nfunction FSItem:toggle()\n  self.open = not self.open\nend\n\n---@param addr string\n---@param meta string\nfunction FSItem:add_child(addr, meta)\n  local target_node = self:find(addr)\n  if target_node then\n    table.insert(target_node.children, M(meta))\n  end\nend\n\n---@param addr string\n---@return FylerFSItem?\nfunction FSItem:find(addr)\n  if self.meta == addr then\n    return self\n  end\n\n  for _, child in ipairs(self.children) do\n    local found = child:find(addr)\n    if found then\n      return found\n    end\n  end\n\n  return nil\nend\n\nFSItem.update = a.async(function(self, cb)\n  if not self.open then\n    return cb()\n  end\n\n  local meta_data = store.get(self.meta)\n  local err, items = a.await(fs.ls, meta_data.path)\n  if err then\n    return cb()\n  end\n\n  self.children = vim\n    .iter(self.children)\n    :filter(function(child) ---@param child FylerFSItem\n      return vim.iter(items):any(function(item)\n        return item.path == store.get(child.meta).path and item.type == store.get(child.meta).type\n      end)\n    end)\n    :totable()\n\n  for _, item in ipairs(items) do\n    if\n      not vim.iter(self.children):any(function(child) ---@param child FylerFSItem\n        return store.get(child.meta).path == item.path and store.get(child.meta).type == item.type\n      end)\n    then\n      self:add_child(self.meta, store.set(item))\n    end\n  end\n\n  for _, child in ipairs(self.children) do\n    a.await(child.update, child)\n  end\n\n  return cb()\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/algos.lua", "local fs = require(\"fyler.lib.fs\")\nlocal regex = require(\"fyler.views.explorer.regex\")\nlocal store = require(\"fyler.views.explorer.store\")\nlocal M = {}\n\nlocal api = vim.api\n\n---@param view FylerExplorerView\n---@return table\nfunction M.tree_table_from_node(view)\n  ---@param node FylerFSItem\n  local function get_tbl(node)\n    local sub_tbl = store.get(node.meta)\n    sub_tbl.meta = node.meta\n\n    if sub_tbl:is_directory() then\n      sub_tbl.children = {}\n    end\n\n    if not node.open then\n      return sub_tbl\n    end\n\n    for _, child in ipairs(node.children) do\n      table.insert(sub_tbl.children, get_tbl(child))\n    end\n\n    return sub_tbl\n  end\n\n  return get_tbl(view.fs_root)\nend\n\n---@param view FylerExplorerView\n---@return table\nfunction M.tree_table_from_buffer(view)\n  if not view.win:has_valid_bufnr() then\n    return {}\n  end\n\n  local buf_lines = vim\n    .iter(api.nvim_buf_get_lines(view.win.bufnr, 0, -1, false))\n    :filter(function(buf_line)\n      return buf_line ~= \"\"\n    end)\n    :totable()\n\n  local root = vim.tbl_deep_extend(\"force\", store.get(view.fs_root.meta), {\n    meta = view.fs_root.meta,\n    children = {},\n  })\n\n  local stack = {\n    { node = root, indent = -1 },\n  }\n\n  for _, buf_line in ipairs(buf_lines) do\n    local meta = regex.match_meta(buf_line)\n    local name = regex.match_name(buf_line)\n    local indent = regex.match_indent(buf_line)\n    local metadata = meta and store.get(meta)\n\n    while #stack > 1 and #stack[#stack].indent >= #indent do\n      table.remove(stack)\n    end\n\n    local parent = stack[#stack].node\n    local path = fs.joinpath(parent.path, name)\n    local new_node = {\n      meta = meta,\n      name = name,\n      type = (metadata or {}).type or \"\",\n      path = path,\n    }\n\n    table.insert(parent.children, new_node)\n    if metadata and metadata:is_directory() then\n      new_node.children = {}\n      table.insert(stack, { node = new_node, indent = indent })\n    end\n  end\n\n  return root\nend\n\n---@param view FylerExplorerView\n---@return table\nfunction M.get_diff(view)\n  local recent_tree_hash = {}\n\n  local function save_hash(root)\n    recent_tree_hash[root.meta] = root.path\n    for _, child in ipairs(root.children or {}) do\n      save_hash(child)\n    end\n  end\n\n  save_hash(M.tree_table_from_node(view))\n\n  local fs_actions = {\n    create = {},\n    delete = {},\n    move = {},\n  }\n\n  local function calculate_fs_actions(root)\n    if not root.meta then\n      table.insert(fs_actions.create, root.path)\n    else\n      if recent_tree_hash[root.meta] ~= root.path then\n        table.insert(fs_actions.move, { src = recent_tree_hash[root.meta], dst = root.path })\n      end\n\n      recent_tree_hash[root.meta] = nil\n    end\n\n    for _, child in ipairs(root.children or {}) do\n      calculate_fs_actions(child)\n    end\n  end\n\n  calculate_fs_actions(M.tree_table_from_buffer(view))\n\n  for _, v in pairs(recent_tree_hash) do\n    if v then\n      table.insert(fs_actions.delete, v)\n    end\n  end\n\n  return fs_actions\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/fs.lua", "local List = require(\"fyler.lib.structs.list\")\nlocal Stack = require(\"fyler.lib.structs.stack\")\n\nlocal a = require(\"fyler.lib.async\")\n\nlocal M = {}\n\nlocal api = vim.api\n\nlocal uv = vim.uv or vim.loop\nlocal fn = vim.fn\n\n---@return string\nfunction M.getcwd()\n  return uv.cwd() or fn.getcwd(0)\nend\n\n---@param path string\n---@return string\nfunction M.normalize(path)\n  return vim.fs.normalize(path)\nend\n\n---@return string\nfunction M.joinpath(...)\n  return vim.fs.joinpath(...)\nend\n\n---@param path string\n---@return string\nfunction M.abspath(path)\n  return vim.fs.abspath(path)\nend\n\n---@param path string\nfunction M.relpath(base, path)\n  return vim.fs.relpath(base, path)\nend\n\n---@param path string\n---@return string?, string?\nfunction M.resolve_link(path)\n  local res_path = nil\n  local res_type = nil\n  while true do\n    local stat = uv.fs_stat(path)\n    if not stat then\n      break\n    end\n\n    local linkdata = uv.fs_readlink(path)\n    if not linkdata then\n      res_path = path\n      res_type = stat.type\n      break\n    end\n\n    path = linkdata\n  end\n\n  return res_path, res_type\nend\n\n---@param path string\n---@param cb fun(err?: string, items: table)\nM.ls = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, {})\n  end\n\n  ---@diagnostic disable-next-line: param-type-mismatch\n  local dir = uv.fs_opendir(path, nil, 1000)\n  local items = {}\n\n  while true do\n    local _, entries = a.await(uv.fs_readdir, dir)\n    if not entries then\n      break\n    end\n\n    items = vim.list_extend(\n      items,\n      vim\n        .iter(entries)\n        :map(function(entry)\n          local link_path, link_type = M.resolve_link(M.joinpath(path, entry.name))\n          return {\n            name = entry.name,\n            type = entry.type,\n            path = M.joinpath(path, entry.name),\n            link_path = link_path,\n            link_type = link_type,\n          }\n        end)\n        :totable()\n    )\n  end\n\n  return cb(nil, items)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.touch = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if stat then\n    return cb(stat_err, false)\n  end\n\n  local fd_err, fd = a.await(uv.fs_open, path, \"a\", 420)\n  if not fd then\n    return cb(fd_err, false)\n  end\n\n  return cb(a.await(uv.fs_close, fd))\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rm = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat or stat.type == \"directory\" then\n    return cb(stat_err, false)\n  end\n\n  local unlink_err, success = a.await(uv.fs_unlink, path)\n  if not success then\n    return cb(unlink_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rm_r = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, false)\n  end\n\n  local stk, lst = Stack(), List()\n\n  stk:push { path = path, type = stat.type }\n\n  while not stk:is_empty() do\n    local cur_entry = stk:pop()\n\n    lst:insert(1, cur_entry)\n\n    if cur_entry.type == \"directory\" then\n      local ls_err, entries = a.await(M.ls, cur_entry.path)\n      if ls_err then\n        return cb(ls_err, false)\n      end\n\n      for _, entry in ipairs(entries) do\n        stk:push(entry)\n      end\n    end\n  end\n\n  for _, entry in ipairs(lst:totable()) do\n    if entry.type == \"directory\" then\n      local rmdir_err, rmdir_success = a.await(M.rmdir, entry.path)\n      if not rmdir_success then\n        return cb(rmdir_err, false)\n      end\n    else\n      local rm_err, rm_success = a.await(M.rm, entry.path)\n      if not rm_success then\n        return cb(rm_err, false)\n      end\n    end\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.mkdir = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if stat and stat.type == \"directory\" then\n    return cb(stat_err, false)\n  end\n\n  local mkdir_err, success = a.await(uv.fs_mkdir, path, 493)\n  if not success then\n    return cb(mkdir_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.mkdir_p = a.async(function(path, cb)\n  local parts = vim\n    .iter(vim.split(path, \"/\"))\n    :filter(function(part)\n      return part ~= \"\"\n    end)\n    :totable()\n\n  local is_win = fn.has(\"win32\") == 1 or fn.has(\"win64\") == 1\n\n  local dir = is_win and parts[1] or \"\"\n\n  local start_idx = is_win and 2 or 1\n  for i = start_idx, #parts do\n    dir = dir .. string.format(\"/%s\", parts[i])\n\n    local _, stat = a.await(uv.fs_stat, dir)\n    if not stat then\n      local mkdir_err, mkdir_success = a.await(M.mkdir, dir)\n      if not mkdir_success then\n        return cb(mkdir_err, false)\n      end\n    end\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rmdir = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, false)\n  end\n\n  local rmdir_err, success = a.await(uv.fs_rmdir, path)\n  if not success then\n    return cb(rmdir_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param src_path string\n---@param dst_path string\n---@param cb fun(err?: string, success: boolean)\nM.mv = a.async(function(src_path, dst_path, cb)\n  local stat_err, src_stat = a.await(uv.fs_stat, src_path)\n  if not src_stat then\n    return cb(stat_err, false)\n  end\n\n  local _, dst_stat = a.await(uv.fs_stat, dst_path)\n  if dst_stat then\n    return cb(\"Destination path already exists\", false)\n  end\n\n  local rename_err, rename_success = a.await(uv.fs_rename, src_path, dst_path)\n  if not rename_success then\n    return cb(rename_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.create = a.async(function(path, cb)\n  local mkdirp_err, mkdirp_success =\n    a.await(M.mkdir_p, fn.fnamemodify(path, vim.endswith(path, \"/\") and \":h:h\" or \":h\"))\n  if not mkdirp_success then\n    return cb(mkdirp_err, false)\n  end\n\n  if vim.endswith(path, \"/\") then\n    local mkdir_err, mkdir_success = a.await(M.mkdir, path)\n    if not mkdir_success then\n      return cb(mkdir_err, false)\n    end\n  else\n    local touch_err, touch_success = a.await(M.touch, path)\n    if not touch_success then\n      return cb(touch_err, false)\n    end\n  end\n\n  return cb(nil, true)\nend)\n\nlocal function get_alt_buf(for_buf)\n  for _, buf in ipairs(api.nvim_list_bufs()) do\n    if api.nvim_buf_is_valid(buf) and buf ~= for_buf then\n      return buf\n    end\n  end\n\n  return api.nvim_create_buf(false, true)\nend\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.delete = a.async(function(path, cb)\n  local rm_r_err, rm_r_success = a.await(M.rm_r, path)\n  if not rm_r_success then\n    return cb(rm_r_err, false)\n  end\n\n  local buf = fn.bufnr(path)\n  if buf == -1 then\n    return cb(\"Unable to find buffer to delete\", true)\n  end\n\n  local alt = get_alt_buf(buf)\n  for _, win in ipairs(api.nvim_list_wins()) do\n    if api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) == buf then\n      if alt < 1 or alt == buf then\n        alt = api.nvim_create_buf(true, false)\n      end\n\n      api.nvim_win_set_buf(win, alt)\n    end\n  end\n\n  local success, msg = pcall(api.nvim_buf_delete, buf, { force = true })\n  if not success then\n    return cb(msg, true)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param src_path string\n---@param dst_path string\n---@param cb fun(err?: string, success: boolean)\nM.move = a.async(function(src_path, dst_path, cb)\n  local mkdirp_err, mkdirp_success = a.await(M.mkdir_p, fn.fnamemodify(dst_path, \":h\"))\n  if not mkdirp_success then\n    return cb(mkdirp_err, false)\n  end\n\n  local mv_err, mv_success = a.await(M.mv, src_path, dst_path)\n  if not mv_success then\n    return cb(mv_err, false)\n  end\n\n  local src_buf = fn.bufnr(src_path)\n  if src_buf == -1 then\n    return cb(\"unable to find moved buffer\", true)\n  end\n\n  local dst_buf = fn.bufadd(dst_path)\n  fn.bufload(dst_buf)\n  vim.bo[dst_buf].buflisted = true\n\n  for _, win in ipairs(api.nvim_list_wins()) do\n    if api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) == src_buf then\n      api.nvim_win_set_buf(win, dst_buf)\n    end\n  end\n\n  local success, msg = pcall(api.nvim_buf_delete, src_buf, { force = true })\n  if not success then\n    return cb(msg, true)\n  end\n\n  return cb(nil, true)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler.lua", "local M = {}\n\nlocal did_setup = false\n\nlocal api = vim.api\nlocal fn = vim.fn\n\n---@param opts FylerConfig\nfunction M.setup(opts)\n  if fn.has(\"nvim-0.11\") ~= 1 then\n    return vim.notify(\"Fyler requires at least NVIM 0.11\")\n  end\n\n  if did_setup then\n    return\n  end\n\n  require(\"fyler.config\").setup(opts)\n  require(\"fyler.lib.hls\").setup(require(\"fyler.config\"))\n  require(\"fyler.autocmds\").setup(require(\"fyler.config\"))\n\n  if require(\"fyler.config\").values.default_explorer then\n    vim.g.loaded_netrw = 1\n    vim.g.loaded_netrwPlugin = 1\n    if fn.exists(\"#FileExplorer\") then\n      api.nvim_create_augroup(\"FileExplorer\", { clear = true })\n    end\n\n    if vim.v.vim_did_enter == 0 then\n      local arg_path = fn.argv(0)\n      local first_arg = type(arg_path) == \"string\" and arg_path or arg_path[1]\n      if fn.isdirectory(first_arg) == 0 then\n        return\n      end\n\n      local current_bufnr = api.nvim_get_current_buf()\n      if api.nvim_buf_is_valid(current_bufnr) then\n        api.nvim_buf_delete(current_bufnr, { force = true })\n      end\n\n      M.open { cwd = arg_path }\n    end\n  end\n\n  did_setup = true\nend\n\nM.open = vim.schedule_wrap(function(opts)\n  opts = opts or {}\n\n  require(\"fyler.views.explorer\").open {\n    cwd = opts.cwd,\n    kind = opts.kind,\n  }\nend)\n\nreturn M\n"], ["/fyler.nvim/plugin/fyler.lua", "vim.api.nvim_create_user_command(\"Fyler\", function(args)\n  local opts = {}\n  for _, farg in ipairs(args.fargs) do\n    local key, value = unpack(vim.split(farg, \"=\"))\n    opts[key] = value\n  end\n\n  require(\"fyler\").open(opts)\nend, {\n  nargs = \"*\",\n  complete = function(arglead, cmdline)\n    if arglead:find(\"^kind=\") then\n      return {\n        \"kind=float\",\n        \"kind=split:left\",\n        \"kind=split:above\",\n        \"kind=split:right\",\n        \"kind=split:below\",\n        \"kind=split:leftmost\",\n        \"kind=split:abovemost\",\n        \"kind=split:rightmost\",\n        \"kind=split:belowmost\",\n      }\n    end\n\n    if arglead:find(\"^cwd=\") then\n      return {\n        \"cwd=\" .. (vim.uv or vim.loop).cwd(),\n      }\n    end\n\n    return vim.tbl_filter(function(arg)\n      return cmdline:match(arg) == nil\n    end, {\n      \"kind=\",\n      \"cwd=\",\n    })\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/async.lua", "local M = {}\n\nlocal queue = require(\"fyler.lib.structs.queue\")() ---@type FylerQueue\nlocal is_loop_running = false\n\n---@param co thread\n---@param ... any\nlocal function schedule(co, ...)\n  queue:enqueue {\n    args = { ... },\n    co = co,\n    started = false,\n  }\n\n  if is_loop_running then\n    return\n  end\n\n  is_loop_running = true\n\n  local function loop()\n    if queue:is_empty() then\n      is_loop_running = false\n      return\n    end\n\n    local front = queue:front()\n    local status = coroutine.status(front.co)\n\n    if status == \"dead\" then\n      queue:dequeue()\n\n      vim.defer_fn(loop, 0)\n    elseif status == \"suspended\" and front.started == false then\n      local success = coroutine.resume(front.co, unpack(front.args))\n      if not success then\n        queue:dequeue()\n      end\n\n      front.started = true\n\n      vim.defer_fn(loop, 0)\n    else\n      vim.defer_fn(loop, 10)\n    end\n  end\n\n  vim.defer_fn(loop, 0)\nend\n\nfunction M.schedule_async(async_fn)\n  return function(...)\n    schedule(coroutine.create(async_fn), ...)\n  end\nend\n\nfunction M.async(async_fn)\n  return function(...)\n    local ok, err = coroutine.resume(coroutine.create(async_fn), ...)\n    if not ok then\n      error(err)\n    end\n  end\nend\n\nfunction M.await(fn, ...)\n  local thread = coroutine.running()\n  local args = { ... }\n\n  table.insert(\n    args,\n    vim.schedule_wrap(function(...)\n      if not thread then\n        return error(\"no coroutine is running\")\n      end\n\n      coroutine.resume(thread, ...)\n    end)\n  )\n\n  fn(unpack(args))\n\n  return coroutine.yield()\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/git.lua", "local a = require(\"fyler.lib.async\")\nlocal fs = require(\"fyler.lib.fs\")\n\nlocal M = {}\n\n---@param cb fun(result: boolean)\nlocal is_git_repo = a.async(function(cb)\n  local out = a.await(vim.system, { \"git\", \"rev-parse\", \"--is-inside-work-tree\" }, nil) ---@type vim.SystemCompleted\n  return cb(string.match(out.stdout, \"^(.*)\\n$\") == \"true\")\nend)\n\n---@param cb fun(status?: string)\nlocal git_status = a.async(function(cb)\n  if not a.await(is_git_repo) then\n    return cb(nil)\n  end\n\n  local out = a.await(vim.system, { \"git\", \"status\", \"--porcelain\", \"-z\" }, nil) ---@type vim.SystemCompleted\n  if not out.stdout then\n    return cb(nil)\n  end\n\n  return cb(out.stdout)\nend)\n\n---@param cb fun(path?: string)\nlocal git_toplevel = a.async(function(cb)\n  local out = a.await(vim.system, { \"git\", \"rev-parse\", \"--show-toplevel\" }, nil) ---@type vim.SystemCompleted\n  if not out.stdout then\n    return cb(nil)\n  end\n\n  return cb(string.match(out.stdout, \"^(.*)\\n$\"))\nend)\n\n---@param cb fun(status_map?: table)\nM.status_map = a.async(function(cb)\n  local status_str = a.await(git_status)\n  if not status_str then\n    return cb(nil)\n  end\n\n  local statuses = vim\n    .iter(vim.split(status_str, \"\\0\"))\n    :filter(function(status)\n      if status == \"\" then\n        return false\n      end\n\n      return true\n    end)\n    :totable()\n\n  local toplevel = a.await(git_toplevel)\n  if not toplevel then\n    return cb(nil)\n  end\n\n  local status_map = {}\n  for _, status in ipairs(statuses) do\n    local symbol, path = (function()\n      if string.match(status, \"^.*%s.*$\") then\n        return string.match(status, \"^(.*)%s(.*)$\")\n      else\n        return nil, status\n      end\n    end)()\n\n    status_map[fs.joinpath(toplevel, fs.normalize(path))] = symbol\n  end\n\n  return cb(status_map)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/integrations/icon/init.lua", "---@param type string\n---@param _ string\n---@return string?, string?\nlocal function default_icon_provider(type, _)\n  if type == \"directory\" then\n    return \"D\", \"FylerFSDirectory\"\n  elseif type == \"file\" then\n    return \"F\", \"FylerFSFile\"\n  else\n    return \"*\", \"\"\n  end\nend\n\nreturn setmetatable({}, {\n  __index = function(_, key)\n    local status, icon_provider = pcall(require, string.format(\"fyler.integrations.icon.%s\", key))\n    if not status then\n      return default_icon_provider\n    end\n\n    return function(...)\n      local success, icon, hl = pcall(icon_provider.get_icon, ...)\n      if not success then\n        return default_icon_provider(...)\n      end\n\n      return icon, hl\n    end\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/structs/list.lua", "---@class FylerLinkedList\n---@field node FylerLinkedListNode\nlocal LinkedList = {}\nLinkedList.__index = LinkedList\n\n---@class FylerLinkedListNode\n---@field next? FylerLinkedListNode\n---@field data  any\nlocal LinkedListNode = {}\nLinkedListNode.__index = LinkedListNode\n\n---@return integer\nfunction LinkedList:len()\n  local count = 0\n  local current = self.node\n  while current do\n    count = count + 1\n    current = current.next\n  end\n\n  return count\nend\n\n---@param fn fun(node: FylerLinkedListNode)\nfunction LinkedList:each(fn)\n  local start = self.node\n  while start do\n    fn(start.data)\n    start = start.next\n  end\nend\n\n---@param pos integer\n---@param data any\nfunction LinkedList:insert(pos, data)\n  local newNode = setmetatable({ data = data }, LinkedListNode)\n  if pos == 1 then\n    newNode.next = self.node\n    self.node = newNode\n    return\n  end\n\n  local start = self.node\n  for _ = 1, pos - 2 do\n    if not start then\n      error(\"position is out of bound\")\n    end\n    start = start.next\n  end\n\n  if not start then\n    error(\"position is out of bound\")\n  end\n\n  newNode.next = start.next\n  start.next = newNode\nend\n\n---@param pos integer\nfunction LinkedList:erase(pos)\n  assert(pos >= 1, \"position must be 1 or greater\")\n\n  if not self.node then\n    error(\"list is empty\")\n  end\n\n  if pos == 1 then\n    self.node = self.node.next\n    return\n  end\n\n  local start = self.node\n  for _ = 1, pos - 2 do\n    if not start or not start.next then\n      error(\"position is out of bound\")\n    end\n\n    start = start.next\n  end\n\n  if not start or not start.next then\n    error(\"position is out of bound\")\n  end\n\n  start.next = start.next.next\nend\n\n---@return table\nfunction LinkedList:totable()\n  local tbl = {}\n  self:each(function(item)\n    table.insert(tbl, item)\n  end)\n\n  return tbl\nend\n\nreturn setmetatable({}, {\n  ---@return FylerLinkedList\n  __call = function()\n    return setmetatable({}, LinkedList)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/structs/stack.lua", "local List = require(\"fyler.lib.structs.list\")\n\n---@class FylerStack\n---@field items FylerLinkedList\nlocal Stack = {}\nStack.__index = Stack\n\n---@param data any\nfunction Stack:push(data)\n  self.items:insert(1, data)\nend\n\nfunction Stack:pop()\n  assert(not self:is_empty(), \"stack is empty\")\n\n  local data = self.items.node.data\n  self.items:erase(1)\n  return data\nend\n\n---@return any\nfunction Stack:top()\n  assert(self.items.node, \"stack is empty\")\n  return self.items.node.data\nend\n\n---@return boolean\nfunction Stack:is_empty()\n  return self.items:len() == 0\nend\n\nreturn setmetatable({}, {\n  ---@return FylerStack\n  __call = function()\n    return setmetatable({ items = List() }, Stack)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/structs/queue.lua", "local List = require(\"fyler.lib.structs.list\")\n\n---@class FylerQueue\n---@field items FylerLinkedList\nlocal Queue = {}\nQueue.__index = Queue\n\n---@param data any\nfunction Queue:enqueue(data)\n  self.items:insert(self.items:len() + 1, data)\nend\n\n---@return any\nfunction Queue:dequeue()\n  assert(not self:is_empty(), \"Queue is empty\")\n\n  local data = self.items.node.data\n  self.items:erase(1)\n  return data\nend\n\n---@return any\nfunction Queue:front()\n  assert(self.items.node, \"Queue is empty\")\n  return self.items.node.data\nend\n\n---@return boolean\nfunction Queue:is_empty()\n  return self.items:len() == 0\nend\n\nreturn setmetatable({}, {\n  ---@return FylerQueue\n  __call = function()\n    return setmetatable({ items = List() }, Queue)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/integrations/icon/nvim-web-devicons.lua", "local M = {}\n\nlocal fn = vim.fn\n\n---@param type string\n---@param name string\n---@return string?, string?\nfunction M.get_icon(type, name)\n  local success, devicons = pcall(require, \"nvim-web-devicons\")\n  if not success then\n    return nil, nil\n  end\n\n  local icon, hl = devicons.get_icon(name, fn.fnamemodify(name, \":e\"))\n  icon = (type == \"directory\" and \"\" or (icon or \"\"))\n  hl = hl or (type == \"directory\" and \"Fylerblue\" or \"\")\n  return icon, hl\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/store.lua", "local M = {}\n\nlocal count = 0\nlocal store = {}\n\nlocal Metadata = {}\nMetadata.__index = Metadata\n\nfunction Metadata:is_directory()\n  return self.type == \"directory\" or (self.type == \"link\" and self.link_type == \"directory\")\nend\n\nfunction Metadata:resolved_path()\n  return self.type == \"link\" and self.link_path or self.path\nend\n\n---@param key string\nfunction M.get(key)\n  return setmetatable(vim.deepcopy(store[key]), Metadata)\nend\n\n---@param tbl table\n---@return string\nfunction M.set(tbl)\n  count = count + 1\n  local meta = string.format(\"%05d\", count)\n  store[meta] = tbl\n  return meta\nend\n\nfunction M.debug()\n  for k, v in pairs(store) do\n    print(k, vim.inspect(v))\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/regex.lua", "local M = {}\n\n---@param str string\n---@return string\nfunction M.match_meta(str)\n  assert(str, \"str is required\")\n  return str:match(\" /(%d%d%d%d%d)\")\nend\n\n---@param str string\n---@return string\nfunction M.match_indent(str)\n  assert(str, \"str is required\")\n  return str:match(\"^(%s*)\")\nend\n\n---@param str string\n---@return string\nfunction M.match_name(str)\n  assert(str, \"str is required\")\n  if str:match(\"/%d%d%d%d%d\") then\n    return str:match(\"/%d%d%d%d%d (.*)$\")\n  else\n    return str:gsub(\"^%s*\", \"\"):match(\".*\")\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/integrations/icon/mini-icons.lua", "local M = {}\n\n---@param type string\n---@param name string\n---@return string?, string?\nfunction M.get_icon(type, name)\n  local success, miniicons = pcall(require, \"mini.icons\")\n  if not success then\n    return nil, nil\n  end\n\n  return miniicons.get(type, name)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/ui.lua", "local components = require(\"fyler.lib.ui.components\")\n\nlocal Line = components.Line\n\nlocal function MESSAGE(tbl)\n  local lines = {}\n  for _, line in ipairs(tbl or {}) do\n    table.insert(lines, Line { words = line })\n  end\n\n  return lines\nend\n\nlocal M = {}\n\n---@param tbl table\nfunction M.Confirm(tbl)\n  if not tbl then\n    return {}\n  end\n\n  return MESSAGE(tbl)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/actions.lua", "local M = {}\n\n---@param view table\nfunction M.n_close_view(view, cb)\n  return function()\n    cb(false)\n    view:close()\n  end\nend\n\nfunction M.n_confirm(view, cb)\n  return function()\n    cb(true)\n    view:close()\n  end\nend\n\nfunction M.n_discard(view, cb)\n  return function()\n    cb(false)\n    view:close()\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/cache.lua", "local M = {}\n\nlocal cache_table = {}\n\n---@param entry_key string\n---@param val any\nfunction M.set_entry(entry_key, val)\n  cache_table[entry_key] = val\nend\n\n---@param entry_key string\n---@return any\nfunction M.get_entry(entry_key)\n  return vim.deepcopy(cache_table[entry_key])\nend\n\nreturn M\n"], ["/fyler.nvim/syntax/fyler.lua", "if vim.b.current_syntax then\n  return\nend\n\nvim.cmd([[\n  syntax match FylerMetaKey /\\/\\d\\d\\d\\d\\d / conceal\n]])\n\nvim.b.current_syntax = \"fyler\"\n"]], "task_instance_info": {"created_time": "2025-08-21 00:45:12", "created_task_model": "DeepSeek-R1", "code_description": "This code segment functions to: Invert nested key-value relationships within a configuration structure and generate a lookup table for reverse mapping association resolution."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```lua\n[TASK_BEGIN]\nfunction M.get_indentscope(name)\n  assert(name, \"name is required\")\n  return M.values.indentscope[name]\nend\n[TASK_END]\n```", "inference_time": "2025-08-21 00-45-53"}, "editdistance_info": {"edit_distance": 21.9178, "calculate_time": "2025-08-21 00:45:53", "true_code_clean": "function M.get_reverse_mappings(name)\n  assert(name, \"name is required\")\n  local mappings = M.get_mappings(name)\n  local reverse_mappings = {}\n  for _, map in pairs(mappings) do\n    for key, val in pairs(map) do\n      reverse_mappings[val] = key\n    end\n  end\n  return reverse_mappings\nend", "predict_code_clean": "function M.get_indentscope(name)\n  assert(name, \"name is required\")\n  return M.values.indentscope[name]\nend"}}
{"repo_name": "fyler.nvim", "file_name": "/fyler.nvim/lua/fyler/lib/async.lua", "inference_info": {"prefix_code": "local M = {}\n\nlocal queue = require(\"fyler.lib.structs.queue\")() ---@type FylerQueue\nlocal is_loop_running = false\n\n---@param co thread\n---@param ... any\n", "suffix_code": "\n\nfunction M.schedule_async(async_fn)\n  return function(...)\n    schedule(coroutine.create(async_fn), ...)\n  end\nend\n\nfunction M.async(async_fn)\n  return function(...)\n    local ok, err = coroutine.resume(coroutine.create(async_fn), ...)\n    if not ok then\n      error(err)\n    end\n  end\nend\n\nfunction M.await(fn, ...)\n  local thread = coroutine.running()\n  local args = { ... }\n\n  table.insert(\n    args,\n    vim.schedule_wrap(function(...)\n      if not thread then\n        return error(\"no coroutine is running\")\n      end\n\n      coroutine.resume(thread, ...)\n    end)\n  )\n\n  fn(unpack(args))\n\n  return coroutine.yield()\nend\n\nreturn M\n", "middle_code": "local function schedule(co, ...)\n  queue:enqueue {\n    args = { ... },\n    co = co,\n    started = false,\n  }\n  if is_loop_running then\n    return\n  end\n  is_loop_running = true\n  local function loop()\n    if queue:is_empty() then\n      is_loop_running = false\n      return\n    end\n    local front = queue:front()\n    local status = coroutine.status(front.co)\n    if status == \"dead\" then\n      queue:dequeue()\n      vim.defer_fn(loop, 0)\n    elseif status == \"suspended\" and front.started == false then\n      local success = coroutine.resume(front.co, unpack(front.args))\n      if not success then\n        queue:dequeue()\n      end\n      front.started = true\n      vim.defer_fn(loop, 0)\n    else\n      vim.defer_fn(loop, 10)\n    end\n  end\n  vim.defer_fn(loop, 0)\nend", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "lua", "sub_task_type": null}, "context_code": [["/fyler.nvim/lua/fyler/views/explorer/actions.lua", "local a = require(\"fyler.lib.async\")\nlocal algos = require(\"fyler.views.explorer.algos\")\nlocal cache = require(\"fyler.cache\")\nlocal config = require(\"fyler.config\")\nlocal confirm_view = require(\"fyler.views.confirm\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal regex = require(\"fyler.views.explorer.regex\")\nlocal store = require(\"fyler.views.explorer.store\")\nlocal ui = require(\"fyler.views.explorer.ui\")\n\nlocal M = {}\n\nlocal fn = vim.fn\nlocal api = vim.api\n\n---@param view table\nfunction M.n_close_view(view)\n  return function()\n    local success = pcall(api.nvim_win_close, view.win.winid, true)\n    if not success then\n      api.nvim_win_set_buf(view.win.winid, fn.bufnr(\"#\", true))\n    end\n\n    pcall(api.nvim_buf_delete, view.win.bufnr, { force = true })\n  end\nend\n\n---@param view FylerExplorerView\nfunction M.n_select(view)\n  return function()\n    local key = regex.match_meta(api.nvim_get_current_line())\n    if not key then\n      return\n    end\n\n    local meta_data = store.get(key)\n    if meta_data:is_directory() then\n      view.fs_root:find(key):toggle()\n      api.nvim_exec_autocmds(\"User\", { pattern = \"RefreshView\" })\n    else\n      local recent_win = cache.get_entry(\"recent_win\")\n\n      if recent_win and api.nvim_win_is_valid(recent_win) then\n        fn.win_execute(recent_win, string.format(\"edit %s\", meta_data:resolved_path()))\n        fn.win_gotoid(recent_win)\n\n        if config.values.close_on_select then\n          view.win:hide()\n        end\n      end\n    end\n  end\nend\n\n---@param tbl table\n---@return table\nlocal function get_tbl(tbl)\n  local lines = { { { str = \"\", hl = \"\" } } }\n  if not vim.tbl_isempty(tbl.create) then\n    table.insert(lines, { { str = \"# Creation\", hl = \"FylerConfirmGreen\" } })\n    for _, change in ipairs(tbl.create) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  if not vim.tbl_isempty(tbl.delete) then\n    table.insert(lines, { { str = \"# Deletion\", hl = \"FylerConfirmRed\" } })\n    for _, change in ipairs(tbl.delete) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  if not vim.tbl_isempty(tbl.move) then\n    table.insert(lines, { { str = \"# Migration\", hl = \"FylerConfirmYellow\" } })\n    for _, change in ipairs(tbl.move) do\n      table.insert(lines, {\n        { str = \"  | \" },\n        { str = fs.relpath(fs.getcwd(), change.src), hl = \"FylerConfirmGrey\" },\n        { str = \" > \" },\n        { str = fs.relpath(fs.getcwd(), change.dst), hl = \"FylerConfirmGrey\" },\n      })\n    end\n    table.insert(lines, { { str = \"\" } })\n  end\n\n  return lines\nend\n\n---@param changes table\n---@return boolean\nlocal function can_bypass(changes)\n  if not vim.tbl_isempty(changes.delete) then\n    return false\n  end\n\n  if #changes.move > 1 then\n    return false\n  end\n\n  if #changes.create > 5 then\n    return false\n  end\n\n  return true\nend\n\n---@param view FylerExplorerView\nfunction M.synchronize(view)\n  return a.async(function()\n    local changes = algos.get_diff(view)\n    local can_sync = (function()\n      if #changes.create == 0 and #changes.delete == 0 and #changes.move == 0 then\n        return true\n      end\n\n      if not config.values.auto_confirm_simple_edits then\n        return a.await(confirm_view.open, get_tbl(changes), \"(y/n)\")\n      end\n\n      if can_bypass(changes) then\n        return true\n      end\n\n      return a.await(confirm_view.open, get_tbl(changes), \"(y/n)\")\n    end)()\n\n    if can_sync then\n      for _, change in ipairs(changes.create) do\n        local err, success = a.await(fs.create, change)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n\n      for _, change in ipairs(changes.delete) do\n        local err, success = a.await(fs.delete, change)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n\n      for _, change in ipairs(changes.move) do\n        local err, success = a.await(fs.move, change.src, change.dst)\n        if not success then\n          vim.schedule(function()\n            vim.notify(err, vim.log.levels.ERROR)\n          end)\n        end\n      end\n    end\n\n    vim.schedule(function()\n      api.nvim_exec_autocmds(\"User\", { pattern = \"RefreshView\" })\n    end)\n  end)\nend\n\n---@param view FylerExplorerView\n---@param on_render function\nfunction M.refreshview(view, on_render)\n  return a.async(function()\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    a.await(view.fs_root.update, view.fs_root)\n\n    vim.bo[view.win.bufnr].undolevels = -1\n\n    view.win.ui:render {\n      ui_lines = a.await(ui.Explorer, algos.tree_table_from_node(view).children),\n      on_render = function()\n        if on_render then\n          on_render()\n        end\n\n        M.draw_indentscope(view)()\n\n        if not view.win:has_valid_bufnr() then\n          return\n        end\n\n        vim.bo[view.win.bufnr].undolevels = vim.go.undolevels\n      end,\n    }\n\n    vim.bo[view.win.bufnr].syntax = \"fyler\"\n    vim.bo[view.win.bufnr].filetype = \"fyler\"\n  end)\nend\n\nfunction M.constrain_cursor(view)\n  return function()\n    local cur = api.nvim_get_current_line()\n    local meta = regex.match_meta(cur)\n    if not meta then\n      return\n    end\n\n    local _, ub = string.find(cur, meta)\n    if not view.win:has_valid_winid() then\n      return\n    end\n\n    local row, col = unpack(api.nvim_win_get_cursor(view.win.winid))\n    if col <= ub then\n      api.nvim_win_set_cursor(view.win.winid, { row, ub + 1 })\n    end\n  end\nend\n\n---@param view FylerExplorerView\nfunction M.try_focus_buffer(view)\n  return a.schedule_async(function(arg)\n    local explorer = require(\"fyler.views.explorer\")\n\n    if not view.win:is_visible() then\n      return\n    end\n\n    if arg.file == \"\" then\n      return\n    end\n\n    if string.match(arg.file, \"^fyler://*\") then\n      local recent_win = cache.get_entry(\"recent_win\")\n      if (type(recent_win) ~= \"number\") or (not api.nvim_win_is_valid(recent_win)) then\n        return\n      end\n\n      local recent_bufname = fn.bufname(api.nvim_win_get_buf(recent_win))\n      if recent_bufname == \"\" or string.match(recent_bufname, \"^fyler://*\") then\n        return\n      end\n\n      arg.file = fs.abspath(recent_bufname)\n    end\n\n    if not vim.startswith(arg.file, view.cwd) then\n      explorer.open {\n        enter = fn.bufname(\"%\") == view.win.bufname,\n        cwd = fn.fnamemodify(arg.file, \":h\"),\n      }\n    end\n\n    local relpath = fs.relpath(view.cwd, arg.file)\n    if not relpath then\n      return\n    end\n\n    local focused_node = view.fs_root\n    local last_visit = 0\n    local parts = vim.split(relpath, \"/\")\n\n    a.await(focused_node.update, focused_node)\n\n    for i, part in ipairs(parts) do\n      local child = vim.iter(focused_node.children):find(function(child)\n        return store.get(child.meta).name == part\n      end)\n\n      if not child then\n        break\n      end\n\n      if store.get(child.meta):is_directory() then\n        child.open = true\n        a.await(child.update, child)\n      end\n\n      focused_node, last_visit = child, i\n    end\n\n    if last_visit ~= #parts then\n      return\n    end\n\n    M.refreshview(view, function()\n      if not view.win:has_valid_winid() then\n        return\n      end\n\n      local buf_lines = api.nvim_buf_get_lines(view.win.bufnr, 0, -1, false)\n      for ln, buf_line in ipairs(buf_lines) do\n        if buf_line:find(focused_node.meta) then\n          api.nvim_win_set_cursor(view.win.winid, { ln, 0 })\n        end\n      end\n    end)()\n  end)\nend\n\nlocal extmark_namespace = api.nvim_create_namespace(\"FylerIndentScope\")\n\n---@param view FylerExplorerView\nfunction M.draw_indentscope(view)\n  local function draw_line(ln)\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    local cur_line = unpack(api.nvim_buf_get_lines(view.win.bufnr, ln - 1, ln, false))\n    local cur_indent = #regex.match_indent(cur_line)\n    if cur_indent == 0 then\n      return\n    end\n\n    local indent_depth = math.floor(cur_indent * 0.5)\n    for i = 1, indent_depth do\n      api.nvim_buf_set_extmark(view.win.bufnr, extmark_namespace, ln - 1, 0, {\n        hl_mode = \"combine\",\n        virt_text = {\n          {\n            config.values.indentscope.marker,\n            config.values.indentscope.group,\n          },\n        },\n        virt_text_pos = \"overlay\",\n        virt_text_win_col = (i - 1) * 2,\n      })\n    end\n  end\n\n  return function()\n    if not view.win:has_valid_bufnr() then\n      return\n    end\n\n    if not config.values.indentscope.enabled then\n      return\n    end\n\n    api.nvim_buf_clear_namespace(view.win.bufnr, extmark_namespace, 0, -1)\n    for i = 1, api.nvim_buf_line_count(view.win.bufnr) do\n      draw_line(i)\n    end\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/fs.lua", "local List = require(\"fyler.lib.structs.list\")\nlocal Stack = require(\"fyler.lib.structs.stack\")\n\nlocal a = require(\"fyler.lib.async\")\n\nlocal M = {}\n\nlocal api = vim.api\n\nlocal uv = vim.uv or vim.loop\nlocal fn = vim.fn\n\n---@return string\nfunction M.getcwd()\n  return uv.cwd() or fn.getcwd(0)\nend\n\n---@param path string\n---@return string\nfunction M.normalize(path)\n  return vim.fs.normalize(path)\nend\n\n---@return string\nfunction M.joinpath(...)\n  return vim.fs.joinpath(...)\nend\n\n---@param path string\n---@return string\nfunction M.abspath(path)\n  return vim.fs.abspath(path)\nend\n\n---@param path string\nfunction M.relpath(base, path)\n  return vim.fs.relpath(base, path)\nend\n\n---@param path string\n---@return string?, string?\nfunction M.resolve_link(path)\n  local res_path = nil\n  local res_type = nil\n  while true do\n    local stat = uv.fs_stat(path)\n    if not stat then\n      break\n    end\n\n    local linkdata = uv.fs_readlink(path)\n    if not linkdata then\n      res_path = path\n      res_type = stat.type\n      break\n    end\n\n    path = linkdata\n  end\n\n  return res_path, res_type\nend\n\n---@param path string\n---@param cb fun(err?: string, items: table)\nM.ls = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, {})\n  end\n\n  ---@diagnostic disable-next-line: param-type-mismatch\n  local dir = uv.fs_opendir(path, nil, 1000)\n  local items = {}\n\n  while true do\n    local _, entries = a.await(uv.fs_readdir, dir)\n    if not entries then\n      break\n    end\n\n    items = vim.list_extend(\n      items,\n      vim\n        .iter(entries)\n        :map(function(entry)\n          local link_path, link_type = M.resolve_link(M.joinpath(path, entry.name))\n          return {\n            name = entry.name,\n            type = entry.type,\n            path = M.joinpath(path, entry.name),\n            link_path = link_path,\n            link_type = link_type,\n          }\n        end)\n        :totable()\n    )\n  end\n\n  return cb(nil, items)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.touch = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if stat then\n    return cb(stat_err, false)\n  end\n\n  local fd_err, fd = a.await(uv.fs_open, path, \"a\", 420)\n  if not fd then\n    return cb(fd_err, false)\n  end\n\n  return cb(a.await(uv.fs_close, fd))\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rm = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat or stat.type == \"directory\" then\n    return cb(stat_err, false)\n  end\n\n  local unlink_err, success = a.await(uv.fs_unlink, path)\n  if not success then\n    return cb(unlink_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rm_r = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, false)\n  end\n\n  local stk, lst = Stack(), List()\n\n  stk:push { path = path, type = stat.type }\n\n  while not stk:is_empty() do\n    local cur_entry = stk:pop()\n\n    lst:insert(1, cur_entry)\n\n    if cur_entry.type == \"directory\" then\n      local ls_err, entries = a.await(M.ls, cur_entry.path)\n      if ls_err then\n        return cb(ls_err, false)\n      end\n\n      for _, entry in ipairs(entries) do\n        stk:push(entry)\n      end\n    end\n  end\n\n  for _, entry in ipairs(lst:totable()) do\n    if entry.type == \"directory\" then\n      local rmdir_err, rmdir_success = a.await(M.rmdir, entry.path)\n      if not rmdir_success then\n        return cb(rmdir_err, false)\n      end\n    else\n      local rm_err, rm_success = a.await(M.rm, entry.path)\n      if not rm_success then\n        return cb(rm_err, false)\n      end\n    end\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.mkdir = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if stat and stat.type == \"directory\" then\n    return cb(stat_err, false)\n  end\n\n  local mkdir_err, success = a.await(uv.fs_mkdir, path, 493)\n  if not success then\n    return cb(mkdir_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.mkdir_p = a.async(function(path, cb)\n  local parts = vim\n    .iter(vim.split(path, \"/\"))\n    :filter(function(part)\n      return part ~= \"\"\n    end)\n    :totable()\n\n  local is_win = fn.has(\"win32\") == 1 or fn.has(\"win64\") == 1\n\n  local dir = is_win and parts[1] or \"\"\n\n  local start_idx = is_win and 2 or 1\n  for i = start_idx, #parts do\n    dir = dir .. string.format(\"/%s\", parts[i])\n\n    local _, stat = a.await(uv.fs_stat, dir)\n    if not stat then\n      local mkdir_err, mkdir_success = a.await(M.mkdir, dir)\n      if not mkdir_success then\n        return cb(mkdir_err, false)\n      end\n    end\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.rmdir = a.async(function(path, cb)\n  local stat_err, stat = a.await(uv.fs_stat, path)\n  if not stat then\n    return cb(stat_err, false)\n  end\n\n  local rmdir_err, success = a.await(uv.fs_rmdir, path)\n  if not success then\n    return cb(rmdir_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param src_path string\n---@param dst_path string\n---@param cb fun(err?: string, success: boolean)\nM.mv = a.async(function(src_path, dst_path, cb)\n  local stat_err, src_stat = a.await(uv.fs_stat, src_path)\n  if not src_stat then\n    return cb(stat_err, false)\n  end\n\n  local _, dst_stat = a.await(uv.fs_stat, dst_path)\n  if dst_stat then\n    return cb(\"Destination path already exists\", false)\n  end\n\n  local rename_err, rename_success = a.await(uv.fs_rename, src_path, dst_path)\n  if not rename_success then\n    return cb(rename_err, false)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.create = a.async(function(path, cb)\n  local mkdirp_err, mkdirp_success =\n    a.await(M.mkdir_p, fn.fnamemodify(path, vim.endswith(path, \"/\") and \":h:h\" or \":h\"))\n  if not mkdirp_success then\n    return cb(mkdirp_err, false)\n  end\n\n  if vim.endswith(path, \"/\") then\n    local mkdir_err, mkdir_success = a.await(M.mkdir, path)\n    if not mkdir_success then\n      return cb(mkdir_err, false)\n    end\n  else\n    local touch_err, touch_success = a.await(M.touch, path)\n    if not touch_success then\n      return cb(touch_err, false)\n    end\n  end\n\n  return cb(nil, true)\nend)\n\nlocal function get_alt_buf(for_buf)\n  for _, buf in ipairs(api.nvim_list_bufs()) do\n    if api.nvim_buf_is_valid(buf) and buf ~= for_buf then\n      return buf\n    end\n  end\n\n  return api.nvim_create_buf(false, true)\nend\n\n---@param path string\n---@param cb fun(err?: string, success: boolean)\nM.delete = a.async(function(path, cb)\n  local rm_r_err, rm_r_success = a.await(M.rm_r, path)\n  if not rm_r_success then\n    return cb(rm_r_err, false)\n  end\n\n  local buf = fn.bufnr(path)\n  if buf == -1 then\n    return cb(\"Unable to find buffer to delete\", true)\n  end\n\n  local alt = get_alt_buf(buf)\n  for _, win in ipairs(api.nvim_list_wins()) do\n    if api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) == buf then\n      if alt < 1 or alt == buf then\n        alt = api.nvim_create_buf(true, false)\n      end\n\n      api.nvim_win_set_buf(win, alt)\n    end\n  end\n\n  local success, msg = pcall(api.nvim_buf_delete, buf, { force = true })\n  if not success then\n    return cb(msg, true)\n  end\n\n  return cb(nil, true)\nend)\n\n---@param src_path string\n---@param dst_path string\n---@param cb fun(err?: string, success: boolean)\nM.move = a.async(function(src_path, dst_path, cb)\n  local mkdirp_err, mkdirp_success = a.await(M.mkdir_p, fn.fnamemodify(dst_path, \":h\"))\n  if not mkdirp_success then\n    return cb(mkdirp_err, false)\n  end\n\n  local mv_err, mv_success = a.await(M.mv, src_path, dst_path)\n  if not mv_success then\n    return cb(mv_err, false)\n  end\n\n  local src_buf = fn.bufnr(src_path)\n  if src_buf == -1 then\n    return cb(\"unable to find moved buffer\", true)\n  end\n\n  local dst_buf = fn.bufadd(dst_path)\n  fn.bufload(dst_buf)\n  vim.bo[dst_buf].buflisted = true\n\n  for _, win in ipairs(api.nvim_list_wins()) do\n    if api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) == src_buf then\n      api.nvim_win_set_buf(win, dst_buf)\n    end\n  end\n\n  local success, msg = pcall(api.nvim_buf_delete, src_buf, { force = true })\n  if not success then\n    return cb(msg, true)\n  end\n\n  return cb(nil, true)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/ui.lua", "local a = require(\"fyler.lib.async\")\nlocal components = require(\"fyler.lib.ui.components\")\nlocal config = require(\"fyler.config\")\nlocal git = require(\"fyler.lib.git\")\n\nlocal icon_provider = (function()\n  if type(config.values.icon_provider) == \"function\" then\n    return config.values.icon_provider\n  else\n    return require(\"fyler.integrations.icon\")[config.values.icon_provider]\n  end\nend)()\n\nlocal Line = components.Line\n\nlocal M = {}\n\n-- stylua: ignore start\nlocal git_status_hl = setmetatable({\n  [\"  \"] = \"FylerGitAdded\",\n  [\"UU\"] = \"FylerGitConflict\",\n  [\" D\"] = \"FylerGitDeleted\",\n  [\"!!\"] = \"FylerGitIgnored\",\n  [\" M\"] = \"FylerGitModified\",\n  [\"R \"] = \"FylerGitRenamed\",\n  [\"M \"] = \"FylerGitStaged\",\n  [\"??\"] = \"FylerGitUntracked\",\n  [\"MM\"] = \"FylerGitUnstaged\",\n}, {\n  __index = function()\n    return \"\"\n  end,\n})\n-- stylua: ignore end\n\nlocal function get_sorted(tbl)\n  table.sort(tbl, function(x, y)\n    if x:is_directory() and not y:is_directory() then\n      return true\n    elseif not x:is_directory() and y:is_directory() then\n      return false\n    else\n      return x.name < y.name\n    end\n  end)\n\n  return tbl\nend\n\nlocal TREE_STRUCTURE\n---@param tbl table\n---@param status_map? table\n---@param cb fun(lines: FylerUiLine[])\nTREE_STRUCTURE = a.async(function(tbl, status_map, depth, cb)\n  depth = depth or 0\n  if not tbl then\n    return cb {}\n  end\n\n  local lines = {}\n  for _, item in ipairs(get_sorted(tbl)) do\n    local icon, hl = (function()\n      if item.type == \"directory\" then\n        return icon_provider(item.type, item.name)\n      elseif item.type == \"link\" then\n        return icon_provider(item.link_type, item.name)\n      else\n        return icon_provider(item.type, item.name)\n      end\n    end)()\n\n    local git_symbol = (function()\n      if not status_map then\n        return nil\n      end\n\n      if status_map[item.path] then\n        return status_map[item.path]\n      end\n\n      return nil\n    end)()\n\n    table.insert(\n      lines,\n      Line {\n        words = {\n          { str = string.rep(\"  \", depth) },\n          {\n            str = icon,\n            hl = (function()\n              if item.type == \"directory\" then\n                return \"FylerFSDirectory\"\n              elseif item.link_type == \"directory\" then\n                return \"FylerFSDirectory\"\n              else\n                return hl\n              end\n            end)(),\n          },\n          {\n            str = git_symbol and string.format(\" %s \", git_symbol) or \" \",\n            hl = git_status_hl[git_symbol],\n          },\n          { str = string.format(\"/%s\", item.meta) },\n          {\n            str = string.format(\" %s\", item.name),\n            hl = (function()\n              if git_symbol then\n                return git_status_hl[git_symbol]\n              elseif item.type == \"directory\" then\n                return \"FylerFSDirectory\"\n              elseif item.link_type == \"directory\" then\n                return \"FylerFSDirectory\"\n              else\n                return \"\"\n              end\n            end)(),\n          },\n        },\n        marks = (function()\n          local line = {}\n          if item.type == \"link\" then\n            table.insert(line, {\n              hl = \"FylerFSLink\",\n              str = string.format(\" %s\", item.link_path),\n            })\n          end\n\n          return line\n        end)(),\n      }\n    )\n\n    if item.children then\n      for _, line in ipairs(a.await(TREE_STRUCTURE, item.children, status_map, depth + 1)) do\n        table.insert(lines, line)\n      end\n    end\n  end\n\n  return cb(lines)\nend)\n\nM.Explorer = a.async(function(tbl, cb)\n  return cb(a.await(TREE_STRUCTURE, tbl, config.values.git_status and a.await(git.status_map) or {}, 0))\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/git.lua", "local a = require(\"fyler.lib.async\")\nlocal fs = require(\"fyler.lib.fs\")\n\nlocal M = {}\n\n---@param cb fun(result: boolean)\nlocal is_git_repo = a.async(function(cb)\n  local out = a.await(vim.system, { \"git\", \"rev-parse\", \"--is-inside-work-tree\" }, nil) ---@type vim.SystemCompleted\n  return cb(string.match(out.stdout, \"^(.*)\\n$\") == \"true\")\nend)\n\n---@param cb fun(status?: string)\nlocal git_status = a.async(function(cb)\n  if not a.await(is_git_repo) then\n    return cb(nil)\n  end\n\n  local out = a.await(vim.system, { \"git\", \"status\", \"--porcelain\", \"-z\" }, nil) ---@type vim.SystemCompleted\n  if not out.stdout then\n    return cb(nil)\n  end\n\n  return cb(out.stdout)\nend)\n\n---@param cb fun(path?: string)\nlocal git_toplevel = a.async(function(cb)\n  local out = a.await(vim.system, { \"git\", \"rev-parse\", \"--show-toplevel\" }, nil) ---@type vim.SystemCompleted\n  if not out.stdout then\n    return cb(nil)\n  end\n\n  return cb(string.match(out.stdout, \"^(.*)\\n$\"))\nend)\n\n---@param cb fun(status_map?: table)\nM.status_map = a.async(function(cb)\n  local status_str = a.await(git_status)\n  if not status_str then\n    return cb(nil)\n  end\n\n  local statuses = vim\n    .iter(vim.split(status_str, \"\\0\"))\n    :filter(function(status)\n      if status == \"\" then\n        return false\n      end\n\n      return true\n    end)\n    :totable()\n\n  local toplevel = a.await(git_toplevel)\n  if not toplevel then\n    return cb(nil)\n  end\n\n  local status_map = {}\n  for _, status in ipairs(statuses) do\n    local symbol, path = (function()\n      if string.match(status, \"^.*%s.*$\") then\n        return string.match(status, \"^(.*)%s(.*)$\")\n      else\n        return nil, status\n      end\n    end)()\n\n    status_map[fs.joinpath(toplevel, fs.normalize(path))] = symbol\n  end\n\n  return cb(status_map)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/init.lua", "local FSItem = require(\"fyler.views.explorer.struct\")\nlocal Win = require(\"fyler.lib.win\")\nlocal a = require(\"fyler.lib.async\")\nlocal config = require(\"fyler.config\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal store = require(\"fyler.views.explorer.store\")\n\nlocal fn = vim.fn\nlocal api = vim.api\n\n---@class FylerExplorerView\n---@field cwd     string      - Directory path which act as a root\n---@field fs_root FylerFSItem - Root |FylerFSItem| instance\n---@field win     FylerWin    - Window instance\nlocal ExplorerView = {}\nExplorerView.__index = ExplorerView\n\nfunction ExplorerView.new(opts)\n  local fs_root = FSItem(store.set {\n    name = fn.fnamemodify(opts.cwd, \":t\"),\n    type = \"directory\",\n    path = opts.cwd,\n  })\n\n  fs_root:toggle()\n\n  local instance = {\n    cwd = opts.cwd,\n    fs_root = fs_root,\n    kind = opts.kind,\n  }\n\n  setmetatable(instance, ExplorerView)\n\n  return instance\nend\n\nExplorerView.open = a.async(function(self, opts)\n  local mappings = config.get_reverse_mappings(\"explorer\")\n  local view = config.get_view(\"explorer\")\n\n  -- stylua: ignore start\n  self.win = Win {\n    border   = view.border,\n    buf_opts = view.buf_opts,\n    bufname  = string.format(\"fyler://%s\", self.cwd),\n    enter    = opts.enter,\n    height   = view.height,\n    kind     = opts.kind or view.kind,\n    name     = \"explorer\",\n    width    = view.width,\n    win_opts = view.win_opts,\n    mappings = {\n      n = {\n        [mappings[\"Select\"]]    = self:_action(\"n_select\"),\n        [mappings[\"CloseView\"]] = self:_action(\"n_close_view\"),\n      },\n    },\n    autocmds = {\n      [\"BufReadCmd\"]   = self:_action(\"refreshview\"),\n      [\"BufWriteCmd\"]  = self:_action(\"synchronize\"),\n      [\"CursorMoved\"]  = self:_action(\"constrain_cursor\"),\n      [\"CursorMovedI\"] = self:_action(\"constrain_cursor\"),\n      [\"WinClosed\"]    = self:_action(\"n_close_view\"),\n    },\n    user_autocmds = {\n      [\"RefreshView\"] = self:_action(\"refreshview\"),\n      [\"Synchronize\"] = self:_action(\"synchronize\"),\n    },\n    render = self:_action(\"refreshview\"),\n  }\n  -- stylua: ignore end\n\n  require(\"fyler.cache\").set_entry(\"recent_win\", api.nvim_get_current_win())\n\n  self.win:show()\nend)\n\n---@param ... any\nfunction ExplorerView:_action(name, ...)\n  local action = require(\"fyler.views.explorer.actions\")[name]\n\n  assert(action, string.format(\"%s action is not available\", name))\n\n  return action(self, ...)\nend\n\nlocal M = {\n  instance = nil, ---@type FylerExplorerView\n}\n\n---@param opts { cwd?: string, kind?: FylerWinKind }\n---@return FylerExplorerView\nfunction M.get_instance(opts)\n  if (not M.instance) or (M.instance.cwd ~= opts.cwd) then\n    M.instance = ExplorerView.new {\n      cwd = opts.cwd,\n      kind = opts.kind,\n    }\n  end\n\n  return M.instance\nend\n\n---@param opts? { enter?: boolean, cwd?: string, kind?: FylerWinKind }\nfunction M.open(opts)\n  opts = opts or {}\n  opts.enter = opts.enter == nil and true or opts.enter\n  opts.cwd = opts.cwd or fs.getcwd()\n  opts.kind = opts.kind or config.get_view(\"explorer\").kind\n\n  if M.instance and fn.winbufnr(M.instance.win.winid) == M.instance.win.bufnr then\n    M.instance.win:hide()\n  end\n\n  M.get_instance(opts):open(opts)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/ui/init.lua", "local api = vim.api\n\n---@class FylerUi\n---@field win FylerWin\nlocal Ui = {}\nUi.__index = Ui\n\nlocal M = setmetatable({}, {\n  ---@param win FylerWin\n  ---@return FylerUi\n  __call = function(_, win)\n    assert(win, \"win is required\")\n\n    return setmetatable({ win = win }, Ui)\n  end,\n})\n\n---@param align FylerUiLineAlign\n---@param line string\n---@return string\nlocal function get_margin(width, align, line)\n  if align == \"center\" then\n    return string.rep(\" \", math.floor((width - #line) * 0.5))\n  elseif align == \"end\" then\n    return string.rep(\" \", math.floor((width - #line)))\n  else\n    return \"\"\n  end\nend\n\n---@param ui_lines FylerUiLine[]\nfunction Ui:_render(ui_lines)\n  if not self.win:has_valid_bufnr() then\n    return\n  end\n\n  local was_modifiable = vim.bo[self.win.bufnr].modifiable\n  local win_width = api.nvim_win_get_width(self.win.winid)\n  local buf_lines = {}\n\n  vim.bo[self.win.bufnr].modifiable = true\n\n  for _, line in ipairs(ui_lines) do\n    local line_text = table.concat(vim.tbl_map(function(word)\n      return word.str\n    end, line.words))\n\n    local margin = get_margin(win_width, line.align, line_text)\n\n    table.insert(line.words, 1, {\n      str = margin,\n    })\n\n    table.insert(buf_lines, margin .. line_text)\n  end\n\n  api.nvim_buf_set_lines(self.win.bufnr, 0, -1, false, buf_lines)\n  api.nvim_buf_clear_namespace(self.win.bufnr, self.win.namespace, 0, -1)\n\n  for i, line in ipairs(ui_lines) do\n    local offset = 0\n\n    for _, word in ipairs(line.words) do\n      api.nvim_buf_set_extmark(self.win.bufnr, self.win.namespace, i - 1, offset, {\n        end_col = offset + #word.str,\n        hl_group = word.hl or \"\",\n      })\n\n      offset = offset + #word.str\n    end\n\n    for _, mark in pairs(line.marks) do\n      api.nvim_buf_set_extmark(self.win.bufnr, self.win.namespace, i - 1, 0, {\n        virt_text = { { mark.str, mark.hl or \"\" } },\n        virt_text_pos = \"eol\",\n        hl_mode = \"combine\",\n      })\n    end\n  end\n\n  if not was_modifiable then\n    vim.bo[self.win.bufnr].modifiable = false\n  end\n\n  vim.bo[self.win.bufnr].modified = false\nend\n\nfunction Ui:render(opts)\n  opts = opts or {}\n\n  vim.schedule(function()\n    self:_render(opts.ui_lines)\n    if opts.on_render then\n      opts.on_render()\n    end\n  end)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/integrations/icon/init.lua", "---@param type string\n---@param _ string\n---@return string?, string?\nlocal function default_icon_provider(type, _)\n  if type == \"directory\" then\n    return \"D\", \"FylerFSDirectory\"\n  elseif type == \"file\" then\n    return \"F\", \"FylerFSFile\"\n  else\n    return \"*\", \"\"\n  end\nend\n\nreturn setmetatable({}, {\n  __index = function(_, key)\n    local status, icon_provider = pcall(require, string.format(\"fyler.integrations.icon.%s\", key))\n    if not status then\n      return default_icon_provider\n    end\n\n    return function(...)\n      local success, icon, hl = pcall(icon_provider.get_icon, ...)\n      if not success then\n        return default_icon_provider(...)\n      end\n\n      return icon, hl\n    end\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/views/confirm/init.lua", "local Win = require(\"fyler.lib.win\")\nlocal config = require(\"fyler.config\")\nlocal ui = require(\"fyler.views.confirm.ui\")\n\n---@class FylerConfirmView\n---@field win FylerWin\nlocal FylerConfirmView = {}\nFylerConfirmView.__index = FylerConfirmView\n\n---@param msg { str: string, hl: string }[]\n---@param chs string\n---@param cb fun(c: boolean)\nfunction FylerConfirmView:open(msg, chs, cb)\n  local mappings = config.get_reverse_mappings(\"confirm\")\n  local view = config.get_view(\"confirm\")\n\n  --stylua: ignore start\n  self.win = Win {\n    border   = view.border,\n    buf_opts = view.buf_opts,\n    bufname  = \"confirm\",\n    enter    = true,\n    height   = view.height,\n    kind     = view.kind,\n    name     = \"confirm\",\n    title    = string.format(\" Confirm %s \", chs),\n    width    = view.width,\n    win_opts = view.win_opts,\n    mappings = {\n      n = {\n        [mappings[\"Confirm\"]] = self:_action(\"n_confirm\", cb),\n        [mappings[\"Discard\"]] = self:_action(\"n_discard\", cb),\n      },\n    },\n    autocmds = {\n      [\"QuitPre\"] = self:_action(\"n_close_view\", cb),\n    },\n    render = function()\n      self.win.ui:render({ ui_lines = ui.Confirm(msg) })\n    end,\n  }\n  --stylua: ignore end\n\n  self.win:show()\nend\n\nfunction FylerConfirmView:close()\n  self.win:hide()\nend\n\n---@param name string\nfunction FylerConfirmView:_action(name, ...)\n  local action = require(\"fyler.views.confirm.actions\")[name]\n\n  assert(action, string.format(\"%s action is not available\", name))\n\n  return action(self, ...)\nend\n\nlocal M = {}\n\n---@param msg { str: string, hl: string }[]\n---@param chs string\n---@param cb fun(c: boolean)\nM.open = vim.schedule_wrap(function(msg, chs, cb)\n  if not M.instance then\n    M.instance = setmetatable({}, FylerConfirmView)\n  end\n\n  if M.instance.win and M.instance.win:has_valid_winid() then\n    M.instance:close()\n  end\n\n  M.instance:open(msg, chs, cb)\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/algos.lua", "local fs = require(\"fyler.lib.fs\")\nlocal regex = require(\"fyler.views.explorer.regex\")\nlocal store = require(\"fyler.views.explorer.store\")\nlocal M = {}\n\nlocal api = vim.api\n\n---@param view FylerExplorerView\n---@return table\nfunction M.tree_table_from_node(view)\n  ---@param node FylerFSItem\n  local function get_tbl(node)\n    local sub_tbl = store.get(node.meta)\n    sub_tbl.meta = node.meta\n\n    if sub_tbl:is_directory() then\n      sub_tbl.children = {}\n    end\n\n    if not node.open then\n      return sub_tbl\n    end\n\n    for _, child in ipairs(node.children) do\n      table.insert(sub_tbl.children, get_tbl(child))\n    end\n\n    return sub_tbl\n  end\n\n  return get_tbl(view.fs_root)\nend\n\n---@param view FylerExplorerView\n---@return table\nfunction M.tree_table_from_buffer(view)\n  if not view.win:has_valid_bufnr() then\n    return {}\n  end\n\n  local buf_lines = vim\n    .iter(api.nvim_buf_get_lines(view.win.bufnr, 0, -1, false))\n    :filter(function(buf_line)\n      return buf_line ~= \"\"\n    end)\n    :totable()\n\n  local root = vim.tbl_deep_extend(\"force\", store.get(view.fs_root.meta), {\n    meta = view.fs_root.meta,\n    children = {},\n  })\n\n  local stack = {\n    { node = root, indent = -1 },\n  }\n\n  for _, buf_line in ipairs(buf_lines) do\n    local meta = regex.match_meta(buf_line)\n    local name = regex.match_name(buf_line)\n    local indent = regex.match_indent(buf_line)\n    local metadata = meta and store.get(meta)\n\n    while #stack > 1 and #stack[#stack].indent >= #indent do\n      table.remove(stack)\n    end\n\n    local parent = stack[#stack].node\n    local path = fs.joinpath(parent.path, name)\n    local new_node = {\n      meta = meta,\n      name = name,\n      type = (metadata or {}).type or \"\",\n      path = path,\n    }\n\n    table.insert(parent.children, new_node)\n    if metadata and metadata:is_directory() then\n      new_node.children = {}\n      table.insert(stack, { node = new_node, indent = indent })\n    end\n  end\n\n  return root\nend\n\n---@param view FylerExplorerView\n---@return table\nfunction M.get_diff(view)\n  local recent_tree_hash = {}\n\n  local function save_hash(root)\n    recent_tree_hash[root.meta] = root.path\n    for _, child in ipairs(root.children or {}) do\n      save_hash(child)\n    end\n  end\n\n  save_hash(M.tree_table_from_node(view))\n\n  local fs_actions = {\n    create = {},\n    delete = {},\n    move = {},\n  }\n\n  local function calculate_fs_actions(root)\n    if not root.meta then\n      table.insert(fs_actions.create, root.path)\n    else\n      if recent_tree_hash[root.meta] ~= root.path then\n        table.insert(fs_actions.move, { src = recent_tree_hash[root.meta], dst = root.path })\n      end\n\n      recent_tree_hash[root.meta] = nil\n    end\n\n    for _, child in ipairs(root.children or {}) do\n      calculate_fs_actions(child)\n    end\n  end\n\n  calculate_fs_actions(M.tree_table_from_buffer(view))\n\n  for _, v in pairs(recent_tree_hash) do\n    if v then\n      table.insert(fs_actions.delete, v)\n    end\n  end\n\n  return fs_actions\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler.lua", "local M = {}\n\nlocal did_setup = false\n\nlocal api = vim.api\nlocal fn = vim.fn\n\n---@param opts FylerConfig\nfunction M.setup(opts)\n  if fn.has(\"nvim-0.11\") ~= 1 then\n    return vim.notify(\"Fyler requires at least NVIM 0.11\")\n  end\n\n  if did_setup then\n    return\n  end\n\n  require(\"fyler.config\").setup(opts)\n  require(\"fyler.lib.hls\").setup(require(\"fyler.config\"))\n  require(\"fyler.autocmds\").setup(require(\"fyler.config\"))\n\n  if require(\"fyler.config\").values.default_explorer then\n    vim.g.loaded_netrw = 1\n    vim.g.loaded_netrwPlugin = 1\n    if fn.exists(\"#FileExplorer\") then\n      api.nvim_create_augroup(\"FileExplorer\", { clear = true })\n    end\n\n    if vim.v.vim_did_enter == 0 then\n      local arg_path = fn.argv(0)\n      local first_arg = type(arg_path) == \"string\" and arg_path or arg_path[1]\n      if fn.isdirectory(first_arg) == 0 then\n        return\n      end\n\n      local current_bufnr = api.nvim_get_current_buf()\n      if api.nvim_buf_is_valid(current_bufnr) then\n        api.nvim_buf_delete(current_bufnr, { force = true })\n      end\n\n      M.open { cwd = arg_path }\n    end\n  end\n\n  did_setup = true\nend\n\nM.open = vim.schedule_wrap(function(opts)\n  opts = opts or {}\n\n  require(\"fyler.views.explorer\").open {\n    cwd = opts.cwd,\n    kind = opts.kind,\n  }\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/autocmds.lua", "local M = {}\n\nlocal api = vim.api\nlocal uv = vim.uv or vim.loop\n\nlocal augroup = api.nvim_create_augroup(\"Fyler\", { clear = true })\n\nfunction M.setup(opts)\n  opts = opts or {}\n\n  api.nvim_create_autocmd(\"ColorScheme\", {\n    group = augroup,\n    callback = function()\n      require(\"fyler.lib.hls\").setup()\n    end,\n  })\n\n  api.nvim_create_autocmd(\"BufEnter\", {\n    group = augroup,\n    callback = function(...)\n      local cur_instance = require(\"fyler.views.explorer\").instance\n      if cur_instance then\n        cur_instance:_action(\"try_focus_buffer\")(...)\n      end\n    end,\n  })\n\n  api.nvim_create_autocmd(\"BufEnter\", {\n    group = augroup,\n    callback = vim.schedule_wrap(function(arg)\n      local explorer = require(\"fyler.views.explorer\").instance\n      if not explorer then\n        return\n      end\n\n      if vim.fn.bufname(arg.buf) == explorer.win.bufname then\n        return\n      end\n\n      if api.nvim_get_current_win() == explorer.win.winid then\n        for option, _ in pairs(require(\"fyler.config\").get_view(\"explorer\").win_opts) do\n          if not explorer.win:has_valid_winid() then\n            return\n          end\n\n          vim.wo[explorer.win.winid][option] = vim.w[explorer.win.winid][option]\n        end\n      end\n    end),\n  })\n\n  if opts.values.default_explorer then\n    api.nvim_create_autocmd(\"BufEnter\", {\n      group = augroup,\n      callback = function(arg)\n        local stats = uv.fs_stat(arg.file)\n\n        if stats and stats.type == \"directory\" then\n          local cur_buf = api.nvim_get_current_buf()\n\n          if api.nvim_buf_is_valid(cur_buf) then\n            api.nvim_buf_delete(cur_buf, { force = true })\n          end\n\n          require(\"fyler\").open { cwd = arg.file }\n        end\n      end,\n    })\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/win.lua", "local Ui = require(\"fyler.lib.ui\")\n\nlocal api = vim.api\n\n---@alias FylerWinKind\n---| \"float\"\n---| \"split:left\"\n---| \"split:above\"\n---| \"split:right\"\n---| \"split:below\"\n---| \"split:leftmost\"\n---| \"split:abovemost\"\n---| \"split:rightmost\"\n---| \"split:belowmost\"\n\n---@class FylerWin\n---@field augroup       string          - Autogroup associated with window instance\n---@field autocmds      table           - Autocommands locally associated with window instance\n---@field border        string|string[] - Border format - read ':winborder' for more info\n---@field bufname       string          - Builtin way to name neovim buffers\n---@field bufnr?        integer         - Buffer number associated with window instance\n---@field buf_opts      table           - Buffer local options\n---@field enter         boolean         - whether to enter in the window on open\n---@field footer?       any             - Footer content\n---@field footer_pos?   string          - Footer alignment\n---@field height        number          - Height of window\n---@field kind          FylerWinKind    - Decides launch behaviour of window instance\n---@field mappings      table           - Kemaps local to the window instance\n---@field name          string          - Also know as `view_name` which helps to get specific config from user end\n---@field namespace     integer         - Namespace associated with window instance\n---@field render?       function        - Defines what to render on the screen on open\n---@field title?        any             - Title content\n---@field title_pos?    string          - Title alignment\n---@field ui            FylerUi         - Ui responsible to render lines return from corresponding render function\n---@field user_autocmds table           - User autocommands associated with window instance\n---@field width         number          - Width of window\n---@field winid?        integer         - Window id associated with window instance\n---@field win_opts      table           - Window local options\nlocal Win = {}\nWin.__index = Win\n\n-- Prepares namespace ID by attaching buffer's given name\n---@param name string\nlocal function get_namespace(name)\n  return api.nvim_create_namespace(\"Fyler\" .. name)\nend\n\n-- Prepares autogroup ID by attaching buffer's given name\n---@param name string\nlocal function get_augroup(name)\n  return api.nvim_create_augroup(\"Fyler\" .. name, { clear = true })\nend\n\nlocal M = setmetatable({}, {\n  ---@return FylerWin\n  __call = function(_, opts)\n    opts = opts or {}\n\n    assert(opts.name, \"name is required field\")\n    assert(opts.bufname, \"bufname is required field\")\n\n    -- stylua: ignore start\n    local instance = {\n      augroup       = get_augroup(opts.name),\n      autocmds      = opts.autocmds or {},\n      border        = opts.border,\n      bufname       = opts.bufname,\n      buf_opts      = opts.buf_opts or {},\n      enter         = opts.enter,\n      footer        = opts.footer,\n      footer_pos    = opts.footer_pos,\n      height        = opts.height,\n      kind          = opts.kind or \"float\",\n      mappings      = opts.mappings or {},\n      name          = opts.name or \"\",\n      namespace     = get_namespace(opts.name),\n      render        = opts.render,\n      title         = opts.title,\n      title_pos     = opts.title_pos,\n      user_autocmds = opts.user_autocmds or {},\n      width         = opts.width,\n      win_opts      = opts.win_opts or {},\n    }\n    -- stylua: ignore end\n\n    instance.ui = Ui(instance)\n    setmetatable(instance, Win)\n\n    return instance\n  end,\n})\n\n-- Determine whether the `Win` has valid buffer\n---@return boolean\nfunction Win:has_valid_bufnr()\n  return type(self.bufnr) == \"number\" and api.nvim_buf_is_valid(self.bufnr)\nend\n\n-- Determine whether the `Win` has valid window\n---@return boolean\nfunction Win:has_valid_winid()\n  return type(self.winid) == \"number\" and api.nvim_win_is_valid(self.winid)\nend\n\n---@return boolean\nfunction Win:is_visible()\n  return self:has_valid_bufnr() and self:has_valid_winid()\nend\n\n-- Construct respective window config in vim understandable format\n---@return vim.api.keyset.win_config\nfunction Win:config()\n  local winconfig = {\n    style = \"minimal\",\n    noautocmd = true,\n    title = self.title,\n    title_pos = self.title_pos,\n    footer = self.footer,\n    footer_pos = self.footer_pos,\n  }\n\n  if self.kind:match(\"^split:\") then\n    winconfig.split = self.kind:match(\"^split:(.*)\")\n    winconfig.title = nil\n    winconfig.title_pos = nil\n    winconfig.footer = nil\n    winconfig.footer_pos = nil\n  end\n\n  if self.kind == \"float\" then\n    winconfig.relative = \"editor\"\n    winconfig.border = self.border\n    winconfig.col = math.floor((1 - self.width) * 0.5 * vim.o.columns)\n    winconfig.row = math.floor((1 - self.height) * 0.5 * vim.o.lines)\n  end\n\n  winconfig.width = math.ceil(self.width * vim.o.columns)\n  winconfig.height = math.ceil(self.height * vim.o.lines)\n\n  return winconfig\nend\n\nfunction Win:show()\n  if self:has_valid_winid() then\n    return\n  end\n\n  local recent_win = api.nvim_get_current_win()\n  local win_config = self:config()\n\n  self.bufnr = api.nvim_create_buf(false, true)\n  if self.render then\n    self.render()\n  end\n\n  api.nvim_buf_set_name(self.bufnr, self.bufname)\n\n  if win_config.split and win_config.split:match(\"^%w+most$\") then\n    if win_config.split == \"leftmost\" then\n      api.nvim_command(string.format(\"topleft %dvsplit\", win_config.width))\n    elseif win_config.split == \"abovemost\" then\n      api.nvim_command(string.format(\"topleft %dsplit\", win_config.height))\n    elseif win_config.split == \"rightmost\" then\n      api.nvim_command(string.format(\"botright %dvsplit\", win_config.width))\n    elseif win_config.split == \"belowmost\" then\n      api.nvim_command(string.format(\"botright %dsplit\", win_config.height))\n    else\n      error(string.format(\"Invalid window kind `%s`\", win_config.split))\n    end\n\n    self.winid = api.nvim_get_current_win()\n\n    if not self.enter then\n      api.nvim_set_current_win(recent_win)\n    end\n\n    api.nvim_win_set_buf(self.winid, self.bufnr)\n  else\n    self.winid = api.nvim_open_win(self.bufnr, self.enter, win_config)\n  end\n\n  api.nvim_exec_autocmds(\"BufEnter\", {})\n\n  for mode, map in pairs(self.mappings) do\n    for key, val in pairs(map) do\n      vim.keymap.set(mode, key, val, { buffer = self.bufnr, silent = true, noremap = true })\n    end\n  end\n\n  for option, value in pairs(self.win_opts) do\n    vim.w[self.winid][option] = vim.wo[self.winid][option]\n    vim.wo[self.winid][option] = value\n  end\n\n  for option, value in pairs(self.buf_opts) do\n    vim.bo[self.bufnr][option] = value\n  end\n\n  for event, callback in pairs(self.autocmds) do\n    api.nvim_create_autocmd(event, {\n      group = self.augroup,\n      buffer = self.bufnr,\n      callback = callback,\n    })\n  end\n\n  for event, callback in pairs(self.user_autocmds) do\n    api.nvim_create_autocmd(\"User\", {\n      pattern = event,\n      group = self.augroup,\n      callback = callback,\n    })\n  end\nend\n\nfunction Win:hide()\n  if self:has_valid_winid() then\n    api.nvim_win_close(self.winid, true)\n  end\n\n  if self:has_valid_bufnr() then\n    api.nvim_buf_delete(self.bufnr, { force = true })\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/structs/queue.lua", "local List = require(\"fyler.lib.structs.list\")\n\n---@class FylerQueue\n---@field items FylerLinkedList\nlocal Queue = {}\nQueue.__index = Queue\n\n---@param data any\nfunction Queue:enqueue(data)\n  self.items:insert(self.items:len() + 1, data)\nend\n\n---@return any\nfunction Queue:dequeue()\n  assert(not self:is_empty(), \"Queue is empty\")\n\n  local data = self.items.node.data\n  self.items:erase(1)\n  return data\nend\n\n---@return any\nfunction Queue:front()\n  assert(self.items.node, \"Queue is empty\")\n  return self.items.node.data\nend\n\n---@return boolean\nfunction Queue:is_empty()\n  return self.items:len() == 0\nend\n\nreturn setmetatable({}, {\n  ---@return FylerQueue\n  __call = function()\n    return setmetatable({ items = List() }, Queue)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/views/explorer/struct.lua", "local a = require(\"fyler.lib.async\")\nlocal fs = require(\"fyler.lib.fs\")\nlocal store = require(\"fyler.views.explorer.store\")\n\n---@class FylerFSItem\n---@field meta string\n---@field open boolean\n---@field children FylerFSItem[]\nlocal FSItem = {}\nFSItem.__index = FSItem\n\nlocal M = setmetatable({}, {\n  ---@param meta string\n  ---@return FylerFSItem\n  __call = function(_, meta)\n    local instance = {\n      meta = meta,\n      open = false,\n      children = {},\n    }\n\n    return setmetatable(instance, FSItem)\n  end,\n})\n\nfunction FSItem:toggle()\n  self.open = not self.open\nend\n\n---@param addr string\n---@param meta string\nfunction FSItem:add_child(addr, meta)\n  local target_node = self:find(addr)\n  if target_node then\n    table.insert(target_node.children, M(meta))\n  end\nend\n\n---@param addr string\n---@return FylerFSItem?\nfunction FSItem:find(addr)\n  if self.meta == addr then\n    return self\n  end\n\n  for _, child in ipairs(self.children) do\n    local found = child:find(addr)\n    if found then\n      return found\n    end\n  end\n\n  return nil\nend\n\nFSItem.update = a.async(function(self, cb)\n  if not self.open then\n    return cb()\n  end\n\n  local meta_data = store.get(self.meta)\n  local err, items = a.await(fs.ls, meta_data.path)\n  if err then\n    return cb()\n  end\n\n  self.children = vim\n    .iter(self.children)\n    :filter(function(child) ---@param child FylerFSItem\n      return vim.iter(items):any(function(item)\n        return item.path == store.get(child.meta).path and item.type == store.get(child.meta).type\n      end)\n    end)\n    :totable()\n\n  for _, item in ipairs(items) do\n    if\n      not vim.iter(self.children):any(function(child) ---@param child FylerFSItem\n        return store.get(child.meta).path == item.path and store.get(child.meta).type == item.type\n      end)\n    then\n      self:add_child(self.meta, store.set(item))\n    end\n  end\n\n  for _, child in ipairs(self.children) do\n    a.await(child.update, child)\n  end\n\n  return cb()\nend)\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/structs/list.lua", "---@class FylerLinkedList\n---@field node FylerLinkedListNode\nlocal LinkedList = {}\nLinkedList.__index = LinkedList\n\n---@class FylerLinkedListNode\n---@field next? FylerLinkedListNode\n---@field data  any\nlocal LinkedListNode = {}\nLinkedListNode.__index = LinkedListNode\n\n---@return integer\nfunction LinkedList:len()\n  local count = 0\n  local current = self.node\n  while current do\n    count = count + 1\n    current = current.next\n  end\n\n  return count\nend\n\n---@param fn fun(node: FylerLinkedListNode)\nfunction LinkedList:each(fn)\n  local start = self.node\n  while start do\n    fn(start.data)\n    start = start.next\n  end\nend\n\n---@param pos integer\n---@param data any\nfunction LinkedList:insert(pos, data)\n  local newNode = setmetatable({ data = data }, LinkedListNode)\n  if pos == 1 then\n    newNode.next = self.node\n    self.node = newNode\n    return\n  end\n\n  local start = self.node\n  for _ = 1, pos - 2 do\n    if not start then\n      error(\"position is out of bound\")\n    end\n    start = start.next\n  end\n\n  if not start then\n    error(\"position is out of bound\")\n  end\n\n  newNode.next = start.next\n  start.next = newNode\nend\n\n---@param pos integer\nfunction LinkedList:erase(pos)\n  assert(pos >= 1, \"position must be 1 or greater\")\n\n  if not self.node then\n    error(\"list is empty\")\n  end\n\n  if pos == 1 then\n    self.node = self.node.next\n    return\n  end\n\n  local start = self.node\n  for _ = 1, pos - 2 do\n    if not start or not start.next then\n      error(\"position is out of bound\")\n    end\n\n    start = start.next\n  end\n\n  if not start or not start.next then\n    error(\"position is out of bound\")\n  end\n\n  start.next = start.next.next\nend\n\n---@return table\nfunction LinkedList:totable()\n  local tbl = {}\n  self:each(function(item)\n    table.insert(tbl, item)\n  end)\n\n  return tbl\nend\n\nreturn setmetatable({}, {\n  ---@return FylerLinkedList\n  __call = function()\n    return setmetatable({}, LinkedList)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/config.lua", "---@class FylerConfigView\n---@field width  number\n---@field height number\n---@field kind   FylerWinKind\n---@field border string|string[]\n\n---@class FylerConfig\n---@field auto_confirm_simple_edits? boolean\n---@field close_on_select?           boolean\n---@field default_explorer?          boolean\n---@field git_status                 boolean\n---@field icon_provider?             string|fun(type: string, name: string): string, string\n---@field indentscope                { enabled: boolean, group: string, marker: string }\n---@field on_highlights              fun(hl_groups: table, palette: table): nil\n---@field views?                     table<string, FylerConfigView>\n---@field mappings?                  table<string, table<\"n\"|\"i\", table<string, string>>>\n\nlocal M = {}\n\nlocal defaults = {\n  auto_confirm_simple_edits = false,\n  close_on_select = true,\n  default_explorer = false,\n  git_status = true,\n  icon_provider = \"mini-icons\",\n  on_highlights = nil,\n  indentscope = {\n    enabled = true,\n    group = \"FylerIndentMarker\",\n    marker = \"\",\n  },\n  mappings = {\n    confirm = {\n      n = {\n        [\"y\"] = \"Confirm\",\n        [\"n\"] = \"Discard\",\n      },\n    },\n    explorer = {\n      n = {\n        [\"q\"] = \"CloseView\",\n        [\"<CR>\"] = \"Select\",\n      },\n    },\n  },\n  views = {\n    confirm = {\n      width = 0.5,\n      height = 0.4,\n      kind = \"float\",\n      border = \"single\",\n      buf_opts = {\n        buflisted = false,\n        modifiable = false,\n      },\n      win_opts = {\n        winhighlight = \"Normal:Normal,FloatBorder:FloatBorder,FloatTitle:FloatTitle\",\n        wrap = false,\n      },\n    },\n    explorer = {\n      width = 0.8,\n      height = 0.8,\n      kind = \"float\",\n      border = \"single\",\n      buf_opts = {\n        buflisted = false,\n        buftype = \"acwrite\",\n        filetype = \"fyler\",\n        syntax = \"fyler\",\n      },\n      win_opts = {\n        concealcursor = \"nvic\",\n        conceallevel = 3,\n        cursorline = true,\n        number = true,\n        relativenumber = true,\n        winhighlight = \"Normal:Normal,FloatBorder:FloatBorder,FloatTitle:FloatTitle\",\n        wrap = false,\n      },\n    },\n  },\n}\n\n---@param name string\nfunction M.get_view(name)\n  assert(name, \"name is required\")\n\n  return M.values.views[name]\nend\n\n---@param name string\nfunction M.get_mappings(name)\n  assert(name, \"name is required\")\n\n  return M.values.mappings[name]\nend\n\n---@param name string\nfunction M.get_reverse_mappings(name)\n  assert(name, \"name is required\")\n\n  local mappings = M.get_mappings(name)\n  local reverse_mappings = {}\n\n  for _, map in pairs(mappings) do\n    for key, val in pairs(map) do\n      reverse_mappings[val] = key\n    end\n  end\n\n  return reverse_mappings\nend\n\n---@param opts? FylerConfig\nfunction M.setup(opts)\n  opts = opts or {}\n  M.values = vim.tbl_deep_extend(\"force\", defaults, opts)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/structs/stack.lua", "local List = require(\"fyler.lib.structs.list\")\n\n---@class FylerStack\n---@field items FylerLinkedList\nlocal Stack = {}\nStack.__index = Stack\n\n---@param data any\nfunction Stack:push(data)\n  self.items:insert(1, data)\nend\n\nfunction Stack:pop()\n  assert(not self:is_empty(), \"stack is empty\")\n\n  local data = self.items.node.data\n  self.items:erase(1)\n  return data\nend\n\n---@return any\nfunction Stack:top()\n  assert(self.items.node, \"stack is empty\")\n  return self.items.node.data\nend\n\n---@return boolean\nfunction Stack:is_empty()\n  return self.items:len() == 0\nend\n\nreturn setmetatable({}, {\n  ---@return FylerStack\n  __call = function()\n    return setmetatable({ items = List() }, Stack)\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/lib/hls.lua", "local api = vim.api\n\nlocal M = {}\n\n---@param dec integer\nlocal function to_hex(dec)\n  return string.format(\"%06X\", math.max(0, math.min(0xFFFFFF, math.floor(dec))))\nend\n\n-- https://github.com/NeogitOrg/neogit\n---@param name string\n---@return string|nil\nlocal function get_fg(name)\n  local color = api.nvim_get_hl(0, { name = name })\n  if color[\"link\"] then\n    return get_fg(color[\"link\"])\n  elseif color[\"reverse\"] and color[\"bg\"] then\n    return \"#\" .. to_hex(color[\"bg\"])\n  elseif color[\"fg\"] then\n    return \"#\" .. to_hex(color[\"fg\"])\n  end\nend\n\n-- https://github.com/NeogitOrg/neogit\n---@param name string\n---@return string|nil\nlocal function get_bg(name)\n  local color = api.nvim_get_hl(0, { name = name })\n  if color[\"link\"] then\n    return get_bg(color[\"link\"])\n  elseif color[\"reverse\"] and color[\"fg\"] then\n    return \"#\" .. to_hex(color[\"fg\"])\n  elseif color[\"bg\"] then\n    return \"#\" .. to_hex(color[\"bg\"])\n  end\nend\n\nlocal function build_palette()\n  -- stylua: ignore start\n  return {\n    black     = \"#000000\",\n    white     = \"#ffffff\",\n\n    bg        = get_bg(\"Normal\"),\n    blue      = get_fg(\"Directory\"),\n    cyan      = get_fg(\"Operator\"),\n    dark_grey = get_fg(\"WhiteSpace\"),\n    fg        = get_fg(\"Normal\"),\n    green     = get_fg(\"String\"),\n    grey      = get_fg(\"Comment\"),\n    orange    = get_fg(\"SpecialChar\"),\n    red       = get_fg(\"Error\"),\n    yellow    = get_fg(\"WarningMsg\"),\n  }\n  -- stylua: ignore end\nend\n\n---@param opts? FylerConfig\nfunction M.setup(opts)\n  opts = opts or {}\n\n  local palette = build_palette()\n\n  -- stylua: ignore start\n  local hl_groups = {\n    FylerConfirmGreen  = { fg = palette.green },\n    FylerConfirmGrey   = { fg = palette.grey },\n    FylerConfirmRed    = { fg = palette.red },\n    FylerConfirmYellow = { fg = palette.yellow },\n    FylerFSDirectory   = { fg = palette.blue },\n    FylerFSFile        = { fg = palette.white },\n    FylerFSLink        = { fg = palette.grey },\n    FylerGitAdded      = { fg = palette.green },\n    FylerGitConflict   = { fg = palette.red },\n    FylerGitDeleted    = { fg = palette.red },\n    FylerGitIgnored    = { fg = palette.red },\n    FylerGitModified   = { fg = palette.yellow },\n    FylerGitRenamed    = { fg = palette.yellow },\n    FylerGitStaged     = { fg = palette.green },\n    FylerGitUnstaged   = { fg = palette.orange },\n    FylerGitUntracked  = { fg = palette.cyan },\n    FylerIndentMarker  = { fg = palette.dark_grey },\n  }\n  -- stylua: ignore end\n\n  if opts.on_highlights then\n    opts.on_highlights(hl_groups, palette)\n  end\n\n  for key, val in pairs(hl_groups) do\n    api.nvim_set_hl(0, key, val)\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/plugin/fyler.lua", "vim.api.nvim_create_user_command(\"Fyler\", function(args)\n  local opts = {}\n  for _, farg in ipairs(args.fargs) do\n    local key, value = unpack(vim.split(farg, \"=\"))\n    opts[key] = value\n  end\n\n  require(\"fyler\").open(opts)\nend, {\n  nargs = \"*\",\n  complete = function(arglead, cmdline)\n    if arglead:find(\"^kind=\") then\n      return {\n        \"kind=float\",\n        \"kind=split:left\",\n        \"kind=split:above\",\n        \"kind=split:right\",\n        \"kind=split:below\",\n        \"kind=split:leftmost\",\n        \"kind=split:abovemost\",\n        \"kind=split:rightmost\",\n        \"kind=split:belowmost\",\n      }\n    end\n\n    if arglead:find(\"^cwd=\") then\n      return {\n        \"cwd=\" .. (vim.uv or vim.loop).cwd(),\n      }\n    end\n\n    return vim.tbl_filter(function(arg)\n      return cmdline:match(arg) == nil\n    end, {\n      \"kind=\",\n      \"cwd=\",\n    })\n  end,\n})\n"], ["/fyler.nvim/lua/fyler/integrations/icon/nvim-web-devicons.lua", "local M = {}\n\nlocal fn = vim.fn\n\n---@param type string\n---@param name string\n---@return string?, string?\nfunction M.get_icon(type, name)\n  local success, devicons = pcall(require, \"nvim-web-devicons\")\n  if not success then\n    return nil, nil\n  end\n\n  local icon, hl = devicons.get_icon(name, fn.fnamemodify(name, \":e\"))\n  icon = (type == \"directory\" and \"\" or (icon or \"\"))\n  hl = hl or (type == \"directory\" and \"Fylerblue\" or \"\")\n  return icon, hl\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/explorer/store.lua", "local M = {}\n\nlocal count = 0\nlocal store = {}\n\nlocal Metadata = {}\nMetadata.__index = Metadata\n\nfunction Metadata:is_directory()\n  return self.type == \"directory\" or (self.type == \"link\" and self.link_type == \"directory\")\nend\n\nfunction Metadata:resolved_path()\n  return self.type == \"link\" and self.link_path or self.path\nend\n\n---@param key string\nfunction M.get(key)\n  return setmetatable(vim.deepcopy(store[key]), Metadata)\nend\n\n---@param tbl table\n---@return string\nfunction M.set(tbl)\n  count = count + 1\n  local meta = string.format(\"%05d\", count)\n  store[meta] = tbl\n  return meta\nend\n\nfunction M.debug()\n  for k, v in pairs(store) do\n    print(k, vim.inspect(v))\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/lib/ui/components.lua", "---@alias FylerUiLineAlign\n---| \"end\"\n---| \"start\"\n---| \"center\"\n\n---@alias FylerUiWord { str: string, hl?: string }\n---@alias FylerUiMark { str: string, hl?: string, id: string }\n\n---@class FylerUiLine\n---@field align FylerUiLineAlign\n---@field words FylerUiWord[]\n---@field marks FylerUiMark[]\nlocal Line = {}\nLine.__index = Line\n\nreturn {\n  Line = setmetatable({}, {\n    ---@param opts { words: FylerUiWord[], marks: FylerUiMark[], align?: FylerUiLineAlign }\n    ---@return FylerUiLine\n    __call = function(_, opts)\n      local instance = {\n        words = opts.words or {},\n        align = opts.align or \"start\",\n        marks = opts.marks or {},\n      }\n\n      setmetatable(instance, Line)\n\n      return instance\n    end,\n  }),\n}\n"], ["/fyler.nvim/lua/fyler/views/explorer/regex.lua", "local M = {}\n\n---@param str string\n---@return string\nfunction M.match_meta(str)\n  assert(str, \"str is required\")\n  return str:match(\" /(%d%d%d%d%d)\")\nend\n\n---@param str string\n---@return string\nfunction M.match_indent(str)\n  assert(str, \"str is required\")\n  return str:match(\"^(%s*)\")\nend\n\n---@param str string\n---@return string\nfunction M.match_name(str)\n  assert(str, \"str is required\")\n  if str:match(\"/%d%d%d%d%d\") then\n    return str:match(\"/%d%d%d%d%d (.*)$\")\n  else\n    return str:gsub(\"^%s*\", \"\"):match(\".*\")\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/ui.lua", "local components = require(\"fyler.lib.ui.components\")\n\nlocal Line = components.Line\n\nlocal function MESSAGE(tbl)\n  local lines = {}\n  for _, line in ipairs(tbl or {}) do\n    table.insert(lines, Line { words = line })\n  end\n\n  return lines\nend\n\nlocal M = {}\n\n---@param tbl table\nfunction M.Confirm(tbl)\n  if not tbl then\n    return {}\n  end\n\n  return MESSAGE(tbl)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/integrations/icon/mini-icons.lua", "local M = {}\n\n---@param type string\n---@param name string\n---@return string?, string?\nfunction M.get_icon(type, name)\n  local success, miniicons = pcall(require, \"mini.icons\")\n  if not success then\n    return nil, nil\n  end\n\n  return miniicons.get(type, name)\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/views/confirm/actions.lua", "local M = {}\n\n---@param view table\nfunction M.n_close_view(view, cb)\n  return function()\n    cb(false)\n    view:close()\n  end\nend\n\nfunction M.n_confirm(view, cb)\n  return function()\n    cb(true)\n    view:close()\n  end\nend\n\nfunction M.n_discard(view, cb)\n  return function()\n    cb(false)\n    view:close()\n  end\nend\n\nreturn M\n"], ["/fyler.nvim/lua/fyler/cache.lua", "local M = {}\n\nlocal cache_table = {}\n\n---@param entry_key string\n---@param val any\nfunction M.set_entry(entry_key, val)\n  cache_table[entry_key] = val\nend\n\n---@param entry_key string\n---@return any\nfunction M.get_entry(entry_key)\n  return vim.deepcopy(cache_table[entry_key])\nend\n\nreturn M\n"], ["/fyler.nvim/syntax/fyler.lua", "if vim.b.current_syntax then\n  return\nend\n\nvim.cmd([[\n  syntax match FylerMetaKey /\\/\\d\\d\\d\\d\\d / conceal\n]])\n\nvim.b.current_syntax = \"fyler\"\n"]], "task_instance_info": {"created_time": "2025-08-21 00:45:12", "created_task_model": "DeepSeek-R1", "code_description": "This code segment functions to: Manage asynchronous task processing using a queue-based system that coordinates coroutine execution with deferred timing mechanisms and handles state transitions between pending, active, and completed operations."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```lua\n[TASK_BEGIN]\nlocal function schedule(co, ...)\n  queue:enqueue(co, { ... })\n  if not is_loop_running then\n    is_loop_running = true\n    vim.schedule(loop)\n  end\nend\n\nlocal function loop()\n  if queue:is_empty() then\n    is_loop_running = false\n    return\n  end\n\n  local co, args = queue:dequeue()\n  local ok, err = coroutine.resume(co, unpack(args))\n  if not ok then\n    error(err)\n  end\n\n  if coroutine.status(co) ~= \"dead\" then\n    queue:enqueue(co, args)\n  end\n\n  vim.schedule(loop)\nend\n[TASK_END]\n```", "inference_time": "2025-08-21 00-46-23"}, "editdistance_info": {"edit_distance": 34.3137, "calculate_time": "2025-08-21 00:46:23", "true_code_clean": "local function schedule(co, ...)\n  queue:enqueue {\n    args = { ... },\n    co = co,\n    started = false,\n  }\n  if is_loop_running then\n    return\n  end\n  is_loop_running = true\n  local function loop()\n    if queue:is_empty() then\n      is_loop_running = false\n      return\n    end\n    local front = queue:front()\n    local status = coroutine.status(front.co)\n    if status == \"dead\" then\n      queue:dequeue()\n      vim.defer_fn(loop, 0)\n    elseif status == \"suspended\" and front.started == false then\n      local success = coroutine.resume(front.co, unpack(front.args))\n      if not success then\n        queue:dequeue()\n      end\n      front.started = true\n      vim.defer_fn(loop, 0)\n    else\n      vim.defer_fn(loop, 10)\n    end\n  end\n  vim.defer_fn(loop, 0)\nend", "predict_code_clean": "local function schedule(co, ...)\n  queue:enqueue(co, { ... })\n  if not is_loop_running then\n    is_loop_running = true\n    vim.schedule(loop)\n  end\nend\nlocal function loop()\n  if queue:is_empty() then\n    is_loop_running = false\n    return\n  end\n  local co, args = queue:dequeue()\n  local ok, err = coroutine.resume(co, unpack(args))\n  if not ok then\n    error(err)\n  end\n  if coroutine.status(co) ~= \"dead\" then\n    queue:enqueue(co, args)\n  end\n  vim.schedule(loop)\nend"}}