-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_vimrc
226 lines (188 loc) · 5.78 KB
/
dot_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
"--------------------
" functions
"--------------------
" Override the diff-mode highlights of base16 for the sake of a better
" readabilty.
" https://github.com/chriskempson/base16-vim/issues/53
function! TweakBase16()
highlight DiffAdd term=bold ctermfg=0 ctermbg=2 guifg=#2b2b2b guibg=#a5c261
highlight DiffDelete term=bold ctermfg=0 ctermbg=1 gui=bold guifg=#2b2b2b guibg=#da4939
highlight DiffChange term=bold ctermfg=0 ctermbg=4 guifg=#2b2b2b guibg=#6d9cbe
highlight DiffText term=reverse cterm=bold ctermfg=0 ctermbg=4 gui=bold guifg=#2b2b2b guibg=#6d9cbe
endfunction
" Toggle line numbering
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
set nonumber
elseif(&number == 1)
set relativenumber
else
set number
endif
endfunc
"--------------------
" filetype
"--------------------
set tabstop=4
set shiftwidth=4
set visualbell
set ruler
set hidden
set shortmess+=I
set cursorline
set colorcolumn=80
" use SPC as a leader key
nnoremap <SPACE> <Nop>
let mapleader=" "
" list
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set list
" toggles
map <leader>tP :set paste!<CR>
" set pastetoggle=<leader>
map <leader>ths :if exists("g:syntax_on") <Bar>
\ syntax off <Bar>
\ else <Bar>
\ syntax enable <Bar>
\ endif <CR>
map <leader>tw :set list!<CR>
nnoremap <leader>tn :call NumberToggle()<cr>
" window
nnoremap <leader>wd :close<CR>
nnoremap <leader>ws :split<CR>
nnoremap <leader>wv :vsplit<CR>
nnoremap <leader>wj <C-W>j
nnoremap <leader>wk <C-W>k
nnoremap <leader>wh <C-W>h
nnoremap <leader>wl <C-W>l
" make C-J/C-K work in cmdline
cnoremap <C-K> <Up>
cnoremap <C-J> <Down>
" http://superuser.com/questions/131950/indentation-for-plain-text-bulleted-lists-in-vim
set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,fb:[+],fb:[x],fb:[-]
" http://stackoverflow.com/a/15317146
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//
"--------------------
" appearance
"--------------------
if has("gui_running")
set macligatures
set macthinstrokes
set guifont=Fira\ Code\ Retina:h14
set guioptions=
else
let base16colorspace=256
endif
"--------------------
" filetype
"--------------------
filetype plugin indent on
autocmd BufRead,BufNewFile */sql/* set filetype=sql
autocmd BufNewFile,BufRead *.mail setlocal ft=mailtext
autocmd FileType mailtext setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=55 nonu
autocmd FileType python setlocal expandtab
autocmd FileType javascript setlocal expandtab shiftwidth=2
autocmd FileType yaml setlocal expandtab tabstop=2 shiftwidth=2
autocmd FileType json setlocal expandtab tabstop=2 shiftwidth=2
autocmd FileType ruby setlocal expandtab tabstop=2 shiftwidth=2
let python_highlight_all = 1
"--------------------
" plug-ins
"--------------------
call plug#begin('~/.vim/plugged')
Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
Plug 'vim-airline/vim-airline-themes'
let g:airline_theme='base16'
Plug 'w0rp/ale'
let g:ale_lint_on_text_changed = 'never'
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_linters = {
\ 'c': ['clang'],
\ 'python': ['flake8', 'pylint'],
\}
let g:ale_fixers = {
\ 'c': ['clang-format'],
\ 'python': ['autopep8'],
\}
nmap <silent> <C-h> <Plug>(ale_previous_wrap)
nmap <silent> <C-l> <Plug>(ale_next_wrap)
Plug 'dyng/ctrlsf.vim'
nnoremap <leader>f :CtrlSF
Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger = '<C-J>'
let g:UltiSnipsJumpBackwardTrigger = '<C-K>'
let g:UltiSnipsSnippetDirectories = [ 'UltiSnips', $HOME.'/.vim/UltiSnips' ]
let g:ultisnips_python_style = 'numpy'
Plug 'honza/vim-snippets'
Plug 'ctrlpvim/ctrlp.vim'
"the directory of the current file, unless it is a subdirectory of the cwd
let g:ctrlp_working_path_mode = 'a'
let g:ctrlp_cmd = 'CtrlPBuffer'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-dadbod'
Plug 'sheerun/vim-polyglot'
Plug 'direnv/direnv.vim'
if has("nvim")
Plug 'raghur/vim-ghost'
autocmd VimEnter * GhostStart
endif
call plug#end()
" Less fanciness while running iTerm transparent window
if match($ITERM_PROFILE, "Hotkey Window") != 0
colorscheme base16-default-light
call TweakBase16()
else
colorscheme nofrils-dark
let g:loaded_airline = 1
syntax off
set nonu
set nolist
set nocursorline
endif
" Set textwidth to 72 for Python docstrings
" http://archive.li/CCySb
function! GetPythonTextWidth()
if !exists('g:python_normal_text_width')
let normal_text_width = 79
else
let normal_text_width = g:python_normal_text_width
endif
if !exists('g:python_comment_text_width')
let comment_text_width = 72
else
let comment_text_width = g:python_comment_text_width
endif
let cur_syntax = synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name")
if cur_syntax == "Comment"
return comment_text_width
elseif cur_syntax == "String"
" Check to see if we're in a docstring
let lnum = line(".")
while lnum >= 1 && (synIDattr(synIDtrans(synID(lnum, col([lnum, "$"]) - 1, 0)), "name") == "String" || match(getline(lnum), '\v^\s*$') > -1)
if match(getline(lnum), "\\('''\\|\"\"\"\\)") > -1
" Assume that any longstring is a docstring
return comment_text_width
endif
let lnum -= 1
endwhile
endif
return normal_text_width
endfunction
augroup pep8
au!
autocmd CursorMoved,CursorMovedI * :if &ft == 'python' | :exe 'setlocal textwidth='.GetPythonTextWidth() | :endif
augroup END