-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvim
238 lines (187 loc) · 5.92 KB
/
nvim
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
set nobackup " coc
set nowritebackup " coc
"set backup " keep a backup file (restore to previous version)
set undofile " keep an undo file (undo changes after closing)
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set number
set relativenumber
" Mostly disable mouse, only insert
set mouse=i
" Don't use Ex mode, use Q for formatting
noremap Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" Switch syntax highlighting on
syntax on
" I like highlighting strings inside C comments.
let c_comment_strings=1
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'textwidth' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set buftype=nofile | read ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
" source ~/.vimrc
" Orig .vimrc below
set backupdir=~/.vimbackup//
set directory=~/.vimbackup//
set ignorecase
set smartcase
set incsearch
set nohlsearch
"wrapping navigation fixer
nnoremap j gj
nnoremap k gk
"allow pasting without auto-indenting
set pastetoggle=<F2>
"change mapleader to , from \
let mapleader=","
"edit/reload vimrc
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" leader directions splits that direction
nmap <silent> <leader>l :vsp<CR><C-w>l
nmap <silent> <leader>h :vsp<CR>
nmap <silent> <leader>j :sp<CR><C-w>j
nmap <silent> <leader>k :sp<CR>
" map ctrl>movement to C-w movement
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" chance camelCase to camel_case - <leader>c[ase]
nmap <silent> <leader>c vaw :s/\%V[A-Z]/\_\l\0/g<CR>
" leader directions splits that direction
nmap <silent> <leader>l :vsp<CR><C-w>l
nmap <silent> <leader>h :vsp<CR>
nmap <silent> <leader>j :sp<CR><C-w>j
nmap <silent> <leader>k :sp<CR>
"
" underline current line
nmap <silent> <leader>u yyp:s/./-/g<CR>
" leader shortcuts
" save
nmap <silent> <leader>w :w<CR>
" add a newline
nmap <silent> <leader>o mzo<Esc>`z
nmap <silent> <leader>O mzO<Esc>`z
" underline current line
nmap <silent> <leader>u yyp:s/./-/g<CR>
" escape terminal
tnoremap <leader>x <C-\><C-n>
" tab navigation
nmap <silent> <leader>f gt
nmap <silent> <leader>d gT
" Move line keys
nnoremap <A-j> :m+<CR>==
nnoremap <A-k> :m-2<CR>==
nnoremap <A-h> <<
nnoremap <A-l> >>
inoremap <A-j> <Esc>:m+<CR>==gi
inoremap <A-k> <Esc>:m-2<CR>==gi
inoremap <A-h> <Esc><<`]a
inoremap <A-l> <Esc>>>`]a
vnoremap <A-j> :m'>+<CR>gv=gv
vnoremap <A-k> :m-2<CR>gv=gv
vnoremap <A-h> <gv
vnoremap <A-l> >gv
" Escape after mashing jkjk
imap jk <esc>
" Filetype settings
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType ansible setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType python setlocal ts=2 sw=4 sts=4 expandtab
autocmd FileType javascript setlocal ts=4 sw=4 sts=4 expandtab
" No idea
set showcmd
set autoindent
if version >= 700
set spl=en spell
set nospell
endif
set foldmethod=indent
nnoremap <space> za
set foldlevelstart=99
" keep at least 2 lines above/below
set scrolloff=2
" error bells
set noerrorbells
set visualbell
" wsl clipboard
set clipboard+=unnamedplus
let g:clipboard = {
\ 'name': 'win32yank-wsl',
\ 'copy': {
\ '+': 'win32yank.exe -i --crlf',
\ '*': 'win32yank.exe -i --crlf',
\ },
\ 'paste': {
\ '+': 'win32yank.exe -o --lf',
\ '*': 'win32yank.exe -o --lf',
\ },
\ 'cache_enabled': 0,
\ }
" vimplug
call plug#begin()
Plug 'gioele/vim-autoswap'
Plug 'machakann/vim-sandwich'
Plug 'tpope/vim-abolish' " find/replacer
Plug 'tpope/vim-repeat'
Plug 'bling/vim-airline'
" Plug 'hynek/vim-python-pep8-indent'
Plug 'maksimr/vim-jsbeautify'
" Plug 'jshint/jshint' # Js analasys
Plug 'mattn/emmet-vim' " HTML expansion
Plug 'numirias/semshi', {'do': ':UpdateRemotePlugins'} " Semantic highlights
" has config from here on
Plug 'junegunn/vim-easy-align'
Plug 'Chiel92/vim-autoformat'
" CocInstall coc-pyright
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
"" coc config
set updatetime=300
set signcolumn=yes
inoremap <silent><expr> <c-space> coc#refresh()
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Highlight the symbol and its references when holding the cursor
autocmd CursorHold * silent call CocActionAsync('highlight')
" Formatting selected code
"xmap <leader>f <Plug>(coc-format-selected)
"nmap <leader>f <Plug>(coc-format-selected)
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<CR>\<c-r>=coc#on_enter()\<CR>"
" Add `:Format` command to format current buffer
command! -nargs=0 Format :call CocActionAsync('format')
" Add `:OR` command for organize imports of the current buffer
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" airline coc
let g:airline#extensions#coc#enabled = 1
"" end coc
" easy-align
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" autoformat
noremap <F3> :Autoformat<CR>
" End plugins
" color scheme
colorscheme koehler
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
filetype plugin indent on