Merge pull request #238 from horriblename/setupopts

treewide: custom plugin setup options
This commit is contained in:
raf 2024-04-07 12:39:15 +00:00 committed by GitHub
commit e1835f6c46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 2222 additions and 2446 deletions

View file

@ -210,7 +210,7 @@ inputs: let
}; };
smartcolumn = { smartcolumn = {
enable = true; enable = true;
columnAt.languages = { setupOpts.custom_colorcolumn = {
# this is a freeform module, it's `buftype = int;` for configuring column position # this is a freeform module, it's `buftype = int;` for configuring column position
nix = 110; nix = 110;
ruby = 120; ruby = 120;

View file

@ -31,3 +31,95 @@ You can now reference this plugin using its string name:
```nix ```nix
config.vim.startPlugins = ["neodev-nvim"]; config.vim.startPlugins = ["neodev-nvim"];
``` ```
## Modular setup options {#sec-modular-setup-options}
Most plugins is initialized with a call to `require('plugin').setup({...})`.
We use a special function that lets you easily add support for such setup options in a modular way:
`mkPluginSetupOption`.
Once you have added the source of the plugin as shown above, you can define the setup options like
this:
```nix
# in modules/.../your-plugin/your-plugin.nix
{lib, ...}:
let
inherit (lib.types) bool int;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.your-plugin = {
setupOpts = mkPluginSetupOption "plugin name" {
enable_feature_a = mkOption {
type = bool;
default = false;
# ...
};
number_option = mkOption {
type = int;
default = 3;
# ...
};
};
};
}
```
```nix
# in modules/.../your-plugin/config.nix
{lib, config, ...}:
let
cfg = config.vim.your-plugin;
in {
vim.luaConfigRC = lib.nvim.dag.entryAnywhere ''
require('plugin-name').setup(${lib.nvim.lua.toLuaObject cfg.setupOpts})
'';
}
```
This above config will result in this lua script:
```lua
require('plugin-name').setup({
enable_feature_a = false,
number_option = 3,
})
```
Now users can set any of the pre-defined option field, and can also add their own fields!
```nix
# in user's config
{
vim.your-plugin.setupOpts = {
enable_feature_a = true;
number_option = 4;
another_field = "hello";
size = { # nested fields work as well
top = 10;
};
};
}
```
## Details of toLuaObject {#sec-details-of-toluaobject}
As you've seen above, `toLuaObject` is used to convert our nix attrSet `cfg.setupOpts`, into a lua
table. Here are some rules of the conversion:
1. nix `null` converts to lua `nil`
2. number and strings convert to their lua counterparts
3. nix attrSet/list converts into lua tables
4. you can write raw lua code using `lib.generators.mkLuaInline`. This function is part of nixpkgs.
```nix
vim.your-plugin.setupOpts = {
on_init = lib.generators.mkLuaInline ''
function()
print('we can write lua!')
end
'';
}
```

View file

@ -12,6 +12,10 @@ Release notes for release 0.6
- Fixed empty winbar when breadcrumbs are disabled - Fixed empty winbar when breadcrumbs are disabled
- Added custom setupOpts for various plugins
- Removed support for deprecated plugin "nvim-compe"
[donnerinoern](https://github.com/donnerinoern): [donnerinoern](https://github.com/donnerinoern):
- Added Gruvbox theme - Added Gruvbox theme

View file

@ -1092,22 +1092,6 @@
"type": "github" "type": "github"
} }
}, },
"nvim-compe": {
"flake": false,
"locked": {
"lastModified": 1633188506,
"narHash": "sha256-Y2oqvsuAKM3qjmmtJVD9z34682eCRF25kPL+rxhhg7I=",
"owner": "hrsh7th",
"repo": "nvim-compe",
"rev": "d186d739c54823e0b010feb205c6f97792322c08",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "nvim-compe",
"type": "github"
}
},
"nvim-cursorline": { "nvim-cursorline": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1574,7 +1558,6 @@
"nvim-cmp": "nvim-cmp", "nvim-cmp": "nvim-cmp",
"nvim-code-action-menu": "nvim-code-action-menu", "nvim-code-action-menu": "nvim-code-action-menu",
"nvim-colorizer-lua": "nvim-colorizer-lua", "nvim-colorizer-lua": "nvim-colorizer-lua",
"nvim-compe": "nvim-compe",
"nvim-cursorline": "nvim-cursorline", "nvim-cursorline": "nvim-cursorline",
"nvim-dap": "nvim-dap", "nvim-dap": "nvim-dap",
"nvim-dap-ui": "nvim-dap-ui", "nvim-dap-ui": "nvim-dap-ui",

View file

@ -228,12 +228,6 @@
flake = false; flake = false;
}; };
# Autocompletes
nvim-compe = {
url = "github:hrsh7th/nvim-compe";
flake = false;
};
nvim-cmp = { nvim-cmp = {
url = "github:hrsh7th/nvim-cmp"; url = "github:hrsh7th/nvim-cmp";
flake = false; flake = false;

View file

@ -48,11 +48,13 @@ in rec {
# Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first
luaTable = items: ''{${concatStringsSep "," items}}''; luaTable = items: ''{${concatStringsSep "," items}}'';
isLuaInline = {_type ? null, ...}: _type == "lua-inline";
toLuaObject = args: toLuaObject = args:
if isAttrs args if isAttrs args
then then
if hasAttr "__raw" args if isLuaInline args
then args.__raw then args.expr
else if hasAttr "__empty" args else if hasAttr "__empty" args
then "{ }" then "{ }"
else else

View file

@ -4,6 +4,6 @@
typesLanguage = import ./languages.nix {inherit lib;}; typesLanguage = import ./languages.nix {inherit lib;};
in { in {
inherit (typesDag) dagOf; inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline;
inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesLanguage) diagnostics mkGrammarOption;
} }

View file

@ -15,7 +15,6 @@ with lib; let
"nvim-tree-lua" "nvim-tree-lua"
"nvim-bufferline-lua" "nvim-bufferline-lua"
"lualine" "lualine"
"nvim-compe"
"nvim-autopairs" "nvim-autopairs"
"nvim-ts-autotag" "nvim-ts-autotag"
"nvim-web-devicons" "nvim-web-devicons"
@ -145,6 +144,18 @@ in {
type = pluginsType; type = pluginsType;
}; };
luaInline = lib.mkOptionType {
name = "luaInline";
check = x: lib.nvim.lua.isLuaInline x || builtins.isString x;
merge = loc: defs: let
val =
if isString loc
then lib.generators.mkLuaInline loc
else loc;
in
lib.mergeOneOption val defs;
};
# opts is a attrset of options, example: # opts is a attrset of options, example:
# ``` # ```
# mkPluginSetupOption "telescope" { # mkPluginSetupOption "telescope" {

View file

@ -4,10 +4,10 @@
... ...
}: let }: let
inherit (builtins) toJSON; inherit (builtins) toJSON;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.lists) optionals; inherit (lib.lists) optionals;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkLuaBinding; inherit (lib.nvim.binds) mkLuaBinding;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
@ -28,55 +28,47 @@ in {
vim.startPlugins = vim.startPlugins =
[ [
"copilot-lua" "copilot-lua"
cfg.copilotNodePackage # cfg.copilotNodePackage
] ]
++ optionals (cfg.cmp.enable) [ ++ optionals (cfg.cmp.enable) [
"copilot-cmp" "copilot-cmp"
]; ];
vim.luaConfigRC.copilot = entryAnywhere '' vim.luaConfigRC.copilot = entryAnywhere ''
require("copilot").setup({ require("copilot").setup(${toLuaObject cfg.setupOpts})
-- available options: https://github.com/zbirenbaum/copilot.lua
copilot_node_command = "${cfg.copilotNodeCommand}",
panel = {
enabled = ${boolToString (!cfg.cmp.enable)},
keymap = {
jump_prev = false,
jump_next = false,
accept = false,
refresh = false,
open = false,
},
layout = {
position = "${cfg.panel.position}",
ratio = ${toString cfg.panel.ratio},
},
},
suggestion = {
enabled = ${boolToString (!cfg.cmp.enable)},
keymap = {
accept = false,
accept_word = false,
accept_line = false,
next = false,
prev = false,
dismiss = false,
},
},
})
${lib.optionalString (cfg.cmp.enable) '' ${lib.optionalString (cfg.cmp.enable) ''
require("copilot_cmp").setup() require("copilot_cmp").setup()
''} ''}
''; '';
# Disable plugin handled keymaps.
# Setting it here so that it doesn't show up in user docs
vim.assistant.copilot.setupOpts = {
panel.keymap = {
jump_prev = lib.mkDefault false;
jump_next = lib.mkDefault false;
accept = lib.mkDefault false;
refresh = lib.mkDefault false;
open = lib.mkDefault false;
};
suggestion.keymap = {
accept = lib.mkDefault false;
accept_word = lib.mkDefault false;
accept_line = lib.mkDefault false;
next = lib.mkDefault false;
prev = lib.mkDefault false;
dismiss = lib.mkDefault false;
};
};
vim.maps.normal = mkMerge [ vim.maps.normal = mkMerge [
(mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding '' (mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding ''
function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end
'' ''
cfg.mappings.panel.open) "[copilot] Accept suggestion") cfg.mappings.panel.open) "[copilot] Accept suggestion")
]; ];

View file

@ -4,31 +4,56 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum float nullOr str package; inherit (lib.types) nullOr str enum float;
inherit (lib.meta) getExe; inherit (lib.nvim.types) mkPluginSetupOption;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
in { in {
imports = [
(mkRenamedOptionModule ["vim" "assistant" "copilot" "panel"] ["vim" "assistant" "copilot" "setupOpts" "panel"])
(mkRenamedOptionModule ["vim" "assistant" "copilot" "copilotNodeCommand"] ["vim" "assistant" "copilot" "setupOpts" "copilot_node_command"])
(mkRenamedOptionModule ["vim" "assistant" "copilot" "copilotNodePackage"] ["vim" "assistant" "copilot" "setupOpts" "copilot_node_command"])
];
options.vim.assistant.copilot = { options.vim.assistant.copilot = {
enable = mkEnableOption "GitHub Copilot AI assistant"; enable = mkEnableOption "GitHub Copilot AI assistant";
cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot"; cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot";
panel = { setupOpts = mkPluginSetupOption "Copilot" {
position = mkOption { copilot_node_command = mkOption {
type = enum [ type = str;
"bottom" default = "${lib.getExe pkgs.nodejs-slim}";
"top" description = ''
"left" The command that will be executed to initiate nodejs for GitHub Copilot.
"right" Recommended to leave as default.
]; '';
default = "bottom";
description = "Panel position";
}; };
ratio = mkOption { panel = {
type = float; enabled = mkEnableOption "Completion Panel" // {default = !cfg.cmp.enable;};
default = 0.4; layout = {
description = "Panel size"; position = mkOption {
type = enum [
"bottom"
"top"
"left"
"right"
];
default = "bottom";
description = "Panel position";
};
ratio = mkOption {
type = float;
default = 0.4;
description = "Panel size";
};
};
};
suggestion = {
enabled = mkEnableOption "Suggestions" // {default = !cfg.cmp.enable;};
# keymap = { };
}; };
}; };
@ -102,23 +127,5 @@ in {
}; };
}; };
}; };
copilotNodeCommand = mkOption {
type = str;
default = "${getExe cfg.copilotNodePackage}";
description = ''
The command that will be executed to initiate nodejs for GitHub Copilot.
Recommended to leave as default.
'';
};
copilotNodePackage = mkOption {
type = nullOr package;
default = pkgs.nodejs-slim;
description = ''
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command
you may want to set this option to null so that the package is not pulled from nixpkgs.
'';
};
}; };
} }

View file

@ -4,9 +4,9 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.autopairs; cfg = config.vim.autopairs;
in { in {
@ -15,14 +15,6 @@ in {
vim.luaConfigRC.autopairs = entryAnywhere '' vim.luaConfigRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup{} require("nvim-autopairs").setup{}
${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
-- nvim-compe integration
require('nvim-autopairs.completion.compe').setup({
map_cr = ${boolToString cfg.nvim-compe.map_cr},
map_complete = ${boolToString cfg.nvim-compe.map_complete},
auto_select = ${boolToString cfg.nvim-compe.auto_select},
})
''}
''; '';
}; };
} }

View file

@ -1,7 +1,12 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkRemovedOptionModule;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum bool; inherit (lib.types) enum;
in { in {
imports = [
(mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer suported.")
];
options.vim = { options.vim = {
autopairs = { autopairs = {
enable = mkEnableOption "autopairs" // {default = false;}; enable = mkEnableOption "autopairs" // {default = false;};
@ -11,26 +16,6 @@ in {
default = "nvim-autopairs"; default = "nvim-autopairs";
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
}; };
nvim-compe = {
map_cr = mkOption {
type = bool;
default = true;
description = ''map <CR> on insert mode'';
};
map_complete = mkOption {
type = bool;
default = true;
description = "auto insert `(` after select function or method item";
};
auto_select = mkOption {
type = bool;
default = false;
description = "auto select first item";
};
};
}; };
}; };
} }

View file

@ -12,6 +12,7 @@
inherit (lib.types) bool str listOf oneOf attrsOf nullOr attrs submodule unspecified lines; inherit (lib.types) bool str listOf oneOf attrsOf nullOr attrs submodule unspecified lines;
inherit (lib.nvim.types) dagOf pluginsOpt extraPluginType; inherit (lib.nvim.types) dagOf pluginsOpt extraPluginType;
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort; inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.vim) valToVim; inherit (lib.nvim.vim) valToVim;
@ -86,7 +87,7 @@
else config; else config;
action = action =
if action.lua if action.lua
then {"__raw" = action.action;} then mkLuaInline action.action
else action.action; else action.action;
}; };
in in

View file

@ -6,10 +6,9 @@
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) listToLuaTable expToLua; inherit (lib.nvim.lua) toLuaObject;
# TODO: move this to its own module # TODO: move this to its own module
inherit (lib) pushDownDefault; inherit (lib) pushDownDefault;
@ -40,237 +39,7 @@ in {
'' ''
} }
require'nvim-tree'.setup({ require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
disable_netrw = ${boolToString cfg.disableNetrw},
hijack_netrw = ${boolToString cfg.hijackNetrw},
auto_reload_on_write = ${boolToString cfg.autoreloadOnWrite},
sort = {
sorter = "${cfg.sort.sorter}",
folders_first = ${boolToString cfg.sort.foldersFirst},
},
hijack_unnamed_buffer_when_opening = ${boolToString cfg.hijackUnnamedBufferWhenOpening},
hijack_cursor = ${boolToString cfg.hijackCursor},
root_dirs = ${listToLuaTable cfg.rootDirs},
prefer_startup_root = ${boolToString cfg.preferStartupRoot},
sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd},
reload_on_bufenter = ${boolToString cfg.reloadOnBufEnter},
respect_buf_cwd = ${boolToString cfg.respectBufCwd},
hijack_directories = {
enable = ${boolToString cfg.hijackDirectories.enable},
auto_open = ${boolToString cfg.hijackDirectories.autoOpen},
},
update_focused_file = {
enable = ${boolToString cfg.updateFocusedFile.enable},
update_root = ${boolToString cfg.updateFocusedFile.updateRoot},
ignore_list = ${listToLuaTable cfg.updateFocusedFile.ignoreList},
},
system_open = {
cmd = "${cfg.systemOpen.cmd}",
args = ${listToLuaTable cfg.systemOpen.args},
},
diagnostics = {
enable = ${boolToString cfg.diagnostics.enable},
icons = {
hint = "${cfg.diagnostics.icons.hint}",
info = "${cfg.diagnostics.icons.info}",
warning = "${cfg.diagnostics.icons.warning}",
error = "${cfg.diagnostics.icons.error}",
},
severity = {
min = vim.diagnostic.severity.${cfg.diagnostics.severity.min},
max = vim.diagnostic.severity.${cfg.diagnostics.severity.max},
},
},
git = {
enable = ${boolToString cfg.git.enable},
show_on_dirs = ${boolToString cfg.git.showOnDirs},
show_on_open_dirs = ${boolToString cfg.git.showOnOpenDirs},
disable_for_dirs = ${listToLuaTable cfg.git.disableForDirs},
timeout = ${toString cfg.git.timeout},
},
modified = {
enable = ${boolToString cfg.modified.enable},
show_on_dirs = ${boolToString cfg.modified.showOnDirs},
show_on_open_dirs = ${boolToString cfg.modified.showOnOpenDirs},
},
filesystem_watchers = {
enable = ${boolToString cfg.filesystemWatchers.enable},
debounce_delay = ${toString cfg.filesystemWatchers.debounceDelay},
ignore_dirs = ${listToLuaTable cfg.filesystemWatchers.ignoreDirs},
},
select_prompts = ${boolToString cfg.selectPrompts},
view = {
centralize_selection = ${boolToString cfg.view.centralizeSelection},
cursorline = ${boolToString cfg.view.cursorline},
debounce_delay = ${toString cfg.view.debounceDelay},
width = ${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 = ${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 = ${expToLua cfg.renderer.indentMarkers.icons},
},
special_files = ${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 = ${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 = ${listToLuaTable cfg.actions.expandAll.exclude},
},
file_popup = {
open_win_config = ${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 = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype},
buftype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype},
},
},
},
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 = ${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},
},
},
})
${ ${
optionalString cfg.openOnSetup '' optionalString cfg.openOnSetup ''

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp; cfg = config.vim.lsp;
in { in {
@ -15,16 +15,14 @@ in {
"lsp-signature" "lsp-signature"
]; ];
lsp.lspSignature.setupOpts = {
bind = config.vim.ui.borders.plugins.lsp-signature.enable;
handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style;
};
luaConfigRC.lsp-signature = entryAnywhere '' luaConfigRC.lsp-signature = entryAnywhere ''
-- Enable lsp signature viewer -- Enable lsp signature viewer
require("lsp_signature").setup({ require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts})
${optionalString config.vim.ui.borders.plugins.lsp-signature.enable ''
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "${config.vim.ui.borders.plugins.lsp-signature.style}"
}
''}
})
''; '';
}; };
}; };

View file

@ -3,7 +3,8 @@
in { in {
options.vim.lsp = { options.vim.lsp = {
lspSignature = { lspSignature = {
enable = mkEnableOption "lsp signature viewer [lsp-signature]"; enable = mkEnableOption "lsp signature viewer";
setupOpts = lib.nvim.types.mkPluginSetupOption "lsp-signature" {};
}; };
}; };
} }

View file

@ -3,10 +3,10 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) toString;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp.nvim-docs-view; cfg = config.vim.lsp.nvim-docs-view;
self = import ./nvim-docs-view.nix {inherit lib;}; self = import ./nvim-docs-view.nix {inherit lib;};
@ -20,12 +20,7 @@ in {
startPlugins = ["nvim-docs-view"]; startPlugins = ["nvim-docs-view"];
luaConfigRC.nvim-docs-view = entryAnywhere '' luaConfigRC.nvim-docs-view = entryAnywhere ''
require("docs-view").setup { require("docs-view").setup ${toLuaObject cfg.setupOpts}
position = "${cfg.position}",
width = ${toString cfg.width},
height = ${toString cfg.height},
update_mode = "${cfg.updateMode}",
}
''; '';
maps.normal = mkMerge [ maps.normal = mkMerge [

View file

@ -1,45 +1,57 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum int;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib) types mkRenamedOptionModule;
in { in {
imports = let
renamedSetupOption = oldPath: newPath:
mkRenamedOptionModule
(["vim" "lsp" "nvim-docs-view"] ++ oldPath)
(["vim" "lsp" "nvim-docs-view" "setupOpts"] ++ newPath);
in [
(renamedSetupOption ["position"] ["position"])
(renamedSetupOption ["width"] ["width"])
(renamedSetupOption ["height"] ["height"])
(renamedSetupOption ["updateMode"] ["update_mode"])
];
options.vim.lsp.nvim-docs-view = { options.vim.lsp.nvim-docs-view = {
enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel."; enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel.";
position = mkOption { setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-docs-view" {
type = enum ["left" "right" "top" "bottom"]; position = mkOption {
default = "right"; type = types.enum ["left" "right" "top" "bottom"];
description = '' default = "right";
Where to open the docs view panel description = ''
''; Where to open the docs view panel
}; '';
};
height = mkOption { height = mkOption {
type = int; type = types.int;
default = 10; default = 10;
description = '' description = ''
Height of the docs view panel if the position is set to either top or bottom Height of the docs view panel if the position is set to either top or bottom
''; '';
}; };
width = mkOption { width = mkOption {
type = int; type = types.int;
default = 60; default = 60;
description = '' description = ''
Width of the docs view panel if the position is set to either left or right Width of the docs view panel if the position is set to either left or right
''; '';
}; };
updateMode = mkOption { update_mode = mkOption {
type = enum ["auto" "manual"]; type = types.enum ["auto" "manual"];
default = "auto"; default = "auto";
description = '' description = ''
Determines the mechanism used to update the docs view panel content Determines the mechanism used to update the docs view panel content.
- If auto, the content will update upon cursor move.
Possible values: - If manual, the content will only update once :DocsViewUpdate is called
- auto: the content will update upon cursor move. '';
- manual: the content will only update once :DocsViewUpdate is called };
'';
}; };
mappings = { mappings = {

View file

@ -6,9 +6,9 @@
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault; inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.obsidian; cfg = config.vim.notes.obsidian;
auto = config.vim.autocomplete;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
@ -23,28 +23,7 @@ in {
}; };
luaConfigRC.obsidian = entryAnywhere '' luaConfigRC.obsidian = entryAnywhere ''
require("obsidian").setup({ require("obsidian").setup(${toLuaObject cfg.setupOpts})
dir = "${cfg.dir}",
completion = {
nvim_cmp = ${
if (auto.type == "nvim-cmp")
then "true"
else "false"
}
},
daily_notes = {
folder = ${
if (cfg.daily-notes.folder == "")
then "nil,"
else "'${cfg.daily-notes.folder}',"
}
date_format = ${
if (cfg.daily-notes.date-format == "")
then "nil,"
else "'${cfg.daily-notes.date-format}',"
}
}
})
''; '';
}; };
}; };

View file

@ -1,33 +1,52 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption mkOption; config,
inherit (lib.types) str bool; lib,
...
}: let
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
in { in {
imports = let
renamedSetupOption = oldPath: newPath:
mkRenamedOptionModule
(["vim" "notes" "obsidian"] ++ oldPath)
(["vim" "notes" "obsidian" "setupOpts"] ++ newPath);
in [
(renamedSetupOption ["dir"] ["dir"])
(renamedSetupOption ["daily-notes" "folder"] ["daily_notes" "folder"])
(renamedSetupOption ["daily-notes" "date-format"] ["daily_notes" "date_format"])
(renamedSetupOption ["completion"] ["completion"])
];
options.vim.notes = { options.vim.notes = {
obsidian = { obsidian = {
enable = mkEnableOption "complementary neovim plugins for Obsidian editor"; enable = mkEnableOption "complementary neovim plugins for Obsidian editor";
dir = mkOption {
type = str;
default = "~/my-vault";
description = "Obsidian vault directory";
};
daily-notes = { setupOpts = lib.nvim.types.mkPluginSetupOption "Obsidian.nvim" {
folder = mkOption { dir = mkOption {
type = str; type = types.str;
default = ""; default = "~/my-vault";
description = "Directory in which daily notes should be created"; description = "Obsidian vault directory";
}; };
date-format = mkOption {
type = str;
default = "";
description = "Date format used for creating daily notes";
};
};
completion = { daily_notes = {
nvim_cmp = mkOption { folder = mkOption {
type = bool; type = types.nullOr types.str;
description = "If using nvim-cmp, otherwise set to false"; default = null;
description = "Directory in which daily notes should be created";
};
date_format = mkOption {
type = types.nullOr types.str;
default = null;
description = "Date format used for creating daily notes";
};
};
completion = {
nvim_cmp = mkOption {
# if using nvim-cmp, otherwise set to false
type = types.bool;
description = "If using nvim-cmp, otherwise set to false";
default = config.vim.autocomplete.type == "nvim-cmp";
};
}; };
}; };
}; };

View file

@ -6,6 +6,7 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault; inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.orgmode; cfg = config.vim.notes.orgmode;
in { in {
@ -37,10 +38,7 @@ in {
}, },
} }
require('orgmode').setup({ require('orgmode').setup(${toLuaObject cfg.setupOpts})
org_agenda_files = ${cfg.orgAgendaFiles},
org_default_notes_file = '${cfg.orgDefaultNotesFile}',
})
''; '';
}; };
} }

View file

@ -4,23 +4,31 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.types) str; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.types) str listOf;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
in { in {
imports = [
(mkRenamedOptionModule ["vim" "notes" "orgmode" "orgAgendaFiles"] ["vim" "notes" "orgmode" "setupOpts" "org_agenda_files"])
(mkRenamedOptionModule ["vim" "notes" "orgmode" "orgDefaultNotesFile"] ["vim" "notes" "orgmode" "setupOpts" "org_default_notes_file"])
];
options.vim.notes.orgmode = { options.vim.notes.orgmode = {
enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds"; enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds";
orgAgendaFiles = mkOption { setupOpts = mkPluginSetupOption "Orgmode" {
type = str; org_agenda_files = mkOption {
default = "{'~/Documents/org/*', '~/my-orgs/**/*'}"; type = listOf str;
description = "List of org files to be used as agenda files."; default = ["~/Documents/org/*" "~/my-orgs/**/*"];
}; description = "List of org files to be used as agenda files.";
};
orgDefaultNotesFile = mkOption { org_default_notes_file = mkOption {
type = str; type = str;
default = "~/Documents/org/refile.org"; default = "~/Documents/org/refile.org";
description = "Default org file to be used for notes."; description = "Default org file to be used for notes.";
};
}; };
treesitter = { treesitter = {

View file

@ -4,11 +4,11 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib) mkMerge mkBinding mkIf;
inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.todo-comments; cfg = config.vim.notes.todo-comments;
self = import ./todo-comments.nix {inherit lib;}; self = import ./todo-comments.nix {inherit pkgs lib;};
inherit (self.options.vim.notes.todo-comments) mappings; inherit (self.options.vim.notes.todo-comments) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -24,28 +24,7 @@ in {
]; ];
luaConfigRC.todo-comments = '' luaConfigRC.todo-comments = ''
require('todo-comments').setup { require('todo-comments').setup(${toLuaObject cfg.setupOpts})
highlight = {
before = "", -- "fg" or "bg" or empty
keyword = "bg", -- "fg", "bg", "wide" or empty
after = "fg", -- "fg" or "bg" or empty
pattern = ${cfg.patterns.highlight},
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
search = {
command = "${pkgs.ripgrep}/bin/rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
pattern = ${cfg.patterns.search},
},
}
''; '';
}; };
}; };

View file

@ -1,22 +1,50 @@
{lib, ...}: let {
inherit (lib.options) mkOption mkEnableOption; pkgs,
inherit (lib.types) str; lib,
inherit (lib.nvim.binds) mkMappingOption; ...
}: let
inherit (lib) mkEnableOption mkOption types mkMappingOption mkRenamedOptionModule;
in { in {
imports = let
renamedSetupOption = oldPath: newPath:
mkRenamedOptionModule
(["vim" "notes" "todo-comments"] ++ oldPath)
(["vim" "notes" "todo-comments" "setupOpts"] ++ newPath);
in [
(renamedSetupOption ["patterns" "highlight"] ["highlight" "pattern"])
(renamedSetupOption ["patterns" "search"] ["search" "pattern"])
];
options.vim.notes.todo-comments = { options.vim.notes.todo-comments = {
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base"; enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
patterns = { setupOpts = lib.nvim.types.mkPluginSetupOption "todo-comments.nvim" {
highlight = mkOption { highlight = {
type = str; pattern = mkOption {
default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]''; type = types.str;
description = "vim regex pattern used for highlighting comments"; default = ''.*<(KEYWORDS)(\([^\)]*\))?:'';
description = "vim regex pattern used for highlighting comments";
};
}; };
search = mkOption { search = {
type = str; pattern = mkOption {
default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]''; type = types.str;
description = "ripgrep regex pattern used for searching comments"; default = ''\b(KEYWORDS)(\([^\)]*\))?:'';
description = "ripgrep regex pattern used for searching comments";
};
command = mkOption {
type = types.str;
default = "${pkgs.ripgrep}/bin/rg";
description = "search command";
};
args = mkOption {
type = types.listOf types.str;
default = ["--color=never" "--no-heading" "--with-filename" "--line-number" "--column"];
description = "arguments to pass to the search command";
};
}; };
}; };

View file

@ -3,10 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib) mkIf nvim;
inherit (lib.trivial) boolToString;
inherit (lib.strings) concatStringsSep;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.projects.project-nvim; cfg = config.vim.projects.project-nvim;
in { in {
@ -15,40 +12,8 @@ in {
"project-nvim" "project-nvim"
]; ];
vim.luaConfigRC.project-nvim = entryAnywhere '' vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
require('project_nvim').setup({ require('project_nvim').setup(${nvim.lua.toLuaObject cfg.setupOpts})
manual_mode = ${boolToString cfg.manualMode},
detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} },
-- All the patterns used to detect root dir, when **"pattern"** is in
-- detection_methods
patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} },
-- Table of lsp clients to ignore by name
-- eg: { "efm", ... }
ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} },
-- Don't calculate root dir on specific directories
-- Ex: { "~/.cargo/*", ... }
exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} },
-- Show hidden files in telescope
show_hidden = ${boolToString cfg.showHidden},
-- When set to false, you will get a message when project.nvim changes your
-- directory.
silent_chdir = ${boolToString cfg.silentChdir},
-- What scope to change the directory, valid options are
-- * global (default)
-- * tab
-- * win
scope_chdir = '${toString cfg.scopeChdir}',
-- Path where project.nvim will store the project history for use in
-- telescope
datapath = vim.fn.stdpath("data"),
})
''; '';
}; };
} }

View file

@ -1,59 +1,80 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption mkOption; config,
inherit (lib.types) enum bool listOf str; lib,
...
}: let
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
in { in {
imports = let
renamedSetupOption = oldPath: newPath:
mkRenamedOptionModule
(["vim" "projects" "project-nvim"] ++ oldPath)
(["vim" "projects" "project-nvim" "setupOpts"] ++ newPath);
in [
(renamedSetupOption ["manualMode"] ["manual_mode"])
(renamedSetupOption ["detectionMethods"] ["detection_methods"])
(renamedSetupOption ["patterns"] ["patterns"])
(renamedSetupOption ["lspIgnored"] ["lsp_ignored"])
(renamedSetupOption ["excludeDirs"] ["exclude_dirs"])
(renamedSetupOption ["showHidden"] ["show_hidden"])
(renamedSetupOption ["silentChdir"] ["silent_chdir"])
(renamedSetupOption ["scopeChdir"] ["scope_chdir"])
];
options.vim.projects.project-nvim = { options.vim.projects.project-nvim = {
enable = mkEnableOption "project-nvim for project management"; enable = mkEnableOption "project-nvim for project management";
manualMode = mkOption { setupOpts = lib.nvim.types.mkPluginSetupOption "Project.nvim" {
type = bool; manual_mode = mkOption {
default = true; type = types.bool;
description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command"; default = true;
}; description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command";
};
# detection methods should accept one or more strings from a list # detection methods should accept one or more strings from a list
detectionMethods = mkOption { detection_methods = mkOption {
type = listOf str; type = types.listOf types.str;
default = ["lsp" "pattern"]; default = ["lsp" "pattern"];
description = "Detection methods to use"; description = "Detection methods to use";
}; };
# patterns # patterns
patterns = mkOption { patterns = mkOption {
type = listOf str; type = types.listOf types.str;
default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"]; default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"];
description = "Patterns to use for pattern detection method"; description = "Patterns to use for pattern detection method";
}; };
# table of lsp servers to ignore by name # table of lsp servers to ignore by name
lspIgnored = mkOption { lsp_ignored = mkOption {
type = listOf str; type = types.listOf types.str;
default = []; default = [];
description = "LSP servers no ignore by name"; description = "LSP servers no ignore by name";
}; };
excludeDirs = mkOption { exclude_dirs = mkOption {
type = listOf str; type = types.listOf types.str;
default = []; default = [];
description = "Directories to exclude from project root search"; description = "Directories to exclude from project root search";
}; };
showHidden = mkOption { show_hidden = mkOption {
type = bool; type = types.bool;
default = false; default = false;
description = "Show hidden files in telescope picker"; description = "Show hidden files in telescope picker";
}; };
silentChdir = mkOption { silent_chdir = mkOption {
type = bool; type = types.bool;
default = true; default = true;
description = "Silently change directory when changing project"; description = "Silently change directory when changing project";
}; };
scopeChdir = mkOption { scope_chdir = mkOption {
type = enum ["global" "tab" "win"]; type = types.enum ["global" "tab" "win"];
default = "global"; default = "global";
description = "What scope to change the directory"; description = "What scope to change the directory";
};
}; };
}; };
} }

View file

@ -3,12 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) toString;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.strings) escapeNixString;
inherit (lib.nvim.lua) listToLuaTable;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.presence.neocord; cfg = config.vim.presence.neocord;
in { in {
@ -17,31 +14,7 @@ in {
vim.luaConfigRC.neocord = entryAnywhere '' vim.luaConfigRC.neocord = entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup({ require("neocord").setup(${toLuaObject cfg.setupOpts})
-- General options
logo = "${cfg.logo}",
logo_tooltip = "${cfg.logo_tooltip}",
main_image = "${cfg.main_image}",
client_id = "${cfg.client_id}",
log_level = ${
if cfg.log_level == null
then "nil"
else "${escapeNixString cfg.log_level}"
},
debounce_timeout = ${toString cfg.debounce_timeout},
blacklist = ${listToLuaTable cfg.blacklist},
show_time = "${boolToString cfg.show_time}",
-- Rich Presence text options
editing_text = "${cfg.rich_presence.editing_text}",
file_explorer_text = "${cfg.rich_presence.file_explorer_text}",
git_commit_text = "${cfg.rich_presence.git_commit_text}",
plugin_manager_text = "${cfg.rich_presence.plugin_manager_text}",
reading_text = "${cfg.rich_presence.reading_text}",
workspace_text = "${cfg.rich_presence.workspace_text}",
line_number_text = "${cfg.rich_presence.line_number_text}",
terminal_text = "${cfg.rich_presence.terminal_text}",
})
''; '';
}; };
} }

View file

@ -1,86 +1,94 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule; inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) bool int str enum nullOr listOf; inherit (lib.types) bool int str enum nullOr listOf;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
imports = [ imports =
(mkRemovedOptionModule ["vim" "presence" "presence-nvim"] '' [
The option vim.presence.presence-nvim has been deprecated in favor of the new neocord module. (mkRemovedOptionModule ["vim" "presence" "presence-nvim"] ''
Options provided by the plugin remain mostly the same, but manual migration is required. The option vim.presence.presence-nvim has been deprecated in favor of the new neocord module.
Options provided by the plugin remain mostly the same, but manual migration is required.
Please see neocord documentation and the neovim-flake options for more info Please see neocord documentation and the neovim-flake options for more info
'') '')
]; ]
++ (map
(optName: mkRenamedOptionModule ["vim" "presence" "neocord" "rich_presence" optName] ["vim" "presence" "neocord" "setupOpts" optName])
["debounce_timeout" "blacklist" "show_time" "editing_text" "file_explorer_text" "git_commit_text" "plugin_manager_text" "reading_text" "workspace_text" "line_number_text" "terminal_text"])
++ (map
(optName: mkRenamedOptionModule ["vim" "presence" "neocord" optName] ["vim" "presence" "neocord" "setupOpts" optName])
["logo" "logo_tooltip" "main_image" "client_id" "log_level" "debounce_timeout" "blacklist" "show_time"]);
options.vim.presence.neocord = { options.vim.presence.neocord = {
enable = mkEnableOption "neocord plugin for discord rich presence"; enable = mkEnableOption "neocord plugin for discord rich presence";
logo = mkOption { setupOpts = mkPluginSetupOption "neocord" {
type = str; # TODO: can the default be documented better, maybe with an enum? logo = mkOption {
default = "auto"; type = str; # TODO: can the default be documented better, maybe with an enum?
description = '' default = "auto";
Logo to be displayed on the RPC item description = ''
Logo to be displayed on the RPC item
This must be either "auto" or an URL to your image of choice This must be either "auto" or an URL to your image of choice
''; '';
}; };
logo_tooltip = mkOption { logo_tooltip = mkOption {
type = str; type = str;
default = "The One True Text Editor"; default = "The One True Text Editor";
description = "Text displayed when hovering over the Neovim image"; description = "Text displayed when hovering over the Neovim image";
}; };
main_image = mkOption { main_image = mkOption {
type = enum ["language" "logo"]; type = enum ["language" "logo"];
default = "language"; default = "language";
description = "Main image to be displayed"; description = "Main image to be displayed";
}; };
client_id = mkOption { client_id = mkOption {
type = str; type = str;
default = "1157438221865717891"; default = "1157438221865717891";
description = "Client ID of the application"; description = "Client ID of the application";
}; };
log_level = mkOption { log_level = mkOption {
type = nullOr (enum ["debug" "info" "warn" "error"]); type = nullOr (enum ["debug" "info" "warn" "error"]);
default = null; default = null;
description = "Log level to be used by the plugin"; description = "Log level to be used by the plugin";
}; };
debounce_timeout = mkOption { debounce_timeout = mkOption {
type = int; type = int;
default = 10; default = 10;
description = "Number of seconds to debounce events"; description = "Number of seconds to debounce events";
}; };
auto_update = mkOption { auto_update = mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Automatically update the presence"; description = "Automatically update the presence";
}; };
enable_line_number = mkOption { enable_line_number = mkOption {
type = bool; type = bool;
default = false; default = false;
description = "Show line number on the RPC item"; description = "Show line number on the RPC item";
}; };
show_time = mkOption { show_time = mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Show time on the RPC item"; description = "Show time on the RPC item";
}; };
blacklist = mkOption { blacklist = mkOption {
type = listOf str; type = listOf str;
default = []; default = [];
example = literalExpression ''["Alpha"]''; example = literalExpression ''["Alpha"]'';
description = "List of filetypes to ignore"; description = "List of filetypes to ignore";
}; };
rich_presence = {
editing_text = mkOption { editing_text = mkOption {
type = str; type = str;
default = "Editing %s"; default = "Editing %s";

View file

@ -3,12 +3,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib) mkIf optionals mkMerge mkBinding nvim;
inherit (lib.lists) optionals; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.strings) concatStringsSep;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.session.nvim-session-manager; cfg = config.vim.session.nvim-session-manager;
in { in {
@ -19,7 +15,7 @@ in {
"nvim-session-manager" "nvim-session-manager"
"plenary-nvim" "plenary-nvim"
] ]
++ optionals (cfg.usePicker) ["dressing-nvim"]; ++ optionals cfg.usePicker ["dressing-nvim"];
maps.normal = mkMerge [ maps.normal = mkMerge [
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session") (mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
@ -29,31 +25,10 @@ in {
# TODO: load_current_dir_session # TODO: load_current_dir_session
]; ];
luaConfigRC.nvim-session-manager = entryAnywhere '' luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
local Path = require('plenary.path') local Path = require('plenary.path')
local sm = require('session_manager.config') local sm = require('session_manager.config')
require('session_manager').setup({ require('session_manager').setup(${toLuaObject cfg.setupOpts})
sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'),
path_replacer = '${toString cfg.pathReplacer}',
colon_replacer = '${toString cfg.colonReplacer}',
autoload_mode = sm.AutoloadMode.${toString cfg.autoloadMode},
autosave_last_session = ${boolToString cfg.autoSave.lastSession},
autosave_ignore_not_normal = ${boolToString cfg.autoSave.ignoreNotNormal},
autosave_ignore_dirs = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreDirs)}},
autosave_ignore_filetypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreFiletypes)}},
autosave_ignore_buftypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreBufTypes)}},
autosave_only_in_session = ${boolToString cfg.autoSave.onlyInSession},
max_path_length = ${toString cfg.maxPathLength},
})
''; '';
}; };
}; };

View file

@ -1,7 +1,23 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) nullOr str bool;
inherit (lib.types) nullOr str bool int listOf enum; inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
in { in {
imports = let
renameSetupOpt = oldPath: newPath:
mkRenamedOptionModule (["vim" "session" "nvim-session-manager"] ++ oldPath) (["vim" "session" "nvim-session-manager" "setupOpts"] ++ newPath);
in [
(renameSetupOpt ["pathReplacer"] ["path_replacer"])
(renameSetupOpt ["colonReplacer"] ["colon_replacer"])
(renameSetupOpt ["autoloadMode"] ["autoload_mode"])
(renameSetupOpt ["maxPathLength"] ["max_path_length"])
(renameSetupOpt ["autoSave" "lastSession"] ["autosave_last_session"])
(renameSetupOpt ["autoSave" "ignoreNotNormal"] ["autosave_ignore_not_normal"])
(renameSetupOpt ["autoSave" "ignoreDirs"] ["autosave_ignore_dirs"])
(renameSetupOpt ["autoSave" "ignoreFiletypes"] ["autosave_ignore_filetypes"])
(renameSetupOpt ["autoSave" "ignoreBufTypes"] ["autosave_ignore_buftypes"])
(renameSetupOpt ["autoSave" "onlyInSession"] ["autosave_only_in_session"])
];
options.vim.session.nvim-session-manager = { options.vim.session.nvim-session-manager = {
enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode"; enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode";
@ -37,63 +53,63 @@ in {
description = "Whether or not we should use dressing.nvim to build a session picker UI"; description = "Whether or not we should use dressing.nvim to build a session picker UI";
}; };
pathReplacer = mkOption { setupOpts = {
type = str; path_replacer = mkOption {
default = "__"; type = types.str;
description = "The character to which the path separator will be replaced for session files"; default = "__";
}; description = "The character to which the path separator will be replaced for session files";
};
colonReplacer = mkOption { colon_replacer = mkOption {
type = str; type = types.str;
default = "++"; default = "++";
description = "The character to which the colon symbol will be replaced for session files"; description = "The character to which the colon symbol will be replaced for session files";
}; };
autoloadMode = mkOption { autoload_mode = mkOption {
type = enum ["Disabled" "CurrentDir" "LastSession"]; type = types.enum ["Disabled" "CurrentDir" "LastSession"];
default = "LastSession"; default = "LastSession";
description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession"; description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession";
}; };
maxPathLength = mkOption { max_path_length = mkOption {
type = nullOr int; type = types.nullOr types.int;
default = 80; default = 80;
description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all"; description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all";
}; };
autoSave = { autosave_last_session = mkOption {
lastSession = mkOption { type = types.bool;
type = bool;
default = true; default = true;
description = "Automatically save last session on exit and on session switch"; description = "Automatically save last session on exit and on session switch";
}; };
ignoreNotNormal = mkOption { autosave_ignore_not_normal = mkOption {
type = bool; type = types.bool;
default = true; default = true;
description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed"; description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed";
}; };
ignoreDirs = mkOption { autosave_ignore_dirs = mkOption {
type = listOf str; type = types.listOf types.str;
default = []; default = [];
description = "A list of directories where the session will not be autosaved"; description = "A list of directories where the session will not be autosaved";
}; };
ignoreFiletypes = mkOption { autosave_ignore_filetypes = mkOption {
type = listOf str; type = types.listOf types.str;
default = ["gitcommit"]; default = ["gitcommit"];
description = "All buffers of these file types will be closed before the session is saved"; description = "All buffers of these file types will be closed before the session is saved";
}; };
ignoreBufTypes = mkOption { autosave_ignore_buftypes = mkOption {
type = listOf str; type = types.listOf types.str;
default = []; default = [];
description = "All buffers of these bufer types will be closed before the session is saved"; description = "All buffers of these bufer types will be closed before the session is saved";
}; };
onlyInSession = mkOption { autosave_only_in_session = mkOption {
type = bool; type = types.bool;
default = false; default = false;
description = "Always autosaves session. If true, only autosaves after a session is active"; description = "Always autosaves session. If true, only autosaves after a session is active";
}; };

View file

@ -3,75 +3,73 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) boolToString; inherit (lib.trivial) boolToString;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) luaTable listToLuaTable;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.statusline.lualine; cfg = config.vim.statusline.lualine;
breadcrumbsCfg = config.vim.ui.breadcrumbs; breadcrumbsCfg = config.vim.ui.breadcrumbs;
in { in {
config = (mkIf cfg.enable) { config = mkMerge [
vim.startPlugins = [ # TODO: move into nvim-tree file
"lualine" (mkIf (config.vim.filetree.nvimTree.enable) {
]; vim.statusline.lualine.setupOpts = {
extensions = ["nvim-tree"];
};
})
(mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") {
vim.statusline.lualine.setupOpts = {
# TODO: rewrite in new syntax
winbar.lualine_c = [
[
"navic"
(mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}")
]
];
};
})
(mkIf cfg.enable {
vim.startPlugins = [
"lualine"
];
vim.luaConfigRC.lualine = entryAnywhere '' vim.luaConfigRC.lualine = entryAnywhere ''
local lualine = require('lualine') local lualine = require('lualine')
lualine.setup { lualine.setup ${toLuaObject cfg.setupOpts}
'';
# this is for backwards-compatibility
vim.statusline.lualine.setupOpts = {
options = { options = {
icons_enabled = ${boolToString cfg.icons.enable}, icons_enabled = cfg.icons.enable;
theme = "${cfg.theme}", theme = cfg.theme;
component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"}, component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right];
section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"}, section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right];
disabled_filetypes = ${listToLuaTable cfg.disabledFiletypes}, globalstatus = cfg.globalStatus;
always_divide_middle = ${boolToString cfg.alwaysDivideMiddle}, refresh = cfg.refresh;
globalstatus = ${boolToString cfg.globalStatus}, };
ignore_focus = ${listToLuaTable cfg.ignoreFocus},
extensions = {${optionalString config.vim.filetree.nvimTree.enable "'nvim-tree'"}},
refresh = {
statusline = ${toString cfg.refresh.statusline},
tabline = ${toString cfg.refresh.tabline},
winbar = ${toString cfg.refresh.winbar},
},
},
-- active sections
sections = { sections = {
lualine_a = ${luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)}, lualine_a = builtins.map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a);
lualine_b = ${luaTable (cfg.activeSection.b ++ cfg.extraActiveSection.b)}, lualine_b = builtins.map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b);
lualine_c = ${luaTable (cfg.activeSection.c ++ cfg.extraActiveSection.c)}, lualine_c = builtins.map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c);
lualine_x = ${luaTable (cfg.activeSection.x ++ cfg.extraActiveSection.x)}, lualine_x = builtins.map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x);
lualine_y = ${luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)}, lualine_y = builtins.map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y);
lualine_z = ${luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)}, lualine_z = builtins.map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z);
}, };
-- inactive sections
inactive_sections = { inactive_sections = {
lualine_a = ${luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)}, lualine_a = builtins.map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a);
lualine_b = ${luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)}, lualine_b = builtins.map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b);
lualine_c = ${luaTable (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)}, lualine_c = builtins.map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c);
lualine_x = ${luaTable (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)}, lualine_x = builtins.map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x);
lualine_y = ${luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)}, lualine_y = builtins.map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y);
lualine_z = ${luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)}, lualine_z = builtins.map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z);
}, };
# probably don't need this?
-- tabline (currently unsupported) tabline = [];
tabline = {}, };
})
${optionalString (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") '' ];
-- enable winbar if nvim-navic is enabled
winbar = {
lualine_c = {
{
"navic",
draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}
}
}
},
''}
}
'';
};
} }

View file

@ -7,6 +7,7 @@
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int bool str listOf enum; inherit (lib.types) int bool str listOf enum;
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.nvim.types) mkPluginSetupOption;
supported_themes = import ./supported_themes.nix; supported_themes = import ./supported_themes.nix;
colorPuccin = colorPuccin =
@ -15,6 +16,8 @@
else "none"; else "none";
in { in {
options.vim.statusline.lualine = { options.vim.statusline.lualine = {
setupOpts = mkPluginSetupOption "Lualine" {};
enable = mkEnableOption "lualine statusline plugin"; enable = mkEnableOption "lualine statusline plugin";
icons = { icons = {

View file

@ -9,6 +9,7 @@
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter; inherit (lib.nvim.dag) entryAnywhere entryAfter;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.terminal.toggleterm; cfg = config.vim.terminal.toggleterm;
in { in {
@ -23,24 +24,7 @@ in {
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal"; maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
luaConfigRC.toggleterm = entryAnywhere '' luaConfigRC.toggleterm = entryAnywhere ''
require("toggleterm").setup({ require("toggleterm").setup(${toLuaObject cfg.setupOpts})
open_mapping = null,
direction = '${toString cfg.direction}',
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
size = function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
winbar = {
enabled = '${toString cfg.enable_winbar}',
name_formatter = function(term) -- term: Terminal
return term.name
end
},
})
''; '';
}; };
} }

View file

@ -5,8 +5,16 @@
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.types) nullOr str enum bool package; inherit (lib.types) nullOr str enum bool package either int;
inherit (lib) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline;
in { in {
imports = [
(mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"])
(mkRenamedOptionModule ["vim" "terminal" "toggleterm" "enable_winbar"] ["vim" "terminal" "toggleterm" "setupOpts" "enable_winbar"])
];
options.vim.terminal.toggleterm = { options.vim.terminal.toggleterm = {
enable = mkEnableOption "toggleterm as a replacement to built-in terminal command"; enable = mkEnableOption "toggleterm as a replacement to built-in terminal command";
mappings = { mappings = {
@ -17,16 +25,44 @@ in {
}; };
}; };
direction = mkOption { setupOpts = mkPluginSetupOption "ToggleTerm" {
type = enum ["horizontal" "vertical" "tab" "float"]; direction = mkOption {
default = "horizontal"; type = enum ["horizontal" "vertical" "tab" "float"];
description = "Direction of the terminal"; default = "horizontal";
}; description = "Direction of the terminal";
};
enable_winbar = mkOption { enable_winbar = mkOption {
type = bool; type = bool;
default = false; default = false;
description = "Enable winbar"; description = "Enable winbar";
};
size = mkOption {
type = either luaInline int;
description = "Number or lua function which is passed to the current terminal";
default = mkLuaInline ''
function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end
'';
};
winbar = {
enabled = mkEnableOption "winbar in terminal" // {default = true;};
name_formatter = mkOption {
type = luaInline;
description = "Winbar formatter function.";
default = mkLuaInline ''
function(term)
return term.name
end
'';
};
};
}; };
lazygit = { lazygit = {

View file

@ -18,7 +18,7 @@ in {
type = enum defaultStyles; type = enum defaultStyles;
default = "rounded"; default = "rounded";
description = '' description = ''
The global border style to use The global border style to use.
''; '';
}; };

View file

@ -5,7 +5,34 @@
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) nullOr listOf enum bool str int; inherit (lib.types) nullOr listOf enum bool str int;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption;
mkSimpleIconOption = default:
mkOption {
inherit default;
type = str;
description = "";
};
in { in {
imports = let
renameSetupOpt = oldPath: newPath:
mkRenamedOptionModule
(["vim" "ui" "breadcrumbs" "navbuddy"] ++ oldPath)
(["vim" "ui" "breadcrumbs" "navbuddy" "setupOpts"] ++ newPath);
in [
(renameSetupOpt ["useDefaultMappings"] ["use_default_mappings"])
(renameSetupOpt ["window"] ["window"])
(renameSetupOpt ["nodeMarkers"] ["node_markers"])
(renameSetupOpt ["lsp" "autoAttach"] ["lsp" "auto_attach"])
(renameSetupOpt ["lsp" "preference"] ["lsp" "preference"])
(renameSetupOpt ["sourceBuffer" "followNode"] ["source_buffer" "follow_node"])
(renameSetupOpt ["sourceBuffer" "highlight"] ["source_buffer" "highlight"])
(renameSetupOpt ["sourceBuffer" "reorient"] ["source_buffer" "reorient"])
(renameSetupOpt ["sourceBuffer" "scrolloff"] ["source_buffer" "scrolloff"])
# TODO: every option under icon is renamed to first letter capitalized
(renameSetupOpt ["icon"] ["icon"])
];
options.vim.ui.breadcrumbs = { options.vim.ui.breadcrumbs = {
enable = mkEnableOption "breadcrumbs"; enable = mkEnableOption "breadcrumbs";
source = mkOption { source = mkOption {
@ -27,13 +54,6 @@ in {
navbuddy = { navbuddy = {
enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic"; enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic";
# this option is interpreted as null if mkEnableOption is used, and therefore cannot be converted to a string in config.nix
useDefaultMappings = mkOption {
type = bool;
default = true;
description = "use default Navbuddy keybindings (disables user-specified keybinds)";
};
mappings = { mappings = {
close = mkOption { close = mkOption {
type = str; type = str;
@ -61,7 +81,7 @@ in {
children = mkOption { children = mkOption {
type = str; type = str;
default = "h"; default = "l";
description = "keybinding to navigate to the child node"; description = "keybinding to navigate to the child node";
}; };
@ -180,299 +200,162 @@ in {
}; };
}; };
window = { setupOpts = mkPluginSetupOption "navbuddy" {
# size = {} useDefaultMappings = mkOption {
# position = {} type = bool;
default = true;
border = mkOption { description = "use default Navbuddy keybindings (disables user-specified keybinds)";
# TODO: let this type accept a custom string
type = enum ["single" "rounded" "double" "solid" "none"];
default = config.vim.ui.borders.globalStyle;
description = "border style to use";
}; };
scrolloff = mkOption { window = {
type = nullOr int; # size = {}
default = null; # position = {}
description = "Scrolloff value within navbuddy window";
};
sections = { border = mkOption {
# left section # TODO: let this type accept a custom string
left = { type = enum ["single" "rounded" "double" "solid" "none"];
/* default = config.vim.ui.borders.globalStyle;
size = { description = "border style to use";
type = with types; nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the left section of Navbuddy UI";
};
}; };
# middle section scrolloff = mkOption {
mid = { type = nullOr int;
/* default = null;
size = { description = "Scrolloff value within navbuddy window";
type = with types; nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the middle section of Navbuddy UI";
};
}; };
# right section sections = {
# there is no size option for the right section, it fills the remaining space # left section
right = { left = {
border = mkOption { /*
# TODO: let this type accept a custom string size = mkOption {
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); type = nullOr (intBetween 0 100);
default = config.vim.ui.borders.globalStyle; default = null;
description = "border style to use for the right section of Navbuddy UI"; description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the left section of Navbuddy UI";
};
}; };
preview = mkOption { # middle section
type = enum ["leaf" "always" "never"]; mid = {
default = "leaf"; /*
description = "display mode of the preview on the right section"; size = {
type = nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the middle section of Navbuddy UI";
};
};
# right section
# there is no size option for the right section, it fills the remaining space
right = {
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the right section of Navbuddy UI";
};
preview = mkOption {
type = enum ["leaf" "always" "never"];
default = "leaf";
description = "display mode of the preview on the right section";
};
}; };
}; };
}; };
};
nodeMarkers = { node_markers = {
enable = mkEnableOption "node markers"; enable = mkEnableOption "node markers";
icons = {
leaf = mkSimpleIconOption " ";
leaf_selected = mkSimpleIconOption " ";
branch = mkSimpleIconOption " ";
};
};
lsp = {
auto_attach = mkOption {
type = bool;
default = true;
description = "Whether to attach to LSP server manually";
};
preference = mkOption {
type = nullOr (listOf str);
default = null;
description = "list of lsp server names in order of preference";
};
};
source_buffer = {
followNode = mkOption {
type = bool;
default = true;
description = "keep the current node in focus on the source buffer";
};
highlight = mkOption {
type = bool;
default = true;
description = "highlight the currently focused node";
};
reorient = mkOption {
type = enum ["smart" "top" "mid" "none"];
default = "smart";
description = "reorient buffer after changing nodes";
};
scrolloff = mkOption {
type = nullOr int;
default = null;
description = "scrolloff value when navbuddy is open";
};
};
icons = { icons = {
leaf = mkOption { File = mkSimpleIconOption "󰈙 ";
type = str; Module = mkSimpleIconOption " ";
default = " "; Namespace = mkSimpleIconOption "󰌗 ";
description = ""; Package = mkSimpleIconOption " ";
}; Class = mkSimpleIconOption "󰌗 ";
Property = mkSimpleIconOption " ";
leafSelected = mkOption { Field = mkSimpleIconOption " ";
type = str; Constructor = mkSimpleIconOption " ";
default = " "; Enum = mkSimpleIconOption "󰕘";
description = ""; Interface = mkSimpleIconOption "󰕘";
}; Function = mkSimpleIconOption "󰊕 ";
Variable = mkSimpleIconOption "󰆧 ";
branch = mkOption { Constant = mkSimpleIconOption "󰏿 ";
type = str; String = mkSimpleIconOption " ";
default = " "; Number = mkSimpleIconOption "󰎠 ";
description = ""; Boolean = mkSimpleIconOption " ";
}; Array = mkSimpleIconOption "󰅪 ";
}; Object = mkSimpleIconOption "󰅩 ";
}; Method = mkSimpleIconOption "󰆧 ";
Key = mkSimpleIconOption "󰌋 ";
lsp = { Null = mkSimpleIconOption "󰟢 ";
autoAttach = mkOption { EnumMember = mkSimpleIconOption "󰕘 ";
type = bool; Struct = mkSimpleIconOption "󰌗 ";
default = true; Event = mkSimpleIconOption " ";
description = "Whether to attach to LSP server manually"; Operator = mkSimpleIconOption "󰆕 ";
}; TypeParameter = mkSimpleIconOption "󰊄 ";
preference = mkOption {
type = nullOr (listOf str);
default = null;
description = "list of lsp server names in order of preference";
};
};
sourceBuffer = {
followNode = mkOption {
type = bool;
default = true;
description = "keep the current node in focus on the source buffer";
};
highlight = mkOption {
type = bool;
default = true;
description = "highlight the currently focused node";
};
reorient = mkOption {
type = enum ["smart" "top" "mid" "none"];
default = "smart";
description = "reorient buffer after changing nodes";
};
scrolloff = mkOption {
type = nullOr int;
default = null;
description = "scrolloff value when navbuddy is open";
};
};
# there probably is a better way to do this
# alas, I am not a nix wizard
icons = {
file = mkOption {
type = str;
default = "󰈙 ";
description = "File icon";
};
module = mkOption {
type = str;
default = " ";
description = "Module icon";
};
namespace = mkOption {
type = str;
default = "󰌗 ";
description = "Namespace icon";
};
package = mkOption {
type = str;
default = " ";
description = "Package icon";
};
class = mkOption {
type = str;
default = "󰌗 ";
description = "Class icon";
};
property = mkOption {
type = str;
default = " ";
description = "Property icon";
};
field = mkOption {
type = str;
default = " ";
description = "Field icon";
};
constructor = mkOption {
type = str;
default = " ";
description = "Constructor icon";
};
enum = mkOption {
type = str;
default = "󰕘";
description = "Enum icon";
};
interface = mkOption {
type = str;
default = "󰕘";
description = "Interface icon";
};
function = mkOption {
type = str;
default = "󰊕 ";
description = "Function icon";
};
variable = mkOption {
type = str;
default = "󰫧 ";
description = "Variable icon";
};
constant = mkOption {
type = str;
default = "󰏿 ";
description = "Constant icon";
};
string = mkOption {
type = str;
default = " ";
description = "String icon";
};
number = mkOption {
type = str;
default = "󰎠 ";
description = "Number icon";
};
boolean = mkOption {
type = str;
default = " ";
description = "Boolean icon";
};
array = mkOption {
type = str;
default = "󰅪 ";
description = "Array icon";
};
object = mkOption {
type = str;
default = "󰅩 ";
description = "Object icon";
};
method = mkOption {
type = str;
default = "󰆧 ";
description = "Method icon";
};
key = mkOption {
type = str;
default = "󰌋 ";
description = "Key icon";
};
null = mkOption {
type = str;
default = "󰟢 ";
description = "Null icon";
};
enumMember = mkOption {
type = str;
default = "󰕘 ";
description = "Enum member icon";
};
struct = mkOption {
type = str;
default = "󰌗 ";
description = "Struct icon";
};
event = mkOption {
type = str;
default = " ";
description = "Event icon";
};
operator = mkOption {
type = str;
default = "󰆕 ";
description = "Operator icon";
};
typeParameter = mkOption {
type = str;
default = "󰊄 ";
description = "Type parameter icon";
}; };
}; };
}; };

View file

@ -3,15 +3,14 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString; inherit (lib.modules) mkIf;
inherit (lib.lists) optionals; inherit (lib.lists) optionals;
inherit (lib.nvim.lua) nullString;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.ui.breadcrumbs; cfg = config.vim.ui.breadcrumbs;
nbcfg = cfg.navbuddy;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = vim.startPlugins =
@ -30,6 +29,55 @@ in {
"nvim-navic" "nvim-navic"
]; ];
vim.ui.breadcrumbs.navbuddy.setupOpts = {
mappings = {
${cfg.navbuddy.mappings.close} = mkLuaInline "actions.close()";
${cfg.navbuddy.mappings.nextSibling} = mkLuaInline "actions.next_sibling()";
${cfg.navbuddy.mappings.previousSibling} = mkLuaInline "actions.previous_sibling()";
${cfg.navbuddy.mappings.parent} = mkLuaInline "actions.parent()";
${cfg.navbuddy.mappings.children} = mkLuaInline "actions.children()";
${cfg.navbuddy.mappings.root} = mkLuaInline "actions.root()";
${cfg.navbuddy.mappings.visualName} = mkLuaInline "actions.visual_name()";
${cfg.navbuddy.mappings.visualScope} = mkLuaInline "actions.visual_scope()";
${cfg.navbuddy.mappings.yankName} = mkLuaInline "actions.yank_name()";
${cfg.navbuddy.mappings.yankScope} = mkLuaInline "actions.yank_scope()";
${cfg.navbuddy.mappings.insertName} = mkLuaInline "actions.insert_name()";
${cfg.navbuddy.mappings.insertScope} = mkLuaInline "actions.insert_scope()";
${cfg.navbuddy.mappings.appendName} = mkLuaInline "actions.append_name()";
${cfg.navbuddy.mappings.appendScope} = mkLuaInline "actions.append_scope()";
${cfg.navbuddy.mappings.rename} = mkLuaInline "actions.rename()";
${cfg.navbuddy.mappings.delete} = mkLuaInline "actions.delete()";
${cfg.navbuddy.mappings.foldCreate} = mkLuaInline "actions.fold_create()";
${cfg.navbuddy.mappings.foldDelete} = mkLuaInline "actions.fold_delete()";
${cfg.navbuddy.mappings.comment} = mkLuaInline "actions.comment()";
${cfg.navbuddy.mappings.select} = mkLuaInline "actions.select()";
${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()";
${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()";
${cfg.navbuddy.mappings.telescope} = mkLuaInline ''
actions.telescope({
layout_strategy = "horizontal",
layout_config = {
height = 0.60,
width = 0.75,
prompt_position = "top",
preview_width = 0.50
},
})'';
${cfg.navbuddy.mappings.help} = mkLuaInline "actions.help()";
};
};
vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] '' vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] ''
${optionalString (cfg.source == "nvim-navic") '' ${optionalString (cfg.source == "nvim-navic") ''
@ -42,128 +90,7 @@ in {
${optionalString cfg.navbuddy.enable '' ${optionalString cfg.navbuddy.enable ''
local navbuddy = require("nvim-navbuddy") local navbuddy = require("nvim-navbuddy")
local actions = require("nvim-navbuddy.actions") local actions = require("nvim-navbuddy.actions")
navbuddy.setup { navbuddy.setup ${toLuaObject cfg.navbuddy.setupOpts}
window = {
border = "${nbcfg.window.border}", -- "rounded", "double", "solid", "none"
size = "60%",
position = "50%",
scrolloff = ${(nullString nbcfg.window.scrolloff)},
sections = {
left = {
size = "20%",
border = ${(nullString nbcfg.window.sections.left.border)},
},
mid = {
size = "40%",
border = ${(nullString nbcfg.window.sections.mid.border)},
},
right = {
border = ${(nullString nbcfg.window.sections.right.border)},
preview = "leaf",
}
},
},
node_markers = {
enabled = ${boolToString nbcfg.nodeMarkers.enable},
icons = {
leaf = "${nbcfg.nodeMarkers.icons.leaf}",
leaf_selected = "${nbcfg.nodeMarkers.icons.leafSelected}",
branch = "${nbcfg.nodeMarkers.icons.branch}",
},
},
lsp = {
auto_attach = ${boolToString nbcfg.lsp.autoAttach},
-- preference = nil, -- TODO: convert list to lua table if not null
},
source_buffer = {
follow_node = ${boolToString nbcfg.sourceBuffer.followNode},
highlight = ${boolToString nbcfg.sourceBuffer.highlight},
reorient = "${nbcfg.sourceBuffer.reorient}",
scrolloff = ${nullString nbcfg.sourceBuffer.scrolloff}
},
icons = {
File = "${cfg.navbuddy.icons.file}",
Module = "${cfg.navbuddy.icons.module}",
Namespace = "${cfg.navbuddy.icons.namespace}",
Package = "${cfg.navbuddy.icons.package}",
Class = "${cfg.navbuddy.icons.class}",
Method = "${cfg.navbuddy.icons.method}",
Property = "${cfg.navbuddy.icons.property}",
Field = "${cfg.navbuddy.icons.field}",
Constructor = "${cfg.navbuddy.icons.constructor}",
Enum = "${cfg.navbuddy.icons.enum}",
Interface = "${cfg.navbuddy.icons.interface}",
Function = "${cfg.navbuddy.icons.function}",
Variable = "${cfg.navbuddy.icons.variable}",
Constant = "${cfg.navbuddy.icons.constant}",
String = "${cfg.navbuddy.icons.string}",
Number = "${cfg.navbuddy.icons.number}",
Boolean = "${cfg.navbuddy.icons.boolean}",
Array = "${cfg.navbuddy.icons.array}",
Object = "${cfg.navbuddy.icons.object}",
Key = "${cfg.navbuddy.icons.key}",
Null = "${cfg.navbuddy.icons.null}",
EnumMember = "${cfg.navbuddy.icons.enumMember}",
Struct = "${cfg.navbuddy.icons.struct}",
Event = "${cfg.navbuddy.icons.event}",
Operator = "${cfg.navbuddy.icons.operator}",
TypeParameter = "${cfg.navbuddy.icons.typeParameter}"
},
-- make those configurable
use_default_mappings = ${boolToString cfg.navbuddy.useDefaultMappings},
mappings = {
["${cfg.navbuddy.mappings.close}"] = actions.close(),
["${cfg.navbuddy.mappings.nextSibling}"] = actions.next_sibling(),
["${cfg.navbuddy.mappings.previousSibling}"] = actions.previous_sibling(),
["${cfg.navbuddy.mappings.close}"] = actions.parent(),
["${cfg.navbuddy.mappings.children}"] = actions.children(),
["${cfg.navbuddy.mappings.root}"] = actions.root(),
["${cfg.navbuddy.mappings.visualName}"] = actions.visual_name(),
["${cfg.navbuddy.mappings.visualScope}"] = actions.visual_scope(),
["${cfg.navbuddy.mappings.yankName}"] = actions.yank_name(),
["${cfg.navbuddy.mappings.yankScope}"] = actions.yank_scope(),
["${cfg.navbuddy.mappings.insertName}"] = actions.insert_name(),
["${cfg.navbuddy.mappings.insertScope}"] = actions.insert_scope(),
["${cfg.navbuddy.mappings.appendName}"] = actions.append_name(),
["${cfg.navbuddy.mappings.appendScope}"] = actions.append_scope(),
["${cfg.navbuddy.mappings.rename}"] = actions.rename(),
["${cfg.navbuddy.mappings.delete}"] = actions.delete(),
["${cfg.navbuddy.mappings.foldCreate}"] = actions.fold_create(),
["${cfg.navbuddy.mappings.foldDelete}"] = actions.fold_delete(),
["${cfg.navbuddy.mappings.comment}"] = actions.comment(),
["${cfg.navbuddy.mappings.select}"] = actions.select(),
["${cfg.navbuddy.mappings.moveDown}"] = actions.move_down(),
["${cfg.navbuddy.mappings.moveUp}"] = actions.move_up(),
["${cfg.navbuddy.mappings.telescope}"] = actions.telescope({
layout_strategy = "horizontal",
layout_config = {
height = 0.60,
width = 0.75,
prompt_position = "top",
preview_width = 0.50
},
}),
["${cfg.navbuddy.mappings.help}"] = actions.help(), -- Open mappings help window
},
}
''} ''}
''; '';
}; };

View file

@ -1,68 +1,104 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf attrs bool enum; inherit (lib.types) attrsOf attrs bool enum;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
imports = [
(mkRenamedOptionModule ["vim" "ui" "colorizer" "options"] ["vim" "ui" "colorizer" "setupOpts" "user_default_options"])
(mkRenamedOptionModule ["vim" "ui" "colorizer" "filetypes"] ["vim" "ui" "colorizer" "setupOpts" "filetypes"])
];
options.vim.ui.colorizer = { options.vim.ui.colorizer = {
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]"; enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
filetypes = mkOption { setupOpts = mkPluginSetupOption "nvim-colorizer" {
type = attrsOf attrs; filetypes = mkOption {
default = { type = attrsOf attrs;
css = {}; default = {
scss = {}; css = {};
}; scss = {};
description = "Filetypes to highlight on"; };
}; description = "Filetypes to highlight on";
options = {
alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
rgb = mkOption {
type = bool;
default = true;
description = "#RGB hex codes";
}; };
rrggbb = mkOption { user_default_options = {
type = bool; rgb = mkOption {
default = true; type = bool;
description = "#RRGGBB hex codes"; default = true;
}; description = "#RGB hex codes";
};
names = mkOption { rrggbb = mkOption {
type = bool; type = bool;
default = true; default = true;
description = ''"Name" codes such as "Blue"''; description = "#RRGGBB hex codes";
}; };
rgb_fn = mkOption { names = mkOption {
type = bool; type = bool;
default = false; default = true;
description = "CSS rgb() and rgba() functions"; description = ''"Name" codes such as "Blue"'';
}; };
rrggbbaa = mkOption { rgb_fn = mkOption {
type = bool; type = bool;
default = false; default = false;
description = "#RRGGBBAA hex codes"; description = "CSS rgb() and rgba() functions";
}; };
hsl_fn = mkOption { rrggbbaa = mkOption {
type = bool; type = bool;
default = false; default = false;
description = "CSS hsl() and hsla() functions"; description = "#RRGGBBAA hex codes";
}; };
mode = mkOption { hsl_fn = mkOption {
type = enum ["foreground" "background"]; type = bool;
default = "background"; default = false;
description = "Set the display mode"; description = "CSS hsl() and hsla() functions";
}; };
tailwind = mkEnableOption "tailwind colors"; css = mkOption {
sass = mkEnableOption "sass colors"; type = bool;
css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; default = false;
css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn"; description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
};
css_fn = mkOption {
type = bool;
default = false;
description = "Enable all CSS *functions*: rgb_fn, hsl_fn";
};
mode = mkOption {
type = enum ["foreground" "background"];
default = "background";
description = "Set the display mode";
};
tailwind = mkOption {
type = bool;
default = false;
description = "Enable tailwind colors";
};
sass = mkOption {
type = bool;
default = false;
description = "Enable sass colors";
};
alwaysUpdate = mkOption {
type = bool;
default = false;
description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
};
};
}; };
}; };
} }

View file

@ -4,9 +4,8 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.colorizer; cfg = config.vim.ui.colorizer;
in { in {
@ -16,23 +15,7 @@ in {
]; ];
vim.luaConfigRC.colorizer = entryAnywhere '' vim.luaConfigRC.colorizer = entryAnywhere ''
require('colorizer').setup({ require('colorizer').setup(${toLuaObject cfg.setupOpts})
filetypes = ${attrsetToLuaTable cfg.filetypes},
user_default_options = {
RGB = ${boolToString cfg.options.rgb};
RRGGBB = ${boolToString cfg.options.rrggbb};
RRGGBBAA = ${boolToString cfg.options.rrggbbaa};
names = ${boolToString cfg.options.names};
rgb_fn = ${boolToString cfg.options.rgb_fn};
hsl_fn = ${boolToString cfg.options.hsl_fn};
css = ${boolToString cfg.options.css};
css_fn = ${boolToString cfg.options.css_fn};
mode = '${toString cfg.options.mode}';
tailwind = ${boolToString cfg.options.tailwind};
sass = ${boolToString cfg.options.tailwind};
always_update = ${boolToString cfg.options.alwaysUpdate};
}
})
''; '';
}; };
} }

View file

@ -4,8 +4,8 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.modes-nvim; cfg = config.vim.ui.modes-nvim;
in { in {
@ -15,18 +15,7 @@ in {
]; ];
vim.luaConfigRC.modes-nvim = entryAnywhere '' vim.luaConfigRC.modes-nvim = entryAnywhere ''
require('modes').setup({ require('modes').setup(${toLuaObject cfg.setupOpts})
set_cursorline = ${boolToString cfg.setCursorline},
line_opacity = {
visual = 0,
},
colors = {
copy = "${toString cfg.colors.copy}",
delete = "${toString cfg.colors.delete}",
insert = "${toString cfg.colors.insert}",
visual = "${toString cfg.colors.visual}",
},
})
''; '';
}; };
} }

View file

@ -1,33 +1,47 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str; inherit (lib.types) bool str float;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.ui.modes-nvim = { options.vim.ui.modes-nvim = {
enable = mkEnableOption "prismatic line decorations [modes.nvim]"; enable = mkEnableOption "modes.nvim's prismatic line decorations";
setCursorline = mkEnableOption "colored cursorline on current line";
colors = { setupOpts = {
copy = mkOption { setCursorline = mkOption {
type = str; type = bool;
description = "The #RRGGBB color code for the visual mode highlights"; description = "Set a colored cursorline on current line";
default = "#f5c359"; default = false; # looks ugly, disabled by default
}; };
delete = mkOption { line_opacity = {
type = str; visual = mkOption {
description = "The #RRGGBB color code for the visual mode highlights"; type = float;
default = "#c75c6a"; description = "Set opacity for cursorline and number background";
default = 0.0;
};
}; };
insert = mkOption { colors = mkPluginSetupOption "modes.nvim" {
type = str; copy = mkOption {
description = "The #RRGGBB color code for the visual mode highlights"; type = str;
default = "#78ccc5"; description = "The #RRGGBB color code for the visual mode highlights";
}; default = "#f5c359";
};
visual = mkOption { delete = mkOption {
type = str; type = str;
description = "The #RRGGBB color code for the visual mode highlights"; description = "The #RRGGBB color code for the visual mode highlights";
default = "#9745be"; default = "#c75c6a";
};
insert = mkOption {
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#78ccc5";
};
visual = mkOption {
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#9745be";
};
}; };
}; };
}; };

View file

@ -2,6 +2,6 @@
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.ui.noice = { options.vim.ui.noice = {
enable = mkEnableOption "UI modification library [noice.nvim]"; enable = mkEnableOption "noice.nvim UI modification library";
}; };
} }

View file

@ -5,6 +5,7 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notify.nvim-notify; cfg = config.vim.notify.nvim-notify;
in { in {
@ -13,19 +14,7 @@ in {
startPlugins = ["nvim-notify"]; startPlugins = ["nvim-notify"];
luaConfigRC.nvim-notify = entryAnywhere '' luaConfigRC.nvim-notify = entryAnywhere ''
require('notify').setup { require('notify').setup(${toLuaObject cfg.setupOpts})
stages = "${cfg.stages}",
timeout = ${toString cfg.timeout},
background_colour = "${cfg.background_colour}",
position = "${cfg.position}",
icons = {
ERROR = "${cfg.icons.ERROR}",
WARN = "${cfg.icons.WARN}",
INFO = "${cfg.icons.INFO}",
DEBUG = "${cfg.icons.DEBUG}",
TRACE = "${cfg.icons.TRACE}",
},
}
-- required to fix offset_encoding errors -- required to fix offset_encoding errors
local notify = vim.notify local notify = vim.notify

View file

@ -1,42 +1,64 @@
{lib, ...}: let {
inherit (lib.options) mkOption mkEnableOption; config,
inherit (lib.types) enum int str attrsOf; lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.types) int str enum attrsOf;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
imports = let
renamedSetupOpt = name:
mkRenamedOptionModule
["vim" "notify" "nvim-notify" name]
["vim" "notify" "nvim-notify" "setupOpts" name];
in [
(renamedSetupOpt "stages")
(renamedSetupOpt "timeout")
(renamedSetupOpt "background_colour")
(renamedSetupOpt "position")
(renamedSetupOpt "icons")
];
options.vim.notify.nvim-notify = { options.vim.notify.nvim-notify = {
enable = mkEnableOption "nvim-notify notifications"; enable = mkEnableOption "nvim-notify notifications";
stages = mkOption {
type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"];
default = "fade_in_slide_out";
description = "The stages of the notification";
};
timeout = mkOption { setupOpts = mkPluginSetupOption "nvim-notify" {
type = int; stages = mkOption {
default = 1000; type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"];
description = "The timeout of the notification"; default = "fade_in_slide_out";
}; description = "The stages of the notification";
};
background_colour = mkOption { timeout = mkOption {
type = str; type = int;
default = "#000000"; default = 1000;
description = "The background colour of the notification"; description = "The timeout of the notification";
}; };
position = mkOption { background_colour = mkOption {
type = enum ["top_left" "top_right" "bottom_left" "bottom_right"]; type = str;
default = "top_right"; default = "#000000";
description = "The position of the notification"; description = "The background colour of the notification";
}; };
icons = mkOption { position = mkOption {
type = attrsOf str; type = enum ["top_left" "top_right" "bottom_left" "bottom_right"];
description = "The icons of the notification"; default = "top_right";
default = { description = "The position of the notification";
ERROR = ""; };
WARN = "";
INFO = ""; icons = mkOption {
DEBUG = ""; type = attrsOf str;
TRACE = ""; description = "The icons of the notification";
default = {
ERROR = "";
WARN = "";
INFO = "";
DEBUG = "";
TRACE = "";
};
}; };
}; };
}; };

View file

@ -4,9 +4,9 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) concatStringsSep;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.smartcolumn; cfg = config.vim.ui.smartcolumn;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -14,13 +14,7 @@ in {
startPlugins = ["smartcolumn"]; startPlugins = ["smartcolumn"];
luaConfigRC.smartcolumn = entryAnywhere '' luaConfigRC.smartcolumn = entryAnywhere ''
require("smartcolumn").setup({ require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
colorcolumn = "${toString cfg.showColumnAt}",
-- { "help", "text", "markdown", "NvimTree", "alpha"},
disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} },
custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages},
scope = "file",
})
''; '';
}; };
}; };

View file

@ -1,31 +1,41 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf either nullOr listOf int str submodule; inherit (lib.types) nullOr int str attrsOf either listOf;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
imports = let
renamedSetupOpt = oldPath: newPath:
mkRenamedOptionModule (["vim" "ui" "smartcolumn"] ++ oldPath) (["vim" "ui" "smartcolumn" "setupOpts"] ++ newPath);
in [
(renamedSetupOpt ["disabledFiletypes"] ["disabled_filetypes"])
(renamedSetupOpt ["showColumnAt"] ["colorcolumn"])
(renamedSetupOpt ["columnAt" "languages"] ["custom_colorcolumn"])
];
options.vim.ui.smartcolumn = { options.vim.ui.smartcolumn = {
enable = mkEnableOption "line length indicator"; enable = mkEnableOption "line length indicator";
showColumnAt = mkOption { setupOpts = mkPluginSetupOption "smartcolumn.nvim" {
type = nullOr int; colorcolumn = mkOption {
default = 120; type = nullOr (either str (listOf str));
description = "The position at which the column will be displayed. Set to null to disable"; default = "120";
}; description = "The position at which the column will be displayed. Set to null to disable";
};
disabledFiletypes = mkOption { disabled_filetypes = mkOption {
type = listOf str; type = listOf str;
default = ["help" "text" "markdown" "NvimTree" "alpha"]; default = ["help" "text" "markdown" "NvimTree" "alpha"];
description = "The filetypes smartcolumn will be disabled for."; description = "The filetypes smartcolumn will be disabled for.";
}; };
columnAt = { custom_colorcolumn = mkOption {
languages = mkOption {
description = "The position at which smart column should be displayed for each individual buffer type"; description = "The position at which smart column should be displayed for each individual buffer type";
type = submodule { type = attrsOf (either int (listOf int));
freeformType = attrsOf (either int (listOf int)); default = {};
};
example = literalExpression '' example = literalExpression ''
vim.ui.smartcolumn.columnAt.languages = { vim.ui.smartcolumn.setupOpts.custom_colorcolumn = {
nix = 110; nix = 110;
ruby = 120; ruby = 120;
java = 130; java = 130;

View file

@ -9,9 +9,10 @@
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module # TODO: move this to its own module
inherit (lib) pushDownDefault; inherit (lib) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.telescope; cfg = config.vim.telescope;
self = import ./telescope.nix {inherit lib;}; self = import ./telescope.nix {inherit pkgs lib;};
mappingDefinitions = self.options.vim.telescope.mappings; mappingDefinitions = self.options.vim.telescope.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
@ -66,52 +67,7 @@ in {
vim.luaConfigRC.telescope = entryAnywhere '' vim.luaConfigRC.telescope = entryAnywhere ''
local telescope = require('telescope') local telescope = require('telescope')
telescope.setup { telescope.setup(${toLuaObject cfg.setupOpts})
defaults = {
vimgrep_arguments = {
"${pkgs.ripgrep}/bin/rg",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
"--hidden",
"--no-ignore",
},
pickers = {
find_command = {
"${pkgs.fd}/bin/fd",
},
},
},
prompt_prefix = " ",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.8,
height = 0.8,
preview_cutoff = 120,
},
file_ignore_patterns = { "node_modules", ".git/", "dist/", "build/", "target/", "result/" }, -- TODO: make this configurable
color_devicons = true,
path_display = { "absolute" },
set_env = { ["COLORTERM"] = "truecolor" },
winblend = 0,
border = {},
}
${ ${
if config.vim.ui.noice.enable if config.vim.ui.noice.enable

View file

@ -1,6 +1,152 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption; pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) int str listOf float bool either enum submodule attrsOf;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
setupOptions = {
defaults = {
vimgrep_arguments = mkOption {
description = ''
Defines the command that will be used for `live_grep` and `grep_string` pickers.
Make sure that color is set to `never` because telescope does not yet interpret color codes.
'';
type = listOf str;
default = [
"${pkgs.ripgrep}/bin/rg"
"--color=never"
"--no-heading"
"--with-filename"
"--line-number"
"--column"
"--smart-case"
"--hidden"
"--no-ignore"
];
};
pickers.find_command = mkOption {
description = "cmd to use for finding files";
type = either (listOf str) luaInline;
default = ["${pkgs.fd}/bin/fd"];
};
prompt_prefix = mkOption {
description = "Shown in front of Telescope's prompt";
type = str;
default = " ";
};
selection_caret = mkOption {
description = "Character(s) to show in front of the current selection";
type = str;
default = " ";
};
entry_prefix = mkOption {
description = "Prefix in front of each result entry. Current selection not included.";
type = str;
default = " ";
};
initial_mode = mkOption {
description = "Determines in which mode telescope starts.";
type = enum ["insert" "normal"];
default = "insert";
};
selection_strategy = mkOption {
description = "Determines how the cursor acts after each sort iteration.";
type = enum ["reset" "follow" "row" "closest" "none"];
default = "reset";
};
sorting_strategy = mkOption {
description = ''Determines the direction "better" results are sorted towards.'';
type = enum ["descending" "ascending"];
default = "ascending";
};
layout_strategy = mkOption {
description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`.";
type = str;
default = "horizontal";
};
layout_config = mkOption {
description = ''
Determines the default configuration values for layout strategies.
See telescope.layout for details of the configurations options for
each strategy.
'';
default = {};
type = submodule {
options = {
horizontal = {
prompt_position = mkOption {
description = "";
type = str;
default = "top";
};
preview_width = mkOption {
description = "";
type = float;
default = 0.55;
};
results_width = mkOption {
description = "";
type = float;
default = 0.8;
};
};
vertical = {
mirror = mkOption {
description = "";
type = bool;
default = false;
};
};
width = mkOption {
description = "";
type = float;
default = 0.8;
};
height = mkOption {
description = "";
type = float;
default = 0.8;
};
preview_cutoff = mkOption {
description = "";
type = int;
default = 120;
};
};
};
};
file_ignore_patterns = mkOption {
description = "A table of lua regex that define the files that should be ignored.";
type = listOf str;
default = ["node_modules" ".git/" "dist/" "build/" "target/" "result/"];
};
color_devicons = mkOption {
description = "Boolean if devicons should be enabled or not.";
type = bool;
default = true;
};
path_display = mkOption {
description = "Determines how file paths are displayed.";
type = listOf (enum ["hidden" "tail" "absolute" "smart" "shorten" "truncate"]);
default = ["absolute"];
};
set_env = mkOption {
description = "Set an envrionment for term_previewer";
type = attrsOf str;
default = {
COLORTERM = "truecolor";
};
};
winblend = mkOption {
description = "pseudo-transparency of keymap hints floating window";
type = int;
default = 0;
};
};
};
in { in {
options.vim.telescope = { options.vim.telescope = {
mappings = { mappings = {
@ -30,5 +176,7 @@ in {
}; };
enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility"; enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility";
setupOpts = mkPluginSetupOption "Telescope" setupOptions;
}; };
} }

View file

@ -9,8 +9,7 @@
inherit (lib.strings) toUpper; inherit (lib.strings) toUpper;
inherit (lib.types) int float bool str enum listOf attrsOf; inherit (lib.types) int float bool str enum listOf attrsOf;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.generators) mkLuaInline;
rawLua = lua: {__raw = lua;};
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] ["vim" "visuals" "fidget-nvim" "setupOpts" "notification" "window" "align"]) (mkRenamedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] ["vim" "visuals" "fidget-nvim" "setupOpts" "notification" "window" "align"])
@ -50,7 +49,7 @@ in {
apply = clear: apply = clear:
if clear if clear
then then
rawLua '' mkLuaInline ''
function(client_id) function(client_id)
local client = vim.lsp.get_client_by_id(client_id) local client = vim.lsp.get_client_by_id(client_id)
return client and client.name or nil return client and client.name or nil
@ -66,7 +65,7 @@ in {
return msg.lsp_client.name return msg.lsp_client.name
end end
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
ignore = mkOption { ignore = mkOption {
description = "Ignore LSP servers by name"; description = "Ignore LSP servers by name";
@ -177,7 +176,7 @@ in {
default = '' default = ''
require("fidget.progress.display").default_format_message require("fidget.progress.display").default_format_message
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
format_annote = mkOption { format_annote = mkOption {
description = "How to format a progress annotation"; description = "How to format a progress annotation";
@ -185,7 +184,7 @@ in {
default = '' default = ''
function(msg) return msg.title end function(msg) return msg.title end
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
format_group_name = mkOption { format_group_name = mkOption {
description = "How to format a progress notification group's name"; description = "How to format a progress notification group's name";
@ -193,13 +192,13 @@ in {
default = '' default = ''
function(group) return tostring(group) end function(group) return tostring(group) end
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
overrides = mkOption { overrides = mkOption {
description = "Override options from the default notification config"; description = "Override options from the default notification config";
type = attrsOf str; type = attrsOf str;
default = {rust_analyzer = "{ name = 'rust-analyzer' }";}; default = {rust_analyzer = "{ name = 'rust-analyzer' }";};
apply = mapAttrs (key: lua: rawLua lua); apply = mapAttrs (key: lua: mkLuaInline lua);
}; };
}; };
@ -227,7 +226,7 @@ in {
description = "Minimum notifications level"; description = "Minimum notifications level";
type = enum ["debug" "info" "warn" "error"]; type = enum ["debug" "info" "warn" "error"];
default = "info"; default = "info";
apply = filter: rawLua "vim.log.levels.${toUpper filter}"; apply = filter: mkLuaInline "vim.log.levels.${toUpper filter}";
}; };
history_size = mkOption { history_size = mkOption {
description = "Number of removed messages to retain in history"; description = "Number of removed messages to retain in history";
@ -243,7 +242,7 @@ in {
description = "How to configure notification groups when instantiated"; description = "How to configure notification groups when instantiated";
type = attrsOf str; type = attrsOf str;
default = {default = "require('fidget.notification').default_config";}; default = {default = "require('fidget.notification').default_config";};
apply = mapAttrs (key: lua: rawLua lua); apply = mapAttrs (key: lua: mkLuaInline lua);
}; };
redirect = mkOption { redirect = mkOption {
description = "Conditionally redirect notifications to another backend"; description = "Conditionally redirect notifications to another backend";
@ -255,7 +254,7 @@ in {
end end
end end
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
view = { view = {
@ -287,7 +286,7 @@ in {
return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg) return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg)
end end
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
}; };
@ -373,7 +372,7 @@ in {
description = "Minimum logging level"; description = "Minimum logging level";
type = enum ["debug" "error" "info" "trace" "warn" "off"]; type = enum ["debug" "error" "info" "trace" "warn" "off"];
default = "warn"; default = "warn";
apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}"; apply = logLevel: mkLuaInline "vim.log.levels.${toUpper logLevel}";
}; };
max_size = mkOption { max_size = mkOption {
description = "Maximum log file size, in KB"; description = "Maximum log file size, in KB";
@ -391,7 +390,7 @@ in {
default = '' default = ''
string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache")) string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache"))
''; '';
apply = rawLua; apply = mkLuaInline;
}; };
}; };
}; };