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

@ -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

View file

@ -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

View file

@ -13,6 +13,7 @@ luarocks install http-codes.nvim
## Dependencies ## Dependencies
One of: One of:
- [fzf-lua](https://github.com/ibhagwan/fzf-lua) - [fzf-lua](https://github.com/ibhagwan/fzf-lua)
- [snacks.nvim](https://github.com/folke/snacks.nvim) - [snacks.nvim](https://github.com/folke/snacks.nvim)
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) - [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)

View file

@ -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)

View file

@ -1,4 +1,4 @@
local codes = require 'http-codes.codes' local codes = require('http-codes.codes')
return { return {
pick = function(open_url) pick = function(open_url)

View file

@ -4,14 +4,20 @@ local OS_TO_OPEN_URL = {
} }
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,
} }

View file

@ -1,8 +1,10 @@
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)
if cached_items then return cached_items end if cached_items then
return cached_items
end
local items = {} local items = {}

View file

@ -1,3 +1,5 @@
return { 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 { return require('telescope').register_extension({
exports = { list = list }, exports = { list = list },
} })

View file

@ -1,18 +1,18 @@
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()