mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 00:26:45 +00:00
feat(smartcolumn): custom setup opts
This commit is contained in:
parent
80fee9dae7
commit
5ea6272bee
3 changed files with 30 additions and 27 deletions
|
@ -210,7 +210,7 @@ inputs: let
|
||||||
};
|
};
|
||||||
smartcolumn = {
|
smartcolumn = {
|
||||||
enable = true;
|
enable = true;
|
||||||
columnAt.languages = {
|
setupOpts.custom_colorcolumn = {
|
||||||
# this is a freeform module, it's `buftype = int;` for configuring column position
|
# this is a freeform module, it's `buftype = int;` for configuring column position
|
||||||
nix = 110;
|
nix = 110;
|
||||||
ruby = 120;
|
ruby = 120;
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) concatStringsSep;
|
|
||||||
inherit (lib.nvim.lua) attrsetToLuaTable;
|
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.ui.smartcolumn;
|
cfg = config.vim.ui.smartcolumn;
|
||||||
in {
|
in {
|
||||||
|
@ -15,13 +14,7 @@ in {
|
||||||
startPlugins = ["smartcolumn"];
|
startPlugins = ["smartcolumn"];
|
||||||
|
|
||||||
vim.luaConfigRC.smartcolumn = entryAnywhere ''
|
vim.luaConfigRC.smartcolumn = entryAnywhere ''
|
||||||
require("smartcolumn").setup({
|
require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
|
||||||
colorcolumn = "${toString cfg.showColumnAt}",
|
|
||||||
-- { "help", "text", "markdown", "NvimTree", "alpha"},
|
|
||||||
disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} },
|
|
||||||
custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages},
|
|
||||||
scope = "file",
|
|
||||||
})
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,41 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) nullOr int str submodule attrsOf either listOf;
|
inherit (lib.types) nullOr int str attrsOf either listOf;
|
||||||
|
inherit (lib.modules) mkRenamedOptionModule;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
|
imports = let
|
||||||
|
renamedSetupOpt = oldPath: newPath:
|
||||||
|
mkRenamedOptionModule (["vim" "ui" "smartcolumn"] ++ oldPath) (["vim" "ui" "smartcolumn" "setupOpts"] ++ newPath);
|
||||||
|
in [
|
||||||
|
(renamedSetupOpt ["disabledFiletypes"] ["disabled_filetypes"])
|
||||||
|
(renamedSetupOpt ["showColumnAt"] ["colorcolumn"])
|
||||||
|
(renamedSetupOpt ["columnAt" "languages"] ["custom_colorcolumn"])
|
||||||
|
];
|
||||||
|
|
||||||
options.vim.ui.smartcolumn = {
|
options.vim.ui.smartcolumn = {
|
||||||
enable = mkEnableOption "line length indicator";
|
enable = mkEnableOption "line length indicator";
|
||||||
|
|
||||||
showColumnAt = mkOption {
|
setupOpts = mkPluginSetupOption "smartcolumn.nvim" {
|
||||||
type = nullOr int;
|
colorcolumn = mkOption {
|
||||||
default = 120;
|
type = nullOr (either str (listOf str));
|
||||||
description = "The position at which the column will be displayed. Set to null to disable";
|
default = "120";
|
||||||
};
|
description = "The position at which the column will be displayed. Set to null to disable";
|
||||||
|
};
|
||||||
|
|
||||||
disabledFiletypes = mkOption {
|
disabled_filetypes = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = ["help" "text" "markdown" "NvimTree" "alpha"];
|
default = ["help" "text" "markdown" "NvimTree" "alpha"];
|
||||||
description = "The filetypes smartcolumn will be disabled for.";
|
description = "The filetypes smartcolumn will be disabled for.";
|
||||||
};
|
};
|
||||||
|
|
||||||
columnAt = {
|
custom_colorcolumn = mkOption {
|
||||||
languages = mkOption {
|
|
||||||
description = "The position at which smart column should be displayed for each individual buffer type";
|
description = "The position at which smart column should be displayed for each individual buffer type";
|
||||||
type = submodule {
|
type = attrsOf (either int (listOf int));
|
||||||
freeformType = attrsOf (either int (listOf int));
|
default = {};
|
||||||
};
|
|
||||||
|
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
vim.ui.smartcolumn.columnAt.languages = {
|
vim.ui.smartcolumn.setupOpts.custom_colorcolumn = {
|
||||||
nix = 110;
|
nix = 110;
|
||||||
ruby = 120;
|
ruby = 120;
|
||||||
java = 130;
|
java = 130;
|
||||||
|
|
Loading…
Reference in a new issue