profiles: add interface settings to the recommended-plugins

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-06 16:30:56 +03:00
parent f95df25986
commit 02812ef960
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
4 changed files with 117 additions and 13 deletions

View file

@ -12,6 +12,7 @@
./modules/plugin.nix ./modules/plugin.nix
./modules/fn.nix ./modules/fn.nix
./modules/plugins/interface/colorizer.nix
./modules/plugins/interface/lualine.nix ./modules/plugins/interface/lualine.nix
./modules/plugins/language-server/lspconfig.nix ./modules/plugins/language-server/lspconfig.nix
./modules/plugins/navigation/hop-nvim.nix ./modules/plugins/navigation/hop-nvim.nix

View file

@ -32,7 +32,7 @@ let
default = "setup"; default = "setup";
}; };
setupSettings = mkOption { setupSettings = mkOption {
type = nullOr attrs; type = nullOr (either attrs (listOf anything));
default = null; default = null;
}; };
afterSetup = mkOption { afterSetup = mkOption {

View file

@ -0,0 +1,84 @@
{ config, lib, pkgs, ... }:
let
inherit (builtins) attrNames hasAttr;
inherit (lib.nix2lua) nf;
cfg = config.plugins.interface.colorizer;
pkgs'.nvim-colorizer-lua = pkgs.vimUtils.buildVimPlugin {
name = "nvim-colorizer-lua";
version = "2020-06-11";
src = pkgs.fetchFromGitHub {
owner = "norcalli";
repo = "nvim-colorizer.lua";
rev = "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6";
hash = "sha256-6YrnItxExL2C8pNIdLd+hXCjsB2MbZANwWkah6dreD8=";
};
};
allFiletypes = lib.unique (cfg.filetypes ++ (attrNames cfg.settings.byFiletype));
allFiletypesWithSettings = map
(ft:
if ft != "*" && !(lib.hasPrefix "!" ft) && hasAttr ft cfg.settings.byFiletype
then nf ft cfg.settings.byFiletype.${ft}
else ft
)
allFiletypes;
in
{
options.plugins.interface.colorizer = with lib; {
enable = mkEnableOption "nvim-colorizer-lua";
package = mkPackageOption pkgs' "nvim-colorizer-lua" { };
filetypes = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "*" "!vim" ];
description = ''
See: https://github.com/norcalli/nvim-colorizer.lua?tab=readme-ov-file#customization
'';
};
settings = {
byFiletype = mkOption {
type = with types; attrsOf attrs;
default = { };
example = {
css = { rgb_fn = true; };
html = { names = false; };
};
description = ''
See: https://github.com/norcalli/nvim-colorizer.lua?tab=readme-ov-file#customization
'';
};
overrideDefaults = mkOption {
type = types.attrs;
default = { };
example = {
mode = "foreground";
};
description = ''
See: https://github.com/norcalli/nvim-colorizer.lua?tab=readme-ov-file#customization
'';
};
};
};
config = lib.mkIf cfg.enable {
# Plugin is required to enable 24-bit color
vim.opt.termguicolors = true;
plugin.nvim-colorizer-lua = {
name = "colorizer";
package = cfg.package;
setupSettings = [
(if allFiletypesWithSettings == [ ] then [ "*" ] else allFiletypesWithSettings)
cfg.settings.overrideDefaults
];
};
};
}

View file

@ -5,7 +5,25 @@ let inherit (lib.nix2lua) nf; in
plugin.editorconfig-nvim.isDependency = lib.mkDefault true; plugin.editorconfig-nvim.isDependency = lib.mkDefault true;
plugins = { plugins = {
interface.lualine = { interface = {
colorizer = {
enable = lib.mkDefault true;
filetypes = lib.mkDefault [ "*" ];
settings = {
byFiletype = lib.mkDefault {
css = { css = true; };
scss = { css = true; };
sass = { css = true; };
less = { css = true; };
};
overrideDefaults = lib.mkDefault {
names = false;
};
};
};
lualine = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
settings = lib.mkDefault { settings = lib.mkDefault {
sections = { sections = {
@ -20,6 +38,7 @@ let inherit (lib.nix2lua) nf; in
}; };
}; };
}; };
};
language-server.lspconfig.enable = lib.mkDefault true; language-server.lspconfig.enable = lib.mkDefault true;