diff --git a/lua/oil/config.lua b/lua/oil/config.lua index d551217..f239f71 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -52,6 +52,10 @@ local default_config = { view_options = { -- Show files and directories that start with "." show_hidden = false, + -- This function defines what is considered a "hidden" file + is_hidden_file = function(name, bufnr) + return vim.startswith(name, ".") + end, }, -- Configuration for the floating window in oil.open_float float = { diff --git a/lua/oil/mutator/parser.lua b/lua/oil/mutator/parser.lua index a20f3c0..f185749 100644 --- a/lua/oil/mutator/parser.lua +++ b/lua/oil/mutator/parser.lua @@ -42,8 +42,9 @@ end ---@param adapter oil.Adapter ---@param line string ---@param column_defs oil.ColumnSpec[] ----@return table ----@return nil|oil.InternalEntry +---@return nil|table Parsed entry data +---@return nil|oil.InternalEntry If the entry already exists +---@return nil|string Error message M.parse_line = function(adapter, line, column_defs) local ret = {} local value, rem = line:match("^/(%d+) (.+)$") @@ -118,7 +119,7 @@ M.parse = function(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true) local original_entries = {} for _, child in pairs(children) do - if view.should_display(child) then + if view.should_display(child, bufnr) then original_entries[child[FIELD.name]] = child[FIELD.id] end end @@ -137,7 +138,7 @@ M.parse = function(bufnr) for i, line in ipairs(lines) do if line:match("^/%d+") then local parsed_entry, entry, err = M.parse_line(adapter, line, column_defs) - if err then + if not parsed_entry then table.insert(errors, { message = err, lnum = i - 1, diff --git a/lua/oil/view.lua b/lua/oil/view.lua index 503a8d0..f5118c2 100644 --- a/lua/oil/view.lua +++ b/lua/oil/view.lua @@ -11,13 +11,11 @@ local M = {} local last_cursor_entry = {} ---@param entry oil.InternalEntry +---@param bufnr integer ---@return boolean -M.should_display = function(entry) +M.should_display = function(entry, bufnr) local name = entry[FIELD.name] - if not config.view_options.show_hidden and vim.startswith(name, ".") then - return false - end - return true + return config.view_options.show_hidden or not config.view_options.is_hidden_file(name, bufnr) end ---@param bufname string @@ -318,7 +316,7 @@ local function render_buffer(bufnr, opts) end local virt_text = {} for _, entry in ipairs(entry_list) do - if not M.should_display(entry) then + if not M.should_display(entry, bufnr) then goto continue end local cols = M.format_entry_cols(entry, column_defs, col_width, adapter)