diff --git a/modules/filetree/nvimtree/config.nix b/modules/filetree/nvimtree/config.nix index e2a789f..161d97e 100644 --- a/modules/filetree/nvimtree/config.nix +++ b/modules/filetree/nvimtree/config.nix @@ -24,47 +24,9 @@ in { ]; vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' - ${ - lib.optionalString (cfg.openOnSetup) '' - -- Open on startup has been deprecated - -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup - - -- use a nix eval to dynamically insert the open on startup function - local function open_nvim_tree(data) - local IGNORED_FT = { - "markdown", - } - - -- buffer is a real file on the disk - local real_file = vim.fn.filereadable(data.file) == 1 - - -- buffer is a [No Name] - local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - - -- &ft - local filetype = vim.bo[data.buf].ft - - -- only files please - if not real_file and not no_name then - return - end - - -- skip ignored filetypes - if vim.tbl_contains(IGNORED_FT, filetype) then - return - end - - -- open the tree but don't focus it - require("nvim-tree.api").tree.toggle({ focus = false }) - end - - -- function to automatically open the tree on VimEnter - vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) - '' - } - ${ lib.optionalString (cfg.disableNetrw) '' + -- disable netrew completely vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 '' @@ -143,164 +105,204 @@ in { view = { centralize_selection = ${boolToString cfg.view.centralizeSelection}, - cursorline = ${boolToString cfg.view.cursorline}, - debounce_delay = ${toString cfg.view.debounceDelay}, - width = ${nvim.lua.expToLua cfg.view.width}, - side = "${cfg.view.side}", - preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions}, - number = ${boolToString cfg.view.number}, - relativenumber = ${boolToString cfg.view.relativenumber}, - signcolumn = "${cfg.view.signcolumn}", - float = { - enable = ${boolToString cfg.view.float.enable}, - quit_on_focus_loss = ${boolToString cfg.view.float.quitOnFocusLoss}, - open_win_config = { - relative = "${cfg.view.float.openWinConfig.relative}", - border = "${cfg.view.float.openWinConfig.border}", - width = ${toString cfg.view.float.openWinConfig.width}, - height = ${toString cfg.view.float.openWinConfig.height}, - row = ${toString cfg.view.float.openWinConfig.row}, - col = ${toString cfg.view.float.openWinConfig.col}, + cursorline = ${boolToString cfg.view.cursorline}, + debounce_delay = ${toString cfg.view.debounceDelay}, + width = ${nvim.lua.expToLua cfg.view.width}, + side = "${cfg.view.side}", + preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions}, + number = ${boolToString cfg.view.number}, + relativenumber = ${boolToString cfg.view.relativenumber}, + signcolumn = "${cfg.view.signcolumn}", + float = { + enable = ${boolToString cfg.view.float.enable}, + quit_on_focus_loss = ${boolToString cfg.view.float.quitOnFocusLoss}, + open_win_config = { + relative = "${cfg.view.float.openWinConfig.relative}", + border = "${cfg.view.float.openWinConfig.border}", + width = ${toString cfg.view.float.openWinConfig.width}, + height = ${toString cfg.view.float.openWinConfig.height}, + row = ${toString cfg.view.float.openWinConfig.row}, + col = ${toString cfg.view.float.openWinConfig.col}, + }, + }, + }, + + renderer = { + add_trailing = ${boolToString cfg.renderer.addTrailing}, + group_empty = ${boolToString cfg.renderer.groupEmpty}, + full_name = ${boolToString cfg.renderer.fullName}, + highlight_git = ${boolToString cfg.renderer.highlightGit}, + highlight_opened_files = ${cfg.renderer.highlightOpenedFiles}, + highlight_modified = ${cfg.renderer.highlightModified}, + root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel}, + indent_width = ${toString cfg.renderer.indentWidth}, + indent_markers = { + enable = ${boolToString cfg.renderer.indentMarkers.enable}, + inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows}, + icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons}, + }, + + special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles}, + symlink_destination = ${boolToString cfg.renderer.symlinkDestination}, + + icons = { + webdev_colors = ${boolToString cfg.renderer.icons.webdevColors}, + git_placement = "${cfg.renderer.icons.gitPlacement}", + modified_placement = "${cfg.renderer.icons.modifiedPlacement}", + padding = "${cfg.renderer.icons.padding}", + symlink_arrow = "${cfg.renderer.icons.symlinkArrow}", + + show = { + git = ${boolToString cfg.renderer.icons.show.git}, + folder = ${boolToString cfg.renderer.icons.show.folder}, + folder_arrow = ${boolToString cfg.renderer.icons.show.folderArrow}, + file = ${boolToString cfg.renderer.icons.show.file}, + modified = ${boolToString cfg.renderer.icons.show.modified}, + }, + + glyphs = { + default = "${cfg.renderer.icons.glyphs.default}", + symlink = "${cfg.renderer.icons.glyphs.symlink}", + modified = "${cfg.renderer.icons.glyphs.modified}", + + folder = { + default = "${cfg.renderer.icons.glyphs.folder.default}", + open = "${cfg.renderer.icons.glyphs.folder.open}", + arrow_open = "${cfg.renderer.icons.glyphs.folder.arrowOpen}", + arrow_closed = "${cfg.renderer.icons.glyphs.folder.arrowClosed}", + empty = "${cfg.renderer.icons.glyphs.folder.empty}", + empty_open = "${cfg.renderer.icons.glyphs.folder.emptyOpen}", + symlink = "${cfg.renderer.icons.glyphs.folder.symlink}", + symlink_open = "${cfg.renderer.icons.glyphs.folder.symlinkOpen}", + }, + + git = { + unstaged = "${cfg.renderer.icons.glyphs.git.unstaged}", + staged = "${cfg.renderer.icons.glyphs.git.staged}", + unmerged = "${cfg.renderer.icons.glyphs.git.unmerged}", + renamed = "${cfg.renderer.icons.glyphs.git.renamed}", + untracked = "${cfg.renderer.icons.glyphs.git.untracked}", + deleted = "${cfg.renderer.icons.glyphs.git.deleted}", + ignored = "${cfg.renderer.icons.glyphs.git.ignored}", + }, + }, + }, + }, + + filters = { + git_ignored = ${boolToString cfg.filters.gitIgnored}, + dotfiles = ${boolToString cfg.filters.dotfiles}, + git_clean = ${boolToString cfg.filters.gitClean}, + no_buffer = ${boolToString cfg.filters.noBuffer}, + exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude}, + }, + + trash = { + cmd = "${cfg.trash.cmd}", + }, + + actions = { + use_system_clipboard = ${boolToString cfg.actions.useSystemClipboard}, + change_dir = { + enable = ${boolToString cfg.actions.changeDir.enable}, + global = ${boolToString cfg.actions.changeDir.global}, + restrict_above_cwd = ${boolToString cfg.actions.changeDir.restrictAboveCwd}, + }, + + expand_all = { + max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery}, + exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude}, + }, + + file_popup = { + open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig}, + }, + + open_file = { + quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, + eject = ${boolToString cfg.actions.openFile.eject}, + resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, + window_picker = { + enable = ${boolToString cfg.actions.openFile.windowPicker.enable}, + picker = "${cfg.actions.openFile.windowPicker.picker}", + chars = "${cfg.actions.openFile.windowPicker.chars}", + exclude = { + filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype}, + buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype}, }, }, }, - renderer = { - add_trailing = ${boolToString cfg.renderer.addTrailing}, - group_empty = ${boolToString cfg.renderer.groupEmpty}, - full_name = ${boolToString cfg.renderer.fullName}, - highlight_git = ${boolToString cfg.renderer.highlightGit}, - highlight_opened_files = ${cfg.renderer.highlightOpenedFiles}, - highlight_modified = ${cfg.renderer.highlightModified}, - root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel}, - indent_width = ${toString cfg.renderer.indentWidth}, - indent_markers = { - enable = ${boolToString cfg.renderer.indentMarkers.enable}, - inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows}, - icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons}, - }, + remove_file = { + close_window = ${boolToString cfg.actions.removeFile.closeWindow}, + }, + }, - special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles}, - symlink_destination = ${boolToString cfg.renderer.symlinkDestination}, + live_filter = { + prefix = "${cfg.liveFilter.prefix}", + always_show_folders = ${boolToString cfg.liveFilter.alwaysShowFolders}, + }, - icons = { - webdev_colors = ${boolToString cfg.renderer.icons.webdevColors}, - git_placement = "${cfg.renderer.icons.gitPlacement}", - modified_placement = "${cfg.renderer.icons.modifiedPlacement}", - padding = "${cfg.renderer.icons.padding}", - symlink_arrow = "${cfg.renderer.icons.symlinkArrow}", + tab = { + sync = { + open = ${boolToString cfg.tab.sync.open}, + close = ${boolToString cfg.tab.sync.close}, + ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore}, + }, + }, - show = { - git = ${boolToString cfg.renderer.icons.show.git}, - folder = ${boolToString cfg.renderer.icons.show.folder}, - folder_arrow = ${boolToString cfg.renderer.icons.show.folderArrow}, - file = ${boolToString cfg.renderer.icons.show.file}, - modified = ${boolToString cfg.renderer.icons.show.modified}, - }, + notify = { + threshold = vim.log.levels.${cfg.notify.threshold}, + absolute_path = ${boolToString cfg.notify.absolutePath}, + }, - glyphs = { - default = "${cfg.renderer.icons.glyphs.default}", - symlink = "${cfg.renderer.icons.glyphs.symlink}", - modified = "${cfg.renderer.icons.glyphs.modified}", + ui = { + confirm = { + remove = ${boolToString cfg.ui.confirm.remove}, + trash = ${boolToString cfg.ui.confirm.trash}, + }, + }, + }) - folder = { - default = "${cfg.renderer.icons.glyphs.folder.default}", - open = "${cfg.renderer.icons.glyphs.folder.open}", - arrow_open = "${cfg.renderer.icons.glyphs.folder.arrowOpen}", - arrow_closed = "${cfg.renderer.icons.glyphs.folder.arrowClosed}", - empty = "${cfg.renderer.icons.glyphs.folder.empty}", - empty_open = "${cfg.renderer.icons.glyphs.folder.emptyOpen}", - symlink = "${cfg.renderer.icons.glyphs.folder.symlink}", - symlink_open = "${cfg.renderer.icons.glyphs.folder.symlinkOpen}", - }, + -- autostart behaviour + ${ + lib.optionalString (cfg.openOnSetup) '' + -- Open on startup has been deprecated + -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup - git = { - unstaged = "${cfg.renderer.icons.glyphs.git.unstaged}", - staged = "${cfg.renderer.icons.glyphs.git.staged}", - unmerged = "${cfg.renderer.icons.glyphs.git.unmerged}", - renamed = "${cfg.renderer.icons.glyphs.git.renamed}", - untracked = "${cfg.renderer.icons.glyphs.git.untracked}", - deleted = "${cfg.renderer.icons.glyphs.git.deleted}", - ignored = "${cfg.renderer.icons.glyphs.git.ignored}", - }, - }, - }, - }, + -- use a nix eval to dynamically insert the open on startup function + local function open_nvim_tree(data) + local IGNORED_FT = { + "markdown", + } - filters = { - git_ignored = ${boolToString cfg.filters.gitIgnored}, - dotfiles = ${boolToString cfg.filters.dotfiles}, - git_clean = ${boolToString cfg.filters.gitClean}, - no_buffer = ${boolToString cfg.filters.noBuffer}, - exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude}, - }, + -- buffer is a real file on the disk + local real_file = vim.fn.filereadable(data.file) == 1 - trash = { - cmd = "${cfg.trash.cmd}", - }, + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - actions = { - use_system_clipboard = ${boolToString cfg.actions.useSystemClipboard}, - change_dir = { - enable = ${boolToString cfg.actions.changeDir.enable}, - global = ${boolToString cfg.actions.changeDir.global}, - restrict_above_cwd = ${boolToString cfg.actions.changeDir.restrictAboveCwd}, - }, + -- &ft + local filetype = vim.bo[data.buf].ft - expand_all = { - max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery}, - exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude}, - }, + -- only files please + if not real_file and not no_name then + return + end - file_popup = { - open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig}, - }, + -- skip ignored filetypes + if vim.tbl_contains(IGNORED_FT, filetype) then + return + end - open_file = { - quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, - eject = ${boolToString cfg.actions.openFile.eject}, - resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, - window_picker = { - enable = ${boolToString cfg.actions.openFile.windowPicker.enable}, - picker = "${cfg.actions.openFile.windowPicker.picker}", - chars = "${cfg.actions.openFile.windowPicker.chars}", - exclude = { - filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype}, - buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype}, - }, - }, - }, + -- open the tree but don't focus it + require("nvim-tree.api").tree.toggle({ focus = false }) + end - remove_file = { - close_window = ${boolToString cfg.actions.removeFile.closeWindow}, - }, - }, - - live_filter = { - prefix = "${cfg.liveFilter.prefix}", - always_show_folders = ${boolToString cfg.liveFilter.alwaysShowFolders}, - }, - - tab = { - sync = { - open = ${boolToString cfg.tab.sync.open}, - close = ${boolToString cfg.tab.sync.close}, - ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore}, - }, - }, - - notify = { - threshold = vim.log.levels.${cfg.notify.threshold}, - absolute_path = ${boolToString cfg.notify.absolutePath}, - }, - - ui = { - confirm = { - remove = ${boolToString cfg.ui.confirm.remove}, - trash = ${boolToString cfg.ui.confirm.trash}, - }, - }, - }) + -- function to automatically open the tree on VimEnter + vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + '' + } ''; }; } diff --git a/modules/filetree/nvimtree/nvimtree.nix b/modules/filetree/nvimtree/nvimtree.nix index 93d7942..8821eeb 100644 --- a/modules/filetree/nvimtree/nvimtree.nix +++ b/modules/filetree/nvimtree/nvimtree.nix @@ -260,10 +260,12 @@ with builtins; { severity = mkOption { description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`"; + default = { min = "HINT"; max = "ERROR"; }; + type = types.submodule { options = { min = mkOption { @@ -306,7 +308,7 @@ with builtins; { ''; }; - timeOut = mkOption { + timeout = mkOption { type = types.int; default = 400; description = '' @@ -472,6 +474,7 @@ with builtins; { float = mkOption { description = "Configuration options for floating window."; + default = { enable = false; quitOnFocusLoss = true;