Skip to content

Instantly share code, notes, and snippets.

@Ethan826
Last active August 15, 2019 20:05
Show Gist options
  • Save Ethan826/236963d0e6751f4a130bdf94f66133bd to your computer and use it in GitHub Desktop.
Save Ethan826/236963d0e6751f4a130bdf94f66133bd to your computer and use it in GitHub Desktop.
" Plug
call plug#begin('~/.vim/plugged')
Plug 'HerringtonDarkholme/yats.vim'
Plug 'NLKNguyen/papercolor-theme'
Plug 'Shougo/denite.nvim'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'airblade/vim-gitgutter'
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
Plug 'cespare/vim-toml'
Plug 'ecomba/vim-ruby-refactoring'
Plug 'jiangmiao/auto-pairs'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/seoul256.vim'
Plug 'mattn/emmet-vim'
Plug 'mhartington/nvim-typescript', {'do': './install.sh'}
Plug 'mustache/vim-mustache-handlebars'
Plug 'neoclide/coc.nvim', {'do': './install.sh nightly'}
Plug 'ntpeters/vim-better-whitespace'
Plug 'osyo-manga/vim-over'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fireplace'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'venantius/vim-cljfmt'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'w0rp/ale'
" Initialize plugin system
call plug#end()
" Basic configuration
nnoremap <SPACE> <Nop>
let mapleader = "\<Space>" " leader is space
filetype indent on " activates indenting for files
set autoindent " auto indenting
set backspace=2 " backspace in insert mode works like normal editor
set expandtab " Insert spaces when TAB is pressed
set formatoptions+=o " Continue comment marker in new lines.
set hidden " Required for operations modifying multiple buffers like rename
set nobackup " get rid of anoying ~file
set ignorecase " ignore case in / and ? searches
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set number " Show the line numbers on the left side
set shiftwidth=2 " indent by 2 spaces when auto-indenting
set showmatch " Show matching brackets
set softtabstop=2 " indent by 2 spaces when hitting tab
set tabstop=2 " Render TABs using this many spaces
syntax on " syntax highlighting
tnoremap <Esc> <C-\><C-n> " Escape enters normal mode in terminal
nnoremap Y y$ " `Y` behaves like `D` and `C`
set smartcase " don't ignore case if there are capitals in search string
set clipboard=unnamedplus " use the system clipboard by default
" ----------------------------------------------------------
" Appearance
set background=dark
let g:seoul256_background = 236
colorscheme PaperColor
set laststatus=2
set colorcolumn=80
" ----------------------------------------------------------
" Buffers
nnoremap <silent> <Leader>bn :bnext<cr>
nnoremap <silent> <Leader><Tab> :bnext<cr>
nnoremap <silent> <Leader>bp :bprevious<cr>
nnoremap <silent> <Leader>bd :bd<cr>
" ----------------------------------------------------------
" Vim Airline
let g:airline_theme='papercolor'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_powerline_fonts = 1
" ----------------------------------------------------------
" FZF
nnoremap <silent> <Leader><Leader> :Commands<cr>
nnoremap <silent> <Leader>fb :Buffers<cr>
nnoremap <silent> <Leader>fc :Commits<cr>
nnoremap <silent> <Leader>ff :FZF<cr>
nnoremap <silent> <Leader>fg :GitFiles<cr>
nnoremap <silent> <Leader>rg :Rg<cr>
" Open files in horizontal split
nnoremap <silent> <Leader>s :call fzf#run({
\ 'down': '40%',
\ 'sink': 'botright split' })<CR>
" Open files in vertical horizontal split
nnoremap <silent> <Leader>v :call fzf#run({
\ 'right': winwidth('.') / 2,
\ 'sink': 'vertical botright split' })<CR>
" ----------------------------------------------------------
" COC
set cmdheight=2 " Better display for messages
set updatetime=300 " Smaller updatetime for CursorHold & CursorHoldI
set shortmess+=c " don't give |ins-completion-menu| messages.
set signcolumn=yes " always show signcolumns
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
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.
inoremap <silent><expr> <c-space> coc#refresh()
" 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>"
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <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)
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add diagnostic info for https://github.com/itchyny/lightline.vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'cocstatus': 'coc#status'
\ },
\ }
" Using CocList
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" ----------------------------------------------------------
" Ale
"
let g:ale_completion_enabled = 1
let g:ale_linters = { 'rust': ['rls'], 'ruby': ['rubocop'], 'handlebars': ['ember-template-lint'] }
let g:ale_fixers = { 'rust': ['rustfmt'], 'handlebars': ['prettier'], 'json': ['prettier'] }
let g:airline#extensions#ale#enabled = 1
let g:ale_rust_cargo_use_check = 1
let g:ale_fix_on_save = 1
let g:ale_enabled = 1
let g:ale_sign_error = '⨉'
let g:ale_sign_warning = '⚠'
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '']
let g:ale_lint_on_save = 1
let g:ale_lint_on_enter = 1
" ----------------------------------------------------------
" Filetype specific
autocmd FileType html setlocal shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType html.handlebars setlocal shiftwidth=4 tabstop=4 softtabstop=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment