Replace vim-picker with telescope

This commit is contained in:
Knyffen 2023-11-12 17:46:05 +01:00
parent e7c411ec77
commit 891a610718

View File

@ -92,11 +92,14 @@
" Fuzzy finding
" Plug 'jhawthorn/fzy' " Install this systemwide (or configure a manual
" location. See below)
Plug 'srstevenson/vim-picker'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'jesseleite/vim-agriculture'
" vim-telescope (and dependencies)
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'branch': '0.1.x' }
" line indentation guides
Plug 'Yggdroot/indentLine'
@ -487,46 +490,28 @@ if !(has('win32') || has('win64'))
" nnoremap ¬ :PickerEdit ~/jobxx/<cr>
endif
function! CallPickerEdit()
function! FuzzyFileFinder()
let l:IsInGitRepo = system('git rev-parse --is-inside-work-tree')
if l:IsInGitRepo =~ 'true'
let l:GitRepoDir = system('git rev-parse --show-toplevel')
execute 'PickerEdit ' . l:GitRepoDir
execute 'Telescope find_files cwd=' . l:GitRepoDir->fnameescape()
else
execute 'PickerEdit ' . glob('~/')
" TODO: Verify if this works
" if $USER =~ '^knyff$'
" " TODO: Make PickerEdit work on windows
" execute 'PickerEdit C:\User\' . $USER
" PickerEdit C:\User\knyff\
" else
" PickerEdit ~/
" endif
execute 'Telescope find_files cwd=' . glob('~/')->fnameescape()
endif
endfunction
function! CallPickerPDF()
let l:IsInGitRepo = system('git rev-parse --is-inside-work-tree')
if l:IsInGitRepo =~ 'true'
" TODO: Make this work
" let l:CurrBufNr = bufnr('%')
let l:GitRepoDir = system('git rev-parse --show-toplevel')
call picker#File('git ls-files --cached --exclude-standard --others', 'te zathura', l:GitRepoDir)
" execute 'b '.l:CurrBufNr
else
" let l:OldBufNr = bufnr('%')
" echo bufnr('%')
execute 'tabedit'
call picker#File('find ' . glob('~/') . ' -type f', 'te zathura')
" let l:CurrBufNr = bufnr('%')
" echo bufnr('%')
" execute 'tabclose'
" execute 'b '.l:CurrBufNr
endif
nnoremap ¬ :call FuzzyFileFinder()<cr>
function! OpenPDFInsteadOfBuffer()
echo expand('%')->fnameescape()
call system('zathura ' . expand('%')->fnameescape() . ' &')
bd
endfunction
nnoremap ¬ :call CallPickerEdit()<cr>
nnoremap ¿ :call CallPickerPDF()<cr>
augroup OpenExternalFiles
au!
au FileType pdf call OpenPDFInsteadOfBuffer()
augroup END
endif
" NeoMake {{{