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 = {
enable = true;
columnAt.languages = {
setupOpts.custom_colorcolumn = {
# this is a freeform module, it's `buftype = int;` for configuring column position
nix = 110;
ruby = 120;

View file

@ -31,3 +31,95 @@ You can now reference this plugin using its string name:
```nix
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
- Added custom setupOpts for various plugins
- Removed support for deprecated plugin "nvim-compe"
[donnerinoern](https://github.com/donnerinoern):
- Added Gruvbox theme

View file

@ -1092,22 +1092,6 @@
"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": {
"flake": false,
"locked": {
@ -1574,7 +1558,6 @@
"nvim-cmp": "nvim-cmp",
"nvim-code-action-menu": "nvim-code-action-menu",
"nvim-colorizer-lua": "nvim-colorizer-lua",
"nvim-compe": "nvim-compe",
"nvim-cursorline": "nvim-cursorline",
"nvim-dap": "nvim-dap",
"nvim-dap-ui": "nvim-dap-ui",

View file

@ -228,12 +228,6 @@
flake = false;
};
# Autocompletes
nvim-compe = {
url = "github:hrsh7th/nvim-compe";
flake = false;
};
nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
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
luaTable = items: ''{${concatStringsSep "," items}}'';
isLuaInline = {_type ? null, ...}: _type == "lua-inline";
toLuaObject = args:
if isAttrs args
then
if hasAttr "__raw" args
then args.__raw
if isLuaInline args
then args.expr
else if hasAttr "__empty" args
then "{ }"
else

View file

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

View file

@ -15,7 +15,6 @@ with lib; let
"nvim-tree-lua"
"nvim-bufferline-lua"
"lualine"
"nvim-compe"
"nvim-autopairs"
"nvim-ts-autotag"
"nvim-web-devicons"
@ -145,6 +144,18 @@ in {
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:
# ```
# mkPluginSetupOption "telescope" {

View file

@ -4,10 +4,10 @@
...
}: let
inherit (builtins) toJSON;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.lists) optionals;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkLuaBinding;
cfg = config.vim.assistant.copilot;
@ -28,55 +28,47 @@ in {
vim.startPlugins =
[
"copilot-lua"
cfg.copilotNodePackage
# cfg.copilotNodePackage
]
++ optionals (cfg.cmp.enable) [
"copilot-cmp"
];
vim.luaConfigRC.copilot = entryAnywhere ''
require("copilot").setup({
-- 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,
},
},
})
require("copilot").setup(${toLuaObject cfg.setupOpts})
${lib.optionalString (cfg.cmp.enable) ''
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 [
(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.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.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")
];

View file

@ -4,17 +4,35 @@
lib,
...
}: let
inherit (lib) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum float nullOr str package;
inherit (lib.meta) getExe;
inherit (lib.types) nullOr str enum float;
inherit (lib.nvim.types) mkPluginSetupOption;
cfg = config.vim.assistant.copilot;
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 = {
enable = mkEnableOption "GitHub Copilot AI assistant";
cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot";
setupOpts = mkPluginSetupOption "Copilot" {
copilot_node_command = mkOption {
type = str;
default = "${lib.getExe pkgs.nodejs-slim}";
description = ''
The command that will be executed to initiate nodejs for GitHub Copilot.
Recommended to leave as default.
'';
};
panel = {
enabled = mkEnableOption "Completion Panel" // {default = !cfg.cmp.enable;};
layout = {
position = mkOption {
type = enum [
"bottom"
@ -31,6 +49,13 @@ in {
description = "Panel size";
};
};
};
suggestion = {
enabled = mkEnableOption "Suggestions" // {default = !cfg.cmp.enable;};
# keymap = { };
};
};
mappings = {
panel = {
@ -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
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.autopairs;
in {
@ -15,14 +15,6 @@ in {
vim.luaConfigRC.autopairs = entryAnywhere ''
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
inherit (lib) mkRemovedOptionModule;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum bool;
inherit (lib.types) enum;
in {
imports = [
(mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer suported.")
];
options.vim = {
autopairs = {
enable = mkEnableOption "autopairs" // {default = false;};
@ -11,26 +16,6 @@ in {
default = "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.nvim.types) dagOf pluginsOpt extraPluginType;
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.vim) valToVim;
@ -86,7 +87,7 @@
else config;
action =
if action.lua
then {"__raw" = action.action;}
then mkLuaInline action.action
else action.action;
};
in

View file

@ -6,10 +6,9 @@
}: let
inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) listToLuaTable expToLua;
inherit (lib.nvim.lua) toLuaObject;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
@ -40,237 +39,7 @@ in {
''
}
require'nvim-tree'.setup({
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},
},
},
})
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
${
optionalString cfg.openOnSetup ''

View file

@ -4,7 +4,9 @@
...
}: let
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) nullOr str bool int listOf enum attrs oneOf addCheck submodule;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) nullOr str bool int submodule listOf enum oneOf attrs addCheck;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.filetree.nvimTree = {
enable = mkEnableOption "filetree via nvim-tree.lua";
@ -38,19 +40,20 @@ in {
type = bool;
};
hijackNetrw = mkOption {
setupOpts = mkPluginSetupOption "Nvim Tree" {
hijack_netrw = mkOption {
default = true;
description = "Prevents netrw from automatically opening when opening directories";
type = bool;
};
autoreloadOnWrite = mkOption {
auto_reload_on_write = mkOption {
default = true;
description = "Auto reload tree on write";
type = bool;
};
updateFocusedFile = mkOption {
update_focused_file = mkOption {
description = ''
Update the focused file on `BufEnter`, un-collapses the folders recursively
until it finds the file.
@ -64,7 +67,7 @@ in {
description = "update focused file";
};
updateRoot = mkOption {
update_root = mkOption {
type = bool;
default = false;
description = ''
@ -75,7 +78,7 @@ in {
'';
};
ignoreList = mkOption {
ignore_list = mkOption {
type = listOf str;
default = [];
description = ''
@ -97,26 +100,26 @@ in {
type = enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"];
};
foldersFirst = mkOption {
folders_first = mkOption {
default = true;
description = "Sort folders before files. Has no effect when `sort.sorter` is a function.";
type = bool;
};
};
hijackCursor = mkOption {
hijack_cursor = mkOption {
default = false;
description = "Hijack the cursor in the tree to put it at the start of the filename";
type = bool;
};
hijackUnnamedBufferWhenOpening = mkOption {
hijack_unnamed_buffer_when_opening = mkOption {
default = false;
description = "Open nvimtree in place of the unnamed buffer if it's empty.";
type = bool;
};
rootDirs = mkOption {
root_dirs = mkOption {
default = [];
description = ''
Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true`
@ -124,7 +127,7 @@ in {
type = listOf str;
};
preferStartupRoot = mkOption {
prefer_startup_root = mkOption {
default = false;
description = ''
Prefer startup root directory when updating root directory of the tree.
@ -133,7 +136,7 @@ in {
type = bool;
};
syncRootWithCwd = mkOption {
sync_root_with_cwd = mkOption {
type = bool;
default = false;
description = ''
@ -144,47 +147,38 @@ in {
'';
};
reloadOnBufEnter = mkOption {
reload_on_bufenter = mkOption {
default = false;
type = bool;
description = "Automatically reloads the tree on `BufEnter` nvim-tree.";
};
respectBufCwd = mkOption {
respect_buf_cwd = mkOption {
default = false;
type = bool;
description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.";
};
hijackDirectories = mkOption {
description = "hijack new directory buffers when they are opened (`:e dir`).";
default = {
enable = true;
autoOpen = false;
};
type = submodule {
options = {
hijack_directories = {
enable = mkOption {
type = bool;
description = ''
Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim.
If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled.
'';
default = true;
};
autoOpen = mkOption {
auto_open = mkOption {
type = bool;
description = ''
Opens the tree if the tree was previously closed.
'';
};
};
default = false;
};
};
systemOpen = {
system_open = {
args = mkOption {
default = [];
description = "Optional argument list.";
@ -215,18 +209,18 @@ in {
options = {
enable = mkEnableOption "diagnostics view in the signcolumn.";
debounceDelay = mkOption {
debounce_delay = mkOption {
description = "Idle milliseconds between diagnostic event and update.";
type = int;
default = 50;
};
showOnDirs = mkOption {
show_on_dirs = mkOption {
description = "Show diagnostic icons on parent directories.";
default = false;
};
showOnOpenDirs = mkOption {
show_on_open_dirs = mkOption {
type = bool;
default = true;
description = ''
@ -273,12 +267,14 @@ in {
description = "Minimum severity.";
type = enum ["HINT" "INFO" "WARNING" "ERROR"];
default = "HINT";
apply = x: mkLuaInline "vim.diagnostic.severity.${x}";
};
max = mkOption {
description = "Maximum severity.";
type = enum ["HINT" "INFO" "WARNING" "ERROR"];
default = "ERROR";
apply = x: mkLuaInline "vim.diagnostic.severity.${x}";
};
};
};
@ -290,19 +286,19 @@ in {
git = {
enable = mkEnableOption "Git integration with icons and colors.";
showOnDirs = mkOption {
show_on_dirs = mkOption {
type = bool;
default = true;
description = "Show git icons on parent directories.";
};
showOnOpenDirs = mkOption {
show_on_open_dirs = mkOption {
type = bool;
default = true;
description = "Show git icons on directories that are open.";
};
disableForDirs = mkOption {
disable_for_dirs = mkOption {
type = listOf str;
default = [];
description = ''
@ -328,13 +324,13 @@ in {
options = {
enable = mkEnableOption "Modified files with icons and color highlight.";
showOnDirs = mkOption {
show_on_dirs = mkOption {
type = bool;
description = "Show modified icons on parent directories.";
default = true;
};
showOnOpenDirs = mkOption {
show_on_open_dirs = mkOption {
type = bool;
description = "Show modified icons on directories that are open.";
default = true;
@ -343,7 +339,7 @@ in {
};
};
filesystemWatchers = mkOption {
filesystem_watchers = mkOption {
description = ''
Will use file system watcher (libuv fs_event) to watch the filesystem for changes.
Using this will disable BufEnter / BufWritePost events in nvim-tree which
@ -360,13 +356,13 @@ in {
default = true;
};
debounceDelay = mkOption {
debounce_delay = mkOption {
description = "Idle milliseconds between filesystem change and action.";
type = int;
default = 50;
};
ignoreDirs = mkOption {
ignore_dirs = mkOption {
type = listOf str;
default = [];
description = ''
@ -379,7 +375,7 @@ in {
};
};
selectPrompts = mkEnableOption ''
select_prompts = mkEnableOption ''
Use `vim.ui.select` style prompts. Necessary when using a UI prompt decorator such as dressing.nvim or telescope-ui-select.nvim
'';
@ -388,7 +384,7 @@ in {
default = {};
type = submodule {
options = {
centralizeSelection = mkOption {
centralize_selection = mkOption {
description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree.";
type = bool;
default = false;
@ -400,7 +396,7 @@ in {
default = true;
};
debounceDelay = mkOption {
debounce_delay = mkOption {
type = int;
default = 15;
description = ''
@ -434,7 +430,7 @@ in {
default = "left";
};
preserveWindowProportions = mkOption {
preserve_window_proportions = mkOption {
description = ''
Preserves window proportions when opening a file.
If `false`, the height and width of windows other than nvim-tree will be equalized.
@ -477,13 +473,13 @@ in {
default = false;
};
quitOnFocusLoss = mkOption {
quit_on_focus_loss = mkOption {
description = "Close the floating tree window when it loses focus.";
type = bool;
default = true;
};
openWinConfig = mkOption {
open_win_config = mkOption {
description = "Floating window config. See `:h nvim_open_win()` for more details.";
type = attrs;
default = {
@ -503,25 +499,25 @@ in {
};
renderer = {
addTrailing = mkOption {
add_trailing = mkOption {
default = false;
description = "Appends a trailing slash to folder names.";
type = bool;
};
groupEmpty = mkOption {
group_empty = mkOption {
default = false;
description = "Compact folders that only contain a single folder into one node in the file tree.";
type = bool;
};
fullName = mkOption {
full_name = mkOption {
default = false;
description = "Display node whose name length is wider than the width of nvim-tree window in floating window.";
type = bool;
};
highlightGit = mkOption {
highlight_git = mkOption {
type = bool;
default = false;
description = ''
@ -531,7 +527,7 @@ in {
'';
};
highlightOpenedFiles = mkOption {
highlight_opened_files = mkOption {
type = enum ["none" "icon" "name" "all"];
default = "none";
description = ''
@ -540,7 +536,7 @@ in {
'';
};
highlightModified = mkOption {
highlight_modified = mkOption {
type = enum ["none" "icon" "name" "all"];
default = "none";
description = ''
@ -549,7 +545,7 @@ in {
'';
};
rootFolderLabel = mkOption {
root_folder_label = mkOption {
type = oneOf [str bool];
default = false;
example = ''"":~:s?$?/..?"'';
@ -566,19 +562,19 @@ in {
'';
};
indentWidth = mkOption {
indent_width = mkOption {
type = addCheck int (x: x >= 1);
default = 2;
description = "Number of spaces for an each tree nesting level. Minimum 1.";
};
indentMarkers = mkOption {
indent_markers = mkOption {
description = "Configuration options for tree indent markers.";
default = {};
type = submodule {
options = {
enable = mkEnableOption "Display indent markers when folders are open.";
inlineArrows = mkOption {
inline_arrows = mkOption {
type = bool;
default = true;
description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`";
@ -599,13 +595,13 @@ in {
};
};
specialFiles = mkOption {
special_files = mkOption {
type = listOf str;
default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;)
description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile";
};
symlinkDestination = mkOption {
symlink_destination = mkOption {
type = bool;
default = true;
description = "Whether to show the destination of the symlink.";
@ -616,19 +612,19 @@ in {
default = {};
type = submodule {
options = {
webdevColors = mkOption {
webdev_colors = mkOption {
type = bool;
description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`";
default = true;
};
gitPlacement = mkOption {
git_placement = mkOption {
type = enum ["before" "after" "signcolumn"];
description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
default = "before";
};
modifiedPlacement = mkOption {
modified_placement = mkOption {
type = enum ["before" "after" "signcolumn"];
description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
default = "after";
@ -640,7 +636,7 @@ in {
default = " ";
};
symlinkArrow = mkOption {
symlink_arrow = mkOption {
type = str;
description = "Used as a separator between symlinks' source and target.";
default = " ";
@ -659,7 +655,7 @@ in {
default = true;
};
folderArrow = mkOption {
folder_arrow = mkOption {
type = bool;
default = true;
description = ''
@ -720,12 +716,12 @@ in {
default = {
default = "";
open = "";
arrowOpen = "";
arrowClosed = "";
arrow_open = "";
arrow_closed = "";
empty = "";
emptyOpen = "";
empty_open = "";
symlink = "";
symlinkOpen = "";
symlink_open = "";
};
};
@ -754,15 +750,15 @@ in {
description = "Filtering options.";
default = {
gitIgnored = false;
git_ignored = false;
dotfiles = false;
gitClean = false;
noBuffer = false;
git_clean = false;
no_buffer = false;
exclude = [];
};
type = submodule {
options = {
gitIgnored = mkOption {
git_ignored = mkOption {
type = bool;
description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`";
default = false;
@ -774,7 +770,7 @@ in {
default = false;
};
gitClean = mkOption {
git_clean = mkOption {
type = bool;
default = false;
@ -784,7 +780,7 @@ in {
'';
};
noBuffer = mkOption {
no_buffer = mkOption {
type = bool;
default = false;
description = "Do not show files that have no `buflisted()` buffer.";
@ -820,7 +816,7 @@ in {
default = {};
type = submodule {
options = {
useSystemClipboard = mkOption {
use_system_clipboard = mkOption {
type = bool;
default = true;
description = ''
@ -831,7 +827,7 @@ in {
};
# change_dir actions
changeDir = mkOption {
change_dir = mkOption {
description = "vim `change-directory` behaviour";
default = {};
type = submodule {
@ -851,7 +847,7 @@ in {
'';
};
restrictAboveCwd = mkOption {
restrict_above_cwd = mkOption {
type = bool;
default = false;
description = ''
@ -863,12 +859,12 @@ in {
};
# expand_all actions
expandAll = mkOption {
expand_all = mkOption {
description = "Configuration for expand_all behaviour.";
default = {};
type = submodule {
options = {
maxFolderDiscovery = mkOption {
max_folder_discovery = mkOption {
type = int;
default = 300;
description = ''
@ -886,12 +882,12 @@ in {
};
# file_popup actions
filePopup = mkOption {
file_popup = mkOption {
description = "Configuration for file_popup behaviour.";
default = {};
type = submodule {
options = {
openWinConfig = mkOption {
open_win_config = mkOption {
type = attrs;
default = {
col = 1;
@ -907,12 +903,12 @@ in {
};
# open_file actions
openFile = mkOption {
open_file = mkOption {
description = "Configuration options for opening a file from nvim-tree.";
default = {};
type = submodule {
options = {
quitOnOpen = mkOption {
quit_on_open = mkOption {
type = bool;
description = "Closes the explorer when opening a file.";
default = false;
@ -924,14 +920,14 @@ in {
default = false;
};
resizeWindow = mkOption {
resize_window = mkOption {
type = bool;
default = false;
description = "Resizes the tree when opening a file. Previously `view.auto_resize`";
};
windowPicker = mkOption {
window_picker = mkOption {
description = "window_picker";
default = {};
type = submodule {
@ -985,8 +981,8 @@ in {
};
};
removeFile = {
closeWindow = mkOption {
remove_file = {
close_window = mkOption {
type = bool;
default = true;
description = "Close any window displaying a file when removing the file from the tree";
@ -996,7 +992,7 @@ in {
};
};
liveFilter = mkOption {
live_filter = mkOption {
description = ''
Configurations for the live_filtering feature.
The live filter allows you to filter the tree nodes dynamically, based on
@ -1013,7 +1009,7 @@ in {
default = "[FILTER]: ";
};
alwaysShowFolders = mkOption {
always_show_folders = mkOption {
type = bool;
description = "Whether to filter folders or not.";
default = true;
@ -1073,9 +1069,10 @@ in {
type = enum ["ERROR" "WARNING" "INFO" "DEBUG"];
description = "Specify minimum notification level, uses the values from `vim.log.levels`";
default = "INFO";
apply = x: mkLuaInline "vim.log.levels.${x}";
};
absolutePath = mkOption {
absolute_path = mkOption {
type = bool;
description = "Whether to use absolute paths or item names in fs action notifications.";
default = true;
@ -1105,6 +1102,7 @@ in {
};
};
};
};
# kept for backwards compatibility
openOnSetup = mkOption {

View file

@ -5,7 +5,7 @@
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp;
in {
@ -15,16 +15,14 @@ in {
"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 ''
-- Enable lsp signature viewer
require("lsp_signature").setup({
${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}"
}
''}
})
require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts})
'';
};
};

View file

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

View file

@ -1,13 +1,26 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum int;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib) types mkRenamedOptionModule;
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 = {
enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel.";
setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-docs-view" {
position = mkOption {
type = enum ["left" "right" "top" "bottom"];
type = types.enum ["left" "right" "top" "bottom"];
default = "right";
description = ''
Where to open the docs view panel
@ -15,7 +28,7 @@ in {
};
height = mkOption {
type = int;
type = types.int;
default = 10;
description = ''
Height of the docs view panel if the position is set to either top or bottom
@ -23,24 +36,23 @@ in {
};
width = mkOption {
type = int;
type = types.int;
default = 60;
description = ''
Width of the docs view panel if the position is set to either left or right
'';
};
updateMode = mkOption {
type = enum ["auto" "manual"];
update_mode = mkOption {
type = types.enum ["auto" "manual"];
default = "auto";
description = ''
Determines the mechanism used to update the docs view panel content
Possible values:
- auto: the content will update upon cursor move.
- manual: the content will only update once :DocsViewUpdate is called
Determines the mechanism used to update the docs view panel content.
- If auto, the content will update upon cursor move.
- If manual, the content will only update once :DocsViewUpdate is called
'';
};
};
mappings = {
viewToggle = mkMappingOption "Open or close the docs view panel" "lvt";

View file

@ -6,9 +6,9 @@
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.obsidian;
auto = config.vim.autocomplete;
in {
config = mkIf cfg.enable {
vim = {
@ -23,28 +23,7 @@ in {
};
luaConfigRC.obsidian = entryAnywhere ''
require("obsidian").setup({
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}',"
}
}
})
require("obsidian").setup(${toLuaObject cfg.setupOpts})
'';
};
};

View file

@ -1,33 +1,52 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) str bool;
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
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 = {
obsidian = {
enable = mkEnableOption "complementary neovim plugins for Obsidian editor";
setupOpts = lib.nvim.types.mkPluginSetupOption "Obsidian.nvim" {
dir = mkOption {
type = str;
type = types.str;
default = "~/my-vault";
description = "Obsidian vault directory";
};
daily-notes = {
daily_notes = {
folder = mkOption {
type = str;
default = "";
type = types.nullOr types.str;
default = null;
description = "Directory in which daily notes should be created";
};
date-format = mkOption {
type = str;
default = "";
date_format = mkOption {
type = types.nullOr types.str;
default = null;
description = "Date format used for creating daily notes";
};
};
completion = {
nvim_cmp = mkOption {
type = bool;
# 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.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.orgmode;
in {
@ -37,10 +38,7 @@ in {
},
}
require('orgmode').setup({
org_agenda_files = ${cfg.orgAgendaFiles},
org_default_notes_file = '${cfg.orgDefaultNotesFile}',
})
require('orgmode').setup(${toLuaObject cfg.setupOpts})
'';
};
}

View file

@ -4,24 +4,32 @@
pkgs,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) str listOf;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
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 = {
enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds";
orgAgendaFiles = mkOption {
type = str;
default = "{'~/Documents/org/*', '~/my-orgs/**/*'}";
setupOpts = mkPluginSetupOption "Orgmode" {
org_agenda_files = mkOption {
type = listOf str;
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;
default = "~/Documents/org/refile.org";
description = "Default org file to be used for notes.";
};
};
treesitter = {
enable = mkEnableOption "Orgmode treesitter" // {default = config.vim.languages.enableTreesitter;};

View file

@ -4,11 +4,11 @@
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
inherit (lib) mkMerge mkBinding mkIf;
inherit (lib.nvim.lua) toLuaObject;
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;
in {
config = mkIf cfg.enable {
@ -24,28 +24,7 @@ in {
];
luaConfigRC.todo-comments = ''
require('todo-comments').setup {
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},
},
}
require('todo-comments').setup(${toLuaObject cfg.setupOpts})
'';
};
};

View file

@ -1,23 +1,51 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
inherit (lib.nvim.binds) mkMappingOption;
{
pkgs,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types mkMappingOption mkRenamedOptionModule;
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 = {
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
patterns = {
highlight = mkOption {
type = str;
default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]'';
setupOpts = lib.nvim.types.mkPluginSetupOption "todo-comments.nvim" {
highlight = {
pattern = mkOption {
type = types.str;
default = ''.*<(KEYWORDS)(\([^\)]*\))?:'';
description = "vim regex pattern used for highlighting comments";
};
};
search = mkOption {
type = str;
default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]'';
search = {
pattern = mkOption {
type = types.str;
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";
};
};
};
mappings = {

View file

@ -3,10 +3,7 @@
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.strings) concatStringsSep;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib) mkIf nvim;
cfg = config.vim.projects.project-nvim;
in {
@ -15,40 +12,8 @@ in {
"project-nvim"
];
vim.luaConfigRC.project-nvim = entryAnywhere ''
require('project_nvim').setup({
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"),
})
vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere ''
require('project_nvim').setup(${nvim.lua.toLuaObject cfg.setupOpts})
'';
};
}

View file

@ -1,59 +1,80 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum bool listOf str;
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
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 = {
enable = mkEnableOption "project-nvim for project management";
manualMode = mkOption {
type = bool;
setupOpts = lib.nvim.types.mkPluginSetupOption "Project.nvim" {
manual_mode = mkOption {
type = types.bool;
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
detectionMethods = mkOption {
type = listOf str;
detection_methods = mkOption {
type = types.listOf types.str;
default = ["lsp" "pattern"];
description = "Detection methods to use";
};
# patterns
patterns = mkOption {
type = listOf str;
type = types.listOf types.str;
default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"];
description = "Patterns to use for pattern detection method";
};
# table of lsp servers to ignore by name
lspIgnored = mkOption {
type = listOf str;
lsp_ignored = mkOption {
type = types.listOf types.str;
default = [];
description = "LSP servers no ignore by name";
};
excludeDirs = mkOption {
type = listOf str;
exclude_dirs = mkOption {
type = types.listOf types.str;
default = [];
description = "Directories to exclude from project root search";
};
showHidden = mkOption {
type = bool;
show_hidden = mkOption {
type = types.bool;
default = false;
description = "Show hidden files in telescope picker";
};
silentChdir = mkOption {
type = bool;
silent_chdir = mkOption {
type = types.bool;
default = true;
description = "Silently change directory when changing project";
};
scopeChdir = mkOption {
type = enum ["global" "tab" "win"];
scope_chdir = mkOption {
type = types.enum ["global" "tab" "win"];
default = "global";
description = "What scope to change the directory";
};
};
};
}

View file

@ -3,12 +3,9 @@
lib,
...
}: let
inherit (builtins) toString;
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.lua) toLuaObject;
cfg = config.vim.presence.neocord;
in {
@ -17,31 +14,7 @@ in {
vim.luaConfigRC.neocord = entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup({
-- 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}",
})
require("neocord").setup(${toLuaObject cfg.setupOpts})
'';
};
}

View file

@ -1,20 +1,29 @@
{lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule;
inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) bool int str enum nullOr listOf;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
imports = [
imports =
[
(mkRemovedOptionModule ["vim" "presence" "presence-nvim"] ''
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
'')
];
]
++ (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 = {
enable = mkEnableOption "neocord plugin for discord rich presence";
setupOpts = mkPluginSetupOption "neocord" {
logo = mkOption {
type = str; # TODO: can the default be documented better, maybe with an enum?
default = "auto";
@ -80,7 +89,6 @@ in {
description = "List of filetypes to ignore";
};
rich_presence = {
editing_text = mkOption {
type = str;
default = "Editing %s";

View file

@ -3,12 +3,8 @@
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) optionals;
inherit (lib.strings) concatStringsSep;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib) mkIf optionals mkMerge mkBinding nvim;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.session.nvim-session-manager;
in {
@ -19,7 +15,7 @@ in {
"nvim-session-manager"
"plenary-nvim"
]
++ optionals (cfg.usePicker) ["dressing-nvim"];
++ optionals cfg.usePicker ["dressing-nvim"];
maps.normal = mkMerge [
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
@ -29,31 +25,10 @@ in {
# TODO: load_current_dir_session
];
luaConfigRC.nvim-session-manager = entryAnywhere ''
luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
local Path = require('plenary.path')
local sm = require('session_manager.config')
require('session_manager').setup({
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},
})
require('session_manager').setup(${toLuaObject cfg.setupOpts})
'';
};
};

View file

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

View file

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

View file

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

View file

@ -9,6 +9,7 @@
inherit (lib.meta) getExe;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.terminal.toggleterm;
in {
@ -23,24 +24,7 @@ in {
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
luaConfigRC.toggleterm = entryAnywhere ''
require("toggleterm").setup({
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
},
})
require("toggleterm").setup(${toLuaObject cfg.setupOpts})
'';
};
}

View file

@ -5,8 +5,16 @@
}: let
inherit (lib.options) mkOption mkEnableOption;
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 {
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 = {
enable = mkEnableOption "toggleterm as a replacement to built-in terminal command";
mappings = {
@ -17,6 +25,7 @@ in {
};
};
setupOpts = mkPluginSetupOption "ToggleTerm" {
direction = mkOption {
type = enum ["horizontal" "vertical" "tab" "float"];
default = "horizontal";
@ -29,6 +38,33 @@ in {
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 = {
enable = mkEnableOption "LazyGit integration";
direction = mkOption {

View file

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

View file

@ -5,7 +5,34 @@
}: let
inherit (lib.options) mkOption mkEnableOption;
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 {
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 = {
enable = mkEnableOption "breadcrumbs";
source = mkOption {
@ -27,13 +54,6 @@ in {
navbuddy = {
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 = {
close = mkOption {
type = str;
@ -61,7 +81,7 @@ in {
children = mkOption {
type = str;
default = "h";
default = "l";
description = "keybinding to navigate to the child node";
};
@ -180,6 +200,13 @@ in {
};
};
setupOpts = mkPluginSetupOption "navbuddy" {
useDefaultMappings = mkOption {
type = bool;
default = true;
description = "use default Navbuddy keybindings (disables user-specified keybinds)";
};
window = {
# size = {}
# position = {}
@ -201,8 +228,8 @@ in {
# left section
left = {
/*
size = {
type = with types; nullOr (intBetween 0 100);
size = mkOption {
type = nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
@ -220,7 +247,7 @@ in {
mid = {
/*
size = {
type = with types; nullOr (intBetween 0 100);
type = nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
@ -253,31 +280,17 @@ in {
};
};
nodeMarkers = {
node_markers = {
enable = mkEnableOption "node markers";
icons = {
leaf = mkOption {
type = str;
default = " ";
description = "";
};
leafSelected = mkOption {
type = str;
default = " ";
description = "";
};
branch = mkOption {
type = str;
default = " ";
description = "";
};
leaf = mkSimpleIconOption " ";
leaf_selected = mkSimpleIconOption " ";
branch = mkSimpleIconOption " ";
};
};
lsp = {
autoAttach = mkOption {
auto_attach = mkOption {
type = bool;
default = true;
description = "Whether to attach to LSP server manually";
@ -290,7 +303,7 @@ in {
};
};
sourceBuffer = {
source_buffer = {
followNode = mkOption {
type = bool;
default = true;
@ -316,163 +329,33 @@ in {
};
};
# 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";
File = mkSimpleIconOption "󰈙 ";
Module = mkSimpleIconOption " ";
Namespace = mkSimpleIconOption "󰌗 ";
Package = mkSimpleIconOption " ";
Class = mkSimpleIconOption "󰌗 ";
Property = mkSimpleIconOption " ";
Field = mkSimpleIconOption " ";
Constructor = mkSimpleIconOption " ";
Enum = mkSimpleIconOption "󰕘";
Interface = mkSimpleIconOption "󰕘";
Function = mkSimpleIconOption "󰊕 ";
Variable = mkSimpleIconOption "󰆧 ";
Constant = mkSimpleIconOption "󰏿 ";
String = mkSimpleIconOption " ";
Number = mkSimpleIconOption "󰎠 ";
Boolean = mkSimpleIconOption " ";
Array = mkSimpleIconOption "󰅪 ";
Object = mkSimpleIconOption "󰅩 ";
Method = mkSimpleIconOption "󰆧 ";
Key = mkSimpleIconOption "󰌋 ";
Null = mkSimpleIconOption "󰟢 ";
EnumMember = mkSimpleIconOption "󰕘 ";
Struct = mkSimpleIconOption "󰌗 ";
Event = mkSimpleIconOption " ";
Operator = mkSimpleIconOption "󰆕 ";
TypeParameter = mkSimpleIconOption "󰊄 ";
};
};
};

View file

@ -3,15 +3,14 @@
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.modules) mkIf;
inherit (lib.lists) optionals;
inherit (lib.nvim.lua) nullString;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.ui.breadcrumbs;
nbcfg = cfg.navbuddy;
in {
config = mkIf cfg.enable {
vim.startPlugins =
@ -30,6 +29,55 @@ in {
"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"] ''
${optionalString (cfg.source == "nvim-navic") ''
@ -42,128 +90,7 @@ in {
${optionalString cfg.navbuddy.enable ''
local navbuddy = require("nvim-navbuddy")
local actions = require("nvim-navbuddy.actions")
navbuddy.setup {
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
},
}
navbuddy.setup ${toLuaObject cfg.navbuddy.setupOpts}
''}
'';
};

View file

@ -1,10 +1,22 @@
{lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf attrs bool enum;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption;
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 = {
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
setupOpts = mkPluginSetupOption "nvim-colorizer" {
filetypes = mkOption {
type = attrsOf attrs;
default = {
@ -14,9 +26,7 @@ in {
description = "Filetypes to highlight on";
};
options = {
alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
user_default_options = {
rgb = mkOption {
type = bool;
default = true;
@ -53,16 +63,42 @@ in {
description = "CSS hsl() and hsla() functions";
};
css = mkOption {
type = bool;
default = false;
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 = mkEnableOption "tailwind colors";
sass = mkEnableOption "sass colors";
css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn";
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
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.colorizer;
in {
@ -16,23 +15,7 @@ in {
];
vim.luaConfigRC.colorizer = entryAnywhere ''
require('colorizer').setup({
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};
}
})
require('colorizer').setup(${toLuaObject cfg.setupOpts})
'';
};
}

View file

@ -4,8 +4,8 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.modes-nvim;
in {
@ -15,18 +15,7 @@ in {
];
vim.luaConfigRC.modes-nvim = entryAnywhere ''
require('modes').setup({
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}",
},
})
require('modes').setup(${toLuaObject cfg.setupOpts})
'';
};
}

View file

@ -1,29 +1,42 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
inherit (lib.types) bool str float;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.ui.modes-nvim = {
enable = mkEnableOption "prismatic line decorations [modes.nvim]";
setCursorline = mkEnableOption "colored cursorline on current line";
colors = {
enable = mkEnableOption "modes.nvim's prismatic line decorations";
setupOpts = {
setCursorline = mkOption {
type = bool;
description = "Set a colored cursorline on current line";
default = false; # looks ugly, disabled by default
};
line_opacity = {
visual = mkOption {
type = float;
description = "Set opacity for cursorline and number background";
default = 0.0;
};
};
colors = mkPluginSetupOption "modes.nvim" {
copy = mkOption {
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
default = "#f5c359";
};
delete = mkOption {
type = str;
description = "The #RRGGBB color code for the visual mode highlights";
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";
@ -31,4 +44,5 @@ in {
};
};
};
};
}

View file

@ -2,6 +2,6 @@
inherit (lib.options) mkEnableOption;
in {
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
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notify.nvim-notify;
in {
@ -13,19 +14,7 @@ in {
startPlugins = ["nvim-notify"];
luaConfigRC.nvim-notify = entryAnywhere ''
require('notify').setup {
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}",
},
}
require('notify').setup(${toLuaObject cfg.setupOpts})
-- required to fix offset_encoding errors
local notify = vim.notify

View file

@ -1,9 +1,30 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum int str attrsOf;
{
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.types) int str enum attrsOf;
inherit (lib.nvim.types) mkPluginSetupOption;
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 = {
enable = mkEnableOption "nvim-notify notifications";
setupOpts = mkPluginSetupOption "nvim-notify" {
stages = mkOption {
type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"];
default = "fade_in_slide_out";
@ -40,4 +61,5 @@ in {
};
};
};
};
}

View file

@ -4,9 +4,9 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.strings) concatStringsSep;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.smartcolumn;
in {
config = mkIf cfg.enable {
@ -14,13 +14,7 @@ in {
startPlugins = ["smartcolumn"];
luaConfigRC.smartcolumn = entryAnywhere ''
require("smartcolumn").setup({
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",
})
require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
'';
};
};

View file

@ -1,31 +1,41 @@
{lib, ...}: let
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 {
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 = {
enable = mkEnableOption "line length indicator";
showColumnAt = mkOption {
type = nullOr int;
default = 120;
setupOpts = mkPluginSetupOption "smartcolumn.nvim" {
colorcolumn = mkOption {
type = nullOr (either str (listOf str));
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;
default = ["help" "text" "markdown" "NvimTree" "alpha"];
description = "The filetypes smartcolumn will be disabled for.";
};
columnAt = {
languages = mkOption {
custom_colorcolumn = mkOption {
description = "The position at which smart column should be displayed for each individual buffer type";
type = submodule {
freeformType = attrsOf (either int (listOf int));
};
type = attrsOf (either int (listOf int));
default = {};
example = literalExpression ''
vim.ui.smartcolumn.columnAt.languages = {
vim.ui.smartcolumn.setupOpts.custom_colorcolumn = {
nix = 110;
ruby = 120;
java = 130;

View file

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