treewide: begin restructuring the module tree

This commit is contained in:
raf 2024-04-07 17:16:08 +03:00
commit 7c730a78e5
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
254 changed files with 749 additions and 664 deletions

View file

@ -0,0 +1,46 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.lists) optionals;
inherit (lib.types) enum;
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 = enum defaultStyles;
default = "rounded";
description = ''
The 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 = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "The border style to use for the ${name} plugin";
};
};
in {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionally, 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,363 @@
{
config,
lib,
...
}: 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 {
type = 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 = 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";
mappings = {
close = mkOption {
type = str;
default = "<esc>";
description = "keybinding to close Navbuddy UI";
};
nextSibling = mkOption {
type = str;
default = "j";
description = "keybinding to navigate to the next sibling node";
};
previousSibling = mkOption {
type = str;
default = "k";
description = "keybinding to navigate to the previous sibling node";
};
parent = mkOption {
type = str;
default = "h";
description = "keybinding to navigate to the parent node";
};
children = mkOption {
type = str;
default = "l";
description = "keybinding to navigate to the child node";
};
root = mkOption {
type = str;
default = "0";
description = "keybinding to navigate to the root node";
};
visualName = mkOption {
type = str;
default = "v";
description = "visual selection of name";
};
visualScope = mkOption {
type = str;
default = "V";
description = "visual selection of scope";
};
yankName = mkOption {
type = str;
default = "y";
description = "yank the name to system clipboard";
};
yankScope = mkOption {
type = str;
default = "Y";
description = "yank the scope to system clipboard";
};
insertName = mkOption {
type = str;
default = "i";
description = "insert at start of name";
};
insertScope = mkOption {
type = str;
default = "I";
description = "insert at start of scope";
};
appendName = mkOption {
type = str;
default = "a";
description = "insert at end of name";
};
appendScope = mkOption {
type = str;
default = "A";
description = "insert at end of scope";
};
rename = mkOption {
type = str;
default = "r";
description = "rename the node";
};
delete = mkOption {
type = str;
default = "d";
description = "delete the node";
};
foldCreate = mkOption {
type = str;
default = "f";
description = "create a new fold";
};
foldDelete = mkOption {
type = str;
default = "F";
description = "delete the current fold";
};
comment = mkOption {
type = str;
default = "c";
description = "comment the node";
};
select = mkOption {
type = str;
default = "<enter>";
description = "goto selected symbol";
};
moveDown = mkOption {
type = str;
default = "J";
description = "move focused node down";
};
moveUp = mkOption {
type = str;
default = "K";
description = "move focused node up";
};
telescope = mkOption {
type = str;
default = "t";
description = "fuzzy finder at current level";
};
help = mkOption {
type = str;
default = "g?";
description = "open mapping help window";
};
};
setupOpts = mkPluginSetupOption "navbuddy" {
useDefaultMappings = mkOption {
type = bool;
default = true;
description = "use default Navbuddy keybindings (disables user-specified keybinds)";
};
window = {
# size = {}
# position = {}
border = mkOption {
# TODO: let this type accept a custom string
type = enum ["single" "rounded" "double" "solid" "none"];
default = config.vim.ui.borders.globalStyle;
description = "border style to use";
};
scrolloff = mkOption {
type = nullOr int;
default = null;
description = "Scrolloff value within navbuddy window";
};
sections = {
# left section
left = {
/*
size = mkOption {
type = nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the left section of Navbuddy UI";
};
};
# middle section
mid = {
/*
size = {
type = nullOr (intBetween 0 100);
default = null;
description = "size of the left section of Navbuddy UI in percentage (0-100)";
};
*/
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the middle section of Navbuddy UI";
};
};
# right section
# there is no size option for the right section, it fills the remaining space
right = {
border = mkOption {
# TODO: let this type accept a custom string
type = nullOr (enum ["single" "rounded" "double" "solid" "none"]);
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the right section of Navbuddy UI";
};
preview = mkOption {
type = enum ["leaf" "always" "never"];
default = "leaf";
description = "display mode of the preview on the right section";
};
};
};
};
node_markers = {
enable = mkEnableOption "node markers";
icons = {
leaf = mkSimpleIconOption " ";
leaf_selected = mkSimpleIconOption " ";
branch = mkSimpleIconOption " ";
};
};
lsp = {
auto_attach = mkOption {
type = bool;
default = true;
description = "Whether to attach to LSP server manually";
};
preference = mkOption {
type = nullOr (listOf str);
default = null;
description = "list of lsp server names in order of preference";
};
};
source_buffer = {
followNode = mkOption {
type = bool;
default = true;
description = "keep the current node in focus on the source buffer";
};
highlight = mkOption {
type = bool;
default = true;
description = "highlight the currently focused node";
};
reorient = mkOption {
type = enum ["smart" "top" "mid" "none"];
default = "smart";
description = "reorient buffer after changing nodes";
};
scrolloff = mkOption {
type = nullOr int;
default = null;
description = "scrolloff value when navbuddy is open";
};
};
icons = {
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

@ -0,0 +1,97 @@
{
config,
lib,
...
}: let
inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf;
inherit (lib.lists) optionals;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.ui.breadcrumbs;
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.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") ''
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 ${toLuaObject cfg.navbuddy.setupOpts}
''}
'';
};
}

View file

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

View file

@ -0,0 +1,104 @@
{
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 = {
css = {};
scss = {};
};
description = "Filetypes to highlight on";
};
user_default_options = {
rgb = mkOption {
type = bool;
default = true;
description = "#RGB hex codes";
};
rrggbb = mkOption {
type = bool;
default = true;
description = "#RRGGBB hex codes";
};
names = mkOption {
type = bool;
default = true;
description = ''"Name" codes such as "Blue"'';
};
rgb_fn = mkOption {
type = bool;
default = false;
description = "CSS rgb() and rgba() functions";
};
rrggbbaa = mkOption {
type = bool;
default = false;
description = "#RRGGBBAA hex codes";
};
hsl_fn = mkOption {
type = bool;
default = false;
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 = 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

@ -0,0 +1,21 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.colorizer;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"nvim-colorizer-lua"
];
vim.luaConfigRC.colorizer = entryAnywhere ''
require('colorizer').setup(${toLuaObject cfg.setupOpts})
'';
};
}

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,25 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.illuminate;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["vim-illuminate"];
vim.luaConfigRC.vim-illuminate = 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,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.ui.illuminate = {
enable = mkEnableOption "automatically highlight other uses of the word under the cursor [vim-illuminate]";
};
}

View file

@ -0,0 +1,21 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.modes-nvim;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"modes-nvim"
];
vim.luaConfigRC.modes-nvim = entryAnywhere ''
require('modes').setup(${toLuaObject cfg.setupOpts})
'';
};
}

View file

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

View file

@ -0,0 +1,48 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) bool str float;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.ui.modes-nvim = {
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";
default = "#9745be";
};
};
};
};
}

View file

@ -0,0 +1,75 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.noice;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"noice-nvim"
"nui-nvim"
];
vim.luaConfigRC.noice-nvim = 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,7 @@
{lib, ...}: let
inherit (lib.options) 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,31 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notify.nvim-notify;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["nvim-notify"];
luaConfigRC.nvim-notify = entryAnywhere ''
require('notify').setup(${toLuaObject cfg.setupOpts})
-- 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,65 @@
{
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";
description = "The stages of the notification";
};
timeout = mkOption {
type = int;
default = 1000;
description = "The timeout of the notification";
};
background_colour = mkOption {
type = str;
default = "#000000";
description = "The background colour of the notification";
};
position = mkOption {
type = enum ["top_left" "top_right" "bottom_left" "bottom_right"];
default = "top_right";
description = "The position of the notification";
};
icons = mkOption {
type = attrsOf str;
description = "The icons of the notification";
default = {
ERROR = "";
WARN = "";
INFO = "";
DEBUG = "";
TRACE = "";
};
};
};
};
}

View file

@ -0,0 +1,21 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.smartcolumn;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["smartcolumn"];
luaConfigRC.smartcolumn = entryAnywhere ''
require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
'';
};
};
}

View file

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

View file

@ -0,0 +1,48 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
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";
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";
};
disabled_filetypes = mkOption {
type = listOf str;
default = ["help" "text" "markdown" "NvimTree" "alpha"];
description = "The filetypes smartcolumn will be disabled for.";
};
custom_colorcolumn = mkOption {
description = "The position at which smart column should be displayed for each individual buffer type";
type = attrsOf (either int (listOf int));
default = {};
example = literalExpression ''
vim.ui.smartcolumn.setupOpts.custom_colorcolumn = {
nix = 110;
ruby = 120;
java = 130;
go = [90 130];
};
'';
};
};
};
}