map to new fzf function

This commit is contained in:
Jeremy Gardais 2023-08-04 08:26:19 +02:00
parent 8a6d0ab4b8
commit 60ab6ecb2e
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 49 additions and 1 deletions

50
vimrc
View File

@ -119,16 +119,61 @@ nmap <leader>x :w<cr>:!./"%"<cr>
" Édition rapide de vimrc avec <leader>+e
map <leader>e :e! ~/.vim/vimrc<cr>
""" Splits
""" Splits {{{
" Open new split on the bottom part
set splitbelow
" Open new split on the right part
set splitright
" FZF function to list all files on the system {{{
function! FzfFiles()
let tmp = tempname()
"execute '!ls | fzf >'.tmp
" Run fzf with update DEFAULT_COMMAND
" Change the prompt and preview with batcat
" Store filename in tmp
execute '!FZF_DEFAULT_COMMAND="fd -uu --type f --search-path /" fzf
\ --prompt="vi> " --preview "bat --color=always --line-range 0:50 {}"
\ >'.tmp
let g:fzffilename = readfile(tmp)[0]
silent execute '!rm '.tmp
"execute 'split '.fname
endfunction
"nnoremap <Leader><Space> :Sopen
nnoremap <Leader><Space> :silent call FzfFiles()<CR> :execute 'split '.fzffilename<CR>
" }}}
" With fzf#run plugin WAY TO SLOW {{{
"
"nnoremap <silent> <Leader><Space> :call fzf#run({
"\ 'down': '40%',
"\ 'sink': 'split' })<CR>
"nnoremap <silent> <Leader><Enter> :call fzf#run({
"\ 'down': '40%',
"\ 'sink': 'vsplit' })<CR>
"command! Sudosave :execute ':silent w !sudo tee % > /dev/null' | :edit!
"command! Sopen :execute ':!fd -uu --search-path / --type file | fzf
"\ --prompt="vi> " --preview "bat --color=always --line-range 0:50 {}"
"\ --no-multi' | :split
"command! Sopen :execute ':!FZF_DEFAULT_COMMAND="fd -uu --type f --search-path /"
"\ fzf --prompt="vi> " --preview "bat --color=always --line-range 0:50 {}"
"\ --no-multi' | split
"nnoremap <Leader><Space> :Sopen
"nnoremap <silent> <Leader><Space> :call fzf#run({
"\ 'down': '25%',
"\ 'sink': 'vertical botright split' })<CR>
" }}}
""" Buffers
" Gestion des splits
map <C-w><Space> :split<Space>
map <C-w><Return> :vsplit<Space>
"map <leader><Space> :split<Space>
" Navigation
" Détails sur les buffers: http://vim-fr.org/index.php/Buffer
"map <leader>p :bp<cr>
@ -608,6 +653,9 @@ call plug#begin('~/.vim/plugged')
Plug 'dracula/vim'
Plug 'tomasiser/vim-code-dark'
" fzf integration
Plug 'junegunn/fzf'
" Display a tree of directories
Plug 'scrooloose/nerdtree'