-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot-vimrc
245 lines (214 loc) · 6.37 KB
/
dot-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
" The MIT License (MIT)
"
" Copyright (c) 2014 Neil H Watson
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to deal
" in the Software without restriction, including without limitation the rights
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
" copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in all
" copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
" SOFTWARE.
set cursorline
set cursorcolumn
set directory=$HOME/.vim/swap//
set history=50
set ruler
set tabstop=8
set softtabstop=3
set shiftwidth=3
set shiftround
set expandtab
set modeline
set mouse= " disable because nvim steals from terminal
set autoindent
set undolevels=100
set undofile
set undodir=~/.vim/undo
set showmatch
set showcmd
set number
" set relativenumber
set textwidth=0
set colorcolumn=78
set wildmenu
" for fancy status line plugins
set laststatus=2
" set termwinsize=0*120
set termguicolors
set scrolloff=999
set splitright
set splitbelow
set omnifunc=syntaxcomplete#Complete
let mapleader = "s"
"
" Plugins
"
call plug#begin('~/.vim/plugged')
Plug 'stephpy/vim-yaml'
Plug 'psliwka/vim-smoothie'
Plug 'itchyny/lightline.vim'
Plug 'w0rp/ale'
Plug 'godlygeek/tabular'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'hashivim/vim-terraform'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all --no-fish --no-zsh' }
Plug 'junegunn/fzf.vim'
Plug 'drmikehenry/vim-fontsize'
Plug 'ron89/thesaurus_query.vim'
Plug 'tpope/vim-vividchalk'
Plug 'sheerun/vim-polyglot'
" Plug 'nvim-treesitter/nvim-treesitter'
Plug 'lucasprag/simpleblack'
call plug#end()
" Install with:
":PlugInstall
" Update with:
":PlugUpgrade
"
" End of plugins
" autowrite buffer on suspend, buffer switch etc...
set autowrite
try
colorscheme simpleblack
" colorscheme vividchalk
catch /^Vim\%((\a\+)\)\=:E185/
colorscheme default
endtry
set background=dark
highlight LineNr guifg=Lightgray guibg=Black
"for scp
"set nocp
let g:netrw_silent=1
"date stamps
"Sunday January 02 2008.
iab dmy <c-r>=strftime("%A %B %d %Y")<cr>
"20080102
iab ymd <c-r>=strftime("%Y%m%d")<cr>
"02:32:22
iab hms <c-r>=strftime("%H:%M:%S")<cr>
"Day-of-week, Month, Day, Year
iab cdate <c-r>=strftime("%a %b %d %Y")<cr>
" misc abbs
iab CFE CFEngine
iab vimmode vim: sw=3 sts=3 tw=78
iab kub kubernetes
iab Kub Kubernetes
au BufRead,BufNewFile */journal/*.txt set textwidth=78 spell
au BufRead,BufNewFile Makefile* set noexpandtab
"au BufRead,BufNewFile *.py set noexpandtab
" Add help tags, causes E154 duplicate tag error
" :helptags ~/.vim/doc/
let g:EnableCFE3KeywordAbbreviations=1
"===================================
"FUNCTIONS
"===================================
fun! Getchar()
let c = getchar()
if c != 0
let c = nr2char(c)
endif
return c
endfun
fun! Eatchar(pat)
let c = Getchar()
return (c =~ a:pat) ? '' : c
endfun
" Skeletons
"
" autocmd BufNewFile foo.sh 0r ~/Foo.sh
autocmd BufNewFile *.sh 0r ~/.vim/skeletons/bash.sh
autocmd BufNewFile *playbook* 0r ~/.vim/skeletons/ansible.yaml
"
" My maps
"
augroup Java
autocmd!
" Box comments
autocmd Filetype java,groovy nnoremap <buffer> <leader>mc
\ !!boxes -d java-cmt<cr>
autocmd Filetype java,groovy vnoremap <buffer> <leader>mc
\ !boxes -d java-cmt<CR>
" Remove comments
autocmd Filetype java,groovy nnoremap <buffer> <leader>xc
\ !!boxes -r -d java-cmt<CR>
autocmd Filetype java,groovy vnoremap <buffer> <leader>xc
\ !boxes -r -d java-cmt<CR>
augroup END
" augroup Org
" autocmd!
" autocmd Filetype org set nomodeline
" augroup END
augroup markdown
autocmd!
autocmd Filetype markdown let g:markdown_fenced_languages = [ 'bash', 'sql', 'javascript', 'groovy', 'jenkinsfile', 'yaml', 'ansible' ]
augroup END
augroup Shell
autocmd!
" Box comments
autocmd Filetype ansible,text,yaml,sh,shell,markdown nnoremap <buffer>
\ <leader>mc !!boxes -d shell<CR>
autocmd Filetype ansible,text,yaml,sh,shell,markdown vnoremap <buffer>
\ <leader>mc !boxes -d shell<CR>
" Remove comments
autocmd Filetype ansible,text,yaml,sh,shell,markdown nnoremap <buffer>
\ <leader>xc !!boxes -r -d shell<CR>
autocmd Filetype ansible,text,yaml,sh,shell,markdown vnoremap <buffer>
\ <leader>xc !boxes -r -d shell<CR>
augroup END
" update file
nnoremap <leader>u :update<CR>
" Make help window vsplit
autocmd FileType help wincmd L
" FZF maps
nnoremap <leader>fb :Buffers<CR>
nnoremap <leader>ff :Files<CR>
nnoremap <leader>fg :GFiles<CR>
nnoremap <leader>fl :BLines<CR>
nnoremap <leader>fh :History<CR>
nnoremap <leader>fh: :History:<CR>
nnoremap <leader>fh/ :History/<CR>
nnoremap <leader>fm :Marks<CR>
inoremap <c-x><c-f> <plug>(fzf-complete-path)
" line completiong from open buffers
imap <C-x><C-l> <plug>(fzf-complete-line)
" Global line completion (not just open buffers. ripgrep required.)
imap <expr> <c-x><c-j> fzf#vim#complete(fzf#wrap({
\ 'prefix': '^.*$',
\ 'source': 'rg -n ^ --color always',
\ 'options': '--ansi --delimiter : --nth 3..',
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
imap <c-x><c-k> <plug>(fzf-complete-word)
let g:fzf_layout = { 'right': '~80%' }
" Ale maps
nmap <silent> <c-k> <Plug>(ale_previous_wrap)
nmap <silent> <c-j> <Plug>(ale_next_wrap)
" Window control
nnoremap <leader>w <C-w>
" clipboard maps
" yank to system clipboard
nnoremap <leader>c "+y<CR>
" yank buffer to system clipboard
nnoremap <leader>ca :%y+<CR>
" paste from system clipboard
nnoremap <leader>p "+gp
" next and previous errors
noremap <leader>[ :lprevious<CR>
noremap <leader>] :lnext<CR>
" Run buffer on write when enabled
command! Autorun au BufWritePost <buffer> !%:p
command! Noautorun au! BufWritePost <buffer>
nnoremap <leader>r :!%:p<CR>
" Custom files
"source ~</.vim/autoclosing.vim