diff options
Diffstat (limited to '')
-rw-r--r-- | nvim/init.vim | 739 |
1 files changed, 739 insertions, 0 deletions
diff --git a/nvim/init.vim b/nvim/init.vim new file mode 100644 index 0000000..6de99ff --- /dev/null +++ b/nvim/init.vim @@ -0,0 +1,739 @@ +"LEMON'S VIMRC - 16 NOVEMBER 2014 +" Preamble +set t_Co=256 +set background=dark +set path+=** +" + +" +nnoremap <C-J> <C-W><C-J> +nnoremap <C-K> <C-W><C-K> +nnoremap <C-L> <C-W><C-L> +nnoremap <C-H> <C-W><C-H> + + +" vertical diff please +set diffopt=vertical + + +" Remap the leader key +let mapleader = "," + +" map ESCAPE to exit to Normal mode in neovim terminal +tnoremap <Esc> <C-\><C-N> + + +" Signify mapping & config +nnoremap <leader>R :SignifyRefresh<CR> +let g:signify_realtime = 1 + + +" Basic options + +set cmdheight=1 +set termguicolors +set inccommand=split +set foldmethod=manual +set encoding=utf-8 +set modelines=0 +set relativenumber +set autoindent +set showmode +set cursorline +set ttyfast +set ttimeout +set notimeout +set nottimeout +set backspace=indent,eol,start +set ruler +set laststatus=2 +set history=1000 " remember more commands and search history +set undolevels=1000 " use many muchos levels of undo +set wildignore=*.swp,*.bak,*.pyc,*.class +set title " change the terminal's title +set visualbell " don't beep +set noerrorbells " don't beep +set number +set fillchars=diff:⣿,vert:\| +set noswapfile +set ruler " show the cursor position all the time +set showcmd " display incomplete commands +set vb +"set list +set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮ +set lazyredraw +set matchtime=3 +set showbreak=↪ +set shell=/usr/bin/fish +set splitbelow +set splitright +set autowrite +set autoread +set linebreak +set hidden +"set colorcolumn=80 +" +" Wildmenu completion +set wildmenu +" set wildmode=list:longest " don't like this +set wildignore+=.hg,.git,.svn " Version control +set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files +set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files +set wildignore+=*.spl " compiled spelling word lists +set wildignore+=*.sw? " Vim swap files +set wildignore+=*.DS_Store " OSX bullshit +set wildignore+=*.luac " Lua byte code +set wildignore+=migrations " Django migrations +set wildignore+=*.pyc " Python byte code +set wildignore+=*.orig " Merge resolution files +" Clojure/Leiningen +set wildignore+=classes +set wildignore+=lib + +" Make Vim able to edit crontab files ... +set backupskip=/tmp/*,/private/tmp/*" +" +" Remaps ... +"NERDTree! +nmap \e :NERDTreeToggle<CR> +let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree + +" targbar handler +nmap <F8> :TagbarToggle<CR> + +" Don't use Ex mode, use Q for formatting +"map Q gq + +" easier formatting of paragraphs +" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc +vmap Q gq +nmap Q gqap + +" set trailing whitespace to be visible with using special chars with ,s +"set listchars=tab:>-,trail:*,eol:$ +"nmap <silent> <leader>s :set nolist!<CR> +" some misc settings +:nmap \l :setlocal number!<CR> +:nmap \o :set paste!<CR> + +" map sort function to a key +" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc +vnoremap <Leader>s :sort<CR> + +" Plug Plugs... +call plug#begin('~/.config/nvim/plugged') +if has('nvim') + Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +else + Plug 'Shougo/deoplete.nvim' + Plug 'roxma/nvim-yarp' + Plug 'roxma/vim-hug-neovim-rpc' +endif +Plug 'google/yapf', { 'rtp': 'plugins/vim', 'for': 'python' } +Plug 'deoplete-plugins/deoplete-go', {'do': 'make'} +Plug 'rust-lang/rust.vim' +Plug 'tpope/vim-commentary' +Plug 'junegunn/fzf' +Plug 'junegunn/fzf.vim' +Plug 'zchee/deoplete-jedi' +Plug 'davidhalter/jedi' +Plug 'mhinz/vim-signify' " marking changes in repo +Plug 'anekos/hledger-vim' +Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries'} +Plug 'buoto/gotests-vim' +Plug 'zchee/deoplete-clang' +Plug 'w0rp/ale' +Plug 'tpope/vim-fugitive' +Plug 'tpope/vim-unimpaired' +Plug 'tpope/vim-surround' +Plug 'scrooloose/nerdtree' +Plug 'majutsushi/tagbar' +Plug 'SirVer/ultisnips' +Plug 'honza/vim-snippets' +Plug 'jlanzarotta/bufexplorer' +Plug 'itchyny/lightline.vim' +Plug 'janko-m/vim-test' +Plug 'tpope/vim-dispatch' +Plug 'radenling/vim-dispatch-neovim' +Plug 'Shougo/neoinclude.vim' +Plug 'psf/black', { 'branch': 'stable' } +Plug 'sebdah/vim-delve' +Plug 'tweekmonster/django-plus.vim' +Plug 'junegunn/limelight.vim' +Plug 'junegunn/vim-peekaboo' +call plug#end() + +" Lightline config +let g:lightline = { + \ 'colorscheme': 'default', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } + +" point neovim to virtualenv specific to neovim (using 3.7) +let g:python3_host_prog = "/home/lemon/.virtualenvs/pynvim/bin/python3" +let g:deoplete#enable_at_startup = 1 + +"" Some servers have issues with backup files, see #649 +set nobackup +set nowritebackup +" +"" Better display for messages +"set cmdheight=2 +" +"" You will have bad experience for diagnostic messages when it's default 4000. +"set updatetime=300 +" +"" don't give |ins-completion-menu| messages. +"set shortmess+=c +" +"" always show signcolumns +"set signcolumn=yes +" + +" .. Rust +let g:autofmt_autosave = 1 +" + +" vim-test config .. +" use vim-dispatch to run tests in the quickfix window +" from Modern Vim Ch.4 +" the mappings below are from vim-test +" https://github.com/janko/vim-test +" dispatch opens send test output to quickfix window +"let test#strategy = "dispatch" +" neovim strategy runs the test in the neovim terminal +let test#strategy = "neovim" +let test#python#runner = "pytest" +let test#neovim#term_position = "topleft" +let test#python#pytest#options = '--tb=short --color=no' +let test#go#runner = 'gotest' +"let test#go#gotest#options = '-v' + +" To run mypy using vim-dispath -with Dispatch +autocmd FileType python let b:dispatch = 'mypy --ignore-missing-imports' + +nmap <silent> t<C-n> :TestNearest<CR> +nmap <silent> t<C-f> :TestFile<CR> +nmap <silent> t<C-s> :TestSuite<CR> +"nmap <silent> t<C-l> :TestLast<CR> +nmap <silent> <S-F10> :TestLast<CR> +nmap <silent> t<C-g> :TestVisit<CR> +" +" +" +" clang support ... for Debian Stretch only! +"let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-3.8/lib/libclang.so.1' +"let g:deoplete#sources#clang#clang_header = '/usr/lib/llvm-3.8/lib/clang/3.8.1/include' +" works on Debian Buster anyway +"let g:deoplete#sources#clang#clang_header = '/usr/lib/llvm-6.0/lib/clang/6.0.1/include/' +let g:deoplete#sources#clang#clang_header = '/usr/include/clang/10/include' +let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-10/lib/libclang-10.so.1' +" +" deoplete omnifuc +let g:deoplete#enable_at_startup = 1 +let g:deoplete#disable_auto_complete = 0 +"call deoplete#custom#option('auto_complete', 0) +"call deoplete#custom#source('jedi', 'debug_enabled', 1) +"call deoplete#enable_logging('DEBUG', '/tmp/deoplete.log') +"inoremap <silent><expr><C-Space> deoplete#mappings#manual_complete() +" +" jedi-specific stuff +" WHICH DOES NOT APPEAR TO WORK +" USE CTAGS TO GENERATE FILE FOR NAVIGATION +" e.g ctags ~/.virtualenvs/ctrack/lib64/python3.8/site-packages/**/*.py +" To pull in a virtualenv - file kept in root of project will automatically +" be picked up +" disable autocompletion, cause we use deoplete for completion +let g:jedi#completions_enabled = 0 + +" open the go-to function in split, not another buffer +let g:jedi#use_splits_not_buffers = "right" + +let g:jedi#goto_command = "<leader>d" +let g:jedi#goto_assignments_command = "<leader>g" +let g:jedi#goto_stubs_command = "<leader>s" +let g:jedi#goto_definitions_command = "" +let g:jedi#documentation_command = "K" +let g:jedi#usages_command = "<leader>n" +let g:jedi#completions_command = "<C-Space>" +let g:jedi#rename_command = "<leader>r" +" +" golang stuff +let g:go_term_mode = "split" +let g:go_term_height = 10 +"autocmd FileType go nmap <leader>r :w<CR>:split <bar> terminal go run %<CR> +autocmd FileType go nmap <leader>r :GoRun<CR> +" highlights the variable in the file for you.. +"let g:go_auto_sameids = 1 +" auto import... +let g:go_fmt_command = "goimports" +" automatic type info on cursor +let g:go_auto_type_info = 1 +au Filetype go nmap <leader>ga <Plug>(go-alternate-edit) +au Filetype go nmap <leader>gah <Plug>(go-alternate-split) +au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical) +au FileType go nmap <F10> :GoTest -short<cr> +au FileType go nmap <F9> :DlvToggleBreakpoint<CR> +au FileType go nmap <S-F9> :DlvTest<CR> +au FileType go nmap <F11> :DlvDebug<CR> +au FileType go nmap <S-F5> :GoRename<CR> + + +" ultisnips... +"inoremap <silent><expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" +"let g:UltiSnipsExpandTrigger="<tab>" +"let g:UltiSnipsSnippetsDir = "/home/lemon/dotfiles/Ultisnips" +"let g:UltiSnipsSnippetDirectories=["/home/lemon/dotfiles/Ultisnips"] +"" let g:UltiSnipsJumpForwardTrigger="<c-n>" +"" let g:UltiSnipsJumpBackwardTrigger="<c-p>" +"let g:UltiSnipsJumpForwardTrigger="<c-j>" +"let g:UltiSnipsJumpBackwardTrigger="<c-k>" + +" yapf - format python code (https://github.com/google/yapf)... +map <leader>y :call yapf#YAPF()<cr> +imap <leader>y :call yapf#YAPF()<cr> +"autocmd FileType python nnoremap <leader>yy :0,$!yapf<Cr><C-o> + + +" isort - sort python imports (https://github.com/timothycrosley/isort) ... +let maplocalleader = "\\" +autocmd FileType python nnoremap <LocalLeader>j :!isort %<CR><CR> + + +" Tabs, spaces, wrapping ... +set tabstop=4 +set shiftwidth=4 +set shiftround +set softtabstop=4 +set expandtab +set tw=79 " width of document(used by gd) +set nowrap "don't automatically wrap on load +set formatoptions=qrn1j +set fo-=t " don't automatically wrap text when typing +" +" +" Enable folding ... +set foldmethod=manual +set foldlevel=99 +" + + +" Backups ... +set undodir=~/.nvim-tmp/tmp/undo// "undo files +set backupdir=~/.nvim-tmp/tmp/backup// " backups +set directory=~/.nvim-tmp/tmp/swap// " swap files +set backup " enable backups +" +" Highlight VCS conflict markers ... +match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' + +" Searching and movement ... +nnoremap / /\v +vnoremap / /\v +set ignorecase +set smartcase +set incsearch +set showmatch +set hlsearch +set gdefault +set scrolloff=3 +set sidescroll=1 +set sidescrolloff=10 +set virtualedit+=block +nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> + +nmap \x :cclose<CR> + +" Don't move on * +nnoremap * *<c-o> + +" Easier to type move extreme left and right +noremap H ^ +noremap L g_ + +" Use ctrl-e and ctrl-a +inoremap <c-a> <esc>I +inoremap <c-e> <esc>A + +" open a Quickfix window for the last search +nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR> + +" ################################## +" Ag! +" +" How to do search (May 2020) +" +" lgrep -R "search term" .venv +" +" (ALE currently hijacks the quicklist which is why we need l there) +" - to search current directory including +" virtualenv. Results will open in :lopen (loclist) + +" :Ag +" +" Will do nice FZF search, but not into gitignored or hidden files. +" +" !ag -Q "breakpoint()" .venv +" +" will do an exact match search but not populate the loclist. +" ################################## +" +" +let g:ackprg = 'ag --smart-case --nogroup --nocolor --column' +" WARNING - IF REPLACE GREP WITH AG, IT DOESN'T POPULATE THE QUICKFIX +" WHICH IS SOMETHING I WANT FOR BIG SEARCHES +"if executable('ag') +" set grepprg=ag\ --nogroup\ --smart-case\ --nocolor\ --column +" set grepformat=%f:%l:%c:%m +"endif +" bind \ (backward slash) to grep shortcut +" THIS ALLOWS AN ag SEARCH AND PUTS OUTPUT IN Quick Fix window +" this is great for passing ag flags, such as .venv or Q or whatever +"command -nargs=+ -complete=file -bar Agg silent! grep! <args>|cwindow|redraw! + + +" (example use :14 to select from menu) +nnoremap <leader>S :g//#<left><left> + + +" Folding ... +" Enable folding with the spacebar +nnoremap <space> za +nnoremap <leader>fm :set foldmethod=manual<CR> +" Make zO recursively open whatever fold we're in, even if it's partially open. +nnoremap zO zczO +" Use ,z to "focus" the current fold +nnoremap <leader>z zMzvzz + +"" Quick Editing ... +nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr> + +" Convenience mappings ... +" No more help key. +noremap <F1> :checktime<cr> +inoremap <F1> <esc>:checktime<cr> + +" Kill window +"nnoremap <leader>K :q<cr> + +" Wrap +nnoremap <leader>W :set wrap!<cr> + +" Change case +"noremap <C-S-u> gUiw +"inoremap <C-S-u> <esc> gUiwea + +" Substitute +nnoremap <leader>su :%s//<left> +nnoremap <Leader>s :%s/<C-r><C-w>//g<Left><Left> +" +" Emacs bindings in command line mode +cnoremap <c-a> <home> +cnoremap <c-e> <end> + +" Turn off vimdiff +nnoremap <leader>D :diffoff!<cr> + +" Formatting, like Textmate +nnoremap Q gqip + +" Easier linewise reselection +nnoremap <leader>V V`] + +" Split line (colleague of Join lines) +nnoremap S i<cr><esc><right> + +" Source the current line +vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr> +nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr> + +" Select (charwise) the contents of the current line, excluding indentation. +" Great for pasting Python lines into REPLs. +nnoremap vv ^vg_ + +" Mutt ... +augroup ft_muttrc + au! + + au BufRead,BufNewFile *.muttrc set ft=muttrc + + au FileType muttrc setlocal foldmethod=marker foldmarker=,}}} +augroup END +" + +" vim-fugitive ... +" prevent buffer build-up +autocmd BufReadPost fugitive://* set bufhidden=delete +" +" ALE statusline ... +"set statusline+=%{ALEGetStatusLine()} +"let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '• ok'] +"let g:ale_linters = {'python': ['flake8'],} + + +" ale setting.. +"let g:ale_lint_on_text_changed = 'never' + +" black config ... +"let g:black_virtualenv = "/home/lemon/.virtualenvs/black-for-vim/" +"nmap <leader>l :Black<CR> +" LET'S RUN VIRTUALENV BLACK ON SAVE! +"autocmd BufWritePre *.py execute ':Black' +"let g:black_virtualenv = $VIRTUAL_ENV + + +let g:ale_enabled = 1 +let g:ale_sign_column_always = 1 +let g:ale_open_list = 0 +let g:ale_set_highlights = 1 +let g:ale_set_signs = 1 +let g:ale_set_loclist = 0 +let g:ale_set_quickfix = 1 +let g:ale_echo_cursor = 1 +let g:ale_echo_msg_error_str = 'Error' +let g:ale_echo_msg_format = '%linter% - %code: %%s' +let g:ale_loclist_msg_format = '%linter% - %code: %%s' +let g:ale_echo_msg_warning_str = 'Warning' +"let g:ale_linters = {'python': ['flake8', 'mypy', 'pyls', 'pylint'], +"\ 'ocaml': ['merlin'], +" \} +let g:ale_linters = {'python': ['flake8', 'mypy'], +\ 'ocaml': ['merlin'], +\ 'cpp': ['clang'], +\ 'c': ['clang'], +\ 'go': ['gometalinter', 'gofmt'], + \} +"let g:ale_linters_ignore = {'python': ['pyls']} +let g:ale_fixers = {'python': ['isort', 'black']} +let g:ale_python_mypy_ignore_invalid_syntax = 1 +let g:ale_python_mypy_executable = 'mypy' +let g:ale_python_mypy_options = '--config-file mypy.ini' +" let g:ale_sign_error = '>>' +let g:ale_sign_warning = '--' +let g:ale_fix_on_save = 1 +let g:ale_linters_explicit = 0 + + +" Mappings in the style of unimpaired-next +nmap [W <Plug>(ale_first) +nmap [w <Plug>(ale_previous) +nmap ]w <Plug>(ale_next) +nmap ]W <Plug>(ale_last) + + +" Bufexplorer config ... +let g:bufExplorerDefaultHelp=1 " Show default help. +let g:bufExplorerShowNoName=1 " Show "No Name" buffers. +let g:bufExplorerShowUnlisted=1 " Show unlisted buffers. +" +" Django ... +augroup ft_django + au! + + au BufNewFile,BufRead urls.py setlocal nowrap + au BufNewFile,BufRead urls.py normal! zR + au BufNewFile,BufRead dashboard.py normal! zR + au BufNewFile,BufRead local_settings.py normal! zR + + au BufNewFile,BufRead admin.py setlocal filetype=python.django + au BufNewFile,BufRead urls.py setlocal filetype=python.django + au BufNewFile,BufRead models.py setlocal filetype=python.django + au BufNewFile,BufRead views.py setlocal filetype=python.django + au BufNewFile,BufRead settings.py setlocal filetype=python.django + au BufNewFile,BufRead settings.py setlocal foldmethod=marker + au BufNewFile,BufRead forms.py setlocal filetype=python.django + au BufNewFile,BufRead common_settings.py setlocal filetype=python.django + au BufNewFile,BufRead common_settings.py setlocal foldmethod=marker +augroup END + +" vim-markdown ... +let g:vim_markdown_folding_disabled=1 +set foldenable +let g:vim_markdown_initial_foldlevel=1 +let g:vim_markdown_no_default_key_mappings=1 +let g:vim_markdown_math=1 +let g:vim_markdown_frontmatter=1 +" +" get rid of annoying Press ENTER prompts etc ... +"set shortmess=atI +" +" Remap movement in windows ... +map <c-j> <c-w>j +map <c-k> <c-w>k +map <c-l> <c-w>l +map <c-h> <c-w>h + +" General python properness ... +autocmd FileType python set sw=4 +autocmd FileType python set ts=4 +autocmd FileType python set sts=4 + +" Escape sudo heck ... +cmap w!! %!sudo tee > /dev/null % + + +" my todo.todo... {{ +autocmd BufNewFile,BufRead *.todo set syntax=markdown +"autocmd BufWritePost *.todo !todo-push +nmap <F2> a<C-R>=strftime("%c")<CR><Esc> +"let @d=':r! date _kb-I
ikb ($a)0"+dd:!xlcipkbkbkbkbclip -o >> /home/lemon/todo/done.todo
' +let @d='0$a(k2a)0"+dd:!xlcipkbkbkbkbclip -o >> /home/lemon/todo/done.todo
' +" ...}} + +" +" FZF ... +" This is the default extra key bindings +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" Default fzf layout +" - down / up / left / right +let g:fzf_layout = { 'down': '~40%' } + +" Customize fzf colors to match your color scheme +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } +" More fzf settings +" (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187) + let g:fzf_nvim_statusline = 0 " disable statusline overwriting + + nnoremap <C-p> :<C-u>FZF<CR> + nnoremap <leader><C-p> :<C-u>FZF!<CR> + nnoremap ; :Buffers<CR> + nnoremap <leader>t :Files<CR> + nnoremap <leader>o :Tags<CR> + nnoremap <leader>h :History<CR> + nnoremap <silent> <leader>0 :Files<CR> + nnoremap <silent> <leader>A :Windows<CR> + nnoremap <silent> <leader>; :BLines<CR> + nnoremap <silent> <leader>l :Lines<CR> +" nnoremap <silent> <leader># :Lines<CR> + nnoremap <silent> <leader>o :BTags<CR> +" command history is :History: + nnoremap <silent> <leader>? :History:<CR> + nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR> +" nnoremap <silent> <leader>. :AgIn # +" nnoremap <silent> <leader>a :Buffers<CR> +" nnoremap <silent> <leader>O :Tags<CR> + nnoremap <silent> <leader>P :call SearchWordWithAg()<CR> + vnoremap <silent> <leader>P :call SearchVisualSelectionWithAg()<CR> +" nnoremap <silent> <leader>gl :Commits<CR> +" nnoremap <silent> <leader>ga :BCommits<CR> + nnoremap <silent> <leader>ft :Filetypes<CR> + nnoremap <silent> <leader>CC :Commands<CR> + + imap <C-x><C-f> <plug>(fzf-complete-file-ag) + imap <C-x><C-l> <plug>(fzf-complete-line) + + function! SearchWordWithAg() + execute 'Ag' expand('<cword>') + endfunction + + function! SearchVisualSelectionWithAg() range + let old_reg = getreg('"') + let old_regtype = getregtype('"') + let old_clipboard = &clipboard + set clipboard& + normal! ""gvy + let selection = getreg('"') + call setreg('"', old_reg, old_regtype) + let &clipboard = old_clipboard + execute 'Ag' selection + endfunction + +" function! SearchWithAgInDirectory(...) +" call fzf#vim#ag(join(a:000[1:], ' '), extend({'dir': a:1}, g:fzf#vim#default_layout)) +" endfunction +" command! -nargs=+ -complete=dir AgIn call SearchWithAgInDirectory(<f-args>) + +" Enable per-command history. +" CTRL-N and CTRL-P will be automatically bound to next-history and +" previous-history instead of down and up. If you don't like the change, +" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. +let g:fzf_history_dir = '~/.local/share/fzf-history' +" +" Mapping selecting mappings +nmap <leader><tab> <plug>(fzf-maps-n) +xmap <leader><tab> <plug>(fzf-maps-x) +omap <leader><tab> <plug>(fzf-maps-o) + +" Insert mode completion +imap <c-x><c-k> <plug>(fzf-complete-word) +imap <c-x><c-f> <plug>(fzf-complete-path) +imap <c-x><c-j> <plug>(fzf-complete-file-ag) +imap <c-x><c-l> <plug>(fzf-complete-line) + +" Advanced customization using autoload functions +inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'} +" +" +" Ocaml/merlin +"let g:opamshare = substitute(system('opam config var share'),'\n$','','''') +"execute "set rtp+=" . g:opamshare . "/merlin/vim" +"set rtp^="/home/lemon/.opam/4.06.1/share/ocp-indent/vim" +" + +" Search from git root via :Rag (Root Ag) +" Thanks! https://github.com/fortes/dotfiles/blob/7ba6ea651edde8fbc24fdf9df52ba06f7e956efc/stowed-files/nvim/.vimrc +" :Rag - hidden preview enabled with "?" key +" :Rag! - fullscreen and preview window above + +" Change to git root of current file (if in a repo) +function! FindGitRootCD() + let root = systemlist('git -C ' . expand('%:p:h') . ' rev-parse --show-toplevel')[0] + if v:shell_error + return '' + else + return {'dir': root} + endif +endfunction + + +function! GitRootCD() + let result = FindGitRootCD() + if type(result) == type({}) + execute 'lcd' fnameescape(result['dir']) + echo 'Now in '.result['dir'] + else + echo 'Not in git repo!' + endif +endfunction + +command! GitRootCD :call GitRootCD() + +command! -bang -nargs=* Rag + \ call GitRootCD() | call fzf#vim#ag(<q-args>, + \ <bang>0 ? fzf#vim#with_preview('up:60%', '?') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ <bang>0) + +" Use fuzzy searching for K & Q, select items to go into quickfix +nnoremap L :Rag! <C-R><C-W><cr> +vnoremap L :<C-u>norm! gv"sy<cr>:silent! Rag! <C-R>s<cr> +nnoremap Q :Rag!<SPACE> +" + +"highlight ColorColumn ctermbg=0 +highlight NonText cterm=NONE +" +syntax enable |