diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-11-21 09:48:56 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-11-21 09:48:56 +0900 |
| commit | 397fad7b18b10168a762e475bc0de3420c5b3cbf (patch) | |
| tree | 5711e2af6776525e4595ab4533cf903bcd8d7780 | |
| parent | 4844af695af012642fa95e53f32f2639c898694d (diff) | |
modified plugins/lualine.lua, modified plugins/lualine.lua, created plugins/rest.lua, created plugins/rest.lua
4 files changed, 274 insertions, 0 deletions
diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua index 0ae3b88..9bfe875 100644 --- a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua @@ -149,6 +149,17 @@ return { lualine_x = { { function() + local ok, rest = pcall(require, "rest") + if ok and rest then + return "rest" + end + return "" + end, + icon = "", + color = { fg = "#428890" }, + }, + { + function() -- Check if MCPHub is loaded if not vim.g.loaded_mcphub then return " -" diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/rest.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/rest.lua new file mode 100644 index 0000000..3c491dd --- /dev/null +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/rest.lua @@ -0,0 +1,126 @@ +return { + "rest-nvim/rest.nvim", + dependencies = { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "http") + end, + }, + }, + config = function() + ---rest.nvim default configuration + ---@class rest.Config + local default_config = { + ---@type table<string, fun():string> Table of custom dynamic variables + custom_dynamic_variables = {}, + ---@class rest.Config.Request + request = { + ---@type boolean Skip SSL verification, useful for unknown certificates + skip_ssl_verification = false, + ---Default request hooks + ---@class rest.Config.Request.Hooks + hooks = { + ---@type boolean Encode URL before making request + encode_url = true, + ---@type string Set `User-Agent` header when it is empty + user_agent = "rest.nvim v" .. require("rest-nvim.api").VERSION, + ---@type boolean Set `Content-Type` header when it is empty and body is provided + set_content_type = true, + }, + }, + ---@class rest.Config.Response + response = { + ---Default response hooks + ---@class rest.Config.Response.Hooks + hooks = { + ---@type boolean Decode the request URL segments on response UI to improve readability + decode_url = true, + ---@type boolean Format the response body using `gq` command + format = true, + }, + }, + ---@class rest.Config.Clients + clients = { + ---@class rest.Config.Clients.Curl + curl = { + ---Statistics to be shown, takes cURL's `--write-out` flag variables + ---See `man curl` for `--write-out` flag + ---@type RestStatisticsStyle[] + statistics = { + { id = "time_total", winbar = "take", title = "Time taken" }, + { id = "size_download", winbar = "size", title = "Download size" }, + }, + ---Curl-secific request/response hooks + ---@class rest.Config.Clients.Curl.Opts + opts = { + ---@type boolean Add `--compressed` argument when `Accept-Encoding` header includes + ---`gzip` + set_compressed = false, + ---@type table<string, Certificate> Table containing certificates for each domains + certificates = {}, + }, + }, + }, + ---@class rest.Config.Cookies + cookies = { + ---@type boolean Whether enable cookies support or not + enable = true, + ---@type string Cookies file path + path = vim.fs.joinpath(vim.fn.stdpath("data") --[[@as string]], "rest-nvim.cookies"), + }, + ---@class rest.Config.Env + env = { + ---@type boolean + enable = true, + ---@type string + pattern = ".*%.env.*", + ---@type fun():string[] + find = function() + local config = require("rest-nvim.config") + return vim.fs.find(function(name, _) + return name:match(config.env.pattern) + end, { + path = vim.fn.getcwd(), + type = "file", + limit = math.huge, + }) + end, + }, + ---@class rest.Config.UI + ui = { + ---@type boolean Whether to set winbar to result panes + winbar = true, + ---@class rest.Config.UI.Keybinds + keybinds = { + ---@type string Mapping for cycle to previous result pane + prev = "H", + ---@type string Mapping for cycle to next result pane + next = "L", + }, + }, + ---@class rest.Config.Highlight + highlight = { + ---@type boolean Whether current request highlighting is enabled or not + enable = true, + ---@type number Duration time of the request highlighting in milliseconds + timeout = 750, + }, + ---@see vim.log.levels + ---@type integer log level + _log_level = vim.log.levels.WARN, + } + end, + keys = { + { "<localleader>ho", ":Rest open<CR>", desc = "Open result pane" }, + { "<localleader>hr", ":Rest run<CR>", desc = "Run request under the cursor" }, + { "<localleader>hn", ":Rest run", desc = "Run request with name" }, + { "<localleader>hq", ":Rest last<CR>", desc = "Run last request" }, + { "<localleader>hl", ":Rest logs<CR>", desc = "Edit logs file" }, + { "<localleader>hc", ":Rest cookies<CR>", desc = "Edit cookies file" }, + { "<localleader>hd", ":Rest env show<CR>", desc = "Show dotenv file registered to current .http file" }, + { "<localleader>hs", ":Rest env select<CR>", desc = "Select & register .env file" }, + { "<localleader>ha", ":Rest env set", desc = "Register .env file to current .http file" }, + }, +} diff --git a/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua b/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua index 0ae3b88..9bfe875 100644 --- a/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua +++ b/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/lualine.lua @@ -149,6 +149,17 @@ return { lualine_x = { { function() + local ok, rest = pcall(require, "rest") + if ok and rest then + return "rest" + end + return "" + end, + icon = "", + color = { fg = "#428890" }, + }, + { + function() -- Check if MCPHub is loaded if not vim.g.loaded_mcphub then return " -" diff --git a/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/rest.lua b/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/rest.lua new file mode 100644 index 0000000..3c491dd --- /dev/null +++ b/mac/.config/TheSiahxyz/lua/TheSiahxyz/plugins/rest.lua @@ -0,0 +1,126 @@ +return { + "rest-nvim/rest.nvim", + dependencies = { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "http") + end, + }, + }, + config = function() + ---rest.nvim default configuration + ---@class rest.Config + local default_config = { + ---@type table<string, fun():string> Table of custom dynamic variables + custom_dynamic_variables = {}, + ---@class rest.Config.Request + request = { + ---@type boolean Skip SSL verification, useful for unknown certificates + skip_ssl_verification = false, + ---Default request hooks + ---@class rest.Config.Request.Hooks + hooks = { + ---@type boolean Encode URL before making request + encode_url = true, + ---@type string Set `User-Agent` header when it is empty + user_agent = "rest.nvim v" .. require("rest-nvim.api").VERSION, + ---@type boolean Set `Content-Type` header when it is empty and body is provided + set_content_type = true, + }, + }, + ---@class rest.Config.Response + response = { + ---Default response hooks + ---@class rest.Config.Response.Hooks + hooks = { + ---@type boolean Decode the request URL segments on response UI to improve readability + decode_url = true, + ---@type boolean Format the response body using `gq` command + format = true, + }, + }, + ---@class rest.Config.Clients + clients = { + ---@class rest.Config.Clients.Curl + curl = { + ---Statistics to be shown, takes cURL's `--write-out` flag variables + ---See `man curl` for `--write-out` flag + ---@type RestStatisticsStyle[] + statistics = { + { id = "time_total", winbar = "take", title = "Time taken" }, + { id = "size_download", winbar = "size", title = "Download size" }, + }, + ---Curl-secific request/response hooks + ---@class rest.Config.Clients.Curl.Opts + opts = { + ---@type boolean Add `--compressed` argument when `Accept-Encoding` header includes + ---`gzip` + set_compressed = false, + ---@type table<string, Certificate> Table containing certificates for each domains + certificates = {}, + }, + }, + }, + ---@class rest.Config.Cookies + cookies = { + ---@type boolean Whether enable cookies support or not + enable = true, + ---@type string Cookies file path + path = vim.fs.joinpath(vim.fn.stdpath("data") --[[@as string]], "rest-nvim.cookies"), + }, + ---@class rest.Config.Env + env = { + ---@type boolean + enable = true, + ---@type string + pattern = ".*%.env.*", + ---@type fun():string[] + find = function() + local config = require("rest-nvim.config") + return vim.fs.find(function(name, _) + return name:match(config.env.pattern) + end, { + path = vim.fn.getcwd(), + type = "file", + limit = math.huge, + }) + end, + }, + ---@class rest.Config.UI + ui = { + ---@type boolean Whether to set winbar to result panes + winbar = true, + ---@class rest.Config.UI.Keybinds + keybinds = { + ---@type string Mapping for cycle to previous result pane + prev = "H", + ---@type string Mapping for cycle to next result pane + next = "L", + }, + }, + ---@class rest.Config.Highlight + highlight = { + ---@type boolean Whether current request highlighting is enabled or not + enable = true, + ---@type number Duration time of the request highlighting in milliseconds + timeout = 750, + }, + ---@see vim.log.levels + ---@type integer log level + _log_level = vim.log.levels.WARN, + } + end, + keys = { + { "<localleader>ho", ":Rest open<CR>", desc = "Open result pane" }, + { "<localleader>hr", ":Rest run<CR>", desc = "Run request under the cursor" }, + { "<localleader>hn", ":Rest run", desc = "Run request with name" }, + { "<localleader>hq", ":Rest last<CR>", desc = "Run last request" }, + { "<localleader>hl", ":Rest logs<CR>", desc = "Edit logs file" }, + { "<localleader>hc", ":Rest cookies<CR>", desc = "Edit cookies file" }, + { "<localleader>hd", ":Rest env show<CR>", desc = "Show dotenv file registered to current .http file" }, + { "<localleader>hs", ":Rest env select<CR>", desc = "Select & register .env file" }, + { "<localleader>ha", ":Rest env set", desc = "Register .env file to current .http file" }, + }, +} |
