-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
321 lines (264 loc) · 7.63 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
au BufRead,BufNewFile *.sass setfiletype sass
au! BufRead,BufNewFile *.scss setfiletype css
" Use vim settings, instead of vi
set nocompatible
set loadplugins
" no swap files
set noswapfile
" Load snippets.vim
runtime snippets.vim
" Reindent operations (<< and >>)
""" BIKESHEDDING set shiftwidth=4
" 4 space tab
""" BIKESHEDDING set tabstop=4
" Causes backspace to delete 4 spaces
""" BIKESHEDDING set softtabstop=4
" Replaces a <TAB> with spaces
""" BIKESHEDDING set expandtab
" Uses shiftwidth instead of tabstop at start of lines
set smarttab
set modeline
set ruler
set history=100
set nowrap
" Change terminal title
set title
" No annoying error noises
set noerrorbells
" Make backspace delete lots of things
set backspace=indent,eol,start
" Show us the command we're typing
set showcmd
" Highlight matching parens
set showmatch
" Search options: incremental search, highlight search
set hlsearch
set incsearch
" Selective case insensitivity
set smartcase
" Show full tags when doing search completion
set showfulltag
" Speed up macros
set lazyredraw
" No annoying error noises
set noerrorbells
" Wrap on these
set whichwrap+=<,>,[,]
" Use the cool tab complete menu
set wildmenu
set wildmode=longest,full
set wildignore+=*.o,*~,*.pyc
" Allow edit buffers to be hidden
set hidden
" 1 height windows
set winminheight=1
" misc
set autowrite
if exists('+autochdir')
set autochdir
endif
set ttyfast
set smartcase
filetype indent on
filetype plugin on
set autoindent
set smartindent
syntax on
"colorscheme sidonia
"nice scheme as well
"colorscheme desert
" make the mouse works under screen :
" Comment out these 2 lines for fix neovide error
"set ttymouse=xterm2
"set mouse=ar
" Change buffer
map <C-N> :tabnext<CR>
map <C-P> :tabprevious<CR>
"inoremap <C-A> <Home>
"inoremap <C-E> <End>
"nnoremap <C-A> ^
"nnoremap <C-E> $
" Hide coloration of found words
map <C-C> :nohlsearch<CR>
autocmd FileType Makefile noexpandtab
au filetype tmpl set omnifunc=htmlcomplete#CompleteTags
" Change the current tab with ^j and ^k (normal mode only)
nnoremap <silent> <C-j> <C-f>
nnoremap <silent> <C-k> <C-b>
" Easy way for ^, $
nnoremap <silent> e ^
vnoremap <silent> e ^
nnoremap <silent> r $
vnoremap <silent> r $
nnoremap <silent> t 0
vnoremap <silent> t 0
nnoremap <silent> s e
" gg, GG shortcuts
noremap <silent> <nowait> G GG
" Change cursor while switching between insert mode and normal mode for iTerm2
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
" let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" Fix: Delay while switching betweeen insert mode and normal mode
set timeoutlen=1000 ttimeoutlen=0
" Dont show support message at startup
set shortmess=atI
" Use spaces while press tab
set expandtab
" Dont show line numbers
set nonu
" In visual mode, use Y to copy to system clipboard
vnoremap Y "*y
" In normal mode, do the same with the current line
nnoremap Y "*yy
" vv = V
nnoremap vv V
" :ls to show buffers
"
cabbrev t tabedit
" Make !resize work in iTerm2
" Preferences -> Profiles -> {your profile} -> Terminal,
" Uncheck this "Disable session-initiated window resizing"
" Large window
cabbrev l silent exec "!resize -s 45 120"
" Smaller window
" cabbrev s silent exec "!resize -s 45 80"
fun! LargerFont()
silent exec '!echo -e "\033]50;SetProfile=Larger Takeshi\a"'
redraw!
endfun
fun! SmallerFont()
silent exec '!echo -e "\033]50;SetProfile=Takeshi\a"' | redraw!
redraw!
endfun
" Larger font
cabbrev lf call LargerFont()
" Smaller font
cabbrev sf call SmallerFont()
" Fix auto jump to closing brace in auto-pairs
let g:AutoPairsMultilineClose = 0
let g:AutoPairsFlyMode = 0
" yank also copy to system pasteboad
set clipboard=unnamed
" yank also copy to system clipboard for Ubuntu
set clipboard=unnamedplus
" encoding
set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file.
" set relative line numbers
set nonu
" Disable arrow keys for insert mode
inoremap <Left> <Nop>
inoremap <Right> <Nop>
inoremap <Up> <Nop>
inoremap <Down> <Nop>
" Use goimports instead of gofmt
let g:gofmt_exe = 'goimports'
let g:gofmt_display_errors = 1
" Trim whitespace on save
" From: http://vim.wikia.com/wiki/Remove_unwanted_spaces
autocmd BufWritePre * %s/\s\+$//e
" Show status line always
set laststatus=2
fun! GetPaddingSpaces(s)
let w = winwidth('%')
let width = &modified ? w - 1: w
let padding = (width - len(a:s)) / 2
return repeat('\ ', padding)
endfun
fun! GetStatus()
let sign = &modified ? '*' : ''
let lineNumber= repeat('1', len(printf('%i', getline('.'))))
let columnNumber = repeat('1', len(printf('%i', virtcol('.'))))
let fullPath = fnameescape(pathshorten(expand('%:p:h')))
let filename = fnameescape(expand('%:t'))
let path = fullPath.'/'.filename.':'.lineNumber.':'.columnNumber
let spaces = GetPaddingSpaces(path)
" Show file encoding on status line
"let s = 'set statusline=%2*'.sign.spaces.'%1*'.fullPath.'/%2*'.filename.'%1*:%l'."%=%2*%{''.(&fenc!=''?&fenc:&enc).''}"
let s = 'set statusline=%2*'.sign.spaces.'%1*'.fullPath.'/%2*'.filename.'%1*:%l:%2*%c'
exec s
endfun
autocmd CursorMovedI * call GetStatus()
autocmd BufWritePost * call GetStatus()
autocmd BufRead,BufNewFile * call GetStatus()
autocmd! BufRead,BufNewFile * call GetStatus()
autocmd! BufEnter * call GetStatus()
autocmd VimEnter * call GetStatus()
" Command light hight
set cmdheight=1
" New line
nmap <CR> o<Esc>i
" Fix 13_AutoPairsReturn
let g:AutoPairsMapCR=0
" Set default shell for Vim
set shell=/bin/sh
cd %:p:h
" Use <Down> key to complete for supertab
let g:SuperTabMappingForward = "<Down>"
" Install Vim plugins by vim-plug
call plug#begin('~/.vim/plugged')
Plug 'Jorengarenar/miniSnip'
Plug 'ervandew/supertab'
Plug 'projekt0n/github-nvim-theme'
" Initialize plugin system
call plug#end()
" Clang complete for objc
" This function net used yet
function ClangLibPath()
let clangPath = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/'
return clangPath
endfunction
let g:clang_user_options='|| exit 0'
let g:clang_complete_auto = 1
let g:clang_complete_copen = 0
let g:clang_library_path="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib"
" Hide preview window
set completeopt-=preview
" Disable arrow keys navigation to force me not to use them
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
set guifont=Roboto\ Mono\ Nerd\ Medium\ Patch:h13:cANSI
if has('nvim')
colorscheme github_dimmed
" override normal text color to white, aim for Todo.md
hi markdownCodeBlock guifg=white
hi Normal guifg=white
endif
" Set status line colors
hi statusline ctermbg=61 ctermfg=White
" Set status line colors for Neovide
hi statusline guibg=#5F5FAF guifg=White
" Color groups for status lines"
hi User1 ctermbg=61 ctermfg=Black
hi User2 ctermbg=61 ctermfg=White
" Color groups for status lines for Neovide
hi User1 guibg=#5F5FAF guifg=#303645
hi User2 guibg=#5F5FAF guifg=White
" Remember previous window size
let g:neovide_remember_window_size = v:true
" Custom tab bar colors
"
hi TabLineSel term=none cterm=none ctermbg=1 guifg=black guibg=#5F5FAF
hi TabLine term=none cterm=none guibg=#A08367
hi TabLineFill term=none cterm=none ctermbg=none
" Cursor Line
hi CursorLine term=none cterm=none
" Enable cscope
set cscopetag
" Wrap text to textwidth: set textwidth=80, and use this command
nmap <C-L> gqG
nnoremap y "+y
vnoremap y "+y
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
let g:deoplete#enable_at_startup = 1
" ctrl-n to complete
inoremap <C-n> <C-x><C-o>