Move away from unreliable fzf for leaderf

This commit is contained in:
Doyle 2020-10-20 23:57:45 +11:00
parent 95f96f2503
commit 6c2b395e76
5 changed files with 140 additions and 133 deletions

View File

@ -1,9 +1,7 @@
" // Startup /////////////////////////////////////////////////////////////////// " ==============================================================================
" Windows/Linux differences " Plugins
" ==============================================================================
let s:running_windows = has("win16") || has("win32") || has("win64") let s:running_windows = has("win16") || has("win32") || has("win64")
set nocompatible
if s:running_windows if s:running_windows
let g:myvimdir ="~/vimfiles" let g:myvimdir ="~/vimfiles"
silent! call plug#begin('~/vimfiles/plugged') silent! call plug#begin('~/vimfiles/plugged')
@ -12,15 +10,12 @@ else
silent! call plug#begin('~/.vim/plugged') silent! call plug#begin('~/.vim/plugged')
endif endif
" {on} Means to lazy-load when that command is invoked
Plug 'https://github.com/ervandew/supertab' Plug 'https://github.com/ervandew/supertab'
Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'https://github.com/tpope/vim-fugitive' Plug 'https://github.com/tpope/vim-fugitive'
Plug 'https://github.com/bfrg/vim-cpp-modern' Plug 'https://github.com/bfrg/vim-cpp-modern'
Plug 'https://github.com/skywind3000/asyncrun.vim'
Plug 'skywind3000/asyncrun.vim' Plug 'https://github.com/Yggdroot/LeaderF'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Themes " Themes
Plug 'https://github.com/tomasr/molokai' Plug 'https://github.com/tomasr/molokai'
@ -29,7 +24,10 @@ Plug 'https://github.com/morhetz/gruvbox'
call plug#end() call plug#end()
" // General Settings ////////////////////////////////////////////////////////// " ==============================================================================
" Settings
" ==============================================================================
set nocompatible
set autowrite " Automatically save before commands like :next and :make set autowrite " Automatically save before commands like :next and :make
set autoread " Auto reload changed files set autoread " Auto reload changed files
set backspace=2 " Backspace like most programs in insert mode set backspace=2 " Backspace like most programs in insert mode
@ -44,7 +42,6 @@ set vb " Turn on screen flash which is quieter than audio bell
set wildmenu " Allow vim command-line autocompletion set wildmenu " Allow vim command-line autocompletion
set wildmode=full " Specifies option for wildmenu set wildmode=full " Specifies option for wildmenu
set expandtab " Turn tabs into spaces set expandtab " Turn tabs into spaces
set noswapfile " Disable swapfile set noswapfile " Disable swapfile
set cscopetag " Search both cscopes db and tags file" set cscopetag " Search both cscopes db and tags file"
@ -62,21 +59,34 @@ if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p") call mkdir(expand(&undodir), "p")
endif endif
" // Appearance //////////////////////////////////////////////////////////////// " ==============================================================================
" Fix C-syntax highlighting marking valid curly braces as invalid " Appearance
" let c_no_curly_error=1 " ==============================================================================
syntax on " syntax highlighting
syntax on " syntax highlighting set autoindent " Always use autoindent
set laststatus=2 " always show status bar set background=dark " Some themes use this indicator to theme themselves
set ruler " show the cursor position all the time set colorcolumn=80,100 " Set a 80, 100 char column marker
set guioptions= " remove extra gui elements set cpoptions+=$ " $ as end marker for the change operator
set cpoptions+=$ " $ as end marker for the change operator set cursorline " Highlight current line
set showmatch " automatically show matching brackets. works like it does in bbedit. set encoding=utf-8 " Consistent character encoding
set number " Show line numbers set fileformats=unix,dos
set relativenumber " Show relative line numbers set foldlevelstart=99 " Initially all folds open
set background=dark " Some themes use this indicator to theme themselves set foldmethod=indent " Allow folding of
set cursorline " Highlight current line set foldnestmax=1 " Maximum number of nested folds
set colorcolumn=80,100 " Set a 80, 100 char column marker set guioptions= " remove extra gui elements
set laststatus=2 " always show status bar
set linebreak " When wrapping lines, don't break words
set list " Show 'listchar' characters
set number " Show line numbers
set relativenumber " Show relative line numbers
set ruler " show the cursor position all the time
set shiftwidth=4 " Number of space chars for indentation
set showmatch " automatically show matching brackets. works like it does in bbedit.
set smartindent
set smarttab " Make 'tab' insert indents at the beginning of a line
set tabstop=4 " Number of space chars for pressing tab
set textwidth=80 " Always format to 80 chars
set listchars=tab:>-
" Show EOL type and last modified timestamp, right after the filename " Show EOL type and last modified timestamp, right after the filename
set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))})%=%l,%c%V\ %P set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))})%=%l,%c%V\ %P
@ -84,65 +94,65 @@ set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(ex
" Resize splits when the window is resized " Resize splits when the window is resized
au VimResized * :wincmd = au VimResized * :wincmd =
set autoindent " Always use autoindent " ==============================================================================
set encoding=utf-8 " Consistent character encoding " Theme
set foldnestmax=1 " Maximum number of nested folds " ==============================================================================
" set foldlevel=99 " Initially all folds open
set foldlevelstart=99 " Initially all folds open
set foldmethod=indent " Allow folding of
set linebreak " When wrapping lines, don't break words
set list " Show 'listchar' characters
set shiftwidth=4 " Number of space chars for indentation
set smartindent
set smarttab " Make 'tab' insert indents at the beginning of a line
set tabstop=4 " Number of space chars for pressing tab
set textwidth=80 " Always format to 80 chars
set fileformats=unix,dos
set listchars=tab:>-
let g:gruvbox_contrast_dark='hard' let g:gruvbox_contrast_dark='hard'
let g:gruvbox_italic=0 let g:gruvbox_italic=0
let g:gruvbox_bold=0 let g:gruvbox_bold=0
colorscheme gruvbox colorscheme gruvbox
if has("gui_running") if has("gui_running")
" NOTE(doyle): Some list chars in gui don't show correctly in terminal so separate logic
" old listchars=tab:>-,eol:¬,trail:■,extends:»,precedes:«
set listchars+=trail:■,extends,precedes
if s:running_windows
set guifont=Consolas:h11
else
set guifont=InputMonoCondensed:h10
endif
" NOTE(doyle): Some list chars in gui don't show correctly in terminal so separate logic " Don't show trailing spaces in insert mode
" old listchars=tab:>-,eol:¬,trail:■,extends:»,precedes:« augroup trailing
set listchars+=trail:■,extends,precedes au!
au InsertEnter * :set listchars-=trail:■
au InsertLeave * :set listchars+=trail:■
augroup END
if s:running_windows " Increase font size using (Ctrl+Up Arrow) or (Ctrl+Down Arrow) if we are using
set guifont=Consolas:h11 " gvim Otherwise font size is determined in terminal
else nnoremap <C-Up> :silent! let &guifont = substitute(
set guifont=InputMonoCondensed:h10 \ &guifont,
endif \ ':h\zs\d\+',
\ '\=eval(submatch(0)+1)',
\ 'g')<CR>
nnoremap <C-Down> :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)-1)',
\ 'g')<CR>
" Don't show trailing spaces in insert mode
augroup trailing
au!
au InsertEnter * :set listchars-=trail:■
au InsertLeave * :set listchars+=trail:■
augroup END
else else
set t_Co=256 " 256 colors set t_Co=256 " 256 colors
let &t_AB="\e[48;5;%dm" " vodoo magic for CONEMU let &t_AB="\e[48;5;%dm" " vodoo magic for CONEMU
let &t_AF="\e[38;5;%dm" " vodoo magic for CONEMU let &t_AF="\e[38;5;%dm" " vodoo magic for CONEMU
set listchars+=trail:$,extends:>,precedes:< set listchars+=trail:$,extends:>,precedes:<
" Fix Cmder backspace bug " Fix Cmder backspace bug
inoremap <Char-0x07F> <BS> inoremap <Char-0x07F> <BS>
nnoremap <Char-0x07F> <BS> nnoremap <Char-0x07F> <BS>
endif endif
" Formatting options (see :h fo-table)
augroup persistent_settings augroup persistent_settings
au! au!
" Formatting options (see :h fo-table)
au BufEnter * :set formatoptions=q1j au BufEnter * :set formatoptions=q1j
augroup END augroup END
" Key Mappings & Functions /////////////////////////////////////////////////////// " ==============================================================================
" Key Bindings
" ==============================================================================
" Enable mouse support " Enable mouse support
if has('mouse') if has('mouse')
set mouse=a set mouse=a
@ -166,52 +176,53 @@ map <C-n> :NERDTreeToggle<CR>
" Change to current buffer's directory " Change to current buffer's directory
nmap cd :cd <C-R>=expand("%:p:h")<CR><CR> nmap cd :cd <C-R>=expand("%:p:h")<CR><CR>
" Show list of buffers using leader key (default \)b " Buffer Splitting
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>s :vs<CR> nnoremap <leader>s :vs<CR>
nnoremap <leader>f :Files<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>l :Lines<CR>
nnoremap <leader>a :Ag<CR>
" Execute clang format on tab " Go to next error
" Go to previous error
nnoremap <A-n> :cn<CR>
nnoremap <A-p> :cp<CR>
" Fullscreen
if s:running_windows if s:running_windows
map <C-I> :pyf $home\.vim\clang-format.py<CR> noremap <f11> <esc>:call libcallnr('gvim_fullscreen.dll', 'ToggleFullscreen', 0)<cr>
imap <C-I> <ESC>:pyf $home\.vim\clang-format.py<CR>i endif
" ==============================================================================
" Leaderf
" ==============================================================================
" Config
let g:Lf_MruFileExclude = ['*.so', '*.tmp', '*.bak', '*.exe', '*.dll']
" Bindings
nnoremap <leader>b :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
nnoremap <leader>f :<C-U><C-R>=printf("Leaderf file %s", "")<CR><CR>
nnoremap <leader>l :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
nnoremap <leader>m :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
nnoremap <leader>p :<C-U><C-R>=printf("Leaderf function %s", "")<CR><CR>
nnoremap <leader>t :<C-U><C-R>=printf("Leaderf tag %s", "")<CR><CR>
nnoremap <leader>h :<C-U><C-R>=printf("Leaderf self %s", "")<CR><CR>
noremap <C-P> :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>
" ==============================================================================
" Clang Format
" ==============================================================================
if s:running_windows
map <C-I> :pyf $home\.vim\clang-format.py<CR>
imap <C-I> <ESC>:pyf $home\.vim\clang-format.py<CR>i
else else
map <C-I> :py3f ~/.vim/clang-format.py<CR> map <C-I> :py3f ~/.vim/clang-format.py<CR>
imap <C-I> <ESC>:py3f ~/.vim/clang-format.py<CR>i imap <C-I> <ESC>:py3f ~/.vim/clang-format.py<CR>i
endif endif
" Increase font size using (Ctrl+Up Arrow) or (Ctrl+Down Arrow) if we are using " ==============================================================================
" gvim Otherwise font size is determined in terminal " Compiling / AsyncRun
if has ('gui_running') " ==============================================================================
nnoremap <C-Up> :silent! let &guifont = substitute( " Asyncrun open quickfix window up to 10 lines
\ &guifont, let g:asyncrun_open = 10
\ ':h\zs\d\+',
\ '\=eval(submatch(0)+1)',
\ 'g')<CR>
nnoremap <C-Down> :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)-1)',
\ 'g')<CR>
endif
" Reload vimrc when it's edited
augroup myvimrc
au!
au BufWritePost $MYVIMRC so $MYVIMRC
augroup end
" Return to the same line when a file is reopened
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup end
" Error message formats thanks to " Error message formats thanks to
" https://forums.handmadehero.org/index.php/forum?view=topic&catid=4&id=704#3982 " https://forums.handmadehero.org/index.php/forum?view=topic&catid=4&id=704#3982
@ -234,26 +245,20 @@ else
set makeprg=./build.sh set makeprg=./build.sh
endif endif
"Go to next error " ==============================================================================
"Go to previous error " Other
nnoremap <A-n> :cn<CR> " ==============================================================================
nnoremap <A-p> :cp<CR> " Reload vimrc when it's edited
augroup myvimrc
au!
au BufWritePost $MYVIMRC so $MYVIMRC
augroup end
" Return to the same line when a file is reopened
" Push Quickfix (qf) window to the bottom of the screen. augroup line_return
autocmd FileType qf wincmd J au!
au BufReadPost *
" Resize Quickfix (qf) to a maximum of 10 lines depending on the actual contents \ if line("'\"") > 0 && line("'\"") <= line("$") |
au FileType qf call AdjustWindowHeight(3, 10) \ execute 'normal! g`"zvzz' |
function! AdjustWindowHeight(minheight, maxheight) \ endif
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _" augroup end
endfunction
" Fzf
let g:fzf_tags_command = 'ctags -R --c++-kinds=+p --fields=+iaS'
" Fullscreen
noremap <f11> <esc>:call libcallnr('gvim_fullscreen.dll', 'ToggleFullscreen', 0)<cr>
" Asyncrun open quickfix window up to 10 lines
let g:asyncrun_open = 10

Binary file not shown.

Binary file not shown.

View File

@ -9,7 +9,7 @@ fi
cp -f Installer/_vimrc ~/.vimrc cp -f Installer/_vimrc ~/.vimrc
cp -f Installer/unix_nvim_init.vim ~/.config/nvim/init.vim cp -f Installer/unix_nvim_init.vim ~/.config/nvim/init.vim
sudo apt install silversearcher-ag tmux exuberant-ctags neovim clang-format sudo apt install exuberant-ctags neovim clang-format ripgrep
cat > ~/.tmux.conf <<EOF cat > ~/.tmux.conf <<EOF
set-option -g mouse on set-option -g mouse on

View File

@ -91,7 +91,9 @@ copy /Y %scanmapset_file% %scanmapset_path%
copy /Y %uncap_file% %uncap_path% copy /Y %uncap_file% %uncap_path%
REM REM
REM Ag REM ripgrep
REM REM
echo - Copy Installer\win32_ag.exe to %cmder_install_path%\bin\ag.exe set rg_path=%cmder_install_path%\bin
copy /Y Installer\win32_ag.exe %cmder_install_path%\bin\ag.exe set rg_zip=Installer\win32_rg_v12.1.1.7z
echo - Extracting %rg_zip% to %rg_path%
if not exist "%rg_path%\rg.exe" Installer\win32_7za.exe x -y -o%rg_path% %rg_zip% > NUL