From 0cab81e17c3dfff3804f08266edbd46e10810fd6 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Wed, 27 Mar 2024 11:06:03 -0700 Subject: [PATCH] [vim] add lir instead of defx (no python dep yay) --- .vim/lua/lir_setup.lua | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ .vim/nvim.lua | 21 ++++++------ .vimrc | 6 ++-- 3 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 .vim/lua/lir_setup.lua diff --git a/.vim/lua/lir_setup.lua b/.vim/lua/lir_setup.lua new file mode 100644 index 0000000..c1728bc --- /dev/null +++ b/.vim/lua/lir_setup.lua @@ -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, + [''] = actions.split, + [''] = actions.vsplit, + [''] = 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", + ':lua require"lir.mark.actions".toggle_mark("v")', + { 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" + } +}) diff --git a/.vim/nvim.lua b/.vim/nvim.lua index 5446414..0a15cfc 100644 --- a/.vim/nvim.lua +++ b/.vim/nvim.lua @@ -387,17 +387,17 @@ require('trouble').setup { jump = { "o", "" }, -- jump to the diagnostic or open / close folds --open_split = { "" }, -- open buffer in new split --open_vsplit = { "" }, -- open buffer in new vsplit - open_tab = {}, -- open buffer in new tab - jump_close = { "" }, -- jump to the diagnostic and close the list - toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = "P", -- toggle auto_preview - hover = "K", -- opens a small popup with the full multiline message - preview = "p", -- preview the diagnostic location + open_tab = {}, -- open buffer in new tab + jump_close = { "" }, -- jump to the diagnostic and close the list + toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = "P", -- toggle auto_preview + hover = "K", -- opens a small popup with the full multiline message + preview = "p", -- preview the diagnostic location 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 - previous = "k", -- previous item - next = "j" -- next item + previous = "k", -- previous item + next = "j" -- next item }, } @@ -549,7 +549,7 @@ require 'nvim-treesitter.configs'.setup { playground = { enable = true, 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 keybindings = { toggle_query_editor = 'o', @@ -667,3 +667,4 @@ function neogen_dwim() end require("murdock") +require("lir_setup") diff --git a/.vimrc b/.vimrc index 33ae6e0..7960ea1 100644 --- a/.vimrc +++ b/.vimrc @@ -239,8 +239,7 @@ Plug 'creativenull/efmls-configs-nvim', { 'tag': 'v1.*' } "Plug 'Shougo/vimproc.vim' "Plug 'Shougo/vimfiler.vim' -Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'kristijanhusak/defx-icons' +Plug 'tamago324/lir.nvim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/playground' @@ -922,7 +921,8 @@ endfunction "nmap gt :NERDTreeToggle "nmap gt :VimFilerExplorer -winwidth=40 -toggle -direction=rightbelow -parent -status -force-hide "nmap gt :VimFiler -status -auto-cd -parent -force-quit -nmap gt :Defx `escape(expand('%:p:h'), ' :')` -search=`expand('%:p')` -columns=icons:indent:filename:type +"nmap gt :Defx `escape(expand('%:p:h'), ' :')` -search=`expand('%:p')` -columns=icons:indent:filename:type +nmap gt :edit . ""nnoremap gt :NvimTreeToggle " The same for the TagList, useful for large C files. "nmap gb :TlistToggle