Skip to content

Commit

Permalink
plugins/rest: add dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Sep 9, 2024
1 parent 6c9d178 commit b7dea12
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 94 deletions.
21 changes: 17 additions & 4 deletions plugins/by-name/rest/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
config,
lib,
helpers,
pkgs,
Expand Down Expand Up @@ -401,21 +402,33 @@ helpers.neovim-plugin.mkNeovimPlugin {
};

extraOptions = {
curlPackage = lib.mkPackageOption pkgs "curl" {
nullable = true;
};

enableHttpFiletypeAssociation = lib.mkOption {
type = types.bool;
default = true;
description = ''
Sets up the filetype association of `.http` files to trigger treesitter support.
Sets up the filetype association of `.http` files to trigger treesitter support to enable `rest` functionality.
'';
};
};

extraConfig = cfg: {
assertions = [
{
assertion = config.plugins.treesitter.enable;
message = ''
Nixvim (plugins.rest): Requires the `http` parser from `plugins.treesitter`, please set `plugins.treesitter.enable`.
'';
}
];

extraPackages = [ cfg.curlPackage ];

filetype = lib.mkIf cfg.enableHttpFiletypeAssociation {
extension = {
"http" = "http";
};
extension.http = "http";
};
};
}
176 changes: 86 additions & 90 deletions tests/test-sources/plugins/by-name/rest/default.nix
Original file line number Diff line number Diff line change
@@ -1,106 +1,102 @@
{
empty = {
# As of 2024-05-07, the lua dependencies of luaPackage.rest-nvim are not correctly propagated to
# the vim plugin.
# TODO: re-enable this test when this issue will have been fixed
test.runNvim = false;

plugins.rest.enable = true;
plugins = {
rest.enable = true;
treesitter.enable = true;
};
};

defaults = {
# As of 2024-05-07, the lua dependencies of luaPackage.rest-nvim are not correctly propagated to
# the vim plugin.
# TODO: re-enable this test when this issue will have been fixed
test.runNvim = false;

plugins.rest = {
enable = true;
plugins = {
treesitter.enable = true;
rest = {
enable = true;

settings = {
client = "curl";
env_file = ".env";
env_pattern = "\\.env$";
env_edit_command = "tabedit";
encode_url = true;
skip_ssl_verification = false;
custom_dynamic_variables = { };
logs = {
level = "info";
save = true;
};
result = {
split = {
horizontal = false;
in_place = false;
stay_in_current_window_after_split = true;
settings = {
client = "curl";
env_file = ".env";
env_pattern = "\\.env$";
env_edit_command = "tabedit";
encode_url = true;
skip_ssl_verification = false;
custom_dynamic_variables = { };
logs = {
level = "info";
save = true;
};
behavior = {
show_info = {
url = true;
headers = true;
http_info = true;
curl_command = true;
};
decode_url = true;
statistics = {
enable = true;
stats = [
{
__unkeyed = "total_time";
title = "Time taken:";
}
{
__unkeyed = "size_download_t";
title = "Download size:";
}
];
result = {
split = {
horizontal = false;
in_place = false;
stay_in_current_window_after_split = true;
};
formatters = {
json = "jq";
html.__raw = ''
function(body)
if vim.fn.executable("tidy") == 0 then
return body, { found = false, name = "tidy" }
end
local fmt_body = vim.fn.system({
"tidy",
"-i",
"-q",
"--tidy-mark", "no",
"--show-body-only", "auto",
"--show-errors", "0",
"--show-warnings", "0",
"-",
}, body):gsub("\n$", "")
behavior = {
show_info = {
url = true;
headers = true;
http_info = true;
curl_command = true;
};
decode_url = true;
statistics = {
enable = true;
stats = [
{
__unkeyed = "total_time";
title = "Time taken:";
}
{
__unkeyed = "size_download_t";
title = "Download size:";
}
];
};
formatters = {
json = "jq";
html.__raw = ''
function(body)
if vim.fn.executable("tidy") == 0 then
return body, { found = false, name = "tidy" }
end
local fmt_body = vim.fn.system({
"tidy",
"-i",
"-q",
"--tidy-mark", "no",
"--show-body-only", "auto",
"--show-errors", "0",
"--show-warnings", "0",
"-",
}, body):gsub("\n$", "")
return fmt_body, { found = true, name = "tidy" }
end
'';
return fmt_body, { found = true, name = "tidy" }
end
'';
};
};
keybinds = {
buffer_local = false;
prev = "H";
next = "L";
};
};
keybinds = {
buffer_local = false;
prev = "H";
next = "L";
highlight = {
enable = true;
timeout = 750;
};
keybinds = [
[
"<localleader>rr"
"<cmd>Rest run<cr>"
"Run request under the cursor"
]
[
"<localleader>rl"
"<cmd>Rest run last<cr>"
"Re-run latest request"
]
];
};
highlight = {
enable = true;
timeout = 750;
};
keybinds = [
[
"<localleader>rr"
"<cmd>Rest run<cr>"
"Run request under the cursor"
]
[
"<localleader>rl"
"<cmd>Rest run last<cr>"
"Re-run latest request"
]
];
};
};
};
Expand Down

0 comments on commit b7dea12

Please sign in to comment.