-
Notifications
You must be signed in to change notification settings - Fork 3
/
.vimrc
249 lines (220 loc) · 8.66 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
" vim:set ts=2 sts=2 sw=2 expandtab:
set nocompatible " don't bother with vi compatibility
syntax enable " enable syntax highlighting
let mapleader = ' '
set hidden " allow unsaved background buffers and remember marks/undo for them
set autoindent
set autoread " reload files when changed on disk, i.e. via `git checkout`
set backspace=2 " Fix broken backspace in some setups
set backupcopy=yes " see :help crontab
if $TMUX == ''
set clipboard+=unnamed
endif
set cursorline " highlight current line
set diffopt+=vertical " prefer vertical split when diffing files
set directory-=. " don't store swapfiles in the current directory
set encoding=utf-8
set expandtab " expand tabs to spaces
set hlsearch
set ignorecase " case-insensitive search
set incsearch " search as you type
set laststatus=2 " always show statusline
set showtabline=2 " always show tab bar
set list " show trailing whitespace
set listchars=tab:▸\ ,trail:▫
set nowrap
set number " show line numbers
set ruler " show where you are
set scrolloff=3 " show context above/below cursorline
set shell=/bin/bash
set shiftwidth=2 " normal mode indentation commands use 2 spaces
set showcmd
set showmatch " jump to matching brackets on insertion
set smartcase " case-sensitive search if any caps
set softtabstop=2 " insert mode tab and backspace use 2 spaces
set tabstop=8 " actual tabs occupy 8 characters
set tags=./tags; " start with current file's directory for tags file search, then move up. See http://vim.wikia.com/wiki/Browsing_programs_with_tags
set timeoutlen=250 ttimeoutlen=0 " speed
set t_ti= t_te= " Prevent Vim from clobbering the scrollback buffer. See http://www.shallowsky.com/linux/noaltscreen.html
set wildignore=log/**,node_modules/**,target/**,tmp/**,*.rbc
set wildmenu " show a navigable menu for tab completion
set wildmode=longest,list,full
" Modelines (comments that set vim options on a per-file basis)
set modeline
set modelines=3
" Completion options.
" menu: use a popup menu
" preview: show more info in menu
set completeopt=menu,preview
" Enable basic mouse behavior such as resizing buffers.
set mouse=a
if exists('$TMUX') && !has('nvim') " Support resizing in tmux
set ttymouse=xterm2
endif
" plugin configuration
filetype on " without this vim emits a zero exit status, later, because of :ft off
filetype off
call plug#begin('~/.vim/plugged')
Plug 'Alok/notational-fzf-vim'
Plug 'LnL7/vim-nix'
Plug 'austintaylor/vim-indentobject'
Plug 'edkolev/tmuxline.vim'
Plug 'francoiscabrol/ranger.vim'
Plug 'junegunn/fzf.vim'
Plug 'morhetz/gruvbox'
Plug 'mtth/scratch.vim'
Plug 'rbgrouleff/bclose.vim'
Plug 'sbdchd/neoformat'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-vinegar'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
filetype plugin indent on
" keyboard shortcuts
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
nmap <leader><space> :call whitespace#strip_trailing()<CR>
map <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
map <leader>w :w!<cr>
nmap <leader>fm :Neoformat<cr>
inoremap jk <ESC>
" file & buffer management
if (isdirectory(".git"))
nmap <leader>t :GitFiles --cached --others --exclude-standard<cr>
else
nmap <leader>t :FZF<cr>
endif
nmap <leader>a :Find!<Space>
nmap <leader>e :FZF<cr>
nmap <leader>r :Buffers<cr>
nmap <leader>T :enew<cr>
nmap <leader>l :bnext<cr>
nmap <leader>h :bprevious<cr>
nmap <leader>bq :bp <bar> bd #<cr>
nmap <leader>bl :ls<cr>
" command management
nmap <leader>p :Commands<cr>
" color setup
:set t_Co=256 " 256 colors
set background=dark
try
let g:gruvbox_termcolors=16
let g:gruvbox_contrast_dark = 'hard'
colorscheme gruvbox
catch /^Vim\%((\a\+)\)\=:E185/
color aps256
endtry
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
" Toggling cursor shape based on insert-mode versus normal-mode
" ---
" tmux and iTerm2 cursor fun
" via @andyfowler https://gist.github.com/1195581
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" plugin settings
let g:NERDSpaceDelims=1
let g:gitgutter_enabled = 0
" fdoc is yaml
autocmd BufRead,BufNewFile *.fdoc set filetype=yaml
" md is markdown
autocmd BufRead,BufNewFile *.md set filetype=markdown
" automatically rebalance windows on vim resize
autocmd VimResized * :wincmd =
" ruby files
autocmd BufNewFile,BufRead Gemfile set filetype=ruby
autocmd BufNewFile,BufRead Podfile set filetype=ruby
autocmd BufNewFile,BufRead *.ru set filetype=ruby
" gradle
autocmd BufNewFile,BufRead *.gradle setf groovy
" handlebars & erb
autocmd BufRead,BufNewFile *.{handlebars,handlebars.erb,hbs,hbs.erb} setl ft=html syntax=mustache
if filereadable(".vim.custom")
so .vim.custom
endif
" Configure for a nicer prose writing environment
nnoremap <leader>P :call ProseToggle()<cr>
command! Prose :call ProseToggle()
let g:prose_is_toggled = 0
function! ProseToggle()
if g:prose_is_toggled
set nowrap
nunmap j
nunmap k
let g:prose_is_toggled = 0
else
set wrap linebreak nolist
noremap j gj
noremap k gk
let g:prose_is_toggled = 1
endif
endfunction
" Send last yanked text to clipper – https://github.com/wincent/clipper
nnoremap <leader>y :call system('nc localhost 8377', @0)<CR>
"" spelling
" Good tips found here: https://robots.thoughtbot.com/opt-in-project-specific-vim-spell-checking-and-word-completion
"
" ## Commands
"
" - z= get spelling suggestions when cursor is placed over word
" - zg add misspelling to dictionary file
" - [s ]s navigate across misspellings
"
autocmd BufRead,BufNewFile *.md set filetype=markdown
" Spell-check Markdown files
autocmd FileType markdown setlocal spell
" Spell-check Git messages
autocmd FileType gitcommit setlocal spell
" jsx
let g:jsx_ext_required = 0
" Set spellfile to location that is guaranteed to exist,
" can be symlinked to Dropbox or kept in Git
" and managed outside of thoughtbot/dotfiles using rcm.
set spellfile=$HOME/.vim-spell-en.utf-8.add
" Autocomplete with dictionary words when spell check is on
set complete+=kspell
" fzf
" https://github.com/junegunn/fzf
if (isdirectory('/opt/homebrew'))
" source fzf from the /opt homebrew installation
set rtp+=/opt/homebrew/opt/fzf
else
set rtp+=/usr/local/opt/fzf
endif
command! -bang -nargs=* Find
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --follow --color=always --hidden --no-ignore-vcs -g "!{node_modules,.git}" '.<q-args>.' || true',
\ 1, <bang>0 ? fzf#vim#with_preview('up:60%') : fzf#vim#with_preview('right:50%:hidden', '?'), <bang>0
\ )
" nvALT replacement
" https://github.com/Alok/notational-fzf-vim
let g:nv_search_paths = ['~/Documents/notes']
let g:nv_use_short_pathnames = 1
nnoremap <leader>s :NV<CR>
" Airline
let g:airline_powerline_fonts = 1
let g:airline_theme='gruvbox'
" Ranger
let g:ranger_map_keys = 0
let g:NERDTreeHijackNetrw = 0
let g:ranger_replace_netrw = 1
set signcolumn=no
if has("gui_vimr")
" Here goes some VimR specific settings like
set guifont=JetBrainsMono\ Nerd\ Font\ Mono:h13
endif