-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
275 lines (213 loc) · 6.48 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
270
271
272
273
274
275
" Define autocmd group vimrc.
augroup myvimrc
autocmd!
augroup END
set rtp+=~/.vim/bundle/Vundle.vim
filetype off
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" Plugin 'christoomey/vim-tmux-navigator'
Plugin 'tomasr/molokai'
" Plugin 'bling/vim-airline'
" Plugin 'edkolev/tmuxline.vim'
" Plugin 'vim-airline/vim-airline-themes'
Plugin 'powerline/powerline'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-dispatch'
Plugin 'airblade/vim-gitgutter'
Plugin 'kien/ctrlp.vim'
Plugin 'Yggdroot/indentLine'
Plugin 'davidhalter/jedi-vim'
Plugin 'klen/python-mode'
Plugin 'ervandew/supertab'
Plugin 'scrooloose/nerdtree'
Plugin 'SirVer/ultisnips'
"Plugin 'fatih/vim-go'
call vundle#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()
python3 del powerline_setup
" Vim-Tmux-Navigator
"let g:tmux_navigator_no_mappings = 1
" Airline
let g:airline_theme = "powerlineish"
let g:airline_powerline_fonts = 1
" Supertab
let g:SuperTabDefaultCompletionType = "<C-n>"
" UltiSnips
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<S-tab>"
let g:UltiSnipsSnippetDir="~/.vim/UltiSnips"
" Pymode
let g:pymode_rope = 0
let g:pymode_folding = 0
let g:pymode_lint_unmodified = 1
let g:pymode_lint_checkers = ['pep8', 'pyflakes']
" CtrlP Settings
let g:ctrlp_max_height = 10
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_working_path_mode = 0
" Jedi-vim
let g:jedi#use_splits_not_buffers = "right"
"Disptach
autocmd myvimrc FileType python let b:dispatch = 'py.test %'
nnoremap <F9> :Dispatch<CR>
nnoremap <F10> :Dispatch python %<CR>
" Toggle NERDTree hotkey
map <F2> :NERDTreeToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader=','
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :vsplit $MYVIMRC<CR>
nmap <silent> <leader>et :vsplit ~/.tmux.conf<CR>
nmap <silent> <leader>ed :vsplit ~/.bash_profile<CR>
nmap <silent> <leader>r :so $MYVIMRC<CR>
" CLI/ GUI settings
if has("gui_running")
" Start window maximized
set lines=999 columns=999
" Fix Powerline icons for the GUI
set guifont=Inconsolata\ for\ Powerline:h15
else
" Fix molokai color schema for the CLI
set term=xterm-256color
let g:rehash256 = 1
endif
" Vim, not vi
set nocompatible
" Show the command shortcut in the status line
set showcmd
" Optimize redrawing (improves speed)
set lazyredraw
set ttyfast
" Raise a dialogue for saving changes
set confirm
" Enable file type detection and plugin loading
filetype plugin indent on
" Use Unix as the standard file type
set ffs=unix,mac,dos
" Set output encoding
set encoding=utf-8
" Autoupdate file changes made outside vim
set autoread
" Set filetype specific options via modelines
set modeline
" Disable backups
set nobackup
set noswapfile
set nowritebackup
" Always display the status line, even if only one window is displayed
set laststatus=2
" Ignore these files
set wildignore+=*.pyc,*_build/*,*/coverage/*
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colorscheme
try
colors molokai
catch
endtry
" Enable syntax highlighing
syntax enable
" Open splitpanes below and on the right of the current one.
set splitbelow
set splitright
" Toggle highlighting current line only in active splits
autocmd myvimrc VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd myvimrc WinLeave * setlocal nocursorline
" Highlight current line
set cursorline
" Line numbers
set number
set relativenumber
map <F4> :set relativenumber!<CR>
map! <F4> <Esc>:set relativenumber!<CR>gi
" Regex and search options
set ignorecase
set smartcase
set hlsearch
set incsearch
set magic
" Temporary turn off hlsearch
nnoremap <silent> <leader><CR> :noh<CR>
" Save files
nmap <leader>w :w<CR>
imap <leader>w <Esc>:w<CR>gi
vmap <leader>w <Esc>:w<CR>gv
" Close files (will raise confirmation dialog for unsaved changes)
nmap <leader>q :q<CR>
imap <leader>q <Esc>:q<CR>gi
vmap <leader>q <Esc>:q<CR>gv
" Visual autocomplete for command menu
set wildmenu
" First tab will complete to the longest common string
set wildmode=longest:full,full
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text and formatting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Use 4 spaces instead of tabs
set tabstop=4
set shiftwidth=4
set expandtab
" Use 2 spaces instead of tabs for HTML and YAML files
autocmd myvimrc FileType html,yaml setlocal shiftwidth=2 tabstop=2
" Wrap lines to 72 characters in git commit messages and use 2 spaces for tab
autocmd myvimrc FileType gitcommit setlocal spell textwidth=72 shiftwidth=2 tabstop=2
" Don't leave space between joined lines
set nojoinspaces
" Fix identation when pasting in Insert mode
set pastetoggle=<F3>
" Sort lines alphabetically (useful for sorting Python imports)
vnoremap <leader>s :sort<CR>
" Go back to visual mode after reindenting
vnoremap < <gv
vnoremap > >gv
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Navigation and moving around
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Exit insert mode with jj
inoremap jj <Esc>
" Go to the next line in editor for wrapped lines
nnoremap j gj
nnoremap k gk
"Easier navigation through split windows
nnoremap <C-j> <C-w><Down>
nnoremap <C-k> <C-w><Up>
nnoremap <C-l> <C-w><Right>
nnoremap <C-h> <C-w><Left>
nnoremap <silent> <C-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <C-j> :TmuxNavigateDown<cr>
nnoremap <silent> <C-k> :TmuxNavigateUp<cr>
nnoremap <silent> <C-l> :TmuxNavigateRight<cr>
nnoremap <silent> <C-\> :TmuxNavigatePrevious<cr>
" We say 'NO' to arrow keys
nnoremap <Up> <NOP>
nnoremap <Down> <NOP>
nnoremap <Left> <NOP>
nnoremap <Right> <NOP>
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" Remap 0 to go to first non-blank character of the line
map 0 ^
" Remap Y to apply till EOL, just like D and C.
map Y y$