nvim: Augment FZF/FD more

This commit is contained in:
doyle 2023-01-06 12:38:44 +11:00
parent afd77e38e9
commit c4deece666
2 changed files with 47 additions and 28 deletions

View File

@ -16,6 +16,10 @@ call plug#begin(stdpath('config') . '/plugged')
Plug 'junegunn/fzf' Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
" FZF for LSP
Plug 'gfanto/fzf-lsp.nvim'
Plug 'nvim-lua/plenary.nvim'
" odin for syntax highlighting " odin for syntax highlighting
Plug 'https://github.com/Tetralux/odin.vim' Plug 'https://github.com/Tetralux/odin.vim'
Plug 'https://github.com/sainnhe/gruvbox-material' Plug 'https://github.com/sainnhe/gruvbox-material'
@ -278,12 +282,38 @@ augroup persistent_settings
au bufenter * :set formatoptions=q1j au bufenter * :set formatoptions=q1j
augroup end augroup end
" FZF
" ==============================================================================
" Empty value to disable preview window altogether
let g:fzf_preview_window = []
" Prefix all commands with Fzf for discoverability
let g:fzf_command_prefix = 'Fzf'
" - down / up / left / right
let g:fzf_layout = { 'down': '40%' }
" Add "FzfCustomRG" command which reinitializes
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang FzfCustomRG call RipgrepFzf(<q-args>, <bang>0)
" Augment the "FzfCustomFiles" command
command! -bang -nargs=? -complete=dir FzfCustomFiles
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)
" General Key Bindings " General Key Bindings
" ============================================================================== " ==============================================================================
" Telescope Bindings " Telescope Bindings
nnoremap <leader>h <cmd>FzfHistory<cr> nnoremap <leader>h <cmd>FzfHistory<cr>
nnoremap <leader>f <cmd>FzfFiles<cr> nnoremap <leader>f <cmd>FzfCustomFiles<cr>
nnoremap <leader>g <cmd>FzfRg<cr> nnoremap <leader>g <cmd>FzfCustomRG<cr>
nnoremap <leader>tt <cmd>FzfTags<cr> nnoremap <leader>tt <cmd>FzfTags<cr>
nnoremap <leader>tb <cmd>FzfBTags<cr> nnoremap <leader>tb <cmd>FzfBTags<cr>
nnoremap <leader>cc <cmd>FzfCommits<cr> nnoremap <leader>cc <cmd>FzfCommits<cr>
@ -316,17 +346,6 @@ nnoremap <leader>s :vs<CR>
nnoremap <A-j> :cn<CR> nnoremap <A-j> :cn<CR>
nnoremap <A-k> :cp<CR> nnoremap <A-k> :cp<CR>
" FZF
" ==============================================================================
" Empty value to disable preview window altogether
let g:fzf_preview_window = []
" Prefix all commands with Fzf for discoverability
let g:fzf_command_prefix = 'Fzf'
" - down / up / left / right
let g:fzf_layout = { 'down': '40%' }
" Clang Format " Clang Format
" ============================================================================== " ==============================================================================
map <C-I> :py3file ~/clang-format.py<CR> map <C-I> :py3file ~/clang-format.py<CR>

View File

@ -855,7 +855,7 @@ call win_helpers.bat :MakeFileHardLink "!bin_dir!\fzf.exe" "!fzf_exe!" || exit /
REM Terminal REM Terminal
REM Use FD for FZF to make it ultra fast REM Use FD for FZF to make it ultra fast
echo set FZF_DEFAULT_OPTS=--multi --layout=reverse>> "!tmp_terminal_script!" echo set FZF_DEFAULT_OPTS=--multi --layout=reverse>> "!tmp_terminal_script!"
echo set FZF_DEFAULT_COMMAND=fd --unrestricted>> "!tmp_terminal_script!" echo set FZF_DEFAULT_COMMAND=fd --type f --strip-cwd-prefix --hidden --follow --exclude .git --exclude .cache --exclude .vs>> "!tmp_terminal_script!"
REM jpegview REM jpegview
REM ---------------------------------------------------------------------------- REM ----------------------------------------------------------------------------