From a9249587628995454a460d96999a42d8afb94d8c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 5 Apr 2023 16:58:56 +0300 Subject: [PATCH] feat: import and configure smartcolumn --- modules/ui/default.nix | 1 + modules/ui/smartcolumn/config.nix | 32 ++++++++++++++++++++ modules/ui/smartcolumn/default.nix | 6 ++++ modules/ui/smartcolumn/smartcolumn.nix | 41 ++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 modules/ui/smartcolumn/config.nix create mode 100644 modules/ui/smartcolumn/default.nix create mode 100644 modules/ui/smartcolumn/smartcolumn.nix diff --git a/modules/ui/default.nix b/modules/ui/default.nix index abd2da1..58ab015 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -3,5 +3,6 @@ _: { ./noice ./modes ./notifications + ./smartcolumn ]; } diff --git a/modules/ui/smartcolumn/config.nix b/modules/ui/smartcolumn/config.nix new file mode 100644 index 0000000..56357c9 --- /dev/null +++ b/modules/ui/smartcolumn/config.nix @@ -0,0 +1,32 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + 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}", + disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} }, + -- { "help", "text", "markdown", "NvimTree", "alpha"}, + custom_colorcolumn = { + -- TODO: use cfg.languages..columnAt when it's fixed to dynamically define per-language length + ruby = "120", + java = "120", + nix = "120", + markdown = "80", + }, + scope = "file", + }) + ''; + }; +} diff --git a/modules/ui/smartcolumn/default.nix b/modules/ui/smartcolumn/default.nix new file mode 100644 index 0000000..2169b22 --- /dev/null +++ b/modules/ui/smartcolumn/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./smartcolumn.nix + ./config.nix + ]; +} diff --git a/modules/ui/smartcolumn/smartcolumn.nix b/modules/ui/smartcolumn/smartcolumn.nix new file mode 100644 index 0000000..b49113a --- /dev/null +++ b/modules/ui/smartcolumn/smartcolumn.nix @@ -0,0 +1,41 @@ +{ + config, + lib, + ... +}: +with lib; +with builtins; let + languageOpts = { + columnAt = mkOption { + type = types.nullOr types.int; + default = 80; + }; + }; +in { + options.vim.ui.smartcolumn = { + enable = mkEnableOption "Enable smartcolumn 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."; + }; + + /* + languages = mkOption { + default = {}; + description = "Language specific configuration."; + type = with types; + attrsOf (submodule { + options = attrsOf (submodule langOptions); + }); + }; + */ + }; +}