repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/lua/bugabinga/file_explorer.lua

Raw
local puk = require 'std.puk'
local map = require 'std.map'
local icon = require 'std.icon'

local oil = puk 'oil'

oil.setup {
  -- default_file_explorer = true,
  -- Set to true to watch the filesystem for changes and reload oil
  -- experimental_watch_for_changes = true,
  skip_confirm_for_simple_edits = true,
  prompt_save_on_select_new_entry = false,
  delete_to_trash = true,

  columns = { 'icon' },
  win_options = {
    cursorline = true,
  },
  keymaps = {
    ['q'] = 'actions.close',
    ['<C-v>'] = 'actions.select_vsplit',
    ['<C-s>'] = 'actions.select_split',
    ['`'] = 'actions.tcd',
    ['~'] = '<cmd>edit $HOME<CR>',
    ['<F7>'] = 'actions.open_terminal',
    ['gd'] = {
      desc = 'Toggle detail view',
      callback = function()
        local oil = require 'oil'
        local config = require 'oil.config'
        if #config.columns == 1 then
          oil.set_columns { 'icon', 'permissions', 'size', { 'mtime', format = '%d/%m/%y %T' } }
        else
          oil.set_columns { 'icon' }
        end
      end,
    },
  },
  float = {
    max_width = 69,
    min_width = 69,
    border = vim.g.border_style,
    padding = 2,
  },
  -- Configuration for the floating keymaps help window
  keymaps_help = {
    border = vim.g.border_style,
  },
  view_options = {
    is_always_hidden = function(name, bufnr) return name == '..' end,
    show_hidden = true,
  },
}

map.normal {
  description = 'Open parent directory in buffer.',
  category = 'files',
  keys = '-',
  command = oil.open,
}