mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
feat: implement freeform smartcolumn column positions
This commit is contained in:
parent
c6bcc873a6
commit
2cfeb22764
5 changed files with 48 additions and 38 deletions
10
extra.nix
10
extra.nix
|
@ -178,7 +178,15 @@ inputs: let
|
||||||
|
|
||||||
vim.ui = {
|
vim.ui = {
|
||||||
noice.enable = true;
|
noice.enable = true;
|
||||||
smartcolumn.enable = true;
|
smartcolumn = {
|
||||||
|
enable = true;
|
||||||
|
columnAt.languages = {
|
||||||
|
# this is a freeform module, it's `buftype = int;` for configuring column position
|
||||||
|
nix = 110;
|
||||||
|
ruby = 120;
|
||||||
|
java = 130;
|
||||||
|
};
|
||||||
|
};
|
||||||
colorizer.enable = true;
|
colorizer.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
22
lib/lua.nix
22
lib/lua.nix
|
@ -1,12 +1,32 @@
|
||||||
# Helpers for converting values to lua
|
# Helpers for converting values to lua
|
||||||
{lib}: {
|
{lib}: rec {
|
||||||
|
# yes? no.
|
||||||
yesNo = value:
|
yesNo = value:
|
||||||
if value
|
if value
|
||||||
then "yes"
|
then "yes"
|
||||||
else "no";
|
else "no";
|
||||||
|
|
||||||
|
# Convert a null value to lua's nil
|
||||||
nullString = value:
|
nullString = value:
|
||||||
if value == null
|
if value == null
|
||||||
then "nil"
|
then "nil"
|
||||||
else "'${value}'";
|
else "'${value}'";
|
||||||
|
|
||||||
|
# Helper function to convert an attribute name to a Lua table key
|
||||||
|
attrToKey = name: name;
|
||||||
|
|
||||||
|
# Function to convert a Nix attrset to a Lua table
|
||||||
|
attrsetToLuaTable = attrset:
|
||||||
|
"{ "
|
||||||
|
+ (
|
||||||
|
builtins.concatStringsSep ", "
|
||||||
|
(builtins.attrValues (
|
||||||
|
builtins.mapAttrs (
|
||||||
|
name: value:
|
||||||
|
attrToKey name + " = " + ("\"" + builtins.toJSON value + "\"")
|
||||||
|
)
|
||||||
|
attrset
|
||||||
|
))
|
||||||
|
)
|
||||||
|
+ " }";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,7 @@ in {
|
||||||
colorcolumn = "${toString cfg.showColumnAt}",
|
colorcolumn = "${toString cfg.showColumnAt}",
|
||||||
-- { "help", "text", "markdown", "NvimTree", "alpha"},
|
-- { "help", "text", "markdown", "NvimTree", "alpha"},
|
||||||
disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} },
|
disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} },
|
||||||
custom_colorcolumn = {
|
custom_colorcolumn = ${nvim.lua.attrsetToLuaTable cfg.columnAt.languages},
|
||||||
-- TODO: use cfg.languages.<language>.columnAt when it's fixed to dynamically define per-language length
|
|
||||||
ruby = "120",
|
|
||||||
java = "120",
|
|
||||||
nix = "120",
|
|
||||||
markdown = "80",
|
|
||||||
},
|
|
||||||
scope = "file",
|
scope = "file",
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
languageOpts = {
|
|
||||||
columnAt = mkOption {
|
|
||||||
type = types.nullOr types.int;
|
|
||||||
default = 80;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
options.vim.ui.smartcolumn = {
|
options.vim.ui.smartcolumn = {
|
||||||
enable = mkEnableOption "Enable smartcolumn line length indicator";
|
enable = mkEnableOption "Enable Smartcolumn line length indicator";
|
||||||
|
|
||||||
showColumnAt = mkOption {
|
showColumnAt = mkOption {
|
||||||
type = types.nullOr types.int;
|
type = types.nullOr types.int;
|
||||||
|
@ -27,15 +16,15 @@ in {
|
||||||
description = "The filetypes smartcolumn will be disabled for.";
|
description = "The filetypes smartcolumn will be disabled for.";
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
columnAt = {
|
||||||
languages = mkOption {
|
# TODO: the current implementation only allows for options such as { ruby = "120", java = "120" }
|
||||||
default = {};
|
# whereas the lua config would allow { ruby = "120", java = { "180", "200"} }, this needs to be fixed in the custom lib
|
||||||
description = "Language specific configuration.";
|
languages = lib.mkOption {
|
||||||
type = with types;
|
description = "The position at which smart column should be displayed for each individual buffer type";
|
||||||
attrsOf (submodule {
|
type = lib.types.submodule {
|
||||||
options = languageOpts;
|
freeformType = with lib.types; attrsOf int;
|
||||||
});
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,6 @@ in {
|
||||||
"ccc"
|
"ccc"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
|
||||||
(mkSetLuaBinding mappings.quit "require('ccc').mapping.quit")
|
|
||||||
(mkSetLuaBinding mappings.increase10 "require('ccc').mapping.increase10")
|
|
||||||
(mkSetLuaBinding mappings.decrease10 "require('ccc').mapping.decrease10")
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.luaConfigRC.ccc = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.ccc = nvim.dag.entryAnywhere ''
|
||||||
local ccc = require("ccc")
|
local ccc = require("ccc")
|
||||||
ccc.setup {
|
ccc.setup {
|
||||||
|
@ -52,6 +46,11 @@ in {
|
||||||
{ ccc.picker.css_rgb, ccc.output.css_hsl },
|
{ ccc.picker.css_rgb, ccc.output.css_hsl },
|
||||||
{ ccc.picker.css_hsl, ccc.output.hex },
|
{ ccc.picker.css_hsl, ccc.output.hex },
|
||||||
},
|
},
|
||||||
|
mappings = {
|
||||||
|
["q"] = ccc.mapping.quit,
|
||||||
|
["L"] = ccc.mapping.increase10,
|
||||||
|
["H"] = ccc.mapping.decrease10,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue