-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
388 lines (301 loc) · 10.3 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
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
" Kyle Merfeld's vimrc
"
" sets <leader> to space
let g:mapleader = "\<Space>"
"""""""""""""""""""
" Plug plugins "
"""""""""""""""""""
call plug#begin('~/.vim/plugged')
"Looks
""""""
Plug 'dodie/vim-disapprove-deep-indentation' "ಠ_ಠ
Plug 'nathanaelkane/vim-indent-guides' "shows indents more
Plug 'airblade/vim-gitgutter' "shows changed lines
Plug 'itchyny/lightline.vim' "Statusbar
Plug 'luochen1990/rainbow' "Shows matching paren
Plug 'morhetz/gruvbox' "ColorScheme of choice
"More Functionallity
""""""""""""""""""""
" use multiple 'v' to select with visual mode
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'sebastianmarkow/deoplete-rust' " Rust autocomplete
Plug 'ludovicchabant/vim-gutentags' " ctags
Plug 'MattesGroeger/vim-bookmarks' " <leader>m to bookmark
Plug 'alcesleo/vim-uppercase-sql' " Auto type sql uppercase
Plug 'terryma/vim-expand-region' " lazily select region
Plug 'ivalkeen/vim-simpledb' " Allows you to connect to db
Plug 'racer-rust/vim-racer' " work with rust
Plug 'chrisbra/Recover.vim' " Makes swap files better
Plug 'sheerun/vim-polyglot' " Acts like a language pack
Plug 'rust-lang/rust.vim' " work with rust
Plug 'kmerfeld/term_test' " run tests
Plug 'ervandew/supertab' " tab but better
Plug 'junegunn/goyo.vim' " Distraction free writing
Plug 'majutsushi/tagbar' " <leader>b to see ctags
Plug 'junegunn/fzf.vim' " search files
Plug 'vimwiki/vimwiki' " Personal wiki
Plug 'kien/ctrlp.vim' " Should move to fzf, but im lazy
Plug 'exu/pgsql.vim' " Postgresql syntax
Plug 'w0rp/ale' " Syntax
"Nvim
Plug 'Shougo/echodoc.vim'
Plug 'Shougo/denite.nvim'
call plug#end()
"Under Consideration
""""""""""""""""""""
" These plugins are in a trial period of whether or not to keep
"This one is intentionally last
""""""""""""""""""""
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'autozimu/LanguageClient-neovim', { 'do': ':UpdateRemotePlugins' }
let g:deoplete#enable_at_startup = 1
"Plugin Config
""""""""""""""
"Looks config
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:rainbow_active = 1
let g:lightline = {
\ 'component_function': {
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ }
\ }
vmap v <Plug>(expand_region_expand)
let g:SuperTabDefaultCompletionType = '<c-n>'
" Rust autoformat
let g:rustfmt_autosave = 1
let g:deoplete#enable_at_startup = 1
let g:deoplete#sources#rust#racer_binary='/home/kyle/.cargo/bin/racer'
let g:deoplete#sources#rust#rust_source_path='/home/kyle/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src'
" rust-racer
let g:racer_cmd ='~/.cargo/bin/racer'
let $RUST_SRC_PATH='/home/kyle/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src'
let g:racer_experimental_completer = 1
"Set default sql syntax
let g:sql_type_default = 'pgsql'
"rls
" Required for operations modifying multiple buffers like rename.
set hidden
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ 'javascript': ['/opt/javascript-typescript-langserver/lib/language-server-stdio.js'],
\ }
" Automatically start language servers.
let g:LanguageClient_autoStart = 1
nnoremap <silent> K :call LanguageClient_textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR>
"Distraction free editing
function! ProseMode()
call goyo#execute(0, [])
set spell noci nosi noai nolist noshowmode noshowcmd
set complete+=s
endfunction
command! ProseMode call ProseMode()
nmap \p :ProseMode<CR>
"tmux_test
let g:rtmux = {'rust': 'cargo run',
\ 'vim': 'pwd',
\}
let g:ttmux = {'rust': 'cargo test',
\ 'vim': 'pwd',
\}
let g:ctmux = {'rust': 'cargo check',
\ 'vim': 'pwd',
\}
"Auto delete unedited swap files
let g:RecoverPlugin_Delete_Unmodified_Swapfile = 1
" will place a timestamp with f3
" https://box.matto.nl/systemnotesvimwiki.html
let g:vimwiki_hl_headers = 1
map <F3> :r! date +"\%Y-\%m-\%d \%H:\%M:\%S"<ESC>0j
let g:vimwiki_folding='expr'
let g:vimwiki_folding='expr' "this allows the folding to work for markdown
let g:vimwiki_list = [{
\ 'path': '~/Nextcloud/vimwiki',
\ 'template_path': '~/vimwiki/templates/',
\ 'nested_syntaxes': {
\ 'bash': 'sh'
\ },
\ 'template_default': 'default',
\ 'path_html': '~/Nextcloud/vimwiki/site_html/',
\ }]
function! VimwikiLinkHandler(link)
" Use Vim to open external files with the 'vfile:' scheme. E.g.:
" 1) [[vfile:~/Code/PythonProject/abc123.py]]
" 2) [[vfile:./|Wiki Home]]
let l:link = a:link
if l:link =~# '^vfile:'
let l:link = l:link[1:]
else
return 0
endif
let l:link_infos = vimwiki#base#resolve_link(l:link)
if l:link_infos.filename ==# ''
echomsg 'Vimwiki Error: Unable to resolve link!'
return 0
else
exe 'tabnew ' . fnameescape(l:link_infos.filename)
return 1
endif
endfunction
autocmd FileType vimwiki set spell spelllang=en_gb
let g:tagbar_type_rust = {
\ 'ctagstype' : 'rust',
\ 'kinds' : [
\'T:types,type definitions',
\'f:functions,function definitions',
\'g:enum,enumeration names',
\'s:structure names',
\'m:modules,module names',
\'c:consts,static constants',
\'t:traits,traits',
\'i:impls,trait implementations',
\]
\}
set statusline+=%{gutentags#statusline()}
let g:gutentags_cache_dir = '~/.tags'
nnoremap <silent> <Leader>b :TagbarToggle<CR>
"ale
let g:ale_enabled = 1
"vim bookmarks
highlight BookmarkSign ctermbg=red ctermfg=black
highlight BookmarkAnnotationSign ctermbg=red ctermfg=black
highlight BookmarkLine ctermbg=red ctermfg=black
highlight BookmarkAnnotationLine ctermbg=red ctermfg=black
let g:bookmark_sign ='⌬'
let g:bookmark_highlight_lines = 1
nmap <Leader>m <Plug>BookmarkToggle
let g:bookmark_save_per_working_dir = 1
let g:bookmark_auto_save = 1
"""""""""""""""""""
" Settings "
"""""""""""""""""""
set completeopt=longest,menuone
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" give me another option to go to the beginning and end of a line
map <leader>a ^
map <leader>; $
" Tab stuff
" For regular expressions turn magic on
set magic
set smarttab
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set cindent
set scrolloff=2
set list lcs=trail:·,tab:»·
set smartindent
set spell spelllang=en_us
" :w!!
" write the file when you accidentally opened it without the right (root) privileges
cmap w!! w !sudo tee % > /dev/null
" make swap files less anoying
set backupdir=~/.vim/backup
set directory=~/.vim/swap
set undodir=~/.vim/undo
filetype plugin indent on
set encoding=utf-8
" bind 'jk' to escape
inoremap jk <ESC>
" this makes number lines apear
set number
" allows folding based on indent
set foldmethod=syntax
"set foldmethod=syntax
set foldlevel=99
" set syntax highlighting
if !exists('g:syntax_on')
syntax enable
endif
" Turns on autoComplete
filetype plugin on
" Line wrap type stuff
set wrap
set linebreak
set nolist " list disables linebreak
" Set show matching parenthesis
set showmatch
" Ignore case when searching
set ignorecase
" Reload the file when it has been chaged outside of vim
set autoread
" Highlight search results
set hlsearch
" No annoying sound on errors
set noerrorbells
set novisualbell
set timeoutlen=500
" Shows partial commands
set showcmd
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif"
" Set 81st column to be highlighted
highlight ColorColumn ctermbg=magenta ctermfg=black
let &colorcolumn=join(range(81,335), ',')
" http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
" Smart copy and paste
vmap <Leader>y "+y
vmap <Leader>d "+d
vmap <Leader>p "+p
" some nice bindings
map <leader>v :vnew<cr>
map <leader>V :new<cr>
map <leader>x :bd<cr>
" This allows buffers to be hidden if you've modified a buffer.
" This is almost a must if you wish to use buffers in this way.
set hidden
" Set the current line to be highlighted black
" Black because it doesn't interfere with my color scheme,
" and I have this so that it is easier to see where I am
set cursorline
highlight CursorLine ctermbg=black
" Changes terminal cursor to red. Makes sure I know where I am
highlight TermCursor ctermfg=red guifg=red
" Set vim to 256 color mode
set t_Co=256
" set colorscheme
"
set background=dark
colorscheme gruvbox
"""""""""""""""""""""""""""
" navigating splits "
"""""""""""""""""""""""""""
" auto use insert mode when moving to a terminal split
au BufEnter * if &buftype == 'terminal' | :startinsert | endif
if has ('nvim')
" let you leave terminal insert mode with escape
tnoremap <Esc> <C-\><C-n>
"bindings for moveing between splits. terminal mode or normal
tnoremap <C-h> <C-\><C-n><C-w>h
tnoremap <C-j> <C-\><C-n><C-w>j
tnoremap <C-k> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
inoremap <C-h> <Esc><C-w>h
inoremap <C-j> <Esc><C-w>j
inoremap <C-k> <Esc><C-w>k
inoremap <C-l> <Esc><C-w>l
" http://stackoverflow.com/questions/9092982/mapping-c-j-to-something-in-vim
" This make ctrl-j work
augroup vimrc
au!
au VimEnter * unmap <C-j>
au VimEnter * noremap <C-j> <C-w>j
augroup END
endif
set splitbelow
set splitright
"Swap a and i because Im stubborn
nnoremap a i
nnoremap i a