feat: default to available picker
This commit is contained in:
parent
13256a3acf
commit
46ebe4ded7
4 changed files with 23 additions and 16 deletions
|
|
@ -24,8 +24,8 @@ Parameters: ~
|
||||||
Usage: ~
|
Usage: ~
|
||||||
>lua
|
>lua
|
||||||
require('http-codes').setup({
|
require('http-codes').setup({
|
||||||
-- *REQUIRED*: 'fzf' or 'telescope'
|
-- defaults to available picker: 'fzf-lua' or 'telescope'
|
||||||
use = 'fzf',
|
use = 'fzf-lua'
|
||||||
-- How the mozilla url is opened.
|
-- How the mozilla url is opened.
|
||||||
-- Configured by default based on OS:
|
-- Configured by default based on OS:
|
||||||
open_url = 'xdg-open %s' -- UNIX
|
open_url = 'xdg-open %s' -- UNIX
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,28 @@ M.config = {
|
||||||
M.http_codes = function()
|
M.http_codes = function()
|
||||||
if M.config.use == 'telescope' then
|
if M.config.use == 'telescope' then
|
||||||
require('telescope').extensions.http.list(M.config.open_url)
|
require('telescope').extensions.http.list(M.config.open_url)
|
||||||
elseif M.config.use == 'fzf' then
|
elseif M.config.use == 'fzf-lua' then
|
||||||
require('http-codes.fzf').pick(M.config.open_url)
|
require('http-codes.fzf-lua').pick(M.config.open_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function(user_config)
|
M.setup = function(user_config)
|
||||||
if
|
if pcall(require, 'fzf-lua') then
|
||||||
user_config.use == nil
|
M.config.use = 'fzf-lua'
|
||||||
or not vim.tbl_contains({ 'fzf', 'telescope' }, user_config.use)
|
elseif pcall(require, 'telescope') then
|
||||||
then
|
M.config.use = 'telescope'
|
||||||
|
end
|
||||||
|
|
||||||
|
if M.config.use == nil then
|
||||||
|
vim.notify_once 'http-codes.nvim: install fzf-lua or telescope.nvim'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if user_config.use then M.config.use = user_config.use end
|
||||||
|
|
||||||
|
if not vim.tbl_contains({ 'fzf-lua', 'telescope' }, M.config.use) then
|
||||||
vim.notify_once(
|
vim.notify_once(
|
||||||
'http-codes.nvim: must specify `use = {fzf,telescope}` in setup.',
|
'http-codes.nvim: must specify `use = {fzf-lua,telescope}` in setup.',
|
||||||
vim.log.levels.ERROR
|
vim.log.levels.ERROR
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
11
readme.md
11
readme.md
|
|
@ -11,19 +11,16 @@ require('lazy').setup({
|
||||||
{
|
{
|
||||||
'barrett-ruth/http-codes.nvim'
|
'barrett-ruth/http-codes.nvim'
|
||||||
opts = {
|
opts = {
|
||||||
-- *REQUIRED*: 'fzf' or 'telescope'
|
-- defaults to available picker: 'fzf-lua' or 'telescope'
|
||||||
use = 'fzf',
|
use = 'fzf-lua'
|
||||||
-- How the mozilla url is opened.
|
-- How the mozilla url is opened.
|
||||||
-- Configured by default based on OS:
|
-- Configured by default based on OS:
|
||||||
open_url = 'xdg-open %s' -- UNIX
|
open_url = 'xdg-open %s' -- UNIX
|
||||||
-- = 'open %s' -- OSX
|
-- = 'open %s' -- OSX
|
||||||
-- = 'start %s' -- Windows
|
-- = 'start %s' -- Windows
|
||||||
},
|
},
|
||||||
dependencies = {
|
-- or 'nvim-telescope/telescope.nvim'
|
||||||
-- choose your picker:
|
dependencies = 'ibhagwan/fzf-lua'
|
||||||
'ibhagwan/fzf-lua'
|
|
||||||
-- 'nvim-telescope/telescope.nvim',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue