-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
241 lines (202 loc) · 7.37 KB
/
vimrc
File metadata and controls
241 lines (202 loc) · 7.37 KB
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
syntax on
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/plugin/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'Townk/vim-autoclose'
Plugin 'altercation/vim-colors-solarized'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'mtth/scratch.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'skwp/greplace.vim'
Plugin 'tmux-plugins/vim-tmux-focus-events'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-obsession'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'luochen1990/rainbow'
Plugin 'github/copilot.vim'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" ************ Begin Config ************ "
" Line numbers
:set number relativenumber
nmap ,l :set nonumber norelativenumber<CR>:sleep 5000m<CR>:set number relativenumber<CR>
" Automatically toggle between absolute and hybrid numbers automatically based on mode
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"Turn numbers off
nmap ,nl :set nonumber norelativenumber<CR>
" Highlight everything that matches the pattern
:set hlsearch
nmap // :noh<Enter>
" Highlight the current line
set cursorline
" No Swap Files
set noswapfile
set ts=2
set sw=2
set expandtab
set autoindent
set cindent
" https://vi.stackexchange.com/a/2163
" Influences the working of `<BS>`, `<Del>`, `CTRL-W` and `CTRL-U` in Insert
" mode. This is a list of items, separated by commas. Each item allows
" a way to backspace over something:
"
" value effect
" indent allow backspacing over autoindent
" eol allow backspacing over line breaks (join lines)
" start allow backspacing over the start of insert; CTRL-W and CTRL-U stop once at the start of insert.
set backspace=indent,eol,start
set autoread
" ************ Begin Split Config ************ "
" Easier Split Movement
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Make Splits Open Below and to the Right
set splitbelow
set splitright
" Set default and minimum size for splits
set winheight=30
set winminheight=5
" set winwidth=128
set winminwidth=10
" Faster resizing of splits
nnoremap <silent> + :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> - :exe "resize " . (winheight(0) * 2/3)<CR>
nnoremap <silent> } :exe "vertical resize" . (winwidth(0) * 3/2)<CR>
nnoremap <silent> { :exe "vertical resize" . (winwidth(0) * 2/3)<CR>
" Open Splits
nmap vv :vsplit<Enter>
nmap ss :split<Enter>
" Open Split in a new Tab
nmap <c-o> :tab sp<Enter>
" Close Tab
nmap <C-c> <C-W>c
" Set line wrapping
set wrap linebreak
set showbreak=+++
" ************* End Split Config ************* "
function! Rtags()
execute "! ctags -R"
endfunction
command! Rtags call Rtags()
" ************* Start Whitespace Commands ************* "
command! ShowWhitespace :set list | :set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»
command! HideWhitespace :set nolist
command! ToggleWhitespace :set list!
" ************* End Whitespace Commands ************* "
" Copy what was just yanked to the system clipboard with ,cc
nnoremap <leader>cc :call system('pbcopy', @0)<CR>
" Configure airline
set laststatus=2 " Always show airline-powerline
" let g:airline_theme='powerlineish' " Set airline-powerline theme.
let g:airline_theme='solarized' " Set airline-solarized theme.
let g:airline_detect_modified = 1 " Allow airline to detect modified files.
let g:airline_powerline_fonts = 1 " Populate powerline fonts.
let g:airline_solarized_normal_green = 1
let g:airline_solarized_dark_inactive_border = 1
let g:airline_solarized_bg = 'light'
let g:solarized_termcolors = 256
let g:airline#extensions#branch#displayed_head_limit = 10 "Truncate long branch names to 10 characters.
" Set Up Solarized
set background=dark
set t_Co=256
" This setting seems to have stopped working. Here is some info.
" https://github.com/altercation/vim-colors-solarized/issues/138
let g:solarized_termcolors=256
let g:solarized_contrast = "high"
let g:solarized_visibility= "high"
let g:solarized_termtrans = 1
colorscheme solarized
" Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
" Highlight too long lines
let w:m2=matchadd('ErrorMsg', '\%>150v.\+', -1)
au BufWinEnter *.rb let w:m2=matchadd('ErrorMsg', '\%>150v.\+', -1)
" Clear highlighting with :call clearmatches()
" Trim Trailing Whitespace on Save
autocmd BufWritePre * :%s/\s\+$//e
" File auto-complete until ambiguity
set wildmenu
set wildmode=list:longest
" Scratch Config
let g:scratch_autohide = 1
let g:scratch_top = 0
let g:scratch_horizontal = 0
" NERDTree
nmap ,n :NERDTreeToggle<CR>
nmap ,f :NERDTreeFind<CR>
let g:NERDTreeNodeDelimiter = "\u00a0"
" let NERDTreeWinSize=45
" Close vim if the only window left open is NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" CtrlP
" Remap to ,t
let g:ctrlp_map = ',t'
nnoremap <silent> ,t :CtrlPMixed<CR>
" Remap to ,b
nnoremap <silent> ,b :CtrlPBuffer<cr>
" Ignore VCS files
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
" Default to filename searches - so that appctrl will find application controller
let g:ctrlp_by_filename = 1
" copy current filename into system clipboard - mnemonic: (c)urrent(f)ilename
" this is helpful to paste someone the path you're looking at
nnoremap <silent> ,cf :let @* = expand("%:~")<CR>
nnoremap <silent> ,cn :let @* = expand("%:t")<CR>"
" abbreviations for commonly written code segments.
iabbrev IT it '' do<CR>end
iabbrev CONT context '' do<CR>end
iabbrev DESC describe '' do<CR>end
iabbrev pry binding.pry
" Rainbow Parens
let g:rainbow_active = 1
au VimEnter * RainbowToggleOn
" Format JSON Pretty
nmap =j :%!python -m json.tool<CR>
" Set syntax highlighting for weird extentions.
au BufRead *.hbs set syntax=javascript
au BufRead *.ejs set syntax=javascript
au BufRead *.rabl set syntax=ruby
au BufRead *.rb set syntax=ruby
" flash the line that contains the cursor
" map ; :set cursorline<CR>:set cursorcolumn<CR>:sleep 100m<CR>:set nocursorline<CR>:set nocursorcolumn<CR>
" ************ Begin CoPilot Config ************ "
autocmd BufReadPre *
\ let f=getfsize(expand("<afile>"))
\ | if f > 100000 || f == -2
\ | let b:copilot_enabled = v:false
\ | endif
" ************* End CoPilot Config ************* "