Skip to content

Instantly share code, notes, and snippets.

@Mozart2234
Last active November 3, 2020 17:26
Show Gist options
  • Save Mozart2234/cdc2f22b047f57e67e83ce146744d42b to your computer and use it in GitHub Desktop.
Save Mozart2234/cdc2f22b047f57e67e83ce146744d42b to your computer and use it in GitHub Desktop.
.vimrc-neovim
" ----------------------- CODING CONFIGURATION --------------
syntax on "Enable syntax highlighting
filetype plugin indent on " Enable file type based information
set autoindent " Respect indentation when starting a new line.
set expandtab " Expand tabs to spaces. Essential in Python.
set tabstop=2 " Number of spaces tab is counted for.
set shiftwidth=2 " Number of spaces to use for autoindent.
set backspace=2 " Fix backspace behavior on most terminals.
"-------------------- BASIC CONFIGURATION ------------------
set encoding=UTF-8
set directory=~/.vim/swap//
set undofile
set undodir=~/.vim/undodir//
set guifont=Operator_Mono:h16
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
set laststatus=2
set showcmd
set number
set ruler
set hlsearch
set foldmethod=indent
set nofoldenable
let mapleader = "\<space>" " Map the leader key to space
vnoremap < <gv
vnoremap > >gv
" ---------------------------------------------------------
"
" ----------- SPLIT NAVIGATION -----------------------
noremap <c-h> <c-w><c-h>
noremap <c-j> <c-w><c-j>
noremap <c-k> <c-w><c-k>
noremap <c-l> <c-w><c-l>
" Split
set splitbelow
set splitright
" Make adjusing split sizes a bit more friendly
noremap <silent> <c-left> :vertical resize +3<CR>
noremap <silent> <c-right> :vertical resize -3<CR>
noremap <silent> <c-down> :resize +3<CR>
noremap <silent> <c-up> :resize -3<CR>
" Change 2 split windows from vert to horiz or horiz to vert
map <Leader>th <C-w>t<C-w>H
map <Leader>tk <C-w>t<C-w>K
autocmd FileType python setlocal ts=4 sts=4 sw=4
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" ------------------------------------------------------------
"
" ----------------------- COPYNG CONFIG ----------------------
set clipboard=unnamed
" --------------------------------------------------------------
"
" -------------------- PERSONAL COMMANDS --------------------
command! PackUpdate call minpac#update()
command! PackClean call minpac#clean()
"" ------------------------------------------------------------
""
"" ------------------------- PLUGINS ---------------------------
packadd minpac
call minpac#init()
" Utility
call minpac#add('easymotion/vim-easymotion')
call minpac#add('tpope/vim-surround')
call minpac#add('tpope/vim-unimpaired')
call minpac#add('tpope/vim-commentary')
call minpac#add('wakatime/vim-wakatime')
" call minpac#add('dense-analysis/ale')
call minpac#add('neoclide/coc.nvim', { 'branch': 'release' })
call minpac#add('preservim/nerdtree')
call minpac#add('junegunn/fzf.vim')
" Javascript
call minpac#add('pangloss/vim-javascript')
call minpac#add('leafgarland/typescript-vim') " TypeScript syntax
call minpac#add('maxmellon/vim-jsx-pretty') " JS and JSX syntax
call minpac#add('jparise/vim-graphql') " GraphQL syntax
call minpac#add('mxw/vim-jsx')
call minpac#add('peitalin/vim-jsx-typescript')
"" Theming
call minpac#add('vim-airline/vim-airline')
call minpac#add('morhetz/gruvbox')
call minpac#add('patstockwell/vim-monokai-tasty')
call minpac#add('phanviet/vim-monokai-pro')
call minpac#add('trusktr/seti.vim')
" Ruby
call minpac#add('vim-ruby/vim-ruby')
call minpac#add('tpope/vim-rails')
call minpac#add('thoughtbot/vim-rspec')
" Git
call minpac#add('tpope/vim-fugitive')
call minpac#add('airblade/vim-gitgutter')
call minpac#add('k-takata/minpac', {'type': 'opt'})
call minpac#add('tpope/vim-projectionist')
call minpac#add('mhinz/vim-grepper')
" -----------------------------------------------------------
" ----------- UI CONFIG ----------------------------
set termguicolors "enable true colors support
let g:rehash256=1
set t_Co=256
set background=dark
" highlight Comment gui=italic
" highlight Comment cterm=italic
" highlight htmlArg gui=italic
" highlight htmlArg cterm=italic
" let ayucolor="mirage" " for dark version of theme
" colorscheme ayu
colorscheme monokai_pro
let g:airline_theme='monokai_tasty'
" -------------------------------------------------
" --------------------- FZF ------------------------
nnoremap <C-p> :<C-u>:Files<CR>
" ---------------------- ALE ----------------------
" For Javascript files, 'eslint'
" let g:ale_linters = {}
" let g:ale_fixers = {}
" let g:airline#extensions#ale#enabled = 1
" let g:ale_lint_on_text_changed = 'never'
" let g:ale_lint_on_save = 1
" let g:ale_lint_on_enter = 0
" let g:ale_lint_on_filetype_changed = 0
" " Fix files automatically on save
" let g:ale_fix_on_save = 1
" " Integration with coc.nvim
" let g:ale_disable_lsp = 1
" " ALE Sign errors
" let g:ale_sign_error = "‚óâ"
" let g:ale_sign_warning = "‚óâ"
" hi link ALEErrorSign GruvboxRed
" hi link ALEWarningSign GruvboxYellow
" ------------------- GREPPER --------------------
let g:grepper = {}
let g:grepper.tools = ['grep', 'git', 'rg']
" Search for the current word
nnoremap <Leader>* :Greeper -cword -noprompt<CR>
" Search for the current selection
nmap gs <plug>(GreeperOperator)
xmap gs <plug>(GreeperOperator)
" ------------------ VIM-FUGITIVE ------------------
nnoremap <silent> <leader>gs :Gstatus<CR>
noremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <leader>gh :diffget //2<CR>
nnoremap <leader>gl :diffget //3<CR>
" ------------------ COC ------------------------
let g:coc_global_extensions = ['coc-solargraph', 'coc-pairs', 'coc-snippets', 'coc-tsserver', 'coc-css', 'coc-styled-components']
if isdirectory('./node_modules') && isdirectory('./node_modules/eslint')
let g:coc_global_extensions += ['coc-eslint']
endif
" Use tab for trigger completion with characters ahead and navigate.
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" GoTo code navigation.
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)
" ------------------ NERDTREE ---------------------
map <C-e> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " Autoclose NERDTree if it's the only open window left.
" --------------------------------------------------
"
" ---------------------- AIRLINE -------------------
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment