-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a7a726
commit c29a33d
Showing
2 changed files
with
67 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,83 @@ | ||
{ | ||
lib, | ||
helpers, | ||
config, | ||
pkgs, | ||
... | ||
}: | ||
with lib; { | ||
options.plugins.instant = { | ||
enable = mkEnableOption "instant.nvim"; | ||
|
||
package = helpers.mkPackageOption "instant" pkgs.vimPlugins.instant-nvim; | ||
|
||
username = mkOption { | ||
type = with types; nullOr str; | ||
description = '' | ||
Username. | ||
Explicitly set to `null` if you do not want this option to be set. | ||
} @ args: | ||
with lib; | ||
with import ../helpers.nix {inherit lib;}; | ||
mkPlugin args { | ||
name = "instant"; | ||
description = "instant.nvim"; | ||
package = pkgs.vimPlugins.instant-nvim; | ||
globalPrefix = "instant_"; | ||
|
||
options = let | ||
mkStr = global: default: desc: | ||
mkDefaultOpt { | ||
inherit global; | ||
type = types.str; | ||
description = '' | ||
${desc} | ||
Default: ${default} | ||
''; | ||
}; | ||
in { | ||
username = mkDefaultOpt { | ||
type = types.str; | ||
description = '' | ||
Username. | ||
Explicitly set to `null` if you do not want this option to be set. | ||
''; | ||
}; | ||
|
||
onlyCwd = mkDefaultOpt { | ||
type = types.bool; | ||
description = '' | ||
Choose whether to share files only in the current working directory in session mode. | ||
Default: `true` | ||
''; | ||
}; | ||
|
||
cursorHlGroupUser1 = mkStr "cursor_hl_group_user_1" "Cursor" '' | ||
Cursor highlight group for user 1. | ||
''; | ||
}; | ||
|
||
onlyCwd = helpers.defaultNullOpts.mkBool true '' | ||
Choose whether to share files only in the current working directory in session mode. | ||
''; | ||
|
||
cursorHlGroupUser1 = helpers.defaultNullOpts.mkStr "Cursor" '' | ||
Cursor highlight group for user 1. | ||
''; | ||
|
||
cursorHlGroupUser2 = helpers.defaultNullOpts.mkStr "Cursor" '' | ||
Cursor highlight group for user 2. | ||
''; | ||
|
||
cursorHlGroupUser3 = helpers.defaultNullOpts.mkStr "Cursor" '' | ||
Cursor highlight group for user 3. | ||
''; | ||
|
||
cursorHlGroupUser4 = helpers.defaultNullOpts.mkStr "Cursor" '' | ||
Cursor highlight group for user 4. | ||
''; | ||
|
||
cursorHlGroupDefault = helpers.defaultNullOpts.mkStr "Cursor" '' | ||
Cursor highlight group for any other userr. | ||
''; | ||
cursorHlGroupUser2 = mkStr "cursor_hl_group_user_2" "Cursor" '' | ||
Cursor highlight group for user 2. | ||
''; | ||
|
||
nameHlGroupUser1 = helpers.defaultNullOpts.mkStr "CursorLineNr" '' | ||
Virtual text highlight group for user 1. | ||
''; | ||
cursorHlGroupUser3 = mkStr "cursor_hl_group_user_3" "Cursor" '' | ||
Cursor highlight group for user 3. | ||
''; | ||
|
||
nameHlGroupUser2 = helpers.defaultNullOpts.mkStr "CursorLineNr" '' | ||
Virtual text highlight group for user 2. | ||
''; | ||
cursorHlGroupUser4 = mkStr "cursor_hl_group_user_4" "Cursor" '' | ||
Cursor highlight group for user 4. | ||
''; | ||
|
||
nameHlGroupUser3 = helpers.defaultNullOpts.mkStr "CursorLineNr" '' | ||
Virtual text highlight group for user 3. | ||
''; | ||
cursorHlGroupDefault = mkStr "cursor_hl_group_default" "Cursor" '' | ||
Cursor highlight group for any other userr. | ||
''; | ||
|
||
nameHlGroupUser4 = helpers.defaultNullOpts.mkStr "CursorLineNr" '' | ||
Virtual text highlight group for user 4. | ||
''; | ||
nameHlGroupUser1 = mkStr "name_hl_group_user_1" "CursorLineNr" '' | ||
Virtual text highlight group for user 1. | ||
''; | ||
|
||
nameHlGroupDefault = helpers.defaultNullOpts.mkStr "CursorLineNr" '' | ||
Virtual text highlight group for any other user. | ||
''; | ||
nameHlGroupUser2 = mkStr "name_hl_group_user_2" "CursorLineNr" '' | ||
Virtual text highlight group for user 2. | ||
''; | ||
|
||
extraOptions = mkOption { | ||
type = types.attrs; | ||
default = {}; | ||
description = '' | ||
Extra configuration options for instant without the 'instant_' prefix. | ||
Example: To set 'instant_foobar' to 1, write | ||
```nix | ||
extraConfig = { | ||
foobar = true; | ||
}; | ||
``` | ||
nameHlGroupUser3 = mkStr "name_hl_group_user_3" "CursorLineNr" '' | ||
Virtual text highlight group for user 3. | ||
''; | ||
}; | ||
}; | ||
|
||
config = let | ||
cfg = config.plugins.instant; | ||
in | ||
mkIf cfg.enable { | ||
extraPlugins = [cfg.package]; | ||
nameHlGroupUser4 = mkStr "name_hl_group_user_4" "CursorLineNr" '' | ||
Virtual text highlight group for user 4. | ||
''; | ||
|
||
globals = | ||
mapAttrs' | ||
(name: nameValuePair ("instant_" + name)) | ||
( | ||
with cfg; | ||
{ | ||
inherit username; | ||
only_cwd = onlyCwd; | ||
cursor_hl_group_user_1 = cursorHlGroupUser1; | ||
cursor_hl_group_user_2 = cursorHlGroupUser2; | ||
cursor_hl_group_user_3 = cursorHlGroupUser3; | ||
cursor_hl_group_user_4 = cursorHlGroupUser4; | ||
cursor_hl_group_default = cursorHlGroupDefault; | ||
name_hl_group_user_1 = nameHlGroupUser1; | ||
name_hl_group_user_2 = nameHlGroupUser2; | ||
name_hl_group_user_3 = nameHlGroupUser3; | ||
name_hl_group_user_4 = nameHlGroupUser4; | ||
name_hl_group_default = nameHlGroupDefault; | ||
} | ||
// extraOptions | ||
); | ||
nameHlGroupDefault = mkStr "name_hl_group_default" "CursorLineNr" '' | ||
Virtual text highlight group for any other user. | ||
''; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters