lir.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. local M = {}
  2. M.config = function()
  3. local status_ok, lir = pcall(require, "lir")
  4. if not status_ok then
  5. return
  6. end
  7. local actions = require "lir.actions"
  8. local mark_actions = require "lir.mark.actions"
  9. local clipboard_actions = require "lir.clipboard.actions"
  10. lir.setup {
  11. show_hidden_files = false,
  12. devicons_enable = true,
  13. mappings = {
  14. ["l"] = actions.edit,
  15. ["<CR>"] = actions.edit,
  16. ["<C-s>"] = actions.split,
  17. ["v"] = actions.vsplit,
  18. ["<C-t>"] = actions.tabedit,
  19. ["h"] = actions.up,
  20. ["q"] = actions.quit,
  21. ["A"] = actions.mkdir,
  22. ["a"] = actions.newfile,
  23. ["r"] = actions.rename,
  24. ["@"] = actions.cd,
  25. ["Y"] = actions.yank_path,
  26. ["i"] = actions.toggle_show_hidden,
  27. ["d"] = actions.delete,
  28. ["J"] = function()
  29. mark_actions.toggle_mark()
  30. vim.cmd "normal! j"
  31. end,
  32. ["c"] = clipboard_actions.copy,
  33. ["x"] = clipboard_actions.cut,
  34. ["p"] = clipboard_actions.paste,
  35. },
  36. float = {
  37. winblend = 0,
  38. curdir_window = {
  39. enable = false,
  40. highlight_dirname = true,
  41. },
  42. -- -- You can define a function that returns a table to be passed as the third
  43. -- -- argument of nvim_open_win().
  44. win_opts = function()
  45. local width = math.floor(vim.o.columns * 0.7)
  46. local height = math.floor(vim.o.lines * 0.7)
  47. return {
  48. border = "rounded",
  49. width = width,
  50. height = height,
  51. -- row = 1,
  52. -- col = math.floor((vim.o.columns - width) / 2),
  53. }
  54. end,
  55. },
  56. hide_cursor = false,
  57. on_init = function()
  58. -- use visual mode
  59. vim.api.nvim_buf_set_keymap(
  60. 0,
  61. "x",
  62. "J",
  63. ':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>',
  64. { noremap = true, silent = true }
  65. )
  66. -- echo cwd
  67. -- vim.api.nvim_echo({ { vim.fn.expand "%:p", "Normal" } }, false, {})
  68. end,
  69. }
  70. -- custom folder icon
  71. require("nvim-web-devicons").set_icon {
  72. lir_folder_icon = {
  73. icon = "",
  74. -- color = "#7ebae4",
  75. -- color = "#569CD6",
  76. color = "#42A5F5",
  77. name = "LirFolderNode",
  78. },
  79. }
  80. end
  81. return M