oil.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. local M = {
  2. "stevearc/oil.nvim",
  3. }
  4. M.config = function()
  5. local function max_height()
  6. local height = vim.fn.winheight(0)
  7. if height >= 40 then
  8. return 30
  9. elseif height >= 30 then
  10. return 20
  11. else
  12. return 10
  13. end
  14. end
  15. require("oil").setup({
  16. keymaps = {
  17. ["<C-p>"] = false,
  18. ["g?"] = "actions.show_help",
  19. ["<CR>"] = "actions.select",
  20. ["<C-s>"] = "actions.select_vsplit",
  21. ["<C-h>"] = "actions.select_split",
  22. ["<C-t>"] = "actions.select_tab",
  23. ["<C-c>"] = "actions.close",
  24. ["<C-l>"] = "actions.refresh",
  25. ["-"] = "actions.parent",
  26. ["_"] = "actions.open_cwd",
  27. ["`"] = "actions.cd",
  28. ["~"] = "actions.tcd",
  29. ["g."] = "actions.toggle_hidden",
  30. },
  31. -- Set to false if you still want to use netrw.
  32. default_file_explorer = true,
  33. delete_to_trash = true,
  34. -- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits)
  35. skip_confirm_for_simple_edits = true,
  36. view_options = {
  37. natural_order = true,
  38. -- Show files and directories that start with "."
  39. show_hidden = false,
  40. -- This function defines what is considered a "hidden" file
  41. is_hidden_file = function(name)
  42. local ignore_folders = { "node_modules", "dist", "build", "coverage" }
  43. return vim.startswith(name, ".") or vim.tbl_contains(ignore_folders, name)
  44. end,
  45. wrap = true,
  46. },
  47. -- Configuration for the floating window in oil.open_float
  48. float = {
  49. padding = 2,
  50. max_width = 120,
  51. max_height = max_height(),
  52. border = "rounded",
  53. win_options = {
  54. winblend = 0,
  55. },
  56. },
  57. })
  58. vim.keymap.set("n", "-", function()
  59. require("oil").open()
  60. end)
  61. end
  62. return M