mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01: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 = {
|
||||
enable = true;
|
||||
columnAt.languages = {
|
||||
setupOpts.custom_colorcolumn = {
|
||||
# this is a freeform module, it's `buftype = int;` for configuring column position
|
||||
nix = 110;
|
||||
ruby = 120;
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
...
|
||||
}: 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 {
|
||||
|
@ -15,13 +14,7 @@ in {
|
|||
startPlugins = ["smartcolumn"];
|
||||
|
||||
vim.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})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,31 +1,41 @@
|
|||
{lib, ...}: let
|
||||
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 {
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue