-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
269 lines (196 loc) · 7.87 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
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
filetype off
" --------------- Plugins installed ------------------------------------------- "
call plug#begin('~/.vim/plugged')
" YouCompleteMe disabled by default.
" Uncomment and run :PlugInstall to install it.
" Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
" Plug 'scrooloose/syntastic'
Plug 'andreamichi/base16-vim'
Plug 'airblade/vim-gitgutter'
Plug 'christoomey/vim-tmux-navigator'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'duganchen/vim-soy'
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar'
Plug 'ntpeters/vim-better-whitespace'
Plug 'plasticboy/vim-markdown'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'scrooloose/nerdtree'
Plug 'SirVer/ultisnips'
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'vim-scripts/a.vim', {'for': ['cpp', 'c'] }
Plug 'w0rp/ale'
" Plugins for Neovim.
if has('nvim')
Plug 'kassio/neoterm'
endif
call plug#end()
syntax on
filetype plugin indent on
set background=dark
colorscheme default
" --------------- Indentation and Formatting ----------------------------------
set autoindent " Copy indent from current line when starting a new one.
set smartindent " Smart autoindenting when starting a new line.
set smarttab " <Tab> depends on the value of 'shiftwidth'.
set expandtab " Use appropriate number of spaces rather than tab.
set shiftround " Round indent to multiple of shiftwidth.
set nowrap " Don't wrap lines longer than width of the window>
set scrolloff=5 " minimal number of lines above/below cursor on scrolling.
set tabstop=2 " number of spaces that a <Tab> counts for normally.
set softtabstop=2 " number of spaces that a <Tab> counts for while editing.
set shiftwidth=2 " Values used by smarttab setting.
" Default indentation and folding settings for specific languages.
augroup indentation
autocmd!
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType python setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType java setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType go setlocal noexpandtab
augroup END
" --------------- General Settings --------------------------------------------
set backspace=indent,eol,start " Allow backspace over everything in insert mode.
set number " Add numbers to the left.
set ruler " Show line and column number of the cursor position.
set showcmd " Show partial command in the last line of the screen.
set nostartofline " Keep the cursor on the same column when moving.
set nobackup " Do not create backup files.
set noswapfile " Do not create swap files.
set history=128 " History level.
set undolevels=512 " Number of undo available.
set autoread " Reload file when changed on disk (e.g. git checkout).
set fdm=manual " Folding method used.
set foldlevel=99 " Folding level.
set splitbelow " Open orizontal split on the bottom.
set splitright " Open vertical split on the right.
let mapleader="," " Change the mapleader from '\' to ','.
" --------------- Navigation Settings ------------------------------------------
" Terminal configuration (Neovim).
if exists(':tnoremap')
tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
" If the buffer is a terminal default to Insert mode.
au BufEnter * if &buftype == 'terminal' | :startinsert | endif
endif
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <M-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <M-j> :TmuxNavigateDown<cr>
nnoremap <silent> <M-k> :TmuxNavigateUp<cr>
nnoremap <silent> <M-l> :TmuxNavigateRight<cr>
" --------------- Searching Settings ------------------------------------------
" Searching is not case sensitive when the pattern contains only lower
" case letters (defined by set ignorecase). However, in the presence of
" upper case letters, the search becomes case sensitive.
set hlsearch " highlight all matches of a search pattern.
set incsearch " Show where the pattern, while typying a search command.
set smartcase " Override 'ignorecase' for upper case search patterns.
set ignorecase " Ignore case of normal letters.
" Use <C-l> to clear the highlighting of :set hlsearch.
nnoremap <silent> <C-l> :nohlsearch<CR>
" --------------- Copy/Paste Settings ------------------------------------------
" Copy to clipboard.
vnoremap <Leader>y "+y
nnoremap <Leader>Y "+yg_
nnoremap <Leader>y "+y
nnoremap <Leader>yy "+yy
" Paste from clipboard.
nnoremap <Leader>p "+p
nnoremap <Leader>P "+P
vnoremap <Leader>p "+p
vnoremap <Leader>P "+P
inoremap <Leader>p <ESC>"+P
" --------------- Miscellaneous Settings -------------------------------------
" Easier access to the <ESC>.
inoremap jk <ESC>
" Move to back and forward through buffer.
nnoremap <silent> <C-b> :bp<CR>
nnoremap <silent> <C-n> :bn<CR>
" Swap numbers and relative numbers.
nnoremap <silent> <Leader>n :set relativenumber!<CR>
" FZF configuration.
" nnoremap <Leader><Leader> :Files<CR>
nnoremap <Leader><Leader> :Files<CR>
nnoremap <Leader>b :Buffers<CR>
let $FZF_DEFAULT_COMMAND = 'list_all_files'
" CtrlP working directory is the nearest ancestor (directory with .git) or
" the current working directory.
let g:ctrlp_working_path_mode = 'ra'
" Ctrlp will ignore these files.
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc
" Set clang and c++ for syntastic.
" let g:syntastic_cpp_compiler = 'clang++'
" let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
" Open NERDTree with <Leader>t
nnoremap <Leader>t :NERDTreeToggle<CR>
" Close vim if NERDTree is the only window open.
augroup nerdtree
autocmd! bufenter * if (winnr("$") == 1 &&
\ exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
augroup END
" Removing YouCompleteMe preview window.
let g:ycm_add_preview_to_completeopt = 0
set completeopt-=preview
" Close preview window when done.
augroup youcompleteme
autocmd!
autocmd CompleteDone * pclose
augroup END
" Ultisnips configuration.
let g:UltiSnipsExpandTrigger = "<c-k>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
" Open buffer list
nnoremap gb :ls<CR>:buffer<Space>
" --------------- EasyMotion Settings -----------------------------------------
" Disable default mappings
let g:EasyMotion_do_mapping = 0
" Turn on case insensitive feature.
let g:EasyMotion_smartcase = 1
" Jump anywhere with typing two characters.
nmap s <Plug>(easymotion-overwin-f2)
" Jump between words.
map <Leader>w <Plug>(easymotion-bd-w)
" --------------- Git Settings ------------------------------------------------
" Set 1 to start vim-gitgutter by default
let g:gitgutter_enabled = 0
" Enabled/Disabled'
map <Leader>gg :GitGutterToggle<CR>
map <Leader>gs :Gstatus<CR>
" Automatically wrap at 72 characters and spell check git commit messages
augroup git
autocmd!
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType gitcommit setlocal spell
augroup END
" --------------- Markdown Settings -------------------------------------------
augroup markdown
autocmd!
autocmd BufEnter *.md setlocal foldexpr=MarkdownFolding()
autocmd BufRead,BufNewFile *.md setlocal wrap textwidth=80
augroup END
let g:vim_markdown_folding_disabled=1
" Mapping to space to fold toggle.
nnoremap <Space> za
function! MarkdownFolding()
let h = matchstr(getline(v:lnum), '^#\+')
if empty(h)
return "="
else
return ">" . len(h)
endif
endfunction
" --------------- Local vimrc ------------------------------------------------
if !empty(glob("$HOME/.vimrc.local"))
source $HOME/.vimrc.local
endif