Skip to content

Instantly share code, notes, and snippets.

@jbott
Created May 21, 2019 18:01
Show Gist options
  • Save jbott/290901b1d08ad249cf9c48a34f881f6e to your computer and use it in GitHub Desktop.
Save jbott/290901b1d08ad249cf9c48a34f881f6e to your computer and use it in GitHub Desktop.
Dotfiles
" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim
if &t_Co > 2 || has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
packadd! matchit
endif
" ----- Plugins ----- "
call plug#begin('~/.vim/plugged')
" UI
Plug 'ap/vim-buftabline'
" Switch between buffers using ctrl-h/ctrl-l
nnoremap <C-H> :bprev<CR>
nnoremap <C-L> :bnext<CR>
Plug 'ntpeters/vim-better-whitespace'
" Languages
Plug 'elixir-editors/vim-elixir'
Plug 'fatih/vim-go'
Plug 'rust-lang/rust.vim'
" Auto format on save
let g:rustfmt_autosave = 1
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
" Utility shortcuts
Plug 'junegunn/vim-easy-align'
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
nnoremap <C-P> :Files<CR>
nnoremap <silent> <Leader>rg :Rg <C-R><C-W><CR>
fu! RgCurrWord()
let currWord = expand('<cword>')
if len(currWord) > 0
call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(currWord), 1, 0)
else
execute ':Rg'
endif
endfu
command! -nargs=0 Ag call RgCurrWord()
cnoreabbrev ag Ag
call plug#end()
" ----- Defaults ----- "
set nobackup " do not keep a backup file
set expandtab " Use spaces
set tabstop=4 shiftwidth=4 " set to 4 spaces
set smartcase ignorecase " Search using smart casing
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set modeline modelines=5 " Allow modeline in the first 5 lines of a file
set autoindent " always set autoindenting on
set hidden " Hides last buffer
" ----- Colors ----- "
colorscheme delek
" ----- Autocmd ----- "
" Always start git commit messages with the cursor at the start
autocmd FileType gitcommit call setpos('.', [0, 1, 1, 0])
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment