[vim] add lir instead of defx (no python dep yay)

This commit is contained in:
Barak Michener 2024-03-27 11:06:03 -07:00
parent 80f3c7ec18
commit 0cab81e17c
3 changed files with 101 additions and 13 deletions

87
.vim/lua/lir_setup.lua Normal file
View file

@ -0,0 +1,87 @@
local actions = require 'lir.actions'
local mark_actions = require 'lir.mark.actions'
local clipboard_actions = require 'lir.clipboard.actions'
require 'lir'.setup {
show_hidden_files = false,
ignore = { ".DS_Store" }, -- { ".DS_Store", "node_modules" } etc.
devicons = {
enable = true,
highlight_dirname = true
},
mappings = {
['l'] = actions.edit,
['<C-s>'] = actions.split,
['<C-v>'] = actions.vsplit,
['<C-t>'] = actions.tabedit,
['h'] = actions.up,
['q'] = actions.quit,
['K'] = actions.mkdir,
['N'] = actions.newfile,
['R'] = actions.rename,
['@'] = actions.cd,
['Y'] = actions.yank_path,
['.'] = actions.toggle_show_hidden,
['D'] = actions.delete,
['J'] = function()
mark_actions.toggle_mark()
vim.cmd('normal! j')
end,
['C'] = clipboard_actions.copy,
['X'] = clipboard_actions.cut,
['P'] = clipboard_actions.paste,
},
float = {
winblend = 0,
curdir_window = {
enable = false,
highlight_dirname = false
},
-- -- You can define a function that returns a table to be passed as the third
-- -- argument of nvim_open_win().
-- win_opts = function()
-- local width = math.floor(vim.o.columns * 0.8)
-- local height = math.floor(vim.o.lines * 0.8)
-- return {
-- border = {
-- "+", "─", "+", "│", "+", "─", "+", "│",
-- },
-- width = width,
-- height = height,
-- row = 1,
-- col = math.floor((vim.o.columns - width) / 2),
-- }
-- end,
},
hide_cursor = true
}
vim.api.nvim_create_autocmd({ 'FileType' }, {
pattern = { "lir" },
callback = function()
-- use visual mode
vim.api.nvim_buf_set_keymap(
0,
"x",
"J",
':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>',
{ noremap = true, silent = true }
)
-- echo cwd
-- vim.api.nvim_echo({ { vim.fn.expand("%:p"), "Normal" } }, false, {})
end
})
-- custom folder icon
require 'nvim-web-devicons'.set_icon({
lir_folder_icon = {
icon = "",
color = "#7ebae4",
name = "LirFolderNode"
}
})

View file

@ -387,17 +387,17 @@ require('trouble').setup {
jump = { "o", "<tab>" }, -- jump to the diagnostic or open / close folds jump = { "o", "<tab>" }, -- jump to the diagnostic or open / close folds
--open_split = { "<c-x>" }, -- open buffer in new split --open_split = { "<c-x>" }, -- open buffer in new split
--open_vsplit = { "<c-v>" }, -- open buffer in new vsplit --open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = {}, -- open buffer in new tab open_tab = {}, -- open buffer in new tab
jump_close = { "<cr>" }, -- jump to the diagnostic and close the list jump_close = { "<cr>" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
toggle_preview = "P", -- toggle auto_preview toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location preview = "p", -- preview the diagnostic location
close_folds = { "zM", "zm" }, -- close all folds close_folds = { "zM", "zm" }, -- close all folds
open_folds = { "zR", "zr" }, -- open all folds open_folds = { "zR", "zr" }, -- open all folds
toggle_fold = { "zA", "za" }, -- toggle fold of current file toggle_fold = { "zA", "za" }, -- toggle fold of current file
previous = "k", -- previous item previous = "k", -- previous item
next = "j" -- next item next = "j" -- next item
}, },
} }
@ -549,7 +549,7 @@ require 'nvim-treesitter.configs'.setup {
playground = { playground = {
enable = true, enable = true,
disable = {}, disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false, -- Whether the query persists across vim sessions persist_queries = false, -- Whether the query persists across vim sessions
keybindings = { keybindings = {
toggle_query_editor = 'o', toggle_query_editor = 'o',
@ -667,3 +667,4 @@ function neogen_dwim()
end end
require("murdock") require("murdock")
require("lir_setup")

6
.vimrc
View file

@ -239,8 +239,7 @@ Plug 'creativenull/efmls-configs-nvim', { 'tag': 'v1.*' }
"Plug 'Shougo/vimproc.vim' "Plug 'Shougo/vimproc.vim'
"Plug 'Shougo/vimfiler.vim' "Plug 'Shougo/vimfiler.vim'
Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' } Plug 'tamago324/lir.nvim'
Plug 'kristijanhusak/defx-icons'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/playground' Plug 'nvim-treesitter/playground'
@ -922,7 +921,8 @@ endfunction
"nmap gt :NERDTreeToggle<CR> "nmap gt :NERDTreeToggle<CR>
"nmap <silent> gt :VimFilerExplorer -winwidth=40 -toggle -direction=rightbelow -parent -status -force-hide<CR> "nmap <silent> gt :VimFilerExplorer -winwidth=40 -toggle -direction=rightbelow -parent -status -force-hide<CR>
"nmap <silent> gt :VimFiler -status -auto-cd -parent -force-quit<CR> "nmap <silent> gt :VimFiler -status -auto-cd -parent -force-quit<CR>
nmap <silent> gt :Defx `escape(expand('%:p:h'), ' :')` -search=`expand('%:p')` -columns=icons:indent:filename:type<CR> "nmap <silent> gt :Defx `escape(expand('%:p:h'), ' :')` -search=`expand('%:p')` -columns=icons:indent:filename:type<CR>
nmap <silent> gt :edit .<CR>
""nnoremap <silent> gt :NvimTreeToggle<CR> ""nnoremap <silent> gt :NvimTreeToggle<CR>
" The same for the TagList, useful for large C files. " The same for the TagList, useful for large C files.
"nmap gb :TlistToggle<CR> "nmap gb :TlistToggle<CR>