2022-01-09 17:59:07 +00:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
2022-09-18 11:19:23 +01:00
|
|
|
cfg = config.plugins.nvim-tree;
|
2022-01-09 17:59:07 +00:00
|
|
|
helpers = import ../helpers.nix { lib = lib; };
|
|
|
|
in
|
|
|
|
{
|
2022-09-18 11:19:23 +01:00
|
|
|
options.plugins.nvim-tree = {
|
2022-01-09 17:59:07 +00:00
|
|
|
enable = mkEnableOption "Enable nvim-tree";
|
|
|
|
|
|
|
|
disableNetrw = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
|
|
|
description = "Disable netrw";
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
hijackNetrw = mkOption {
|
2022-01-09 17:59:07 +00:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2022-11-07 17:10:18 +01:00
|
|
|
# TODO: change this to it's new definition sync_root_with_cwd
|
2022-01-09 17:59:07 +00:00
|
|
|
updateCwd = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2022-11-07 17:10:18 +01:00
|
|
|
respectBufCwd = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2022-01-09 17:59:07 +00:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
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";
|
2022-01-09 17:59:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
updateFocusedFile = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2022-11-07 17:10:18 +01:00
|
|
|
# TODO: change this to it's new definition update_root
|
2022-01-09 17:59:07 +00:00
|
|
|
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 {
|
2022-07-18 21:14:41 +00:00
|
|
|
type = types.nullOr types.bool;
|
2022-01-09 17:59:07 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
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;
|
2022-11-07 17:10:18 +01:00
|
|
|
respect_buf_cwd = cfg.respectBufCwd;
|
2022-09-18 11:19:23 +01:00
|
|
|
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;
|
2022-01-09 17:59:07 +00:00
|
|
|
};
|
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
2022-01-09 17:59:07 +00:00
|
|
|
extraPlugins = with pkgs.vimPlugins; [
|
2022-09-18 11:19:23 +01:00
|
|
|
nvim-tree-lua
|
|
|
|
nvim-web-devicons
|
2022-01-09 17:59:07 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
extraConfigLua = ''
|
|
|
|
require('nvim-tree').setup(${helpers.toLuaObject options})
|
|
|
|
'';
|
2022-10-03 19:02:55 +01:00
|
|
|
extraPackages = [ pkgs.git ];
|
2022-01-09 17:59:07 +00:00
|
|
|
};
|
|
|
|
}
|