Skip to content

Instantly share code, notes, and snippets.

@njenan
Last active April 24, 2020 00:33
Show Gist options
  • Save njenan/d0ea712772afa24d9983cf69aedd6b4f to your computer and use it in GitHub Desktop.
Save njenan/d0ea712772afa24d9983cf69aedd6b4f to your computer and use it in GitHub Desktop.
vimrc
set rtp+=/usr/local/opt/fzf
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/goyo.vim'
Plug 'Valloric/YouCompleteMe'
Plug 'SirVer/ultisnips'
Plug 'ervandew/supertab'
Plug 'airblade/vim-gitgutter'
Plug 'flazz/vim-colorschemes'
Plug 'tpope/vim-fugitive'
Plug 'google/vim-maktaba'
Plug 'google/vim-codefmt'
Plug 'google/vim-glaive'
Plug 'iangmiao/auto-pairs'
Plug 'fatih/vim-go'
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } }
Plug 'jiangmiao/auto-pairs'
call plug#end()
call glaive#Install()
colorscheme jellybeans
" Make explore behave like nerdtree
map <F8> :Explore<CR>
let g:netrw_bufsettings = 'noma nomod nu nowrap ro nobl'
let g:netrw_liststyle = 3
set wildmenu
set wildmode=longest:full,full
set number
set incsearch
set hlsearch
set ignorecase
set smartcase
set lazyredraw
set cursorline
set showmatch
set autowrite
set autoread
" make backspace work as expected
set bs=2
" set up folding
set foldenable
set foldlevelstart=99
set foldnestmax=10
set foldmethod=syntax
nnoremap <space> za
" Enable mouse/trackpad scrolling
set mouse=a
map <ScrollWheelUp> k
map <ScrollWheelDown> j
" always move through visible lines instead of real lines (for text wrapping)
nnoremap j gj
nnoremap k gk
" make ; into : because I never use ; anyway
map ; :
" Formatting setup
augroup autoformat_settings
" autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,proto,javascript AutoFormatBuffer clang-format
" autocmd FileType dart AutoFormatBuffer dartfmt
" autocmd FileType go AutoFormatBuffer gofmt
" autocmd FileType gn AutoFormatBuffer gn
autocmd FileType html,css,sass,scss,less,json AutoFormatBuffer js-beautify
" autocmd FileType java AutoFormatBuffer google-java-format
" autocmd FileType python AutoFormatBuffer yapf
" Alternative: autocmd FileType python AutoFormatBuffer autopep8
autocmd FileType vue AutoFormatBuffer prettier
augroup END
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
let g:UltiSnipsSnippetDirectories=["UltiSnips", "custom-snippets"]
" <c-h/j/k/l> through splits
map <c-h> <c-w>h
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
set updatetime=100
" making whitespace characters visible
set list
set listchars=space:·,eol:⏎,tab:→\
" put all swapfiles in 1 place
set swapfile
set dir=~/.vimswp
" quick find/replace
map rn :%s/\(<c-r>=expand("<cword>")<cr>\)/
" Tags hotkeys
map <F9> :BTags<CR>
map <F10> :Tags<CR>
"Make yaml files fold via indent
:autocmd BufRead,BufNewFile *.yml set foldmethod=indent
:autocmd BufRead,BufNewFile *.yaml set foldmethod=indent
:autocmd Filetype *.yml setlocal tabstop=2
:autocmd Filetype *.yaml setlocal tabstop=2
" Preserve newlines in files without them
:set nofixendofline
" Make fzf.vim commands open full screen by default
:cabbrev FZF FZF!
:cabbrev Files Files!
:cabbrev GitFiles GitFiles!
:cabbrev GFiles GFiles!
:cabbrev Buffers Buffers!
:cabbrev Lines Files!
:cabbrev BLines BLines!
:cabbrev Colors Colors!
:cabbrev Locate Locate!
:cabbrev Ag Ag!
:cabbrev Rg Rg!
:cabbrev Tags Tags!
:cabbrev BTags BTags!
:cabbrev Snippets Snippets!
:cabbrev Commands Commands!
:cabbrev Marks Marks!
:cabbrev Helptags Helptags!
:cabbrev Windows Windows!
:cabbrev Commits Commits!
:cabbrev BCommits BCommits!
:cabbrev Maps Maps!
:cabbrev Filestypes Filestypes!
:cabbrev History History!
" use goimports instead of gofmt for vim-go
let g:go_fmt_command = "goimports"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment