{ nix2lua, vim, ... }: { configs ? { } , keymaps ? [ { mode = "n"; bind = "nt"; command = "NvimTreeToggle"; } { mode = "n"; bind = "nf"; command = "NvimTreeFindFile"; } ] }: with nix2lua.lib; let isEmptyVar = name: eq "" (var name); in { nvim-web-devicons = true; nvim-tree-lua = ( [ (pipe1 (require "nvim-tree") (call "setup" configs)) (local (func "open_nvim_tree" [ "data" ] [ # buffer is a [No Name] (local (set "isNoNameBuffer" (and (isEmptyVar "data.file") (isEmptyVar "vim.bo[data.buf].buftype") ) )) # buffer is a directory (local (set "isDirectory" (eq 1 (vim.fn.isdirectory "data.file")) )) (if' (not (and (var "isNoNameBuffer") (var "isDirectory"))) return_void ) # change to the directory (if' (var "isDirectory") (vim.cmd.cd "data.file") ) # open the tree (pipe1 (require "nvim-tree.api") (call0 "tree.open")) ])) (vim.api.nvim_create_autocmd [ "VimEnter" ] { callback = var "open_nvim_tree"; }) ] ++ (map vim.keymap.set keymaps) ); }