-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
163 lines (127 loc) · 4.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
let mapleader = "\<Space>"
" Plugins will be downloaded under the specified directory
call plug#begin('~/.local/share/nvim/plugged')
" Fuzzy finder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Plug 'kien/ctrlp.vim'
Plug 'mileszs/ack.vim'
Plug 'ciaranm/securemodelines'
" Plug 'justinmk/vim-sneak' " Jump to any location specified by two characters
" Plug 'editorconfig/editorconfig-vim'
Plug 'tpope/vim-commentary' " Comment out code easily
Plug 'tpope/vim-rails' " Various Rails shortcut, might not be that necessary
Plug 'tpope/vim-fugitive' " Git wrapper, for features such as GitBlame
Plug 'tpope/vim-surround' " Surround texts easily
" GUI enhancements
Plug 'itchyny/lightline.vim'
Plug 'machakann/vim-highlightedyank'
Plug 'andymass/vim-matchup'
" Conquer of Completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Test runner
Plug 'janko/vim-test'
" Syntactic language support
" Plug 'cespare/vim-toml'
" Plug 'stephpy/vim-yaml'
" Plug 'rust-lang/rust.vim'
" Plug 'rhysd/vim-clang-format'
" Plug 'fatih/vim-go'
" Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } }
Plug 'vim-ruby/vim-ruby'
Plug 'posva/vim-vue'
Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'morhetz/gruvbox'
" List ends here. Plugins become visible to neovim after this call.
call plug#end()
nnoremap :W :w
nnoremap ff :FZF
" Map vim-test's :TestNearest with :tt
nnoremap tt :TestNearest
nnoremap tf :TestFile
" Set tabstop
set tabstop=2 shiftwidth=2 expandtab
" Colors
set background=dark
colorscheme gruvbox
set colorcolumn=120 " Show vertical line at column 120
set number " Also show current absolute line
set showcmd " Show (partial) command in status line.
set mouse=a " Enable mouse usage (all modes) in terminals
" Show underline at current cursor
hi clear CursorLine
hi CursorLine gui=underline cterm=underline
set cursorline
" Show those damn hidden characters
" Verbose: set listchars=nbsp:¬,eol:¶,extends:»,precedes:«,trail:•
set listchars=nbsp:¬,extends:»,precedes:«,trail:•
" Highlight and trim trailing spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
set guioptions-=T " Remove toolbar
set ttyfast
set lazyredraw
" Use old version of regex engine to speed up vim
set re=1
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""'
endif
" Replace ack by ag
let g:ackprg = 'ag --vimgrep --smart-case'
cnoreabbrev ag Ack
cnoreabbrev aG Ack
cnoreabbrev Ag Ack
cnoreabbrev AG Ack
" Map \ key to Ag (silver search)
nnoremap \ :Ack<space>
" Fix Shift-JIS file encoding issue
set fileencodings=ucs-bom,utf-8,sjis,default
" Quick save
nmap <leader>w :w<CR>
" Quick file open
nnoremap <Leader>o :CtrlP<CR>
" Make Ctrl-P plugin a lot faster for Git project
let g:ctrlp_use_caching = 0
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
else
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<space>', '<cr>', '<2-LeftMouse>'],
\ }
endif
" Quick back and forth buffer switching
nnoremap <Leader><Leader> :e#<CR>
" Quick copy & paste to system clipboard
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
" Neat X clipboard integration
" Space+p will paste clipboard into buffer
" Space+c will copy entire buffer into clipboard
noremap <leader>p :read !xsel --clipboard --output<cr>
noremap <leader>c :w !xsel -ib<cr><cr>
" Avoid buftype error when saving remote file
autocmd BufRead scp://* :set bt=acwrite
" Undo
set undodir=/home/dat/.vim/undo/
set undofile
set undolevels=1000
set undoreload=10000