Skip to content

Instantly share code, notes, and snippets.

@wakatara
Last active January 3, 2018 15:54
Show Gist options
  • Save wakatara/52dee877afbee33f510f817629b7aa78 to your computer and use it in GitHub Desktop.
Save wakatara/52dee877afbee33f510f817629b7aa78 to your computer and use it in GitHub Desktop.
.vimrc @ 20180103
set nocompatible
filetype off
set clipboard=unnamed
set hidden
set nospell
set noshowmode
call plug#begin()
" Chrome
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'edkolev/tmuxline.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'lifepillar/vim-solarized8'
" IDE buffs
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'airblade/vim-gitgutter'
Plug 'godlygeek/tabular'
Plug 'mbbill/undotree'
Plug 'skwp/greplace.vim'
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'jiangmiao/auto-pairs'
Plug 'Yggdroot/indentLine'
Plug 'w0rp/ale'
Plug 'roxma/nvim-completion-manager'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" App replace buffs
" Writeroom
Plug 'junegunn/goyo.vim'
" Notational Velocity
Plug 'Alok/notational-fzf-vim'
" Lang and framework buffs
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-endwise'
" Plug 'elixir-lang/vim-elixir'
" Plug 'mattreduce/vim-mix', {'for': 'elixir'}
Plug 'tpope/vim-rails'
Plug 'c-brenn/phoenix.vim'
Plug 'tpope/vim-projectionist'
Plug 'slashmili/alchemist.vim'
Plug 'fatih/vim-go'
Plug 'ElmCast/elm-vim', {'for': 'elm'}
Plug 'posva/vim-vue'
Plug 'ap/vim-css-color'
Plug 'ekalinin/Dockerfile.vim'
Plug 'roxma/ncm-elm-oracle'
Plug 'roxma/ncm-rct-complete'
Plug 'roxma/nvim-cm-tern', {'do': 'npm install'}
Plug 'Shougo/neco-syntax'
Plug 'othree/csscomplete.vim'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Add plugins to &runtimepath
call plug#end()
" Default colour scheme and colour gui
" set t_Co=256
syntax enable " Turn on syntax highlighting allowing local overrides
set background=dark
colorscheme solarized
" Airline and tmuxline config
set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline_theme='solarized'
" let g:airline_theme = 'tender'
let g:airline_detect_spell=0
let g:airline_skip_empty_sections = 1
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V',
\ '' : 'V',
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ }
let g:airline_section_y = ""
let g:airline#extensions#default#layout = [
\ [ 'a', 'b', 'c' ],
\ [ 'x', 'error', 'warning', 'y', 'z' ]
\ ]
filetype plugin indent on
"Set some sensible defaults on things
let mapleader = ',' " Remap leader to comma
set number " Show line numbers
set ruler " Show line and column number
set encoding=utf-8 " Set default encoding to UTF-8 - removed 20161029 as
" breaking Neovim
set spell spelllang=en_ca
" set temporary directory (don't litter local dir with swp/tmp files)
set directory=/tmp/
" Whitespace
" set nowrap
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set list " Show invisible characters
set backspace=indent,eol,start " backspace through everything in insert mode
" List chars
set listchars="" " Reset the listchars
set listchars=tab:\ \ " a tab should display as " ", trailing whitespace as "."
" set listchars+=trail:. " show trailing spaces as dots
set listchars+=extends:> " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set listchars+=precedes:< " The character to show in the last column when
" wrap is off and the line continues beyond
" the right of the screen
" Disable Ex command mode
:nnoremap Q <Nop>
"Disable macro recording mode
:nnoremap q <Nop>
" Splits
noremap <silent> <C-w>\ <C-w>v
noremap <silent> <C-w>- <C-w>s
set splitbelow
set splitright
noremap <silent><C-q> <C-w>q
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
map <CR> :nohl<cr>
" NERDTree config
nnoremap <silent><C-\> :NERDTreeToggle<CR>
" automatically opens directories with NERDTree ie. vim .
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
"closes NERDTree if it is the only window left open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" disable netrw
let loaded_netrwPlugin = 1
" FZF config
" Added 2017-09-08
noremap <silent><C-p> :Files<CR>
" Use ripgrep instead of ag:
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
noremap <C-g> :Rg
" Notational FZF
let g:nv_search_paths = ['~/redacted']
nnoremap <silent> <C-n> :NV<CR>
let g:nv_default_extension = '.md'
let g:nv_use_short_pathnames = 1
" let g:nv_show_filepath = 0
" let g:nv_show_preview = 1
" let g:nv_preview_width = 72
" let g:nv_wrap_preview_text = 0
" TComment config
map <silent> <C-c> :TComment<cr>
noremap <silent> <Leader>cc :TComment<cr>
noremap <silent> <Leader>cr :TCommentRight<cr>
" Greplace config with Ag -
" Use :Gsearch
" Make replacements in buffer using (%s/foo/bar/)
" Use :Greplace to change files. Asks y/n/a interatively
" Save changes with :wall (write all)
set grepprg=ag
let g:grep_cmd_opts = '--line-numbers --noheading'
" Alchemist tag disable in 20161123
" let g:alchemist_tag_disable = 1
" Cursor location crosshair
set cul
" set cuc
" Ale configuration
let g:ale_linters = {'javascript': ['eslint'],}
let g:airline#extensions#ale#enabled = 1
let g:elm_format_autosave = 1
let g:ale_completion_enabled = 1
let g:ale_sign_error = '🔥'
let g:ale_sign_warning = '__'
" UltiSnips config
let g:UltiSnipsExpandTrigger="<TAB>"
let g:UltiSnipsJumpForwardTrigger="<TAB>"
let g:UltiSnipsJumpBackwardTrigger="<S-TAB>"
" vim-markdown config
let g:vim_markdown_conceal = 0
"Added in Goyo 2015-08-18
map <silent><C-y> :Goyo<cr>
" Added in UndoTree 2015-08-16
nnoremap <silent><C-u> :UndotreeToggle<cr>
if has("persistent_undo")
set undodir=~/.vim_undodir/
set undofile
endif
" Inserts a magenta column if slopping over 80 columns
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%82v', 100)
" Make indenting and outdenting easier
nnoremap <C-k> <<
nnoremap <C-l> >>
vnoremap <C-k> <gv
vnoremap <C-l> >gv
" Useful file helpers and functions
" Neovim Completion Manager
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Markdown
autocmd BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} setlocal textwidth=72
" Text files too
autocmd BufRead,BufNewFile *.{txt,text} setlocal textwidth=72 filetype=markdown
" css Omnifunc completion for csscomplete#CompleteCSS
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS noci
" Thorfile, Rakefile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Thorfile,config.ru} set ft=ruby
" make make use real tabs
au FileType make set noexpandtab
" Elixir
autocmd BufWritePost *.exs silent :!mix format %
autocmd BufWritePost *.ex silent :!mix format %
" Erlang
augroup erlang
au!
au BufNewFile,BufRead *.erl setlocal tabstop=4
au BufNewFile,BufRead *.erl setlocal shiftwidth=4
au BufNewFile,BufRead *.erl setlocal softtabstop=4
au BufNewFile,BufRead relx.config setlocal filetype=erlang
augroup END
augroup python_files
autocmd!
autocmd FileType python setlocal noexpandtab
autocmd FileType python set tabstop=4
autocmd FileType python set shiftwidth=4
augroup END
augroup Javascript
autocmd FileType javascript setlocal shiftwidth=4
autocmd FileType javascript setlocal tabstop=4
autocmd FileType javascript setlocal softtabstop=4
augroup END
" Strips trailing whitespace out of files on save
autocmd BufWritePre * :%s/\s\+$//e
" Added 2015-03-17 for autoreloading the .vimrc
au BufWritePost .vimrc so $MYVIMRC
" Added 2015-03-17 for not messing up crontab -e
au BufEnter /private/tmp/crontab.* setl backupcopy=yes
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Rename function to rename, save and remove old file
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <Leader>re :call RenameFile()<cr>
" Zoom / Restore window.
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <C-w>z :ZoomToggle<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment