aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2023-03-06 00:26:13 +0800
committerHsieh Chin Fan <pham@topo.tw>2023-03-06 00:26:13 +0800
commit1aca31103361b456c33e99fa46e54e7a7821fa71 (patch)
tree6d8f75023f92b96afdf4fbcfb68c935a6b72ff07
parent46330677f75c0d20d9a1e32a1875f27ab41349ca (diff)
Remove old vimrc
-rw-r--r--vimrc.bak300
1 files changed, 0 insertions, 300 deletions
diff --git a/vimrc.bak b/vimrc.bak
deleted file mode 100644
index e15d412..0000000
--- a/vimrc.bak
+++ /dev/null
@@ -1,300 +0,0 @@
1"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2" => Custom Config
3"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4set cursorline
5set number
6set relativenumber
7set showcmd
8set nowrap
9set nostartofline
10set sidescroll=1
11set sidescrolloff=999
12set shell=/bin/bash
13set shiftwidth=2
14autocmd FileType vimwiki set shiftwidth=4
15" set clipboard=unnamedplus
16
17" general
18function! Bye()
19 if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
20 :quit
21 else
22 :bdelete
23 endif
24endfunction
25nnoremap <silent> <C-C> :call Bye()<CR>
26nnoremap <silent> <C-S-C> :q!<CR>
27nnoremap <leader>, :.terminal ++noclose<CR>
28vnoremap <leader>, :terminal<CR>
29nnoremap Y viW:!tee >(xsel -ib)<CR>
30vnoremap Y :!tee >(xsel -ib)<CR>
31nnoremap <leader>< :%terminal ++noclose<CR>
32nnoremap <leader>W :set wrap!<CR>
33nnoremap <leader>T :vertical terminal<CR>
34nnoremap <leader>R :read !
35nnoremap <leader>P :r !xsel -ob<CR>
36nnoremap <leader>nn :NERDTree<CR>
37set autoread
38set nofoldenable " disable folding
39
40" move
41" nnoremap <Tab> }
42" nnoremap <S-Tab> {
43inoremap <C-L> <Right>
44cnoremap <C-L> <Right>
45cnoremap <C-H> <Left>
46nmap H 0
47nnoremap L $
48nnoremap <C-L> 60l
49nnoremap <C-H> 60h
50nnoremap / ms/
51
52" disable syntax
53nnoremap <silent> <leader>s
54 \ : if exists("syntax_on") <BAR>
55 \ syntax off <BAR>
56 \ else <BAR>
57 \ syntax enable <BAR>
58 \ endif<CR>
59" show current syntax
60nnoremap <leader>S :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')),' ')<CR>
61
62" Operator pending
63onoremap p i(
64onoremap ap a(
65" next parenthesis
66onoremap fp :<c-u>normal! f(vi(<cr>
67onoremap b i{
68onoremap fb :<c-u>normal! f{vi{<cr>
69onoremap ab a{
70" block
71onoremap B /return<CR>
72
73" Search
74vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>'")
75
76" S&R
77nnoremap <leader>; :%s:::g<Left><Left><Left>
78vnoremap <leader>; :s:::g<Left><Left><Left>
79cnoremap \\ \(\)<Left><Left>
80
81" Fix paste bug triggered by inoremaps
82set t_BE=
83
84" surround with charactor
85vnoremap ' <ESC>`<i'<ESC>`>la'<ESC>
86vnoremap q <ESC>`<i"<ESC>`>la"<ESC>
87vnoremap ( <ESC>`<i(<ESC>`>la)<ESC>
88vnoremap { <ESC>`<i{<ESC>`>la}<ESC>
89vnoremap [ <ESC>`<i[<ESC>`>la]<ESC>gvlol
90inoremap [ []<C-O>h
91vnoremap ` <ESC>`<i`<ESC>`>la`<ESC>
92vnoremap , <ESC>`<i<<ESC>`>la><ESC>
93vnoremap <space> <ESC>`<i<space><ESC>`>la<space><ESC>
94vnoremap 8 <ESC>`<i*<ESC>`>la*<ESC>
95vnoremap z <ESC>`<i「<ESC>`>la」<ESC>
96vnoremap ~ <ESC>`<i~<ESC>`>la~<ESC>
97
98" abbrev
99iabbrev @@ typebrook@gmail.com
100
101
102" vim_markdown
103let g:vim_markdown_folding_disabled = 1
104let g:vim_markdown_conceal = 0
105vnoremap <C-K> <ESC>`<i[<ESC>`>la]()<ESC>i
106
107" XML fold
108let g:xml_syntax_folding=1
109autocmd FileType xml setlocal foldmethod=syntax
110
111" JSON fold
112let g:json_syntax_folding=1
113autocmd FileType json setlocal foldmethod=syntax
114
115" Apply new SniptMat Parser
116let g:snipMate = { 'snippet_version' : 1 }
117
118" Set width of mutt as 72
119au BufRead /tmp/mutt-* set tw=72
120
121" Redirection with buffer
122" Usage:
123" :Redir hi ............. show the full output of command ':hi' in a scratch window
124" :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window
125function! Redir(cmd)
126 for win in range(1, winnr('$'))
127 if getwinvar(win, 'scratch')
128 execute win . 'windo close'
129 endif
130 endfor
131 if a:cmd =~ '^!'
132 let output = system(matchstr(a:cmd, '^!\zs.*'))
133 else
134 redir => output
135 execute a:cmd
136 redir END
137 endif
138 vnew
139 let w:scratch = 1
140 setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
141 call setline(1, split(output, "\n"))
142endfunction
143
144command! -nargs=1 -complete=command Redir silent call Redir(<q-args>)
145
146"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
147" => Settings for Vimwiki
148"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
149
150nnoremap <leader>tt :VimwikiTable<CR>
151nnoremap <leader>wg :VimwikiGoto
152nnoremap <leader>wT :VimwikiSearchTags
153nnoremap <leader>i I- <esc>l
154nnoremap <leader>I :s/^[ ]*- \(\[.\] \)*//<CR>
155nmap <leader>D dd:VimwikiMakeDiaryNote<CR>Gp:w!<CR>:Bclose<CR>
156vnoremap <leader>D d:VimwikiMakeDiaryNote<CR>Gp:w!<CR>
157let g:vimwiki_list = [{
158 \ 'path': '~/log/',
159 \ 'syntax': 'markdown',
160 \ 'ext': '.md',
161 \ }]
162
163" Git push quietly whenever leaving vim with VimWiki files
164augroup vimwikiPush
165 autocmd!
166 autocmd VimLeave ~/log/* :!(cd ~/log && git add * && git commit -am Update && git push origin >/dev/null 2>&1 &)
167augroup END
168
169" Configuration fro vim-instant-markdown
170let g:instant_markdown_autostart = 0
171nnoremap <leader>md :InstantMarkdownPreview<CR>
172
173"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
174" => Settings for Blog
175"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
176
177" Generate static pages
178augroup blogRebuild
179 autocmd!
180 autocmd BufWritePost ~/blog/*.md :!cd ~/blog && hugo >/dev/null
181augroup END
182
183"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
184" => Settings for Slides
185"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
186
187" Generate static pages
188augroup slideRebuild
189 autocmd BufWritePost ~/public/**/slide/*.md :!(cd %:p:h && ~/helper/bin/markdown/reveal %:t >/dev/null &)
190augroup END
191
192"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
193" => Redirect the output of a Vim or external command into a scratch buffer
194"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
195" Copy from : https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7
196"
197" Usage:
198" :Redir hi ............. show the full output of command ':hi' in a scratch window
199" :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window
200
201function! Redir(cmd)
202 for win in range(1, winnr('$'))
203 if getwinvar(win, 'scratch')
204 execute win . 'windo close'
205 endif
206 endfor
207 if a:cmd =~ '^!'
208 let output = system(matchstr(a:cmd, '^!\zs.*'))
209 else
210 redir => output
211 execute a:cmd
212 redir END
213 endif
214 vnew
215 let w:scratch = 1
216 setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
217 call setline(1, split(output, "\n"))
218endfunction
219
220command! -nargs=1 -complete=command Redir silent call Redir(<q-args>)
221nnoremap <leader>r :Redir
222
223
224"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
225" => Make Alt key works on Gnome terminal
226"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
227" Solution is here: https://stackoverflow.com/questions/6778961
228
229let c='a'
230while c <= 'z'
231 exec "set <A-".c.">=\e".c
232 exec "imap \e".c." <A-".c.">"
233 let c = nr2char(1+char2nr(c))
234endw
235set timeout ttimeoutlen=50
236
237
238"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
239" => vim-racer
240"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
241set hidden
242let g:racer_cmd = "~/.cargo/bin/racer"
243let g:racer_experimental_completer = 1
244
245autocmd FileType rust nmap gd <Plug>(rust-def)
246autocmd FileType rust nmap gs <Plug>(rust-def-split)
247autocmd FileType rust nmap gx <Plug>(rust-def-vertical)
248autocmd FileType rust nmap <leader>gd <Plug>(rust-doc)
249
250
251"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
252" => vim-plug
253"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
254" run :PlugInstall to install plugins
255
256call plug#begin('~/.vim/plugged')
257
258" Add indent line
259
260Plug 'Yggdroot/indentLine'
261Plug 'mileszs/ack.vim'
262Plug 'tpope/vim-surround'
263"Plug 'lifepillar/pgsql.vim'
264Plug 'vimwiki/vimwiki'
265"Plug 'iberianpig/tig-explorer.vim'
266Plug 'rust-lang/rust.vim'
267"Plug 'racer-rust/vim-racer'
268"Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
269Plug 'junegunn/fzf.vim'
270Plug 'michal-h21/vim-zettel'
271Plug 'rlue/vim-barbaric'
272Plug 'nathangrigg/vim-beancount'
273Plug 'preservim/nerdtree'
274
275" Initialize plugin system
276call plug#end()
277
278"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
279" => lf
280"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
281" Use lf as file selector
282function! LF()
283 let temp = tempname()
284 exec 'silent !lf -selection-path=' . shellescape(temp)
285 if !filereadable(temp)
286 redraw!
287 return
288 endif
289 let names = readfile(temp)
290 if empty(names)
291 redraw!
292 return
293 endif
294 exec 'edit ' . fnameescape(names[0])
295 for name in names[1:]
296 exec 'argadd ' . fnameescape(name)
297 endfor
298 redraw!
299endfunction
300command! -bar LF call LF()