initial commit
This commit is contained in:
commit
6cf21bf121
5 changed files with 158 additions and 0 deletions
5
.stylua.toml
Normal file
5
.stylua.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
collapse_simple_statement = "Always"
|
||||||
|
quote_style = "AutoPreferSingle"
|
||||||
|
call_parentheses = "None"
|
||||||
|
indent_type = "Spaces"
|
||||||
|
column_width = 80
|
||||||
19
lua/telescope/_extensions/http.lua
Normal file
19
lua/telescope/_extensions/http.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
local ok, telescope = pcall(require, 'telescope')
|
||||||
|
|
||||||
|
if not ok then
|
||||||
|
error 'Install nvim-telescope/telescope.nvim to use barrett-ruth/telescope-http.nvim.'
|
||||||
|
end
|
||||||
|
|
||||||
|
local list = require 'telescope._extensions.http.list'
|
||||||
|
|
||||||
|
local default_opts = { open_url = 'xdg-open %s' }
|
||||||
|
local opts = {}
|
||||||
|
|
||||||
|
return telescope.register_extension {
|
||||||
|
setup = function(http_opts, _)
|
||||||
|
opts = vim.tbl_extend('force', default_opts, http_opts)
|
||||||
|
end,
|
||||||
|
exports = {
|
||||||
|
list = function(_) list(_, opts) end,
|
||||||
|
},
|
||||||
|
}
|
||||||
51
lua/telescope/_extensions/http/codes.lua
Normal file
51
lua/telescope/_extensions/http/codes.lua
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
return {
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['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',
|
||||||
|
['511 Network Authentication Required'] = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511',
|
||||||
|
}
|
||||||
30
lua/telescope/_extensions/http/list.lua
Normal file
30
lua/telescope/_extensions/http/list.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
local actions = require 'telescope.actions'
|
||||||
|
local finders = require 'telescope.finders'
|
||||||
|
local pickers = require 'telescope.pickers'
|
||||||
|
local sorters = require 'telescope.sorters'
|
||||||
|
local state = require 'telescope.actions.state'
|
||||||
|
|
||||||
|
local codes = require 'telescope._extensions.http.codes'
|
||||||
|
|
||||||
|
return function(_, http_opts)
|
||||||
|
pickers
|
||||||
|
.new(_, {
|
||||||
|
prompt_title = 'HTTP Codes',
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = vim.tbl_keys(codes),
|
||||||
|
},
|
||||||
|
sorter = sorters.get_generic_fuzzy_sorter(),
|
||||||
|
attach_mappings = function(prompt_bufnr, _)
|
||||||
|
actions.select_default:replace(function()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
|
||||||
|
local selection = state.get_selected_entry()
|
||||||
|
local link = codes[selection[1]]
|
||||||
|
|
||||||
|
vim.fn.jobstart(http_opts.open_url:format(link))
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
|
end
|
||||||
53
readme.md
Normal file
53
readme.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# telescope-http.nvim
|
||||||
|
|
||||||
|
Quickly investigate HTTP status codes with the help of
|
||||||
|
[telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
|
||||||
|
and [mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install via your favorite package manager, like [paq](https://github.com/savq/paq-nvim):
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require 'paq' {
|
||||||
|
'savq/paq-nvim',
|
||||||
|
'barrett-ruth/telescope-http.nvim'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then load the extension:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require('telescope').load_extension 'http'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require('telescope').setup {
|
||||||
|
extensions = {
|
||||||
|
http = {
|
||||||
|
-- How the mozilla url is opened. By default:
|
||||||
|
open_url = 'xdg-open %s'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Creating a mapping for the following command in vim:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:Telescope http list
|
||||||
|
```
|
||||||
|
|
||||||
|
or lua:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require('telescope').extensions.http.list()
|
||||||
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue