diff --git a/plugins/default.nix b/plugins/default.nix index bb2aaac9..8b142199 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -1,45 +1,46 @@ { imports = [ - ./bufferlines/bufferline.nix ./bufferlines/barbar.nix + ./bufferlines/bufferline.nix - ./colorschemes/gruvbox.nix - ./colorschemes/onedark.nix - ./colorschemes/one.nix ./colorschemes/base16.nix + ./colorschemes/gruvbox.nix + ./colorschemes/one.nix + ./colorschemes/onedark.nix ./colorschemes/tokyonight.nix - ./pluginmanagers/packer.nix - - ./statuslines/lightline.nix - ./statuslines/airline.nix - ./statuslines/lualine.nix - - ./git/gitgutter.nix ./git/fugitive.nix + ./git/gitgutter.nix - ./utils/undotree.nix - ./utils/commentary.nix - ./utils/comment-nvim.nix - ./utils/floaterm.nix - ./utils/startify.nix - ./utils/goyo.nix - ./utils/endwise.nix - ./utils/easyescape.nix - ./utils/nvim-autopairs.nix - ./utils/intellitab.nix - ./utils/specs.nix - ./utils/mark-radar.nix - ./utils/notify.nix - - ./languages/treesitter.nix - ./languages/nix.nix - ./languages/zig.nix ./languages/ledger.nix + ./languages/nix.nix + ./languages/treesitter.nix + ./languages/zig.nix ./nvim-lsp ./nvim-lsp/lspsaga.nix + ./pluginmanagers/packer.nix + + ./statuslines/airline.nix + ./statuslines/lightline.nix + ./statuslines/lualine.nix + ./telescope + + ./utils/comment-nvim.nix + ./utils/commentary.nix + ./utils/easyescape.nix + ./utils/endwise.nix + ./utils/floaterm.nix + ./utils/goyo.nix + ./utils/intellitab.nix + ./utils/mark-radar.nix + ./utils/notify.nix + ./utils/nvim-autopairs.nix + ./utils/nvim-tree.nix + ./utils/specs.nix + ./utils/startify.nix + ./utils/undotree.nix ]; } diff --git a/plugins/utils/nvim-tree.nix b/plugins/utils/nvim-tree.nix new file mode 100644 index 00000000..3740d2b7 --- /dev/null +++ b/plugins/utils/nvim-tree.nix @@ -0,0 +1,257 @@ +{ pkgs, config, lib, ... }: +with lib; +let + cfg = config.programs.nixvim.plugins.nvim-tree; + helpers = import ../helpers.nix { lib = lib; }; +in +{ + options.programs.nixvim.plugins.nvim-tree = { + enable = mkEnableOption "Enable nvim-tree"; + + disableNetrw = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Disable netrw"; + }; + + hijackNetrw = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Hijack netrw"; + }; + + openOnSetup = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Open on setup"; + }; + + ignoreFtOnSetup = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; + + autoClose = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Automatically close"; + }; + + openOnTab = mkOption { + type = types.nullOr types.bool; + default = null; + }; + + hijackCursor = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Hijack cursor"; + }; + + updateCwd = mkOption { + type = types.nullOr types.bool; + default = null; + }; + + updateToBufDir = { + enable = mkOption { + type = types.nullOr types.bool; + default = null; + }; + + autoOpen = mkOption { + type = types.nullOr types.bool; + default = null; + }; + }; + + diagnostics = { + enable = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Enable diagnostics"; + }; + + icons = let + diagnosticOption = desc: mkOption { + type = types.nullOr types.str; + default = null; + description = desc; + }; + in { + hint = diagnosticOption "Hints"; + info = diagnosticOption "Info"; + warning = diagnosticOption "Warning"; + error = diagnosticOption "Error"; + }; + }; + + updateFocusedFile = { + enable = mkOption { + type = types.nullOr types.bool; + default = null; + }; + + updateCwd = mkOption { + type = types.nullOr types.bool; + default = null; + }; + + ignoreList = mkOption { + type = types.nullOr (types.listOf types.bool); + default = null; + }; + }; + + systemOpen = { + cmd = mkOption { + type = types.nullOr types.str; + default = null; + }; + args = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; + }; + + git = { + enable = mkOption { + type = types.nullOr types.str; + default = null; + description = "Enable git integration"; + }; + + ignore = mkOption { + type = types.nullOr types.bool; + default = null; + }; + + timeout = mkOption { + type = types.nullOr types.int; + default = null; + }; + }; + + filters = { + dotfiles = mkOption { + type = types.nullOr types.bool; + default = null; + }; + custom = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; + }; + + view = { + width = mkOption { + type = types.nullOr types.int; + default = null; + }; + height = mkOption { + type = types.nullOr types.int; + default = null; + }; + hideRootFolder = mkOption { + type = types.nullOr types.bool; + default = null; + }; + side = mkOption { + type = types.nullOr types.str; + default = null; + }; + autoResize = mkOption { + type = types.nullOr types.bool; + default = null; + }; + mappings = { + customOnly = mkOption { + type = types.nullOr types.bool; + default = null; + }; + list = mkOption { + # TODO: Type-check the attrset + type = types.nullOr (types.listOf types.attrs); + default = null; + }; + }; + number = mkOption { + type = types.nullOr types.bool; + default = null; + }; + relativenumber = mkOption { + type = types.nullOr types.bool; + default = null; + }; + signcolumn = mkOption { + type = types.nullOr types.str; + default = null; + }; + }; + + trash = { + cmd = mkOption { + type = types.nullOr types.str; + default = null; + }; + requireConfirm = mkOption { + type = types.nullOr types.bool; + default = null; + }; + }; + }; + + config = let + options = { + disable_netrw = cfg.disableNetrw; + hijack_netrw = cfg.hijackNetrw; + open_on_setup = cfg.openOnSetup; + ignore_ft_on_setup = cfg.ignoreFtOnSetup; + auto_close = cfg.autoClose; + open_on_tab = cfg.openOnTab; + hijack_cursor = cfg.hijackCursor; + update_cwd = cfg.updateCwd; + update_to_buf_dir = { + enable = cfg.updateToBufDir.enable; + auto_open = cfg.updateToBufDir.autoOpen; + }; + diagnostics = cfg.diagnostics; + updateFocusedFile = { + enable = cfg.updateFocusedFile.enable; + update_cwd = cfg.updateFocusedFile.updateCwd; + ignore_list = cfg.updateFocusedFile.ignoreList; + }; + system_open = cfg.systemOpen; + filters = cfg.filters; + git = cfg.git; + view = { + width = cfg.view.width; + height = cfg.view.height; + hide_root_folder = cfg.view.hideRootFolder; + side = cfg.view.side; + auto_resize = cfg.view.autoResize; + mappings = { + custom_only = cfg.view.mappings.customOnly; + list = cfg.view.mappings.list; + }; + number = cfg.view.number; + relativenumber = cfg.view.relativenumber; + signcolumn = cfg.view.signcolumn; + }; + trash = { + cmd = cfg.trash.cmd; + require_confirm = cfg.trash.requireConfirm; + }; + }; + in mkIf cfg.enable { + programs.nixvim = { + extraPlugins = with pkgs.vimPlugins; [ + nvim-tree-lua nvim-web-devicons + ]; + + extraConfigLua = '' + require('nvim-tree').setup(${helpers.toLuaObject options}) + ''; + }; + }; +}