blob: 03ffd98da0f09a9935a053b22791277e60ae1653 (
plain)
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
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Custom Config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set cursorline
set number
set relativenumber
set showcmd
set nowrap
set nosol
set ss=1
set siso=999
" general
nmap <c-c> :q<CR>
nnoremap <leader>R :.w !bash<CR>
nnoremap <leader>, :w !bash<CR>
nnoremap <leader>W :set wrap!<CR>
nnoremap <leader>T :vertical terminal<CR>
nnoremap <leader>u :set clipboard=unnamedplus<CR>
nnoremap <CR> o<Esc>
nnoremap <C-L> 60l
nnoremap <C-H> 60h
nnoremap <C-K> ddkP
nnoremap <C-J> ddp
nnoremap <silent> <leader>s
\ : if exists("syntax_on") <BAR>
\ syntax off <BAR>
\ else <BAR>
\ syntax enable <BAR>
\ endif<CR>
nnoremap <leader>S :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')),' ')<CR>
" Operator pending
onoremap p i(
onoremap ap a(
onoremap np :<c-u>normal! f(vi(<cr>
onoremap b /return<CR>
" new
nnoremap H 0
nnoremap L $
inoremap jk <ESC>
inoremap <ESC> <nop>
" surround with '' or ""
nnoremap <leader>' ea'<esc>bi'<esc>e
nnoremap <leader>" ea"<esc>bi"<esc>e
vnoremap ' <ESC>`<i'<ESC>`>la'<ESC>
vnoremap " <ESC>`<i"<ESC>`>la"<ESC>
" abbrev
iabbrev @@ typebrook@gmail.com
" vim_markdown
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Settings for Vimwiki
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>tt :VimwikiTable<CR>
nnoremap <leader>wg :VimwikiGoto
nnoremap <leader>wa :VimwikiSearchTags
nnoremap <leader>i I- <esc>l
let g:vimwiki_list = [{'path': '~/vimwiki/', 'auto_tags': 1}]
" Git push quietly whenever leaving vim after editing Vimwiki
augroup vimwikiPush
autocmd!
autocmd VimLeave ~/vimwiki/* :!(~/vimwiki/scripts/upload.sh > /dev/null 2>&1 &)
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Redirect the output of a Vim or external command into a scratch buffer
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Copy from : https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7
"
" Usage:
" :Redir hi ............. show the full output of command ':hi' in a scratch window
" :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window
function! Redir(cmd)
for win in range(1, winnr('$'))
if getwinvar(win, 'scratch')
execute win . 'windo close'
endif
endfor
if a:cmd =~ '^!'
let output = system(matchstr(a:cmd, '^!\zs.*'))
else
redir => output
execute a:cmd
redir END
endif
vnew
let w:scratch = 1
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
call setline(1, split(output, "\n"))
endfunction
command! -nargs=1 -complete=command Redir silent call Redir(<q-args>)
nnoremap <leader>r :Redir
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Make Alt key works on Gnome terminal
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Solution is here: https://stackoverflow.com/questions/6778961
let c='a'
while c <= 'z'
exec "set <A-".c.">=\e".c
exec "imap \e".c." <A-".c.">"
let c = nr2char(1+char2nr(c))
endw
set timeout ttimeoutlen=50
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vim-racer
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hidden
let g:racer_cmd = "~/.cargo/bin/racer"
let g:racer_experimental_completer = 1
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap gs <Plug>(rust-def-split)
au FileType rust nmap gx <Plug>(rust-def-vertical)
au FileType rust nmap <leader>gd <Plug>(rust-doc)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vim-plug
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" run :PlugInstall to install plugins
call plug#begin('~/.vim/plugged')
" Add indent line
Plug 'Yggdroot/indentLine'
Plug 'mileszs/ack.vim'
Plug 'tpope/vim-surround'
Plug 'lifepillar/pgsql.vim'
Plug 'vimwiki/vimwiki'
Plug 'iberianpig/tig-explorer.vim'
Plug 'rust-lang/rust.vim'
Plug 'racer-rust/vim-racer'
" Initialize plugin system
call plug#end()
|