modules: start breaking down core modules; simplify tree structure

This commit is contained in:
raf 2024-02-17 04:02:15 +03:00
commit 370913e827
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
242 changed files with 178 additions and 124 deletions

View file

@ -0,0 +1,44 @@
{
config,
lib,
...
}: let
inherit (lib) mkOption mkEnableOption types;
cfg = config.vim.ui.borders;
defaultStyles = ["none" "single" "double" "rounded"];
in {
options.vim.ui.borders = {
enable = mkEnableOption "visible borders for most windows";
globalStyle = mkOption {
type = types.enum defaultStyles;
default = "rounded";
description = ''
global border style to use
'';
};
# TODO: make per-plugin borders configurable
plugins = let
mkPluginStyleOption = name: {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption {
type = types.enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "border style to use for the ${name} plugin";
};
};
in {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionall, it supports a "shadow" type that is similar to none but is of higher contrast
which-key = mkPluginStyleOption "which-key";
lspsaga = mkPluginStyleOption "lspsaga";
nvim-cmp = mkPluginStyleOption "nvim-cmp";
lsp-signature = mkPluginStyleOption "lsp-signature";
code-action-menu = mkPluginStyleOption "code-actions-menu";
};
};
}

View file

@ -0,0 +1,5 @@
_: {
imports = [
./borders.nix
];
}

View file

@ -0,0 +1,479 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkOption types;
in {
options.vim.ui.breadcrumbs = {
enable = lib.mkEnableOption "breadcrumbs";
source = mkOption {
type = with types; nullOr (enum ["nvim-navic"]); # TODO: lspsaga and dropbar
default = "nvim-navic";
description = ''
The source to be used for breadcrumbs component. Null means no breadcrumbs.
'';
};
# maybe this should be an option to *disable* alwaysRender optionally but oh well
# too late
alwaysRender = mkOption {
type = types.bool;
default = true;
description = "Whether to always display the breadcrumbs component on winbar (always renders winbar)";
};
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 = types.bool;
default = true;
description = "use default Navbuddy keybindings (disables user-specified keybinds)";
};
mappings = {
close = mkOption {
type = types.str;
default = "<esc>";
description = "keybinding to close Navbuddy UI";
};
nextSibling = mkOption {
type = types.str;
default = "j";
description = "keybinding to navigate to the next sibling node";
};
previousSibling = mkOption {
type = types.str;
default = "k";
description = "keybinding to navigate to the previous sibling node";
};
parent = mkOption {
type = types.str;
default = "h";
description = "keybinding to navigate to the parent node";
};
children = mkOption {
type = types.str;
default = "h";
description = "keybinding to navigate to the child node";
};
root = mkOption {
type = types.str;
default = "0";
description = "keybinding to navigate to the root node";
};
visualName = mkOption {
type = types.str;
default = "v";
description = "visual selection of name";
};
visualScope = mkOption {
type = types.str;
default = "V";
description = "visual selection of scope";
};
yankName = mkOption {
type = types.str;
default = "y";
description = "yank the name to system clipboard";
};
yankScope = mkOption {
type = types.str;
default = "Y";
description = "yank the scope to system clipboard";
};
insertName = mkOption {
type = types.str;
default = "i";
description = "insert at start of name";
};
insertScope = mkOption {
type = types.str;
default = "I";
description = "insert at start of scope";
};
appendName = mkOption {
type = types.str;
default = "a";
description = "insert at end of name";
};
appendScope = mkOption {
type = types.str;
default = "A";
description = "insert at end of scope";
};
rename = mkOption {
type = types.str;
default = "r";
description = "rename the node";
};
delete = mkOption {
type = types.str;
default = "d";
description = "delete the node";
};
foldCreate = mkOption {
type = types.str;
default = "f";
description = "create a new fold";
};
foldDelete = mkOption {
type = types.str;
default = "F";
description = "delete the current fold";
};
comment = mkOption {
type = types.str;
default = "c";
description = "comment the node";
};
select = mkOption {
type = types.str;
default = "<enter>";
description = "goto selected symbol";
};
moveDown = mkOption {
type = types.str;
default = "J";
description = "move focused node down";
};
moveUp = mkOption {
type = types.str;
default = "K";
description = "move focused node up";
};
telescope = mkOption {
type = types.str;
default = "t";
description = "fuzzy finder at current level";
};
help = mkOption {
type = types.str;
default = "g?";
description = "open mapping help window";
};
};
window = {
# size = {}
# position = {}
border = mkOption {
# TODO: let this type accept a custom string
type = types.enum ["single" "rounded" "double" "solid" "none"];
default = config.vim.ui.borders.globalStyle;
description = "border style to use";
};
scrolloff = mkOption {
type = with types; nullOr int;
default = null;
description = "Scrolloff value within navbuddy window";
};
sections = {
# left section
left = {
/*
size = {
type = with types; nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the left section of Navbuddy UI";
};
};
# middle section
mid = {
/*
size = {
type = with types; nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the middle section of Navbuddy UI";
};
};
# right section
# there is no size option for the right section, it fills the remaining space
right = {
border = mkOption {
# TODO: let this type accept a custom string
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the right section of Navbuddy UI";
};
preview = mkOption {
type = types.enum ["leaf" "always" "never"];
default = "leaf";
description = "display mode of the preview on the right section";
};
};
};
};
nodeMarkers = {
enable = mkEnableOption "node markers";
icons = {
leaf = mkOption {
type = types.str;
default = " ";
description = "";
};
leafSelected = mkOption {
type = types.str;
default = " ";
description = "";
};
branch = mkOption {
type = types.str;
default = " ";
description = "";
};
};
};
lsp = {
autoAttach = mkOption {
type = types.bool;
default = true;
description = "Whether to attach to LSP server manually";
};
preference = mkOption {
type = with types; nullOr (listOf str);
default = null;
description = "list of lsp server names in order of preference";
};
};
sourceBuffer = {
followNode = mkOption {
type = types.bool;
default = true;
description = "keep the current node in focus on the source buffer";
};
highlight = mkOption {
type = types.bool;
default = true;
description = "highlight the currently focused node";
};
reorient = mkOption {
type = types.enum ["smart" "top" "mid" "none"];
default = "smart";
description = "reorient buffer after changing nodes";
};
scrolloff = mkOption {
type = with types; nullOr int;
default = null;
description = "scrolloff value when navbuddy is open";
};
};
# there probably is a better way to do this
# alas, I am not a nix wizard
icons = {
file = mkOption {
type = types.str;
default = "󰈙 ";
description = "";
};
module = mkOption {
type = types.str;
default = " ";
description = "";
};
namespace = mkOption {
type = types.str;
default = "󰌗 ";
description = "";
};
package = mkOption {
type = types.str;
default = " ";
description = "";
};
class = mkOption {
type = types.str;
default = "󰌗 ";
description = "";
};
property = mkOption {
type = types.str;
default = " ";
description = "";
};
field = mkOption {
type = types.str;
default = " ";
description = "";
};
constructor = mkOption {
type = types.str;
default = " ";
description = "";
};
enum = mkOption {
type = types.str;
default = "󰕘";
description = "";
};
interface = mkOption {
type = types.str;
default = "󰕘";
description = "";
};
function = mkOption {
type = types.str;
default = "󰊕 ";
description = "";
};
variable = mkOption {
type = types.str;
default = "󰆧 ";
description = "";
};
constant = mkOption {
type = types.str;
default = "󰏿 ";
description = "";
};
string = mkOption {
type = types.str;
default = " ";
description = "";
};
number = mkOption {
type = types.str;
default = "󰎠 ";
description = "";
};
boolean = mkOption {
type = types.str;
default = " ";
description = "";
};
array = mkOption {
type = types.str;
default = "󰅪 ";
description = "";
};
object = mkOption {
type = types.str;
default = "󰅩 ";
description = "";
};
method = mkOption {
type = types.str;
default = "󰆧 ";
description = "";
};
key = mkOption {
type = types.str;
default = "󰌋 ";
description = "";
};
null = mkOption {
type = types.str;
default = "󰟢 ";
description = "";
};
enumMember = mkOption {
type = types.str;
default = "󰕘 ";
description = "";
};
struct = mkOption {
type = types.str;
default = "󰌗 ";
description = "";
};
event = mkOption {
type = types.str;
default = " ";
description = "";
};
operator = mkOption {
type = types.str;
default = "󰆕 ";
description = "";
};
typeParameter = mkOption {
type = types.str;
default = "󰊄 ";
description = "";
};
};
};
};
}

View file

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

View file

@ -0,0 +1,6 @@
_: {
imports = [
./config.nix
./breadcrumbs.nix
];
}

View file

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

View file

@ -0,0 +1,36 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
cfg = config.vim.ui.colorizer;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"nvim-colorizer-lua"
];
vim.luaConfigRC.colorizer = nvim.dag.entryAnywhere ''
require('colorizer').setup({
filetypes = ${nvim.lua.attrsetToLuaTable cfg.filetypes},
user_default_options = {
RGB = ${boolToString cfg.options.rgb};
RRGGBB = ${boolToString cfg.options.rrggbb};
names = ${boolToString cfg.options.names};
RRGGBBAA = ${boolToString cfg.options.rrggbbaa};
rgb_fn = ${boolToString cfg.options.rgb_fn};
hsl_fn = ${boolToString cfg.options.hsl_fn};
css = ${boolToString cfg.options.css};
css_fn = ${boolToString cfg.options.css_fn};
mode = '${toString cfg.options.mode}';
tailwind = ${boolToString cfg.options.tailwind};
sass = ${boolToString cfg.options.tailwind};
always_update = ${boolToString cfg.options.alwaysUpdate};
}
})
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./colorizer.nix
./config.nix
];
}

View file

@ -0,0 +1,12 @@
_: {
imports = [
./noice
./modes
./notifications
./smartcolumn
./colorizer
./illuminate
./breadcrumbs
./borders
];
}

View file

@ -0,0 +1,24 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf nvim;
cfg = config.vim.ui.illuminate;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["vim-illuminate"];
vim.luaConfigRC.vim-illuminate = nvim.dag.entryAnywhere ''
require('illuminate').configure({
filetypes_denylist = {
'dirvish',
'fugitive',
'NvimTree',
'TelescopePrompt',
},
})
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./config.nix
./illuminate.nix
];
}

View file

@ -0,0 +1,11 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption;
in {
options.vim.ui.illuminate = {
enable = mkEnableOption "vim-illuminate: automatically highlight other uses of the word under the cursor";
};
}

View file

@ -0,0 +1,30 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
cfg = config.vim.ui.modes-nvim;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"modes-nvim"
];
vim.luaConfigRC.modes-nvim = nvim.dag.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}",
},
})
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./modes.nix
./config.nix
];
}

View file

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

View file

@ -0,0 +1,73 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
cfg = config.vim.ui.noice;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"noice-nvim"
"nui-nvim"
];
vim.luaConfigRC.noice-nvim = nvim.dag.entryAnywhere ''
require("noice").setup({
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
signature = {
enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out
},
},
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = ${boolToString config.vim.ui.borders.enable}, -- add a border to hover docs and signature help
},
format = {
cmdline = { pattern = "^:", icon = "", lang = "vim" },
search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" },
search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" },
filter = { pattern = "^:%s*!", icon = "", lang = "bash" },
lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" },
help = { pattern = "^:%s*he?l?p?%s+", icon = "󰋖" },
input = {},
},
messages = {
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
-- This is a current Neovim limitation.
enabled = false, -- enables the Noice messages UI
view = "notify", -- default view for messages
view_error = "notify", -- view for errors
view_warn = "notify", -- view for warnings
view_history = "messages", -- view for :messages
view_search = "virtualtext", -- view for search count messages. Set to `false` to disable
},
-- Hide written messages
routes = {
{
filter = {
event = "msg_show",
kind = "",
find = "written",
},
opts = { skip = true },
},
},
})
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./noice.nix
./config.nix
];
}

View file

@ -0,0 +1,11 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption;
in {
options.vim.ui.noice = {
enable = mkEnableOption "noice-nvim UI modification library";
};
}

View file

@ -0,0 +1,5 @@
_: {
imports = [
./nvim-notify
];
}

View file

@ -0,0 +1,39 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf nvim;
cfg = config.vim.notify.nvim-notify;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["nvim-notify"];
vim.luaConfigRC.nvim-notify = nvim.dag.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}",
},
}
-- required to fix offset_encoding errors
local notify = vim.notify
vim.notify = function(msg, ...)
if msg:match("warning: multiple different client offset_encodings") then
return
end
notify(msg, ...)
end
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./config.nix
./nvim-notify.nix
];
}

View file

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

View file

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

View file

@ -0,0 +1,6 @@
_: {
imports = [
./smartcolumn.nix
./config.nix
];
}

View file

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