Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: Add ccc (new PR) #1365

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@
{fingerprint = "0821 8B96 DC73 85E5 BB7C A535 D264 3BD2 13BC 0FA8";}
];
};
JanKremer = {
email = "mail@jankremer.eu";
matrix = "@jankremer:matrix.org";
github = "janurskremer";
githubId = 79042825;
name = "Jan Kremer";
keys = [
{fingerprint = "20AF 0A65 9F2B 93AD 9184 15D1 A7DA 689C B3B0 78EC";}
];
};
}
1 change: 1 addition & 0 deletions plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
./utils/bacon.nix
./utils/baleia.nix
./utils/better-escape.nix
./utils/ccc.nix
./utils/clipboard-image.nix
./utils/comment.nix
./utils/commentary.nix
Expand Down
54 changes: 54 additions & 0 deletions plugins/utils/ccc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
lib,
helpers,
config,
pkgs,
...
}:
helpers.neovim-plugin.mkNeovimPlugin config {
name = "ccc";
originalName = "ccc.nvim";
defaultPackage = pkgs.vimPlugins.ccc-nvim;

maintainers = [helpers.maintainers.JanKremer];

settingsOptions = {
default_color = helpers.defaultNullOpts.mkStr "#000000" ''
The default color used when a color cannot be picked. It must be HEX format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a warning/assertion that this is a valid hex string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we ever check the validity of strings (apart from enumerations)

'';

highlight_mode = helpers.defaultNullOpts.mkEnum ["fg" "bg" "foreground" "background"] "bg" ''
Option to highlight text foreground or background. It is used to
`output_line` and `highlighter`.
'';

lsp = helpers.defaultNullOpts.mkBool true ''
Whether to enable LSP support. The color information is updated in the
background and the result is used by `:CccPick` and highlighter.
'';

highlighter = {
auto_enable = helpers.defaultNullOpts.mkBool false ''
Whether to enable automatically on `BufEnter`.
'';

lsp = helpers.defaultNullOpts.mkBool true ''
If true, highlight using LSP. If a language server with the color
provider is not attached to a buffer, it falls back to highlight with
pickers. See also `:help ccc-option-lsp`.
'';
};
};

settingsExample = {
default_color = "#FFFFFF";
highlight_mode = "fg";
lsp = false;
highlighter = {
auto_enable = true;
lsp = false;
};
};

extraConfig = cfg: {opts.termguicolors = lib.mkDefault true;};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd add a blank line above for consistency

}
20 changes: 20 additions & 0 deletions tests/test-sources/plugins/utils/ccc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
empty = {
plugins.ccc.enable = true;
};

example = {
plugins.ccc = {
enable = true;
settings = {
default_color = "#FFFFFF";
highlight_mode = "fg";
lsp = true;
highlighter = {
auto_enable = true;
lsp = true;
};
};
};
};
}