lir.lua 2.8 KB

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