-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
245 lines (191 loc) · 5.73 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
set nocompatible
call pathogen#infect()
set nowrap
set showmatch
set autoindent
filetype indent on
set wildmode=longest,list
set wildignore+=*.pyc
set textwidth=150
set ignorecase
set smartcase
set incsearch
set gdefault
set ssop=buffers,winsize
set iskeyword+=-,@ " none of these are word dividers
syn on
set hlsearch
set hidden
set cursorline
set cursorcolumn
set scrolloff=3
set sidescrolloff=3
set relativenumber
"detect indent auto switch between tab and space indentation
set tabstop=4
set shiftwidth=4
set expandtab
"highlight bash scripts posix compliant
let g:is_posix = 1
" Save undo/redos
set undofile
set undodir=~/.vimbackup
set directory=~/.vimswp
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
"autocmd FileType python setlocal foldmethod=expr
set foldexpr=PythonFoldExpr(v:lnum)
set foldtext=PythonFoldText()
let g:currentDepth = 0
function! PythonFoldExpr(lnum)
"decrease depth for less indent
if indent( nextnonblank(a:lnum) )/4 < g:currentDepth
let g:currentDepth = g:currentDepth - 1
endif
"increase depth for a class or functiion on previous line
if getline(a:lnum-1) =~ '^\s*\(class\|def\)\s'
let g:currentDepth = g:currentDepth + 1
endif
return g:currentDepth
endfunction
function! PythonFoldText()
let size = 1 + v:foldend - v:foldstart
let size = " \t".size.' '
return size.getline(v:foldend)
endfunction
"au BufWrite *.py 1,$s/\s*$//g
syntax enable
set t_Co=16
set background=dark
let g:solarized_termtrans = 1
let g:solarized_termcolors=16
colorscheme solarized
"hi Search cterm=NONE ctermfg=grey ctermbg=red
highlight CursorLine ctermbg=0
highlight CursorColumn ctermbg=0
" hide highlights to start
function! ToggleSolarized()
if(&background == 'dark')
set background=light
highlight CursorLine ctermbg=7
highlight CursorColumn ctermbg=7
else
" for light mode
set background=dark
highlight CursorLine ctermbg=0
highlight CursorColumn ctermbg=0
endif
endfunction
":AirlineTheme solarized
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.colnr="║"
let g:airline_symbols.dirty="💩"
" this doesnt work, even though i really want it to
"let g:airline_symbols.modified='🛑'
"swaps
set dir=~/.vimswp
"wtf vim
noremap Y y$
autocmd QuickFixCmdPost *grep* cwindow
"move between splits and windows
noremap <C-h> :bn<CR>
noremap <C-l> :bp<CR>
noremap <C-j> <C-W>w
noremap <C-k> <C-W>W
set backspace=indent,eol,start
"comment and uncomment a line
"map ,c ^i#<ESC>
map ,u ^x
"highligh matching curlies
map ,c Vf{%
noremap <Space> <PageDown>
noremap <BS> <PageUp>
noremap <Ins> 2<C-Y>
noremap <Del> 2<C-E>
nnoremap <C-N> :next<CR>
nnoremap <C-P> :prev<CR>
noremap <C-w> :lclose<CR>:bp<bar>sp<bar>bn<bar>bd<CR>
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<cr>
set formatoptions-=t
" enable code completion
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" a better htmldjango detection
augroup filetypedetect
" removes current htmldjango detection located at $VIMRUNTIME/filetype.vim
au! BufNewFile,BufRead *.html
au BufNewFile,BufRead *.html call FThtml()
func! FThtml()
let n = 1
while n < 10 && n < line("$")
if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml
return
endif
if getline(n) =~ '{%\|{{\|{#'
setf htmldjango
return
endif
let n = n + 1
endwhile
setf html
endfunc
augroup END
" close the scratch window from code complete
" when leaving insert mode
"autocmd InsertLeave * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" flake8
" NOTE: using syntastic, need to use syntastic_python_checker_args
let g:flake8_max_line_length=79
" W191: indentation contains tabs
" E121: continuation line indentation is not a multiple of four
" E122: continuation line missing indentation or outdented
" E123: closing bracket does not match indentation of opening bracket's line¬
" E127: continuation line over-indented for visual indent
" E128: continuation line under-indented for visual indent
" E223: tab before operator
" let g:flake8_ignore="W191,E121,E122,E123,E127,E128,E223"
" syntastic (file checking)
let g:syntastic_python_flake8_args=' --max-line-length=79'
let g:syntastic_python_checkers=["flake8"]
"let g:syntastic_python_checker="pyflakes"
let g:syntastic_auto_loc_list=1
let g:syntastic_check_on_open=0
let g:syntastic_loc_list_height=8
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': ['python', 'javascript'],
\ 'passive_filetypes': ['less', 'css'] }
autocmd BufWritePre *.py execute ':Black'
let g:black_linelength=79
"unite
let g:unite_force_overwrite_statusline = 0
let g:unite_source_history_yank_enable = 1
let g:unite_enable_start_insert = 1
let g:unite_prompt = '➤ '
call unite#filters#matcher_default#use(['matcher_glob'])
call unite#filters#sorter_default#use(['sorter_rank'])
nnoremap <C-y> :Unite -no-split history/yank<cr>
nnoremap <C-e> :Unite -no-split file_rec<cr>
nnoremap <C-f> :Unite -no-split file<cr>
nnoremap <C-b> :Unite -no-split buffer<cr>
set encoding=utf-8
set laststatus=2
highlight! Folded cterm=NONE ctermfg=magenta
" Enable CursorLine
set cursorline
let g:fugitive_gitlab_domains = ['https://perfecto']