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/nvim-highlight-colors: init #2105

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#
# Nixpkgs maintainers: https://github.com/NixOS/nixpkgs/blob/0212bde005b3335b2665c1476c36b3936e113b15/maintainers/maintainer-list.nix
{
thubrecht = {
email = "[email protected]";
github = "Tom-Hubrecht";
githubId = 26650391;
name = "Tom Hubrecht";
};
alisonjenkins = {
email = "[email protected]";
github = "alisonjenkins";
Expand Down
1 change: 1 addition & 0 deletions plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
./ui/image.nix
./ui/neoscroll.nix
./ui/noice.nix
./ui/nvim-highlight-colors.nix
./ui/specs.nix
./ui/statuscol.nix
./ui/transparent.nix
Expand Down
96 changes: 96 additions & 0 deletions plugins/ui/nvim-highlight-colors.nix
Copy link
Member

Choose a reason for hiding this comment

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

Could you introduce a test file please, you can reference other tests in tests/test-sources/plugins and/or recently merged PRs.

Generally, we like to have an empty test case, a defaults test case and (ideally) an example test case.

Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
lib,
helpers,
Copy link
Member

Choose a reason for hiding this comment

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

helpers is deprecated, you can use lib.nixvim instead:

Suggested change
helpers,

config,
pkgs,
...
}:

let
inherit (helpers.defaultNullOpts)
mkBool
mkEnum
mkListOf
mkStr
mkStr'
;
Comment on lines +10 to +16
Copy link
Member

Choose a reason for hiding this comment

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

To match the style used elsewhere in nixvim:

Suggested change
inherit (helpers.defaultNullOpts)
mkBool
mkEnum
mkListOf
mkStr
mkStr'
;
inherit (lib.nixvim) defaultNullOpts;

in
helpers.neovim-plugin.mkNeovimPlugin config {
Copy link
Member

Choose a reason for hiding this comment

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

We (very) recently dropped the config arg:

Suggested change
helpers.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {

name = "nvim-highlight-colors";
defaultPackage = pkgs.vimPlugins.nvim-highlight-colors;
Copy link
Member

Choose a reason for hiding this comment

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

Watch out for #2139, if it is merged first you'll have to do:

Suggested change
defaultPackage = pkgs.vimPlugins.nvim-highlight-colors;
package = "nvim-highlight-colors";


maintainers = [ helpers.maintainers.thubrecht ];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
maintainers = [ helpers.maintainers.thubrecht ];
maintainers = [ lib.maintainers.thubrecht ];


settingsOptions = {
Copy link
Member

Choose a reason for hiding this comment

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

Note: because settings is a freeform option, there is no need to declare sub-options for every upstream plugin option. Users can define any config they like, so having too many options can just end up being a maintenance burden.

The judgement call is yours to make though, I won't block a PR for having "too many" settings options 😁

render = mkEnum [
"background"
"foreground"
"virtual"
] "background" "The render style used.";
Comment on lines +25 to +29
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
render = mkEnum [
"background"
"foreground"
"virtual"
] "background" "The render style used.";
render = defaultNullOpts.mkEnumFirstDefault [
"background"
"foreground"
"virtual"
] "The render style used.";


virtual_symbol = mkStr "■" "The virtual symbol to be used when the render method is set to `virtual`.";
virtual_symbol_prefix = mkStr "" "The virtual symbol prefix.";
virtual_symbol_suffix = mkStr " " "The virtual symbol suffix.";
virtual_symbol_position =
mkEnum
[
"inline"
"eol"
"eow"
]
"inline"
''
The position for the virtual symbol.

- `inline` mimics VS Code style
- `eol` stands for `end of column`, it is recommended to set the virtual symbol suffix to `""` when used
- `eow` stands for `end of word`, it is recommended to set the virtual symbol prefix to `" "` and the suffix to `""` when used
'';

enable_hex = mkBool true "Highlight hex colors, e.g. `#ffbbff`.";
enable_short_hex = mkBool true "Highlight short hex colors, e.g. `#cbf`.";
enable_rgb = mkBool true "Highlight rgb colors, e.g. `rgb(0 0 0)`.";
enable_hsl = mkBool true "Highlight hsl colors, e.g. `hsl(150deg 30% 40%)`.";
enable_var_usage = mkBool true "Highlight CSS variables, e.g. `var(--testing-color)`.";
enable_named_colors = mkBool true "Highlight named colors, e.g. `green`.";
enable_tailwind = mkBool true "Highlight tailwind colors, e.g. `bg-blue-500`.";

custom_colors =
mkListOf
(lib.types.submodule {
options = {
label = mkStr' {
description = ''
The text matched for this color. It must be properly escaped with `%` to adhere to `string.gmatch`.
'';
};
color = mkStr' {
description = ''
The color used, in hex format.
'';
};
};
})
[ ]
''
A list of custom colors.
'';

exclude_filetypes = mkListOf lib.stypes.str [ ] "A list of filetypes to exclude from highlighting.";
exclude_buftypes = mkListOf lib.stypes.str [ ] "A list of buftypes to exclude from highlighting.";
Comment on lines +79 to +80
Copy link
Member

Choose a reason for hiding this comment

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

Typo:

Suggested change
exclude_filetypes = mkListOf lib.stypes.str [ ] "A list of filetypes to exclude from highlighting.";
exclude_buftypes = mkListOf lib.stypes.str [ ] "A list of buftypes to exclude from highlighting.";
exclude_filetypes = mkListOf lib.types.str [ ] "A list of filetypes to exclude from highlighting.";
exclude_buftypes = mkListOf lib.types.str [ ] "A list of buftypes to exclude from highlighting.";

};

settingsExample = {
custom_colors = [
{
label = "%-%-theme%-primary%-color";
color = "#0f1219";
}
{
label = "%-%-theme%-secondary%-color";
color = "#5a5d64";
}
];
exclude_buftypes = [ "text" ];
};
}