plugins/kulala: init

This commit is contained in:
bpatel347 2024-11-08 23:16:05 -05:00 committed by Matt Sturgeon
parent 5c6dd20aeb
commit 7b0df222fc
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 273 additions and 0 deletions

View file

@ -0,0 +1,190 @@
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "kulala";
originalName = "kulala.nvim";
package = "kulala-nvim";
maintainers = [ lib.maintainers.BoneyPatel ];
settingsOptions = {
curl_path = defaultNullOpts.mkStr "curl" ''
Path to the cURL binary. Set this if cURL is installed in a non-standard location.
'';
display_mode =
defaultNullOpts.mkEnumFirstDefault
[
"split"
"float"
]
''
Defines how the request/response is displayed. Options are "split" or "float".
'';
split_direction =
defaultNullOpts.mkEnumFirstDefault
[
"vertical"
"horizontal"
]
''
Defines the direction of the split window. Options are "vertical" or "horizontal".
'';
default_view =
defaultNullOpts.mkEnumFirstDefault
[
"body"
"headers"
"headers_body"
]
''
Sets the default view mode for responses. Options are "body", "headers", or "headers_body".
'';
default_env = defaultNullOpts.mkStr "dev" ''
Sets the default environment for requests. Common options are "dev", "test", or "prod".
'';
debug = defaultNullOpts.mkBool false ''
Enables or disables debug mode.
'';
contenttypes =
defaultNullOpts.mkAttrsOf types.anything
{
"application/json" = {
ft = "json";
formatter = [
"jq"
"."
];
pathresolver.__raw = "require('kulala.parser.jsonpath').parse";
};
"application/xml" = {
ft = "xml";
formatter = [
"xmllint"
"--format"
"-"
];
pathresolver = [
"xmllint"
"--xpath"
"{{path}}"
"-"
];
};
"text/html" = {
ft = "html";
formatter = [
"xmllint"
"--format"
"--html"
"-"
];
pathresolver = [ ];
};
}
''
Defines formatters and path resolvers for specific content types.
'';
show_icons =
defaultNullOpts.mkEnumFirstDefault
[
"on_request"
"above_request"
"below_request"
]
''
Determines where icons are displayed relative to requests. Options are `"on_request"`, `"above_request"`, `"below_request"`, or `{__raw = "nil";}` to disable.
'';
icons =
defaultNullOpts.mkAttrsOf types.anything
{
inlay = {
loading = "";
done = "";
error = "";
};
lualine = "🐼";
}
''
Sets default icons for loading states and lualine.
'';
scratchpad_default_contents =
defaultNullOpts.mkListOf types.anything
[
"@MY_TOKEN_NAME=my_token_value"
""
"# @name scratchpad"
"POST https://httpbin.org/post HTTP/1.1"
"accept: application/json"
"content-type: application/json"
]
''
Default contents for the scratchpad feature.
'';
winbar = defaultNullOpts.mkBool false ''
Enables or disables the winbar for displaying request status.
'';
default_winbar_panes =
defaultNullOpts.mkListOf types.str
[
"body"
"headers"
"headers_body"
]
''
Specifies which panes are displayed by default in the winbar.
'';
vscode_rest_client_environmentvars = defaultNullOpts.mkBool false ''
Enables reading environment variables from VSCodes REST client.
'';
disable_script_print_output = defaultNullOpts.mkBool false ''
Disables immediate printing of script outputs; outputs will still be written to disk.
'';
environment_scope =
defaultNullOpts.mkEnumFirstDefault
[
"b"
"g"
]
''
Sets the scope for environment and request variables. Options are "b" (buffer) or "g" (global).
'';
certificates = defaultNullOpts.mkAttrsOf types.anything { } ''
Configures SSL/TLS certificates.
'';
};
settingsExample = {
default_view = "body";
default_env = "dev";
debug = false;
icons = {
inlay = {
loading = "";
done = "";
error = "";
};
lualine = "🐼";
};
additional_curl_options = { };
environment_scope = "b";
};
}

View file

@ -0,0 +1,83 @@
{
empty = {
plugins.kulala.enable = true;
};
default = {
plugins.kulala = {
enable = true;
settings = {
curl_path = "curl";
display_mode = "split";
split_direction = "vertical";
default_view = "body";
default_env = "dev";
debug = false;
contenttypes = {
"application/json" = {
ft = "json";
formatter = [
"jq"
"."
];
pathresolver = "kulala.parser.jsonpath.parse";
};
"application/xml" = {
ft = "xml";
formatter = [
"xmllint"
"--format"
"-"
];
pathresolver = [
"xmllint"
"--xpath"
"{{path}}"
"-"
];
};
"text/html" = {
ft = "html";
formatter = [
"xmllint"
"--format"
"--html"
"-"
];
pathresolver = [ ];
};
};
show_icons = "on_request";
icons = {
inlay = {
loading = "";
done = "";
error = "";
};
lualine = "🐼";
};
additional_curl_options = { };
scratchpad_default_contents = [
"@MY_TOKEN_NAME=my_token_value"
""
"# @name scratchpad"
"POST https://httpbin.org/post HTTP/1.1"
"accept: application/json"
"content-type: application/json"
""
];
winbar = false;
default_winbar_panes = [
"body"
"headers"
"headers_body"
];
vscode_rest_client_environmentvars = false;
disable_script_print_output = false;
environment_scope = "b";
certificates = { };
};
};
};
}