Compare commits
10 commits
01248ffcff
...
2475bcd6b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2475bcd6b1 | ||
| 42fb4b5b2a | |||
| 13b1f756c8 | |||
|
|
ca304930d2 | ||
| 7d5f4a9a82 | |||
| f73b613a33 | |||
| eacae18933 | |||
|
|
838541539e | ||
| 76506cd566 | |||
| 017c1873b7 |
16 changed files with 232 additions and 197 deletions
3
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
3
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
|
|
@ -7,8 +7,7 @@ body:
|
||||||
attributes:
|
attributes:
|
||||||
label: Prerequisites
|
label: Prerequisites
|
||||||
options:
|
options:
|
||||||
- label:
|
- label: I have searched [existing
|
||||||
I have searched [existing
|
|
||||||
issues](https://github.com/barrettruth/http-codes.nvim/issues)
|
issues](https://github.com/barrettruth/http-codes.nvim/issues)
|
||||||
required: true
|
required: true
|
||||||
- label: I have updated to the latest version
|
- label: I have updated to the latest version
|
||||||
|
|
|
||||||
3
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
3
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
|
|
@ -7,8 +7,7 @@ body:
|
||||||
attributes:
|
attributes:
|
||||||
label: Prerequisites
|
label: Prerequisites
|
||||||
options:
|
options:
|
||||||
- label:
|
- label: I have searched [existing
|
||||||
I have searched [existing
|
|
||||||
issues](https://github.com/barrettruth/http-codes.nvim/issues)
|
issues](https://github.com/barrettruth/http-codes.nvim/issues)
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"runtime.version": "Lua 5.1",
|
"runtime.version": "Lua 5.1",
|
||||||
"runtime.path": ["lua/?.lua", "lua/?/init.lua"],
|
"runtime.path": ["lua/?.lua", "lua/?/init.lua"],
|
||||||
"diagnostics.globals": ["vim"],
|
"diagnostics.globals": ["vim", "jit"],
|
||||||
"workspace.library": ["$VIMRUNTIME/lua", "${3rd}/luv/library"],
|
"workspace.library": ["$VIMRUNTIME/lua", "${3rd}/luv/library"],
|
||||||
"workspace.checkThirdParty": false,
|
"workspace.checkThirdParty": false,
|
||||||
"completion.callSnippet": "Replace"
|
"completion.callSnippet": "Replace"
|
||||||
|
|
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 Raphael
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
26
README.md
Normal file
26
README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# http-codes.nvim
|
||||||
|
|
||||||
|
Quickly investigate HTTP status codes with [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP), with telescope, fzf-lua, and snacks.nvim integrations.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install with your package manager or via
|
||||||
|
[luarocks](https://luarocks.org/modules/barrettruth/http-codes.nvim):
|
||||||
|
|
||||||
|
```
|
||||||
|
luarocks install http-codes.nvim
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
One of:
|
||||||
|
|
||||||
|
- [fzf-lua](https://github.com/ibhagwan/fzf-lua)
|
||||||
|
- [snacks.nvim](https://github.com/folke/snacks.nvim)
|
||||||
|
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:help http-codes.nvim
|
||||||
|
```
|
||||||
|
|
@ -1,39 +1,53 @@
|
||||||
http-codes *http-codes.txt*
|
*http-codes* *http-codes.txt*
|
||||||
|
|
||||||
Author: Barrett Ruth <https://barrettruth.com>
|
Author: Barrett Ruth <https://barrettruth.com>
|
||||||
Homepage: <https://github.com/barrettruth/http-codes.nvim>
|
Homepage: <https://github.com/barrett-ruth/http-codes.nvim>
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
INTRODUCTION *http-codes.nvim*
|
INTRODUCTION *http-codes.nvim*
|
||||||
|
|
||||||
http-codes.nvim lets you quickly investigate HTTP status codes with Mozilla,
|
http-codes.nvim lets you quickly investigate HTTP status codes using Mozilla
|
||||||
supporting fzf-lua, snacks.nvim, and telescope.nvim.
|
documentation, with telescope, fzf-lua, and snacks.nvim integrations.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
CONFIGURATION *http-codes.config*
|
USAGE *:HTTPCodes*
|
||||||
|
|
||||||
|
>vim
|
||||||
|
:HTTPCodes
|
||||||
|
<
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
MAPPINGS *http-codes-mappings*
|
||||||
|
|
||||||
|
*<Plug>(http-codes-pick)*
|
||||||
|
<Plug>(http-codes-pick) Open the HTTP status code picker.
|
||||||
|
Equivalent to |:HTTPCodes|.
|
||||||
|
|
||||||
|
Example configuration: >lua
|
||||||
|
vim.keymap.set('n', '<leader>hc', '<Plug>(http-codes-pick)')
|
||||||
|
<
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
CONFIGURATION *vim.g.http_codes*
|
||||||
|
|
||||||
|
Configure via `vim.g.http_codes`:
|
||||||
|
|
||||||
Configure via `vim.g.http_codes` before the plugin loads:
|
|
||||||
>lua
|
>lua
|
||||||
vim.g.http_codes = {
|
vim.g.http_codes = {
|
||||||
|
-- Picker: 'fzf-lua', 'snacks', or 'telescope' (auto-detected)
|
||||||
use = 'fzf-lua',
|
use = 'fzf-lua',
|
||||||
|
-- Command to open URLs (OS-specific by default)
|
||||||
open_url = 'xdg-open %s',
|
open_url = 'xdg-open %s',
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
Options: ~
|
|
||||||
|
|
||||||
{use} `(string|nil)`: Picker to use: 'fzf-lua', 'snacks', or
|
Default `open_url` by operating system:
|
||||||
'telescope'. Auto-detected if not specified.
|
|
||||||
|
|
||||||
{open_url} `(string|nil)`: Command to open URLs. Uses `%s` as placeholder.
|
OS Default
|
||||||
Defaults based on OS:
|
-------- ---------------
|
||||||
- Linux: 'xdg-open %s'
|
Windows start %s
|
||||||
- macOS: 'open %s'
|
macOS open %s
|
||||||
- Windows: 'start %s'
|
Linux xdg-open %s
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
COMMANDS *http-codes.commands*
|
|
||||||
|
|
||||||
:HTTPCodes Browse HTTP codes using the configured picker.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
vim:tw=80:ft=help:
|
vim:tw=80:ts=8:ft=help:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,10 @@ local function init()
|
||||||
end
|
end
|
||||||
|
|
||||||
if not config.use then
|
if not config.use then
|
||||||
vim.notify_once('http-codes.nvim: install fzf-lua, snacks.nvim, or telescope.nvim', vim.log.levels.ERROR)
|
vim.notify_once(
|
||||||
|
'http-codes.nvim: install fzf-lua, snacks.nvim, or telescope.nvim',
|
||||||
|
vim.log.levels.ERROR
|
||||||
|
)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -70,7 +73,13 @@ M.http_codes = M.pick
|
||||||
|
|
||||||
---@deprecated Use `vim.g.http_codes` instead
|
---@deprecated Use `vim.g.http_codes` instead
|
||||||
function M.setup(user_config)
|
function M.setup(user_config)
|
||||||
vim.deprecate('require("http-codes").setup()', 'vim.g.http_codes', 'v0.1.0', 'http-codes.nvim', false)
|
vim.deprecate(
|
||||||
|
'require("http-codes").setup()',
|
||||||
|
'vim.g.http_codes',
|
||||||
|
'v0.1.0',
|
||||||
|
'http-codes.nvim',
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
if user_config then
|
if user_config then
|
||||||
vim.g.http_codes = vim.tbl_deep_extend('force', vim.g.http_codes or {}, user_config)
|
vim.g.http_codes = vim.tbl_deep_extend('force', vim.g.http_codes or {}, user_config)
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,51 @@
|
||||||
return {
|
return {
|
||||||
['201 Created'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201',
|
['201 Created'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201',
|
||||||
['202 Accepted'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202',
|
['202 Accepted'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202',
|
||||||
['203 Non-Authoritative Information'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203',
|
['203 Non-Authoritative Information'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203',
|
||||||
['204 No Content'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204',
|
['204 No Content'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204',
|
||||||
['205 Reset Content'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205',
|
['205 Reset Content'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205',
|
||||||
['206 Partial Content'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206',
|
['206 Partial Content'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206',
|
||||||
['300 Multiple Choices'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300',
|
['300 Multiple Choices'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300',
|
||||||
['301 Moved Permanently'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301',
|
['301 Moved Permanently'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301',
|
||||||
['302 Found'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302',
|
['302 Found'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302',
|
||||||
['303 See Other'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303',
|
['303 See Other'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303',
|
||||||
['304 Not Modified'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304',
|
['304 Not Modified'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304',
|
||||||
['307 Temporary Redirect'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307',
|
['307 Temporary Redirect'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307',
|
||||||
['308 Permanent Redirect'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308',
|
['308 Permanent Redirect'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308',
|
||||||
['400 Bad Request'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400',
|
['400 Bad Request'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400',
|
||||||
['401 Unauthorized'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401',
|
['401 Unauthorized'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401',
|
||||||
['402 Payment Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402',
|
['402 Payment Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402',
|
||||||
['403 Forbidden'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403',
|
['403 Forbidden'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403',
|
||||||
['404 Not Found'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404',
|
['404 Not Found'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404',
|
||||||
['405 Method Not Allowed'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405',
|
['405 Method Not Allowed'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405',
|
||||||
['406 Not Acceptable'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406',
|
['406 Not Acceptable'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406',
|
||||||
['407 Proxy Authentication Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407',
|
['407 Proxy Authentication Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407',
|
||||||
['408 Request Timeout'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408',
|
['408 Request Timeout'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408',
|
||||||
['409 Conflict'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409',
|
['409 Conflict'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409',
|
||||||
['410 Gone'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410',
|
['410 Gone'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410',
|
||||||
['411 Length Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411',
|
['411 Length Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411',
|
||||||
['412 Precondition Failed'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412',
|
['412 Precondition Failed'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412',
|
||||||
['413 Payload Too Large'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413',
|
['413 Payload Too Large'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413',
|
||||||
['414 URI Too Long'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414',
|
['414 URI Too Long'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414',
|
||||||
['415 Unsupported Media Type'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415',
|
['415 Unsupported Media Type'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415',
|
||||||
['416 Range Not Satisfiable'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416',
|
['416 Range Not Satisfiable'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416',
|
||||||
['417 Expectation Failed'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417',
|
['417 Expectation Failed'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417',
|
||||||
['422 Unprocessable Entity'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422',
|
['422 Unprocessable Entity'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422',
|
||||||
['425 Too Early'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425',
|
['425 Too Early'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425',
|
||||||
['426 Upgrade Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426',
|
['426 Upgrade Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426',
|
||||||
['428 Precondition Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428',
|
['428 Precondition Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428',
|
||||||
['429 Too Many Requests'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429',
|
['429 Too Many Requests'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429',
|
||||||
['431 Request Header Fields Too Large'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431',
|
['431 Request Header Fields Too Large'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431',
|
||||||
['451 Unavailable For Legal Reasons'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451',
|
['451 Unavailable For Legal Reasons'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451',
|
||||||
['500 Internal Server Error'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500',
|
['500 Internal Server Error'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500',
|
||||||
['501 Not Implemented'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501',
|
['501 Not Implemented'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501',
|
||||||
['502 Bad Gateway'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502',
|
['502 Bad Gateway'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502',
|
||||||
['503 Service Unavailable'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503',
|
['503 Service Unavailable'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503',
|
||||||
['504 Gateway Timeout'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504',
|
['504 Gateway Timeout'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504',
|
||||||
['505 HTTP Version Not Supported'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505',
|
['505 HTTP Version Not Supported'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505',
|
||||||
['506 Variant Also Negotiates'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506',
|
['506 Variant Also Negotiates'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506',
|
||||||
['507 Insufficient Storage'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507',
|
['507 Insufficient Storage'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507',
|
||||||
['508 Loop Detected'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508',
|
['508 Loop Detected'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508',
|
||||||
['510 Not Extended'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510',
|
['510 Not Extended'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510',
|
||||||
['511 Network Authentication Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511',
|
['511 Network Authentication Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511',
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
local codes = require 'http-codes.codes'
|
local codes = require('http-codes.codes')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pick = function(open_url)
|
pick = function(open_url)
|
||||||
require('fzf-lua').fzf_exec(vim.tbl_keys(codes), {
|
require('fzf-lua').fzf_exec(vim.tbl_keys(codes), {
|
||||||
actions = {
|
actions = {
|
||||||
default = function(selected)
|
default = function(selected)
|
||||||
local link = codes[selected[1]]
|
local link = codes[selected[1]]
|
||||||
|
|
||||||
vim.fn.jobstart(open_url:format(link))
|
vim.fn.jobstart(open_url:format(link))
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,23 @@
|
||||||
local OS_TO_OPEN_URL = {
|
local OS_TO_OPEN_URL = {
|
||||||
OSX = 'open %s',
|
OSX = 'open %s',
|
||||||
Windows = 'start %s',
|
Windows = 'start %s',
|
||||||
}
|
}
|
||||||
|
|
||||||
local function get_os()
|
local function get_os()
|
||||||
if jit then return jit.os end
|
if jit then
|
||||||
|
return jit.os
|
||||||
|
end
|
||||||
|
|
||||||
local fh, _ = assert(io.popen('uname -o 2>/dev/null', 'r'))
|
local fh, _ = assert(io.popen('uname -o 2>/dev/null', 'r'))
|
||||||
if fh then return fh:read() end
|
if fh then
|
||||||
|
return fh:read()
|
||||||
|
end
|
||||||
|
|
||||||
return fh and fh:read() or 'Windows'
|
return fh and fh:read() or 'Windows'
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get_open_url = function() return OS_TO_OPEN_URL[get_os()] or 'xdg-open %s' end,
|
get_open_url = function()
|
||||||
|
return OS_TO_OPEN_URL[get_os()] or 'xdg-open %s'
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,37 @@
|
||||||
local codes = require 'http-codes.codes'
|
local codes = require('http-codes.codes')
|
||||||
local cached_items = nil
|
local cached_items = nil
|
||||||
|
|
||||||
local function codes_to_snack_items(codes)
|
local function codes_to_snack_items(codes_map)
|
||||||
if cached_items then return cached_items end
|
if cached_items then
|
||||||
|
return cached_items
|
||||||
|
end
|
||||||
|
|
||||||
local items = {}
|
local items = {}
|
||||||
|
|
||||||
local idx = 1
|
local idx = 1
|
||||||
for status, _ in pairs(codes) do
|
for status, _ in pairs(codes_map) do
|
||||||
table.insert(items, { idx = idx, text = status })
|
table.insert(items, { idx = idx, text = status })
|
||||||
idx = idx + 1
|
idx = idx + 1
|
||||||
end
|
end
|
||||||
cached_items = items
|
cached_items = items
|
||||||
return items
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pick = function(open_url)
|
pick = function(open_url)
|
||||||
require('snacks.picker').pick(nil, {
|
require('snacks.picker').pick(nil, {
|
||||||
title = 'HTTP Codes',
|
title = 'HTTP Codes',
|
||||||
items = codes_to_snack_items(codes),
|
items = codes_to_snack_items(codes),
|
||||||
format = 'text',
|
format = 'text',
|
||||||
layout = {
|
layout = {
|
||||||
preset = 'select',
|
preset = 'select',
|
||||||
hidden = { 'preview' },
|
hidden = { 'preview' },
|
||||||
},
|
},
|
||||||
confirm = function(picker, item)
|
confirm = function(picker, item)
|
||||||
local link = codes[item.text]
|
local link = codes[item.text]
|
||||||
picker:close()
|
picker:close()
|
||||||
vim.fn.jobstart(open_url:format(link))
|
vim.fn.jobstart(open_url:format(link))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
return {
|
return {
|
||||||
setup = function() require('telescope').load_extension 'http' end,
|
setup = function()
|
||||||
|
require('telescope').load_extension('http')
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local list = require 'telescope._extensions.http.list'
|
local list = require('telescope._extensions.http.list')
|
||||||
|
|
||||||
return require('telescope').register_extension {
|
return require('telescope').register_extension({
|
||||||
exports = { list = list },
|
exports = { list = list },
|
||||||
}
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
local actions = require 'telescope.actions'
|
local actions = require('telescope.actions')
|
||||||
local finders = require 'telescope.finders'
|
local finders = require('telescope.finders')
|
||||||
local pickers = require 'telescope.pickers'
|
local pickers = require('telescope.pickers')
|
||||||
local sorters = require 'telescope.sorters'
|
local sorters = require('telescope.sorters')
|
||||||
local state = require 'telescope.actions.state'
|
local state = require('telescope.actions.state')
|
||||||
|
|
||||||
local codes = require 'http-codes.codes'
|
local codes = require('http-codes.codes')
|
||||||
|
|
||||||
return function(open_url)
|
return function(open_url)
|
||||||
pickers
|
pickers
|
||||||
.new(nil, {
|
.new(nil, {
|
||||||
prompt_title = 'HTTP Codes',
|
prompt_title = 'HTTP Codes',
|
||||||
finder = finders.new_table {
|
finder = finders.new_table({
|
||||||
results = vim.tbl_keys(codes),
|
results = vim.tbl_keys(codes),
|
||||||
},
|
}),
|
||||||
sorter = sorters.get_generic_fuzzy_sorter(),
|
sorter = sorters.get_generic_fuzzy_sorter(),
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, _)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
|
|
||||||
local selection = state.get_selected_entry()
|
local selection = state.get_selected_entry()
|
||||||
local link = codes[selection[1]]
|
local link = codes[selection[1]]
|
||||||
|
|
||||||
vim.fn.jobstart(open_url:format(link))
|
vim.fn.jobstart(open_url:format(link))
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
:find()
|
:find()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,7 @@ vim.g.loaded_http_codes = 1
|
||||||
vim.api.nvim_create_user_command('HTTPCodes', function()
|
vim.api.nvim_create_user_command('HTTPCodes', function()
|
||||||
require('http-codes').pick()
|
require('http-codes').pick()
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<Plug>(http-codes-pick)', function()
|
||||||
|
require('http-codes').pick()
|
||||||
|
end, { desc = 'Pick HTTP status code' })
|
||||||
|
|
|
||||||
47
readme.md
47
readme.md
|
|
@ -1,47 +0,0 @@
|
||||||
# http-codes.nvim
|
|
||||||
|
|
||||||
Quickly investigate HTTP status codes with the help of [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP), with telescope, fzf-lua, and snacks.nvim integrations.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Install using your package manager of choice or via [luarocks](https://luarocks.org/modules/barrettruth/http-codes.nvim):
|
|
||||||
|
|
||||||
```
|
|
||||||
luarocks install http-codes.nvim
|
|
||||||
```
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
One of:
|
|
||||||
- [fzf-lua](https://github.com/ibhagwan/fzf-lua)
|
|
||||||
- [snacks.nvim](https://github.com/folke/snacks.nvim)
|
|
||||||
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Configure via `vim.g.http_codes` before the plugin loads:
|
|
||||||
|
|
||||||
```lua
|
|
||||||
vim.g.http_codes = {
|
|
||||||
use = 'fzf-lua', -- or 'snacks' or 'telescope', auto-detected by default
|
|
||||||
open_url = 'xdg-open %s', -- OS-specific by default
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
| OS | Default open_url |
|
|
||||||
| ------- | ---------------- |
|
|
||||||
| Windows | `start %s` |
|
|
||||||
| macOS | `open %s` |
|
|
||||||
| Linux | `xdg-open %s` |
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```vim
|
|
||||||
:HTTPCodes
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
```vim
|
|
||||||
:help http-codes.nvim
|
|
||||||
```
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue