-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvimrc
220 lines (180 loc) · 6.29 KB
/
nvimrc
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
let g:python_host_prog = '~/env/bin/python'
let g:python3_host_prog = '~/env3/bin/python'
call plug#begin('~/.local/share/nvim/plugged')
Plug 'abcjjy/cscope_mappings'
Plug 'tpope/vim-fugitive'
Plug 'plasticboy/vim-markdown'
Plug 'kien/ctrlp.vim'
Plug 'kshenoy/vim-signature'
Plug 'godlygeek/tabular'
Plug 'Shougo/deoplete.nvim'
Plug 'derekwyatt/vim-fswitch'
Plug 'scrooloose/nerdcommenter'
"Plug 'easymotion/vim-easymotion'
Plug 'phaazon/hop.nvim'
Plug 'dkprice/vim-easygrep'
Plug 'elzr/vim-json'
Plug 'moll/vim-bbye'
Plug 'danro/rename.vim'
Plug 'tpope/vim-obsession'
Plug 'lepture/vim-jinja'
Plug 'kablamo/vim-git-log'
Plug 'abcjjy/diokai'
Plug 'jiangmiao/auto-pairs'
Plug 'Yggdroot/indentLine'
Plug 'vim-scripts/ShaderHighLight'
call plug#end()
set t_Co=256
set hidden
set ts=4
set sw=4
set expandtab
set wrap
set linebreak
set autoindent
set smartindent
set backspace=2
set shiftround
set foldlevel=99
set confirm " ask for confirmation when leaving buffer
set laststatus=2 " always show status line
set title "show title in window bar
set showcmd
let mapleader=","
syntax on
filetype on
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
let mapleader = ","
let g:indentLine_setColors = 0
set ignorecase
set smartcase
set fileignorecase
set incsearch
set wildignore=*.o,*.meta,*.a,*.so
hi Pmenu ctermfg=White ctermbg=DarkBlue
hi PmenuSel ctermfg=DarkBlue ctermbg=White
au BufRead,BufNewFile *.pkg set syntax=cpp
au BufRead,BufNewFile *.h,*.cpp set fdm=syntax
au BufRead,BufNewFile *.h,*.cpp normal zR
au BufRead,BufNewFile *.h,*.cpp,*.c set cindent
au BufRead,BufNewFile *.js set fdm=indent
au BufRead,BufNewFile *.sef set syntax=json|set fdm=indent
au BufRead,BufNewFile *.json set fdm=indent
au BufRead,BufNewFile *.as set syntax=cpp "angelscript
au BufRead,BufNewFile *.angelscript set syntax=cpp "angelscript
au BufEnter * set sw=4|set ts=4
au BufEnter *.yaml set sw=2|set ts=2
set scrolloff=5 " scroll offset bottom and top
set number "show line number
set numberwidth=3 " line number fixed width
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v]\ [%p%%]\ [LEN=%L]\ %{ObsessionStatus()}
match Todo /\c\<\(TODO\|FIXME\):.*/
"set spell " enable spell checking and use Z= for suggestion
nmap gf :edit <cfile><CR> " open file in new window
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
nnoremap <Leader>S :%s/<C-r><C-w>/
map <F4> <Esc>:FSLeft<CR>
set completeopt=menuone,longest
set cursorline " highlight current line
"current line style
"highlight CursorLine cterm=underline term=underline ctermbg=None guibg=None
iabbrev cctd //TODO: not implemented
iabbrev catd CCASSERT(false, "Not implemented");
"EasyGrep options
let g:EasyGrepMode = 2
let g:EasyGrepRecursive = 1
let g:EasyGrepFilesToExclude=".svn,.git,*.swp,*.swo"
let g:EasyGrepSearchCurrentBufferDir = 0
let g:EasyGrepReplaceWindowMode = 2
"Search in visual selected block
function! RangeSearch(direction)
call inputsave()
let g:srchstr = input(a:direction)
call inputrestore()
if strlen(g:srchstr) > 0
let g:srchstr = g:srchstr.
\ '\%>'.(line("'<")-1).'l'.
\ '\%<'.(line("'>")+1).'l'
else
let g:srchstr = ''
endif
endfunction
vnoremap <silent> / :<C-U>call RangeSearch('/')<CR>:if strlen(g:srchstr) > 0\|exec '/'.g:srchstr\|endif<CR>
vnoremap <silent> ? :<C-U>call RangeSearch('?')<CR>:if strlen(g:srchstr) > 0\|exec '?'.g:srchstr\|endif<CR>
autocmd BufWritePost *.cpp silent execute "!hgen2.py %:p" | redraw!
autocmd BufWritePost *.mm silent execute "!hgen2.py %:p" | redraw!
nnoremap <Leader>q :Bdelete<CR>
"hgen short cut
imap hdcl /*H_Declare<CR><Esc>cc#include <string><Esc><<o<CR>*/<Esc>ka
imap hmpv //H_Method public virtual<CR><Esc>cc
imap hmpo //H_Method public virtual override<CR><Esc>cc
imap hmp //H_Method public<CR><Esc>cc
imap hmps //H_Method public static<CR><Esc>cc
imap hmo //H_Method protected<CR><Esc>cc
imap hmov //H_Method protected virtual<CR><Esc>cc
imap hmi //H_Method private<CR><Esc>cc
imap hvp //H_MVar public<Esc>a
imap hvo //H_MVar protected<Esc>a
imap hvi //H_MVar private<Esc>a
imap hvps //H_MVar public static<CR><Esc>cc
imap hvos //H_MVar protected static<CR><Esc>cc
imap hvis //H_MVar private static<CR><Esc>cc
"imap hdcc /*H_Declare<CR><Esc>cc#incc<CR>//H_Class <C-n><CR>*/<Esc>kk$a
"imap #incc #include "cocos2d.h"<CR>#include "cocos-ext.h"<CR>USING_NS_CC;<CR>USING_NS_CC_EXT;<CR>
"imap usst using namespace std;<CR>
"break auto inserted line headers
"imap <C-n> <Esc>o<Esc>cc
nmap <Leader>j :%!python3 -m json.tool --sort-keys --no-ensure-ascii<CR>
nmap <Leader>r <ESC>:Rename
"This is only for my game projects
iab frjs void ::fromJson(const JSONNode & json)<ESC>^wi
iab tojs JSONNode ::toJson()<ESC>^wi
"cocos2dx tags
"set tags+=/Users/jjy/code/cocos2d-x-2.2/tags
set tags+=~/code/libcocos2dx/tags
set tags+=~/code/qqgc/tags
"for tabular
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
nmap <Leader>a, :Tabularize /,<CR>
vmap <Leader>a, :Tabularize /,<CR>
nmap <Leader>a\| :Tabularize /\|<CR>
"Fix bug in signature plugin while delete mark
nmap m- :<C-U>call signature#mark#Purge("line")<CR>:SignatureRefresh<CR>
"localvimrc
let g:localvimrc_ask=0
"set background=dark
"let g:solarized_termcolors=256
"colorscheme solarized
map <LEADER>er <ESC>:!python % &<CR>
set background=dark
colorscheme diokai
"au BufEnter * colorscheme diokai
"au BufEnter *.py colorscheme molokai
hi link EasyMotionTarget ErrorMsg
hi link EasyMotionShade Comment
hi link EasyMotionTarget2First ErrorMsg
hi link EasyMotionTarget2Second ErrorMsg
set sessionoptions=buffers,curdir
"IndentLine makes bracket input laggy in C++ files
let g:indentLine_enabled = 0
let g:netrw_list_hide= '.*\.swp$,.*\.pyc$,.*\.meta$'
let g:deoplete#enable_at_startup = 1
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
lua require'hop'.setup {}
nmap <LEADER>b <Cmd>HopWordBC<CR>
nmap <LEADER>w <Cmd>HopWordAC<CR>
nmap <LEADER>k <Cmd>HopLineStartBC<CR>
nmap <LEADER>j <Cmd>HopLineStartAC<CR>