-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
296 lines (262 loc) · 8.29 KB
/
Copy path.vimrc
File metadata and controls
296 lines (262 loc) · 8.29 KB
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
syntax enable
" line numbers
set number
set ruler
set hlsearch
"set background=dark
"colorscheme solarized
"let g:solarized_termcolors=256
"let g:solarized_termtrans=1
set nocompatible
set nobk
"set listchars=tab:»\ ,trail:_
"set list
" character encoding
set enc=utf8
set encoding=utf-8
set fileencoding=utf-8
" tab sizing
set tabstop=4
set shiftwidth=4
set softtabstop=4
" auto indent
set ai
" smart indent
"set si
" cursor buffer at the top and bottom
set scrolloff=0
" keeps a single space, but not double after punctuation.
set nojoinspaces
" unmodified pasting
set pastetoggle=<F2>
" create command to clear a search pattern
command C let @/=""
" always forward and backward search (never reversed)
nmap n /<CR>
nmap N ?<CR>
" * (asterisk) default is forward and # (hash, pound) is backward.
" I never use asterisk search, but prefer forward search.
nmap # *
" soft wrap
set wrap linebreak textwidth=0
"set nowrap
" vertical ruler
"set colorcolumn=80
" disable clipboard
set clipboard=exclude:.*
" Soloraized in MinTTY
set bg=light
" Highlight line and column
"set cursorcolumn
"set cursorline
" vimdiff
if &diff
" vimdoc.sourceforge.net/htmldoc/syntax.html#hl-DiffText
" bold orange text color and grey background
highlight DiffText cterm=bold ctermfg=1 ctermbg=12 gui=none guifg=maroon guibg=blue
" vimdoc.sourceforge.net/htmldoc/fold.html#fold-diff
" Squashes down the before and after context (but not yet to a true 0;
" might only be before or after).
"set diffopt=filler,context:0
endif
" Status Line {
set laststatus=2 " always show statusbar
set statusline=
set statusline+=%-10.3n\ " buffer number
set statusline+=%f\ " filename
set statusline+=%h%m%r%w " status flags
set statusline+=\[%{strlen(&ft)?&ft:'none'}] " file type
set statusline+=%= " right align remainder
set statusline+=0x%-8B " character value
set statusline+=%-14(%l,%c%V%) " line, character
set statusline+=%<%P " file position
"}
""" ===
" Pathogen plugin bundler
execute pathogen#infect()
" https://github.com/kchmck/vim-coffee-script#coffeewatch-live-preview-compiling
" create alias command to trigger coffee watching window
command W CoffeeWatch
":setl scrollbind
" https://github.com/kchmck/vim-coffee-script#coffee_watch_vert
"let coffee_watch_vert = 1
""" ---
""" ===
" Using Plug automatically executes filetype plugin indent on and syntax enable.
" Can be reverted after the end call. e.g. filetype indent off, syntax off, etc.
" Upgrade Plug itself.
" PlugUpgrade
" Install defined plugins.
" PlugInstall
" Update already installed plugins.
" PlugUpdate
" Install CoC extensions.
" CocInstall ... e.g.: coc-json coc-tsserver
" Update CoC extensions.
" CocUpdate
call plug#begin('~/.vim/plugged') " specify a directory for plugins.
" https://microsoft.github.io/language-server-protocol/implementors/tools/
" Conquer of Completion
" Configuration file: ~/.vim/coc-settings.json
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" pip3 install --user python-language-server
call plug#end() " initialize plugin system.
""" ---
" folding `:help fold-commands`
" http://vim.wikia.com/wiki/Folding
" http://vim.wikia.com/wiki/VimTip991
" `zf` create fold
" `zo` open fold (expand)
" `zc` close fold up
" `za` toggle visibility
" `zd` delete fold
" `zM` fold all
" `zR` unfold all
"set foldmethod=manual
"set foldmethod=marker
"set foldmethod=syntax
" https://stackoverflow.com/a/33281531/3003133
" https://en.wikipedia.org/wiki/Signature_mark
function! EndLineCountFoldText()
let nblines = v:foldend - v:foldstart + 1
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
let line = getline(v:foldstart)
let comment = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
let expansionString = repeat(".", w - strwidth(nblines.comment.'"'))
"let foldLevelStr = repeat(">", v:foldlevel)
let txt = '❧ ' . comment . expansionString . nblines
return txt
endfunction
set foldtext=EndLineCountFoldText()
" split buffers (windows)
" :sp filename Open filename in horizontal split
" :vsp filename Open filename in vertical split
" :sb# Put a buffer in a split window (# is its number)
" :vert sb# Put buffer # in a vertical split window
" Ctrl+w [h|l|j|k|←|→|↑] Shift focus to different split
" Ctrl+w n+ Increase size of current split by n lines
" Ctrl+w n- Decrease size of current split by n lines
" Ctrl+w _ Maximize height of the current split
" Ctrl+w | Maximize width of the current split
" Ctrl+w = Equalized splits
" Ctrl+W R Swap split positions
" Ctrl+W T Pull current window into a new buffer tabview
" Ctrl+W o Close all but current window
" Top to bottom, left to right splitting:
set splitbelow
set splitright
" clearspeed filetype syntax highlighting
autocmd! BufRead,BufNewFile *.cn setfiletype c
" text files
autocmd! BufRead,BufNewFile *.txt set nonumber
" LESS CSS
"autocmd! BufRead,BufNewFile *.less setfiletype css
" SCSS (Sass CSS)
"autocmd! BufRead,BufNewFile *.scss setfiletype css
" jsonc (JSON with comments)
autocmd FileType json syntax match Comment +\/\/.\+$+
" JSON, automatically fold large files
function FoldLarge()
if line('$') > 2000
set foldmethod=syntax
endif
endfunction
augroup vimrc_autocmds_json
autocmd!
autocmd BufRead *.json call FoldLarge()
augroup END
" markdown text files
augroup vimrc_autocmds_md
autocmd!
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.md set nonumber
augroup END
" YAML
augroup vimrc_autocmds_yml
autocmd!
autocmd BufRead,BufNewFile *.yml set tabstop=4
autocmd BufRead,BufNewFile *.yml set shiftwidth=4
autocmd BufRead,BufNewFile *.yml set softtabstop=4
autocmd BufRead,BufNewFile *.yml set expandtab
augroup END
" python
augroup vimrc_autocmds_py
autocmd!
autocmd BufRead,BufNewFile *.py set tabstop=4
autocmd BufRead,BufNewFile *.py set shiftwidth=4
autocmd BufRead,BufNewFile *.py set softtabstop=4
autocmd BufRead,BufNewFile *.py set expandtab
let g:pyindent_continue=4
let g:pyindent_open_paren=4
augroup END
" coffeescript
augroup vimrc_autocmds_coffee
autocmd!
autocmd BufRead,BufNewFile *.coffee set tabstop=4
autocmd BufRead,BufNewFile *.coffee set shiftwidth=4
autocmd BufRead,BufNewFile *.coffee set softtabstop=4
autocmd BufRead,BufNewFile *.coffee set expandtab
augroup END
" OpenCL
augroup vimrc_autocmds_cl
autocmd!
autocmd BufRead,BufNewFile *.cl set filetype=cpp
augroup END
" Docker
augroup vimrc_autocmds_docker
autocmd!
autocmd BufRead,BufNewFile Dockerfile set filetype=dockerfile
autocmd BufRead,BufNewFile Dockerfile.* set filetype=dockerfile
augroup END
" Jenkins
augroup vimrc_autocmds_jenkins
autocmd!
autocmd BufRead,BufNewFile Jenkinsfile set filetype=groovy
autocmd BufRead,BufNewFile Jenkinsfile.* set filetype=groovy
augroup END
" Mermaid (markdown) Diagram
augroup vimrc_autocmds_mmd
autocmd!
autocmd BufRead,BufNewFile *.mmd set tabstop=2
autocmd BufRead,BufNewFile *.mmd set shiftwidth=2
autocmd BufRead,BufNewFile *.mmd set softtabstop=2
autocmd BufRead,BufNewFile *.mmd set expandtab
augroup END
"autocmd BufEnter * :syntax sync fromstart
" Format XML
":%!xmllint --format -
" Format JSON
":%!python3 -m json.tool
":%!jq
" Function example
" https://vi.stackexchange.com/a/21969/5647
"function! FormatJson()
"python3 << EOF
"import vim
"import json
"try:
" buf = vim.current.buffer
" json_content = '\n'.join(buf[:])
" content = json.loads(json_content)
" sorted_formatted = json.dumps(content, indent=4, sort_keys=True)
" buf[:] = sorted_formatted.split('\n')
"except Exception as e:
" print(e)
"EOF
"endfunction
source ~/.vim/coc.vimrc
source ~/.vim/gitgutter.vimrc
" Current vimfile stuff.
" ~/.vim:
" coc-settings.json
" ~/.vim/autoload:
" pathogen.vim plug.vim
" ~/.vim/bundle:
" vim-gitgutter
" ~/.vim/language:
" coffeescript-lsp-core
" ~/.vim/plugged:
" coc.nvim
" ~/.vim/syntax:
" pyopencl.vim
" vim: tabstop=4 shiftwidth=4 expandtab