-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
389 lines (343 loc) · 12.8 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
" vim:fdm=indent
"SETTINGS AND VARIABLES
"======================
"
"Plugin Variables
let g:NERDTreeShowBookmarks = 1
let g:tagbar_left = 1
let g:tagbar_autoshowtag = 1
let g:lucius_style='blue'
let g:liquidcarbon_high_contrast = 1
let g:indent_guides_enable_on_vim_startup = 1
let g:LustyJugglerSuppressRubyWarning = 1
let g:pyflakes_use_quickfix = 0
python << EOF
import os.path, vim
paths = {
"/home/jngeist": "a2ssh",
"/home/joshuag": "cossh",
"/Users/jngeist": "laptop",
"/Users/joshuag": "cos",
"/Users/mysphyt": "home",
}
home = vim.eval("$HOME")
if home in paths:
vim.command("let g:NERDTreeBookmarksFile = '" + home + "/.vim/bookmarks/" + paths[home] + "_bookmarks'")
EOF
" Clear Autocommands
au!
"Load Pathogen
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
filetype plugin indent on
"Basic vim settings
"Enable syntax highlighting
syntax on
set background=dark
set nocompatible "No vi compatible mode.
set backupdir=~/.vim/backup " By default, vim creates backups for every file
" edited, so you get your project littered w/ filename.ext~ files. This puts
" them all in a hidden .backup directory.
set directory=/tmp " Ditto filename.ext.swp files; necessary for vim to
" work right, but you don't want them cluttering up your project directory.
set history=100 " command history = 100
set showcmd " display incomplete commands
set hidden " allows for hidden buffers
set number
set textwidth=80
set wrapmargin=2
set linebreak
let &showbreak='└─'
set enc=utf-8
set listchars=trail:.,tab:>-,eol:$
set nolist
set anti " font antialiasing
set guioptions=egmLt
set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
set clipboard+=unnamed
set wmh=0 " allows one-line window height
set noea " doesn't resize all windows on split.
set autoread " reload files that have changed in filesystem but not in vim
set gfn=DejaVuSansMono:h10
set modeline
set shell=/bin/bash
"Editing Settings
set backspace=indent,eol,start "allow backspacing over everything in insert mode
set spelllang=en_us "spelling in English
" Tabs
set tabstop=4 " with of tab char = 4
set softtabstop=4
set shiftwidth=4 " width of indent w/ >: 4
set expandtab
set showmatch " highlight matching bracket/parent/etc
set incsearch " do incremental searching
set ignorecase " ignore case in searching, unless
set smartcase " search string includes uppercase characters
" Statusline
set statusline=%{StatuslineMagicFlags()}
set statusline+=%f "tail of the filename
set statusline+=%h "help file flag
set statusline+=%y "filetype
set statusline+=%r "read only flag
" display current git branch
set statusline+=%{fugitive#statusline()}
"display a warning if &paste is set
set statusline+=%#error#
set statusline+=%{&paste?'[paste]':''}
set statusline+=%*
set statusline+=%= "left/right separator
set statusline+=%-4{StatuslineCurrentHighlight()}
set statusline+=\ L:%l/%L "cursor line/total lines
set statusline+=\ (%P) "percent through file
set laststatus=2 " Always show status line
" Statusline Function: Display Highlight Group
function! StatuslineCurrentHighlight()
let name = synIDattr(synID(line('.'),col('.'),1),'name')
if name == ''
return ''
else
return '[' . name . ']'
endif
endfunction
function! StatuslineMagicFlags()
if &mod == 1
return '[+] '
else
return ' '
endif
endfunction
" Folding
" Spacebar opens folds.
map <Space> za
map <Space><Space> zA
set foldenable " Turn on folding
set foldmarker={,} " Fold C style code (only use this as default
set foldmethod=marker " Fold on the marker
set foldlevel=100 " Don't autofold anything (but I can still
set foldopen=block,hor,mark,percent,quickfix,tag " what movements
set foldcolumn=4
"Folding function: text for fold headers
function! SimpleFoldText() "
return getline(v:foldstart).' '
endfunction " }
set foldtext=SimpleFoldText() " Custom fold text function
" Mappings
let mapleader = "," "Leader key mapped to , . (Leader is basically a custom meta key, so you can define commands to <Leader><Whatever>
" Toggle invisible chars
noremap <Leader>i :set list!<CR>
imap jj <Esc>
nmap oo :put =''<CR>
nmap OO :put! =''<CR>
nmap // :noh<CR>
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-L> <C-W>l
map <C-H> <C-W>h
map H ^
map L $
map Y y$
nmap <Leader>yf :let @* = expand("%:p")<CR>
nmap <CR> <C-]>
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
nnoremap <tab> %
vnoremap <tab> %
nnoremap j gj
nnoremap k gk
map Q gq
map <Leader><CR> i<CR><ESC>k$
map <Leader>rp :RainbowParenthesesToggle<CR>
map <Leader>nt :NERDTreeToggle<CR>
map <Leader>l :TagbarToggle<CR>
map <Leader>. :call AddNote()<CR>
map <Leader><tab> :LustyJuggler<CR>
noremap <Leader>t :CommandT<CR>
map <Leader>cd :lcd `dirname '%:p'`<CR>
map <Leader>gd :set ft=htmldjango<CR>
map <Leader>gm :set ft=mmd<CR>
map <Leader>gi :call InvisModeToggle()<CR>
map <Leader>gf :call FocusModeToggle()<CR>
" Terminal Settings
" ====================
" Use mouse
if has('mouse')
set mouse=a
endif
" Up colors for teminal emulators
if &t_Co > 2
let &t_Co = 256
colors molokai
else
let g:solarized_hitrail=1
colorscheme solarized
endif
" Turn off cursor marking for non-gui clients
if has("gui_running") == 0
set nocursorline
set nocursorcolumn
endif
syntax on
" Autocommands
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
au FileType mmd map <leader>mp :silent ! open -a Marked.app "%:p"<CR>
au FileType mmd map <leader>op :silent ! mmd.sh -p "%:p"<CR>
au FileType mmd map <leader>ob :silent ! mmd.sh -b "%:p"<CR>
au FileType mmd nmap <Leader>yh :silent redir @*><CR>:silent! !/usr/local/bin/multimarkdown "%:p"<CR>:silent redir END<CR>:echo "HTML yanked."<CR>
au FileType mmd nmap <Leader>gh :%!/usr/local/bin/multimarkdown<CR>
au FileType mmd setlocal linespace=8
au FileType mmd setlocal spell
au BufWritePre *.mmd call UpdateWordCount()
au BufWritePost *.mmd let v:statusmsg = WordCount()
au InsertLeave *.mmd exe "colors " . g:colors_name
au BufWritePost *.scss call SassDump()
au FileType python set fdm=indent
" Omni Completion
autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" Various functions
function! WordCount()
normal mcgg
let firstblank = search('^$')
if firstblank
if search('[^ ]\+', "nW")
exe "silent " . firstblank . ",$s/[^ ]\\+//gn"
let wordcount = str2nr(split(v:statusmsg)[0])
else
let wordcount = 0
endif
else
let wordcount = 0
endif
normal `c
return wordcount
endfunction
function! UpdateWordCount()
let wordcount = WordCount()
normal mcgg
let countline = search('^Word Count\s*:', 'w')
if countline
exe countline . "," . countline . "s/\\d\\+ *$/" . wordcount . "/"
endif
normal `c
endfunction
function! SassDump()
"silent call StripSassConstants()
if strpart(expand("%:t"), 0, 1) != "_"
silent! !sass --update "%:p"
echo expand("%<") . ".scss updated."
endif
endfunction
function! StripSassConstants()
normal mcgg
let firstnonvar = search("^[^$]", "wn")
while line(".") < firstnonvar
let line = getline(line('.'))
let varname = substitute(line, "^\\(\\$\\w*\\):.*", "\\1", "")
let varval = substitute(line, "^.*:\\s*\\(.*\\);", "\\1", "")
exec firstnonvar . ",$s/" . varval . "/" . varname . "/ge"
normal j
endwhile
normal `c
endfunction
function! Push(message)
exec "!git commit -a -m \"" . a:message . "\""
!git push
endfunction
command! -nargs=1 Push call Push(<args>)
function! AddNote()
silent normal ma"byi]
if search("^[" . getreg("b") . "\\]:\\s\\+" . getreg("*"), "n")
echo "Marker " . getreg("b") . " already exists for " . getreg("*")
elseif search("^[" . getreg("b") . "\\]:", "n")
echo "Marker " . getreg("b") . " is a duplicate. Please choose another."
else
let action = "\<C-R>*\<ESC>`a"
let startchar = strpart(getreg("b"), 0, 1)
if startchar == "^"
let tag = "FOOTNOTES"
let action = ''
elseif startchar == "#"
let tag = "SOURCES"
else
let tag = "LINKS"
endif
if ! search("<!--" . tag . "-->")
exe "silent normal Go\<CR><!--" . tag . "-->\<ESC>"
exe "silent normal A\<CR>\<CR><!--END" . tag . "-->\<ESC>kk"
endif
exe "silent normal A\<CR>\<CR>[\<C-R>b]: " . action
if action == ''
echo "`a to return to marker."
else
echo getreg("*") . " added to " . tag . " as [" . getreg("b") . "]."
endif
endif
endfunction
function! GetColors()
redir => hiline
silent hi normal
redir END
let bgcolor = substitute(hiline, ".*guibg=\\(\\S*\\).*", "\\1", "")
let fgcolor = substitute(hiline, ".*guifg=\\(\\S*\\).*", "\\1", "")
let cbgcolor = substitute(hiline, ".*ctermbg=\\(\\S*\\).*", "\\1", "")
let cfgcolor = substitute(hiline, ".*ctermfg=\\(\\S*\\).*", "\\1", "")
redir => cline
silent hi CursorLine
redir END
let clcolor = substitute(cline, ".*guibg=\\(\\S*\\).*", "\\1", "")
let cclcolor = substitute(cline, ".*ctermbg=\\(\\S*\\).*", "\\1", "")
return {'bgcolor': bgcolor, 'fgcolor': fgcolor, 'cbgcolor': cbgcolor, 'cfgcolor': cfgcolor, 'clcolor': clcolor, 'cclcolor': cclcolor}
endfunction
function! FocusModeToggle()
silent exe "colorscheme " . g:colors_name
if exists("b:prosemode") && b:prosemode == "focus"
let b:prosemode = "none"
else
let b:prosemode = "focus"
let colors = GetColors()
if has("gui_running") == 0
exe "hi Normal ctermfg=" . colors["cbgcolor"]
exe "hi CursorLine ctermfg=" . colors["cfgcolor"] . " ctermbg=" . colors["cclcolor"]
setlocal cursorline
else
exe "hi Normal guifg=" . colors["bgcolor"]
exe "hi CursorLine guibg=" . colors["clcolor"] . " guifg=" . colors["fgcolor"]
setlocal cursorline
endif
endif
endfunction
function! InvisModeToggle()
silent exe "colorscheme " . g:colors_name
if exists("b:prosemode") && b:prosemode == "invis"
let b:prosemode = "none"
else
let colors = GetColors()
if has("gui_running") == 0
" Hack - black bc I can't get this working right.
exe "hi Normal ctermfg=" . colors["cclcolor"]
exe "hi CursorLine ctermfg=" . colors["cfgcolor"] . " ctermbg=" . colors["cfgcolor"]
setlocal cursorline
else
exe "hi Normal guifg=" . colors["bgcolor"]
exe "hi CursorLine guifg=" . colors["clcolor"] . " guibg=" . colors["clcolor"]
setlocal cursorline
endif
let b:prosemode = "invis"
endif
endfunction
" Stuff to sort through:
"map <leader>p <Esc>:%!json_xs -f json -t json-pretty<CR>