Skip to content

Commit

Permalink
feat(nvim): going back to fzf
Browse files Browse the repository at this point in the history
  • Loading branch information
spywhere committed Dec 4, 2023
1 parent fa8adb8 commit a337075
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 26 deletions.
50 changes: 50 additions & 0 deletions configs/nvim/lua/plugin/navigation/fzf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local registry = require('lib.registry')
local bindings = require('lib.bindings')

registry.install {
'ibhagwan/fzf-lua',
skip = registry.experiment('telescope').on,
requires = {
'nvim-tree/nvim-web-devicons'
},
config = function ()
require('fzf-lua').setup {
winopts = {
height = 0.9,
width = 0.9
},
fzf_opts = {
['--layout'] = 'default'
},
grep = {
no_header = true,
rg_glob = true
},
keymap = {
builtin = {
['<C-_>'] = 'toggle-preview',
},
fzf = {
['ctrl-u'] = 'half-page-up',
['ctrl-d'] = 'half-page-down',
}
}
}

local fuzzy = function (action, options)
return function ()
if type(options) == 'function' then
options = options()
end
require('fzf-lua')[action](options)
end
end

bindings.map.normal('<C-p>', fuzzy('files'))
bindings.map.normal('<leader>/', fuzzy('blines', {
prompt_prefix='BLines> '
}))
-- fuzzy search buffer content (.buffers is fuzzy search buffer selection)
bindings.map.normal('<leader>f', fuzzy('live_grep'))
end
}
52 changes: 26 additions & 26 deletions configs/nvim/lua/plugin/navigation/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local filter = require('plugin.explorer._filter')

registry.install {
'nvim-telescope/telescope.nvim',
skip = registry.experiment('telescope').off,
tag = '0.1.2',
requires = {
{
Expand All @@ -14,32 +15,6 @@ registry.install {
build = 'make'
}
},
defer = function ()
local telescope = function (action, options)
return function ()
if type(options) == 'function' then
options = options()
end
require('telescope.builtin')[action](options)
end
end

bindings.map.normal('<C-p>', telescope('find_files', {
prompt_prefix='Find> ',
hidden = true
}))
bindings.map.normal('<leader>/', telescope('current_buffer_fuzzy_find', {
prompt_prefix='BLines> '
}))
-- fuzzy search buffer content (.buffers is fuzzy search buffer selection)
bindings.map.normal('<leader>f', function ()
require('telescope.builtin').live_grep {
prompt_prefix='Rg> ',
glob_pattern=filter.get()
}
end)
-- TODO: ripgrep the whole project with rg itself
end,
config = function ()
local actions = require('telescope.actions')
local layout_actions = require('telescope.actions.layout')
Expand Down Expand Up @@ -78,5 +53,30 @@ registry.install {
}

require('telescope').load_extension('fzf')

local telescope = function (action, options)
return function ()
if type(options) == 'function' then
options = options()
end
require('telescope.builtin')[action](options)
end
end

bindings.map.normal('<C-p>', telescope('find_files', {
prompt_prefix='Find> ',
hidden = true
}))
bindings.map.normal('<leader>/', telescope('current_buffer_fuzzy_find', {
prompt_prefix='BLines> '
}))
-- fuzzy search buffer content (.buffers is fuzzy search buffer selection)
bindings.map.normal('<leader>f', function ()
require('telescope.builtin').live_grep {
prompt_prefix='Rg> ',
glob_pattern=filter.get()
}
end)
-- TODO: ripgrep the whole project with rg itself
end
}

0 comments on commit a337075

Please sign in to comment.