fix: pre-commit

This commit is contained in:
Barrett Ruth 2026-02-03 21:18:30 -05:00
parent 01248ffcff
commit 017c1873b7
11 changed files with 146 additions and 128 deletions

View file

@ -32,7 +32,10 @@ local function init()
end
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
end
@ -70,7 +73,13 @@ M.http_codes = M.pick
---@deprecated Use `vim.g.http_codes` instead
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
vim.g.http_codes = vim.tbl_deep_extend('force', vim.g.http_codes or {}, user_config)

View file

@ -1,51 +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',
['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',
}

View file

@ -1,15 +1,15 @@
local codes = require 'http-codes.codes'
local codes = require('http-codes.codes')
return {
pick = function(open_url)
require('fzf-lua').fzf_exec(vim.tbl_keys(codes), {
actions = {
default = function(selected)
local link = codes[selected[1]]
pick = function(open_url)
require('fzf-lua').fzf_exec(vim.tbl_keys(codes), {
actions = {
default = function(selected)
local link = codes[selected[1]]
vim.fn.jobstart(open_url:format(link))
end,
},
})
end,
vim.fn.jobstart(open_url:format(link))
end,
},
})
end,
}

View file

@ -1,17 +1,23 @@
local OS_TO_OPEN_URL = {
OSX = 'open %s',
Windows = 'start %s',
OSX = 'open %s',
Windows = 'start %s',
}
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'))
if fh then return fh:read() end
local fh, _ = assert(io.popen('uname -o 2>/dev/null', 'r'))
if fh then
return fh:read()
end
return fh and fh:read() or 'Windows'
return fh and fh:read() or 'Windows'
end
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,
}

View file

@ -1,35 +1,37 @@
local codes = require 'http-codes.codes'
local codes = require('http-codes.codes')
local cached_items = nil
local function codes_to_snack_items(codes)
if cached_items then return cached_items end
if cached_items then
return cached_items
end
local items = {}
local items = {}
local idx = 1
for status, _ in pairs(codes) do
table.insert(items, { idx = idx, text = status })
idx = idx + 1
end
cached_items = items
return items
local idx = 1
for status, _ in pairs(codes) do
table.insert(items, { idx = idx, text = status })
idx = idx + 1
end
cached_items = items
return items
end
return {
pick = function(open_url)
require('snacks.picker').pick(nil, {
title = 'HTTP Codes',
items = codes_to_snack_items(codes),
format = 'text',
layout = {
preset = 'select',
hidden = { 'preview' },
},
confirm = function(picker, item)
local link = codes[item.text]
picker:close()
vim.fn.jobstart(open_url:format(link))
end,
})
end,
pick = function(open_url)
require('snacks.picker').pick(nil, {
title = 'HTTP Codes',
items = codes_to_snack_items(codes),
format = 'text',
layout = {
preset = 'select',
hidden = { 'preview' },
},
confirm = function(picker, item)
local link = codes[item.text]
picker:close()
vim.fn.jobstart(open_url:format(link))
end,
})
end,
}

View file

@ -1,3 +1,5 @@
return {
setup = function() require('telescope').load_extension 'http' end,
setup = function()
require('telescope').load_extension('http')
end,
}

View file

@ -1,5 +1,5 @@
local list = require 'telescope._extensions.http.list'
local list = require('telescope._extensions.http.list')
return require('telescope').register_extension {
exports = { list = list },
}
return require('telescope').register_extension({
exports = { list = list },
})

View file

@ -1,30 +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 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 'http-codes.codes'
local codes = require('http-codes.codes')
return function(open_url)
pickers
.new(nil, {
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)
pickers
.new(nil, {
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]]
local selection = state.get_selected_entry()
local link = codes[selection[1]]
vim.fn.jobstart(open_url:format(link))
end)
return true
end,
})
:find()
vim.fn.jobstart(open_url:format(link))
end)
return true
end,
})
:find()
end