nvim: Switch to fzf-lua
Switch to fzf-lua now that it supports tmux style pop ups. For details, see https://github.com/ibhagwan/fzf-lua/issues/225.
This commit is contained in:
parent
9bc237314f
commit
eec59c530d
4 changed files with 271 additions and 79 deletions
270
nvim/.config/nvim/after/plugin/fzf-lua.lua
Normal file
270
nvim/.config/nvim/after/plugin/fzf-lua.lua
Normal file
|
@ -0,0 +1,270 @@
|
||||||
|
local actions = require "fzf-lua.actions"
|
||||||
|
local remap = vim.api.nvim_set_keymap
|
||||||
|
local opts = { noremap=true, unique=true, silent=true }
|
||||||
|
|
||||||
|
require'fzf-lua'.setup {
|
||||||
|
fzf_bin = "fzf-tmux",
|
||||||
|
fzf_tmux_opts = { ["-p"] = "90%,90%" },
|
||||||
|
winopts = {
|
||||||
|
height = 0.90,
|
||||||
|
width = 0.90,
|
||||||
|
row = 0.35,
|
||||||
|
col = 0.50,
|
||||||
|
border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' },
|
||||||
|
fullscreen = false,
|
||||||
|
preview = {
|
||||||
|
default = 'bat' ,
|
||||||
|
border = 'border' ,
|
||||||
|
wrap = 'wrap' ,
|
||||||
|
hidden = 'nohidden' ,
|
||||||
|
vertical = 'down:45%' ,
|
||||||
|
horizontal = 'right:60%',
|
||||||
|
layout = 'flex' ,
|
||||||
|
flip_columns = 120 ,
|
||||||
|
title = false ,
|
||||||
|
scrollbar = false ,
|
||||||
|
scrolloff = '-2' ,
|
||||||
|
scrollchars = {'█', '' } ,
|
||||||
|
delay = 100 ,
|
||||||
|
winopts = {
|
||||||
|
number = true ,
|
||||||
|
relativenumber = false ,
|
||||||
|
cursorline = true ,
|
||||||
|
cursorlineopt = 'both' ,
|
||||||
|
cursorcolumn = false ,
|
||||||
|
signcolumn = 'no' ,
|
||||||
|
list = false ,
|
||||||
|
foldenable = false ,
|
||||||
|
foldmethod = 'manual',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
keymap = {
|
||||||
|
fzf = {
|
||||||
|
["Ctrl-d"] = "half-page-down" ,
|
||||||
|
["Ctrl-u"] = "half-page-up" ,
|
||||||
|
["Ctrl-a"] = "beginning-of-line",
|
||||||
|
["Ctrl-e"] = "end-of-line" ,
|
||||||
|
["Ctrl-n"] = "preview-down" ,
|
||||||
|
["Ctrl-p"] = "preview-up" ,
|
||||||
|
["Ctrl-f"] = "preview-page-down",
|
||||||
|
["Ctrl-b"] = "preview-page-up" ,
|
||||||
|
["Ctrl-z"] = "abort" ,
|
||||||
|
["Ctrl-t"] = "toggle-all" ,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions = {
|
||||||
|
files = {
|
||||||
|
["default"] = actions.file_edit_or_qf,
|
||||||
|
["Ctrl-s"] = actions.file_split ,
|
||||||
|
["Ctrl-v"] = actions.file_vsplit ,
|
||||||
|
["Ctrl-t"] = actions.file_tabedit ,
|
||||||
|
["Ctrl-q"] = actions.file_sel_to_qf ,
|
||||||
|
},
|
||||||
|
buffers = {
|
||||||
|
["default"] = actions.buf_edit ,
|
||||||
|
["Ctrl-s"] = actions.buf_split ,
|
||||||
|
["Ctrl-v"] = actions.buf_vsplit ,
|
||||||
|
["Ctrl-t"] = actions.buf_tabedit,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fzf_opts = {
|
||||||
|
['--ansi'] = '' ,
|
||||||
|
['--prompt'] = '> ' ,
|
||||||
|
['--info'] = 'inline' ,
|
||||||
|
['--height'] = '100%' ,
|
||||||
|
['--layout'] = 'reverse',
|
||||||
|
["--border"] = "rounded",
|
||||||
|
["--no-separator"] = "" ,
|
||||||
|
},
|
||||||
|
previewers = {
|
||||||
|
bat = {
|
||||||
|
theme = 'Monokai Extended Bright',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
files = {
|
||||||
|
multiprocess = true ,
|
||||||
|
git_icons = false,
|
||||||
|
file_icons = false,
|
||||||
|
color_icons = false,
|
||||||
|
},
|
||||||
|
git = {
|
||||||
|
files = {
|
||||||
|
prompt = 'GitFiles❯ ',
|
||||||
|
cmd = 'git ls-files --exclude-standard',
|
||||||
|
multiprocess = true ,
|
||||||
|
git_icons = false,
|
||||||
|
file_icons = false,
|
||||||
|
color_icons = false,
|
||||||
|
},
|
||||||
|
status = {
|
||||||
|
prompt = 'GitStatus❯ ',
|
||||||
|
cmd = "git status -s",
|
||||||
|
previewer = "git_diff",
|
||||||
|
file_icons = false,
|
||||||
|
git_icons = false,
|
||||||
|
color_icons = false,
|
||||||
|
actions = {
|
||||||
|
["right"] = { actions.git_unstage, actions.resume },
|
||||||
|
["left"] = { actions.git_stage, actions.resume },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
commits = {
|
||||||
|
prompt = 'Commits❯ ',
|
||||||
|
cmd = "git log --decorate --pretty=oneline --abbrev-commit --color",
|
||||||
|
preview = "git show --color=always {1}",
|
||||||
|
actions = {
|
||||||
|
["default"] = actions.git_buf_split ,
|
||||||
|
["Ctrl-s"] = actions.git_buf_split ,
|
||||||
|
["Ctrl-v"] = actions.git_buf_vsplit ,
|
||||||
|
["Ctrl-t"] = actions.git_buf_tabedit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bcommits = {
|
||||||
|
prompt = 'BCommits❯ ',
|
||||||
|
cmd = "git log --decorate --pretty=oneline --abbrev-commit --color",
|
||||||
|
preview = "git show --color=always {1}",
|
||||||
|
actions = {
|
||||||
|
["default"] = actions.git_buf_split ,
|
||||||
|
["Ctrl-s"] = actions.git_buf_split ,
|
||||||
|
["Ctrl-v"] = actions.git_buf_vsplit ,
|
||||||
|
["Ctrl-t"] = actions.git_buf_tabedit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
branches = {
|
||||||
|
prompt = 'Branches❯ ',
|
||||||
|
cmd = "git branch --all --color",
|
||||||
|
preview = "git log --decorate --graph --pretty=oneline --abbrev-commit --color {1}",
|
||||||
|
actions = {
|
||||||
|
["default"] = actions.git_switch,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
stash = {
|
||||||
|
prompt = 'Stash> ',
|
||||||
|
cmd = "git --no-pager stash list",
|
||||||
|
preview = "git --no-pager stash show --patch --color {1}",
|
||||||
|
actions = {
|
||||||
|
["default"] = actions.git_stash_apply,
|
||||||
|
["ctrl-x"] = { actions.git_stash_drop, actions.resume },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grep = {
|
||||||
|
prompt = 'Rg❯ ' ,
|
||||||
|
input_prompt = 'Grep For❯ ',
|
||||||
|
multiprocess = true ,
|
||||||
|
git_icons = false ,
|
||||||
|
file_icons = false ,
|
||||||
|
color_icons = false ,
|
||||||
|
},
|
||||||
|
args = {
|
||||||
|
prompt = 'Args❯ ',
|
||||||
|
files_only = true ,
|
||||||
|
actions = { ["Ctrl-x"] = actions.arg_del }
|
||||||
|
},
|
||||||
|
oldfiles = {
|
||||||
|
prompt = 'History❯ ',
|
||||||
|
cwd_only = false ,
|
||||||
|
},
|
||||||
|
buffers = {
|
||||||
|
prompt = 'Buffers❯ ',
|
||||||
|
file_icons = false ,
|
||||||
|
color_icons = false ,
|
||||||
|
sort_lastused = true ,
|
||||||
|
actions = {
|
||||||
|
["Ctrl-x"] = { actions.buf_del, actions.resume },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tabs = {
|
||||||
|
prompt = 'Tabs❯ ',
|
||||||
|
tab_title = "Tab" ,
|
||||||
|
tab_marker = "<<" ,
|
||||||
|
file_icons = false ,
|
||||||
|
color_icons = false ,
|
||||||
|
actions = {
|
||||||
|
["default"] = actions.buf_switch,
|
||||||
|
["Ctrl-x"] = { actions.buf_del, actions.resume },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lines = {
|
||||||
|
previewer = "builtin",
|
||||||
|
prompt = 'Lines❯ ',
|
||||||
|
show_unlisted = false ,
|
||||||
|
no_term_buffers = true ,
|
||||||
|
},
|
||||||
|
blines = {
|
||||||
|
previewer = "builtin" ,
|
||||||
|
prompt = 'BLines❯ ',
|
||||||
|
show_unlisted = false ,
|
||||||
|
no_term_buffers = true ,
|
||||||
|
},
|
||||||
|
quickfix = {
|
||||||
|
file_icons = false,
|
||||||
|
git_icons = false,
|
||||||
|
},
|
||||||
|
lsp = {
|
||||||
|
prompt_postfix = 'Lsp❯ ',
|
||||||
|
cwd_only = false ,
|
||||||
|
async_or_timeout = 5000 ,
|
||||||
|
file_icons = false ,
|
||||||
|
git_icons = false ,
|
||||||
|
},
|
||||||
|
diagnostics ={
|
||||||
|
prompt = 'Diagnostics❯ ',
|
||||||
|
cwd_only = false ,
|
||||||
|
file_icons = false ,
|
||||||
|
git_icons = false ,
|
||||||
|
diag_icons = false ,
|
||||||
|
icon_padding = '' ,
|
||||||
|
},
|
||||||
|
manpages = { previewer = { _ctor = false } },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Buffers and Files
|
||||||
|
remap('n', '<Leader>b' , ':FzfLua buffers<CR>' , opts)
|
||||||
|
remap('n', '<Leader>B' , ':FzfLua oldfiles<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fF', ':FzfLua files<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fl', ':FzfLua blines<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fL', ':FzfLua lines<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fq', ':cclose<CR>:FzfLua quickfix<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fQ', ':lclose<CR>:FzfLua loclist<CR>' , opts)
|
||||||
|
|
||||||
|
-- Git
|
||||||
|
remap('n', '<Leader>ff', ':FzfLua git_files<CR>' , opts)
|
||||||
|
remap('n', '<Leader>/' , ':FzfLua git_status<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fb', ':FzfLua git_branches<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fc', ':FzfLua git_bcommits<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fC', ':FzfLua git_commits<CR>' , opts)
|
||||||
|
remap('n', '<Leader>ft', ':FzfLua git_stash<CR>' , opts)
|
||||||
|
|
||||||
|
-- Grep
|
||||||
|
remap('n', '<Leader>fg' , ':FzfLua grep<CR>' , opts)
|
||||||
|
remap('n', '<Leader>f/' , ':FzfLua live_grep<CR>' , opts)
|
||||||
|
remap('n', '<Leader>f\\', ':FzfLua live_grep_resume<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fs' , ':FzfLua grep_cword<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fS' , ':FzfLua grep_cWORD<CR>' , opts)
|
||||||
|
remap('x', '<Leader>fs' , ':<C-u>FzfLua grep_visual<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fr' , ':FzfLua grep_last<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fR' , ':FzfLua live_grep_glob<CR>' , opts)
|
||||||
|
|
||||||
|
-- Misc
|
||||||
|
remap('n', '<Leader>fh', ':FzfLua command_history<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fH', ':FzfLua search_history<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fm', ':FzfLua marks<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fM', ':FzfLua man_pages<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fo', ':FzfLua changes<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fO', ':FzfLua jumps<CR>' , opts)
|
||||||
|
remap('n', '<Leader>fk', ':FzfLua keymaps<CR>' , opts)
|
||||||
|
|
||||||
|
-- LSP
|
||||||
|
remap('n', '<Leader>lr', ':FzfLua lsp_references<CR>' , opts)
|
||||||
|
remap('n', '<Leader>ld', ':FzfLua lsp_definitions<CR>' , opts)
|
||||||
|
remap('n', '<Leader>lD', ':FzfLua lsp_declarations<CR>' , opts)
|
||||||
|
remap('n', '<Leader>lt', ':FzfLua lsp_typedefs<CR>' , opts)
|
||||||
|
remap('n', '<Leader>li', ':FzfLua lsp_implementations<CR>' , opts)
|
||||||
|
remap('n', '<Leader>ls', ':FzfLua lsp_document_symbols<CR>' , opts)
|
||||||
|
remap('n', '<Leader>lw', ':FzfLua lsp_workspace_symbols<CR>' , opts)
|
||||||
|
remap('n', '<Leader>lW', ':FzfLua lsp_live_workspace_symbols<CR>', opts)
|
||||||
|
remap('n', '<Leader>la', ':FzfLua lsp_code_actions<CR>' , opts)
|
||||||
|
remap('n', '<Leader>le', ':FzfLua lsp_document_diagnostics<CR>' , opts)
|
||||||
|
remap('n', '<Leader>lE', ':FzfLua lsp_workspace_diagnostics<CR>' , opts)
|
|
@ -1,12 +0,0 @@
|
||||||
local remap = vim.keymap.set
|
|
||||||
|
|
||||||
remap('n', '<Leader>fg', ':FZFGGrep<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>fG', ':FZFGrep<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>fl', ':FZFBLines<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>f\\', ':FZFRg<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>fT', ':FZFTags<SPACE>', { noremap = true })
|
|
||||||
remap('n', '<Leader>fq', ':cclose<CR>:FZFQuickFix<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>fQ', ':lclose<CR>:FZFLocList<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>fS', ':<C-u>FZFRg <C-r><C-w><CR>', { noremap = true })
|
|
||||||
remap('x', '<Leader>fS', '"zy<Esc>:FZFRg <C-R>z<CR>', { noremap = true })
|
|
||||||
remap('n', '<Leader>ft', ':<C-u>FZFTags <C-r><C-w><CR>', { noremap = true })
|
|
|
@ -1,64 +0,0 @@
|
||||||
" See https://github.com/junegunn/fzf/blob/master/README-VIM.md
|
|
||||||
" An action can be a reference to a function that processes selected lines
|
|
||||||
function! s:build_quickfix_list(lines)
|
|
||||||
call setqflist([], ' ', { 'title': 'FZF Selected', 'items': map(copy(a:lines), '{ "filename": v:val }') })
|
|
||||||
copen
|
|
||||||
cc
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" https://github.com/junegunn/fzf.vim/pull/733
|
|
||||||
function! s:list_buffers()
|
|
||||||
redir => list
|
|
||||||
silent ls
|
|
||||||
redir END
|
|
||||||
return split(list, "\n")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:delete_buffers(lines)
|
|
||||||
execute 'bwipeout' join(map(a:lines, {_, line -> split(line)[0]}))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! BD call fzf#run(fzf#wrap({
|
|
||||||
\ 'source': s:list_buffers(),
|
|
||||||
\ 'sink*': { lines -> s:delete_buffers(lines) },
|
|
||||||
\ 'options': '--multi --reverse --bind ctrl-a:select-all+accept'
|
|
||||||
\ }))
|
|
||||||
|
|
||||||
let g:fzf_action = {
|
|
||||||
\ 'ctrl-q': function('s:build_quickfix_list'),
|
|
||||||
\ 'ctrl-t': 'tab split',
|
|
||||||
\ 'ctrl-x': 'split',
|
|
||||||
\ 'ctrl-v': 'vsplit',
|
|
||||||
\ }
|
|
||||||
|
|
||||||
let $FZF_DEFAULT_OPTS = '--layout=reverse --bind "Ctrl-d:half-page-down,Ctrl-u:half-page-up,Ctrl-n:preview-down,Ctrl-p:preview-up,Ctrl-f:preview-page-down,Ctrl-b:preview-page-up,ctrl-a:select-all+accept"'
|
|
||||||
|
|
||||||
if exists('$TMUX')
|
|
||||||
let g:fzf_layout = { 'tmux': '-p90%,90%' }
|
|
||||||
else
|
|
||||||
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.9 }, }
|
|
||||||
endif
|
|
||||||
|
|
||||||
nnoremap <Leader>b :Buffers<CR>
|
|
||||||
nnoremap <Leader>B :History<CR>
|
|
||||||
nnoremap <Leader>/ :GFiles?<CR>
|
|
||||||
nnoremap <Leader>ff :GFiles<CR>
|
|
||||||
nnoremap <Leader>fF :Files<CR>
|
|
||||||
nnoremap <Leader>fL :Lines<CR>
|
|
||||||
nnoremap <Leader>fc :BCommits<CR>
|
|
||||||
xnoremap <Leader>fc :BCommits<CR>
|
|
||||||
nnoremap <Leader>fC :Commits<CR>
|
|
||||||
nnoremap <Leader>fh :History:<CR>
|
|
||||||
nnoremap <Leader>fH :History/<CR>
|
|
||||||
nnoremap <Leader>fm :Marks<CR>
|
|
||||||
nnoremap <Leader>fo :Locate<CR>
|
|
||||||
nnoremap <Leader>fk :Maps<CR>
|
|
||||||
nnoremap <Leader>f/ :Rg<CR>
|
|
||||||
nnoremap <Leader>fs :<C-u>Rg <C-r><C-w><CR>
|
|
||||||
xnoremap <Leader>fs "zy<Esc>:Rg <C-R>z<CR>
|
|
||||||
nnoremap <Leader>fw :BD<CR>
|
|
||||||
|
|
||||||
imap <C-x><C-w> <Plug>(fzf-complete-word)
|
|
||||||
imap <C-x><C-p> <Plug>(fzf-complete-path)
|
|
||||||
imap <C-x><C-f> <Plug>(fzf-complete-file)
|
|
||||||
imap <C-x><C-l> <Plug>(fzf-complete-line)
|
|
|
@ -3,8 +3,7 @@ vim.cmd 'packadd cfilter'
|
||||||
|
|
||||||
require "paq" {
|
require "paq" {
|
||||||
'phaazon/hop.nvim' ,
|
'phaazon/hop.nvim' ,
|
||||||
'junegunn/fzf' ,
|
'ibhagwan/fzf-lua' ,
|
||||||
'junegunn/fzf.vim' ,
|
|
||||||
'rmagatti/auto-session' ,
|
'rmagatti/auto-session' ,
|
||||||
'dcampos/nvim-snippy' ,
|
'dcampos/nvim-snippy' ,
|
||||||
'honza/vim-snippets' ,
|
'honza/vim-snippets' ,
|
||||||
|
@ -12,7 +11,6 @@ require "paq" {
|
||||||
'tpope/vim-fugitive' ,
|
'tpope/vim-fugitive' ,
|
||||||
'SanchayanMaity/gitlinker.nvim' ,
|
'SanchayanMaity/gitlinker.nvim' ,
|
||||||
'vim-utils/vim-husk' ,
|
'vim-utils/vim-husk' ,
|
||||||
'chengzeyi/fzf-preview.vim' ,
|
|
||||||
'https://gitlab.com/yorickpeterse/nvim-pqf',
|
'https://gitlab.com/yorickpeterse/nvim-pqf',
|
||||||
'wellle/targets.vim' ,
|
'wellle/targets.vim' ,
|
||||||
'tpope/vim-surround' ,
|
'tpope/vim-surround' ,
|
||||||
|
|
Loading…
Reference in a new issue