-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.symlink
executable file
·348 lines (282 loc) · 10.7 KB
/
vimrc.symlink
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
syntax on
set laststatus=2
set noshowmode
set encoding=utf-8
" AirLine symbols
let g:airline_symbols = {}
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = ' '
let g:airline_symbols.branch = '⎇ '
" Control which sections get truncated and at what width
let g:airline#extensions#default#section_truncate_width = {
\ 'b': 60,
\ 'x': 70,
\ 'y': 70,
\ 'z': 40,
\ }
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" Pass some arguments to syntax_checkers
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_check_on_open = 0
let g:syntastic_auto_loc_list = 1
let g:syntastic_haskell_checkers = ['hdevtools', 'hlint']
let g:syntastic_python_checkers = ['python3', 'flake8', 'pylint']
" https://github.com/vim-syntastic/syntastic/issues/1759#issuecomment-398639522
"let g:syntastic_go_checkers = ['golint', 'govet', 'gometalinter', 'gofmt']
"let g:syntastic_go_gometalinter_args = ['--disable-all', '--enable=errcheck']
let g:syntastic_c_gcc_args = ' -Wall -Wextra '
" https://github.com/fatih/vim-go/wiki/Tutorial#check-it
let g:go_metalinter_command = "golangci-lint"
let g:go_metalinter_enabled = ['errcheck', 'gosimple', 'govet', 'ineffassign', 'staticcheck', 'unused']
let g:go_metalinter_autosave = 1
let g:go_metalinter_deadline = "5s"
" Disable specific bundle
"let g:pathogen_disabled = ["syntastic"]
execute pathogen#infect()
set guifont=Source\ Code\ Pro
set t_Co=256
set background=dark
color molokai
set showcmd " display incomplete commands
" Enabled file type detection and file-type specific plugins.
filetype plugin indent on
" Prefer ISO8859-7 over ISO8859-1:
set fileencodings-=latin1
set fileencodings+=greek
" Path setting for finding files
"
set path+=**,
" swap/backup files
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" -----------------------------------------------------------------------------
" Text Format
" -----------------------------------------------------------------------------
set noautoindent
" this enables visual wrapping
set wrap
" this turns off physical line wrapping (ie: auto insertion of newlines)
set textwidth=0
" no margin at the end of the line
set nolist " do not show $ at EOL
set wrapmargin=0
set softtabstop=2 " tab space
set tabstop=2
set shiftwidth=2
set expandtab
set nojoinspaces
set formatoptions+=n " support for numbered/bullet lists
function SetupWrapping()
set textwidth=80
"set linebreak
set wrapmargin=1
set formatoptions+=t
endfunction
" -----------------------------------------------------------------------------
" User Interface
" -----------------------------------------------------------------------------
set showcmd
set wildmenu " way cooler command line mode completion
set wildmode=list:longest " complete like shell
set wildignore+=*.o,+=*.obj,+=*.bak,+=*.exe,+=*~,+=*.hi
set backspace=eol,start,indent " allow backspacing over everything in insert mode
set showmatch " brackets/braces that is
set mat=1 " duration to show matching brace (1/10 sec)
set scrolloff=3 " lines to always seeable when scrolling
set magic
" -----------------------------------------------------------------------------
" Searching
" -----------------------------------------------------------------------------
set incsearch " do incremental searching
set ignorecase " make this default, turn on case in search with /<search>\C/
" type small case will search case independent, type mixed case will use exact
set smartcase
" -----------------------------------------------------------------------------
" Specail File Cases
" -----------------------------------------------------------------------------
if has("autocmd")
" FIXME: This is probably to much.. Maybe {python,yml}
au Filetype * set indentkeys-=<:> indentkeys-=: indentkeys-=<-> indentkeys-=-
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType {make,c,cpp,conf,go} set noexpandtab softtabstop=4 tabstop=4 shiftwidth=4
" Make sure all mardown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt,rst} setf markdown | call SetupWrapping()
" Treat JSON files like JavaScript
au BufNewFile,BufRead *.json set ft=javascript
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set expandtab softtabstop=2 tabstop=2 shiftwidth=2 textwidth=79
" yaml rules
au FileType yaml set expandtab softtabstop=2 tabstop=2 shiftwidth=2
" bash rules
au FileType sh set noexpandtab softtabstop=8 tabstop=8 shiftwidth=2
" rEST rules
au FileType rst set expandtab softtabstop=3 tabstop=3 shiftwidth=3 spell
" Markdown rules
au FileType md set expandtab softtabstop=3 tabstop=3 shiftwidth=3 spell
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
endif
" -----------------------------------------------------------------------------
" Mapping
" -----------------------------------------------------------------------------
"set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR
"set langmap+=ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj
"set langmap+=κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
" setup mapleader
let mapleader=","
map <silent> bb :ToggleBookmark<CR>
map <silent> bn :NextBookmark<CR>
map <silent> bp :PreviousBookmark<CR>
" map - to end of line, _ to start
noremap - ^
noremap _ $
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
" Better way to enter command line (get rid of pointless shift)
" In order to :wq when in greek use ;ς; (qwq) or shift+;;+w+q
nnoremap ; :
"cnoremap ς w
"cnoremap ; q
"nnoremap ¨ :
"Go to first line in location list (useful for synstastic errors)
nnoremap <tab> :ll<CR>
"""---------------------
"""# New Movement Keys #
"""---------------------
"" normally nothing
noremap <C-k> 2<C-Y>
noremap <C-j> 2<C-E>
"""-------------------------------------
"""# File/Window/Buffer Managment Keys #
"""-------------------------------------
"" quick file browse mapping
map <Leader>e :e %:p:h<CR>
map <Leader>E :lcd %:p:h<CR>
"" new tab
""nmap <Leader>t :tabe %:p:h<CR>
nmap <Leader>T :tabe .<CR>
nmap <Leader>n :tabnew<CR>
"" Give tab cycling nicer keys (normally these just do same as j & k)
map <Leader><Tab> :tabnext<CR>
map <Leader><S-Tab> :tabprevious<CR>
"" close window
map <Leader>q :q<CR>
"" quit vim
map <Leader>Q :qall!<CR>
" -----------------------------------------------------------------------------
" Whitespace
" -----------------------------------------------------------------------------
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
"Highlight more than 80 chars
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
function StripTrailingWhitespace()
if !&binary && &filetype != 'diff'
normal mz
normal Hmy
%s/\s\+$//e
normal 'yz<CR>
normal `z
endif
endfunction
"autocmd BufWritePost *.py call Flake8()
autocmd Filetype gitcommit,mail set expandtab textwidth=72 spell
map j gj
map k gk
"map <space> /
map 0 ^
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
" Toggle paste mode on and off
set pastetoggle=<leader><leader>
inoremap jk <Esc>
inoremap jj <Esc>
inoremap ξξ <Esc>
"vnoremap γ; gq
" Similar format with the date command
" # dimara, Mon Jan 5 20:15:11 EET 2015
nnoremap <Leader>d "=strftime("# dimara, %a %b %e %k:%M:%S %Z %Y")<CR>pA
inoremap <Leader>d <C-R>=strftime("# dimara, %a %b %e %k:%M:%S %Z %Y")<CR>
set spelllang=en,el
nnoremap <Leader>s :setlocal spell!<CR>
inoremap <Leader>s <C-o>:setlocal spell!<CR>
"Allow yank more than 50 line
set viminfo='20,<1000,s10,h
autocmd FileType mail set tw=72
"Spell auto correction
imap <c-f> <c-g>u<Esc>[s1z=`]a<c-g>u
nmap <c-f> [s1z=<c-o>
"Shortcut for using named buffer a
map <Leader>y "ayy<CR>
map <Leader>p "ap<CR>
" Macros to help with reviews
" See https://wiki.samba.org/index.php/CodeReview
let g:git_ci_msg_user = substitute(system("git config --get user.name"), '\n$', '', '')
let g:git_ci_msg_email = substitute(system("git config --get user.email"), '\n$', '', '')
nnoremap <Leader>r "=printf("Reviewed-by: %s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR>pA
inoremap <Leader>r <C-R>=printf("Reviewed-by: %s <%s>", g:git_ci_msg_user, g:git_ci_msg_email)<CR>
let g:date = substitute(system("date --rfc-3339=date"), '\n$', '', '')
nnoremap <Leader>c "=printf("%s %s <%s>", g:date, g:git_ci_msg_user, g:git_ci_msg_email)<CR>pA
inoremap <Leader>c <C-R>=printf("%s %s <%s>", g:date, g:git_ci_msg_user, g:git_ci_msg_email)<CR>
function XKBLayoutGetUS()
call XKBLayoutBackup()
let g:xkb_layout_cnt = system("xkblayout-state print %C")
let c = 0
while c < g:xkb_layout_cnt
call system("xkblayout-state set " . c)
call system("xkblayout-state print %s | grep us")
if !v:shell_error
let g:xkb_layout_num_us = c
break
endif
let c += 1
endwhile
call XKBLayoutRestore()
endfunction
function XKBLayoutGetCurrent()
let g:xkb_layout_num_current = system("xkblayout-state print %c")
let g:xkb_layout_sym_current = system("xkblayout-state print %s")
endfunction
function XKBLayoutBackup()
call XKBLayoutGetCurrent()
let g:xkb_layout_num_backup = g:xkb_layout_num_current
let g:xkb_layout_sym_backup = g:xkb_layout_sym_current
endfunction
function XKBLayoutSwitch()
call XKBLayoutBackup()
if exists("g:xkb_layout_num_us")
call system("xkblayout-state set " . g:xkb_layout_num_us)
echo "Switched to 'us' keyboard layout"
endif
endfunction
function XKBLayoutRestore()
call system("xkblayout-state set " . g:xkb_layout_num_backup)
"echo "Switched to '" . g:xkb_layout_sym_current . "' keyboard layout"
endfunction
let g:current_display = $DISPLAY
if !empty(g:current_display) && executable("xkblayout-state")
call XKBLayoutGetUS()
autocmd InsertLeave * call XKBLayoutSwitch()
autocmd InsertEnter * call XKBLayoutRestore()
endif
nnoremap ξξ :call XKBLayoutSwitch()<CR>
"Load .bashrc and make :! shell behave like our command prompts (i.e., with aliases)
"set shellcmdflag=-ic
set mouse=