Created
January 7, 2020 13:33
-
-
Save fursich/f30261c6e2c782a401422a1a8541957b to your computer and use it in GitHub Desktop.
vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim') | |
if !filereadable(vimplug_exists) | |
if !executable("curl") | |
echoerr "You have to install curl or first install vim-plug yourself!" | |
execute "q!" | |
endif | |
echo "Installing Vim-Plug..." | |
echo "" | |
silent !\curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
let g:not_finish_vimplug = "yes" | |
autocmd VimEnter * PlugInstall | |
endif | |
call plug#begin(expand('~/.config/nvim/plugged')) | |
"***************************************************************************** | |
"" Plug install | |
"***************************************************************************** | |
Plug 'preservim/nerdtree' | |
Plug 'tpope/vim-fugitive' | |
" fzf | |
Plug '/usr/local/opt/fzf' | |
Plug 'junegunn/fzf.vim' | |
"" coc.nvim | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
"" Color | |
Plug 'tomasr/molokai' | |
call plug#end() | |
"***************************************************************************** | |
"" Mappings | |
"***************************************************************************** | |
let mapleader=',' | |
"" Split | |
noremap <Leader>h :<C-u>split<CR> | |
noremap <Leader>v :<C-u>vsplit<CR> | |
"" Buffer nav | |
noremap <leader>p :bp<CR> | |
noremap <leader>n :bn<CR> | |
"" Close buffer | |
noremap <leader>d :bd<CR> | |
"" Switching windows | |
noremap <C-j> <C-w>j | |
noremap <C-k> <C-w>k | |
noremap <C-l> <C-w>l | |
noremap <C-h> <C-w>h | |
"" Qall | |
noremap <Leader>qq :qall<CR> | |
noremap <Leader>qq! :qall!<CR> | |
" fzf | |
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null" | |
nnoremap <silent> <leader>fz :FZF -m<CR> | |
nnoremap <silent> <leader>ffl :GFiles<CR> " git ls-files | |
nnoremap <silent> <leader>ffs :GFiles?<CR> " git status | |
nnoremap <silent> <leader>fb :Buffers<CR> | |
nnoremap <silent> <leader>fg :Rg<CR> " ripgrep | |
nnoremap <silent> <leader>fch :History:<CR> " command history | |
nnoremap <silent> <leader>fsh :History/<CR> " search history | |
"***************************************************************************** | |
"" Basic Setup | |
"***************************************************************************** | |
"" Searching | |
set hlsearch | |
set incsearch | |
nnoremap <ESC><ESC> :nohl<CR> | |
"***************************************************************************** | |
"" Configurations | |
"***************************************************************************** | |
function! StatusDiagnostic() abort | |
let info = get(b:, 'coc_diagnostic_info', {}) | |
if empty(info) | return '' | endif | |
let msgs = [] | |
if get(info, 'error', 0) | |
call add(msgs, 'E' . info['error']) | |
endif | |
if get(info, 'warning', 0) | |
call add(msgs, 'W' . info['warning']) | |
endif | |
return join(msgs, ' '). ' ' . get(g:, 'coc_status', '') | |
endfunction | |
"" NERDTree configuration | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | |
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
let g:NERDTreeChDirMode=2 | |
let g:NERDTreeIgnore=['\~$', '\.sqlite$', '__pycache__'] | |
let g:NERDTreeSortOrder=['\/$', '*', '\.swp$', '\.bak$', '\~$'] | |
let g:NERDTreeShowBookmarks=1 | |
" let g:nerdtree_tabs_focus_on_files=1 | |
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>' | |
let NERDTreeShowHidden=1 | |
let g:NERDTreeWinSize = 40 | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite | |
nnoremap <silent> <leader>nf :NERDTreeFind<CR> | |
nnoremap <silent> <C-n> :NERDTreeToggle<CR> | |
"" coc-nvim configuration | |
" 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 | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Or use `complete_info` if your vim support it, like: | |
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" Remap keys for gotos | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Remap for rename current word | |
nmap <leader>rn <Plug>(coc-rename) | |
" Using CocList | |
" Show all diagnostics | |
nnoremap <silent> <leader>ca :<C-u>CocList diagnostics<cr> | |
" Manage extensions | |
nnoremap <silent> <leader>ce :<C-u>CocList extensions<cr> | |
" Show commands | |
nnoremap <silent> <leader>cc :<C-u>CocList commands<cr> | |
" Find symbol of current document | |
nnoremap <silent> <leader>co :<C-u>CocList outline<cr> | |
" Search workspace symbols | |
nnoremap <silent> <leader>cs :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent> <leader>cj :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent> <leader>ck :<C-u>CocPrev<CR> | |
" Resume latest coc list | |
nnoremap <silent> <leader>cp :<C-u>CocListResume<CR> | |
"***************************************************************************** | |
"" Visual Settings | |
"***************************************************************************** | |
set ruler | |
set number | |
let no_buffers_menu=1 | |
if !exists('g:not_finish_vimplug') | |
colorscheme molokai | |
endif | |
"" Map leader to , | |
set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %F%t%=%{FugitiveStatusline()}\ %{coc#status()}%{get(b:,'coc_current_function','')}\ \ (%l\/%L,\ %c/%V)\ \ %P | |
" Search mappings: These will make it so that going to the next one in a | |
" search will center on the line it's found in. | |
nnoremap n nzzzv | |
nnoremap N Nzzzv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment