-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
308 lines (225 loc) · 8.68 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
" =============================================================================
" ~/.vimrc
" Last updated: November 15, 2024 by Abdullah Alharbi
" =============================================================================
" Automatic reloading of .vimrc
autocmd! bufwritepost .vimrc source %
" Arabic support
set encoding=utf-8
set arabicshape
" Better copy & paste
" When you want to paste large blocks of code into vim, press F2 before you
" paste. At the bottom you should see ``-- INSERT (paste) --``.
set pastetoggle=<F2>
set clipboard^=unnamed,unnamedplus
" Mouse and backspace
set mouse=a " on OSX press ALT and click
set bs=2 " make backspace behave like normal again
" Rebind <Leader> key
" I like to have it here becuase it is easier to reach than the default and
" it is next to ``m`` and ``n`` which I use for navigating between tabs.
let mapleader = ","
" Bind nohl
" Removes highlight of your last search
" ``<C>`` stands for ``CTRL`` and therefore ``<C-n>`` stands for ``CTRL+n``
noremap <C-c> :nohl<CR>
vnoremap <C-c> :nohl<CR>
inoremap <C-c> :nohl<CR>
" Quicksave command
noremap <C-Z> :update<CR>
vnoremap <C-Z> <C-C>:update<CR>
inoremap <C-Z> <C-O>:update<CR>
" Quick quit command
noremap <Leader>e :quit<CR> " Quit current window
noremap <Leader>E :qa!<CR> " Quit all windows
" bind Ctrl+<movement> keys to move around the windows, instead of using Ctrl+w + <movement>
" Every unnecessary keystroke that can be saved is good for your health :)
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" easier moving between tabs
map <Leader>n <esc>:tabprevious<CR>
map <Leader>m <esc>:tabnext<CR>
" map sort function to a key
vnoremap <Leader>s :sort<CR>
" easier moving of code blocks
" Try to go into visual mode (v), thenselect several lines of code here and
" then press ``>`` several times.
vnoremap < <gv " better indentation
vnoremap > >gv " better indentation
" Show whitespace
" MUST be inserted BEFORE the colorscheme command
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
au InsertLeave * match ExtraWhitespace /\s\+$/
" Color scheme
" mkdir -p ~/.vim/colors && cd ~/.vim/colors
" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
set t_Co=256
color wombat256mod
" Enable syntax highlighting
" You need to reload this file for the change to apply
filetype off
filetype plugin indent on
syntax on
" Showing line numbers and length
set number " show line numbers
set tw=79 " width of document (used by gd)
set nowrap " don't automatically wrap on load
set fo-=t " don't automatically wrap text when typing
set colorcolumn=88
highlight ColorColumn ctermbg=233
" Relative numbers
set relativenumber
" Easier formatting of paragraphs
vmap Q gq
nmap Q gqap
" Useful settings
set history=700
set undolevels=700
" Indentation
autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4 shiftround expandtab
autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab
autocmd FileType html setlocal tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab
autocmd FileType htmldjango setlocal tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab
autocmd FileType css setlocal tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab
autocmd FileType scss setlocal tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab
" Make search case insensitive
set hlsearch
set incsearch
set ignorecase
set smartcase
" Disable stupid backup and swap files - they trigger too many events
" for file system watchers
set nobackup
set nowritebackup
set noswapfile
" Setup Pathogen to manage your plugins
" mkdir -p ~/.vim/autoload ~/.vim/bundle
" curl -so ~/.vim/autoload/pathogen.vim https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
" Now you can install any plugin into a .vim/bundle/plugin-name/ folder
call pathogen#infect()
" Setup The NERD Tree
" git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
map <C-n> :NERDTreeToggle<CR>
" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeIgnore = ['\.pyc$']
let NERDTreeIgnore = ['^__pycache__$[[dir]]']
" Setting custom indent colors
" cd ~/.vim/bundle
" git clone git://github.com/nathanaelkane/vim-indent-guides.git
let indent_guides_auto_colors = 0
let indent_guides_guide_size = 1
hi IndentGuidesOdd ctermbg=236
hi IndentGuidesEven ctermbg=237
" Syntastic syntax checking plugin
" cd ~/.vim/bundle
" git clone --depth=1 https://github.com/vim-syntastic/syntastic.git
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_flake8_post_args = "--ignore=E501"
let g:syntastic_python_pylint_args = "--load-plugins pylint_django"
let g:syntastic_python_pylint_post_args="--max-line-length=88"
" Settings for vim-javascript
" cd ~/.vim/bundle
" git clone https://github.com/pangloss/vim-javascript.git
let g:javascript_plugin_flow = 1
" Syntax highlighting and indenting for JSX
" cd ~/.vim/bundle
" git clone https://github.com/maxmellon/vim-jsx-pretty.git
let g:vim_jsx_pretty_highlight_close_tag = 1
" Settings for emmet-vim
" cd ~/.vim/bundle
" git clone https://github.com/mattn/emmet-vim.git
" Enable just for html/css
let g:user_emmet_install_global = 0
autocmd FileType html,htmldjango,css,javascript EmmetInstall
" Settings for commentary.vim
" cd ~/.vim/bundle
" git clone https://tpope.io/vim/commentary.git
autocmd FileType python setlocal commentstring=#\ %s
autocmd FileType javascript.jsx setlocal commentstring={/*\ %s\ */}
" surround.vim
" cd ~/.vim/bundle
" git clone https://tpope.io/vim/surround.git
" Syntax highlighting for Django templates
" download django.vim from https://www.vim.org/scripts/script.php?script_id=1487
" mkdir ~/.vim/syntax
" mv django.vim ~/.vim/syntax
" Settings for vim-plug
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
" Black formatter (for Python)
Plug 'psf/black', { 'branch': 'stable' }
" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting
" =============================================================================
" Python IDE Setup
" =============================================================================
" Settings for flake8
" cd ~/.vim/bundle
" git clone https://github.com/nvie/vim-flake8.git
" To config flake8 create .flake8 file in the project directory
" The below example is to configure the maximum line length
" [flake8]
" max-line-length=88
autocmd FileType python map <buffer> <Leader>F :call flake8#Flake8()<CR>
" Settings for Black
noremap <Leader>f :Black<CR>
" Settings for vim-powerline
" cd ~/.vim/bundle
" git clone https://github.com/Lokaltog/vim-powerline.git
set laststatus=2
" Settings for ctrlp
" cd ~/.vim/bundle
" git clone https://github.com/kien/ctrlp.vim.git
let g:ctrlp_max_height = 30
map <leader>4 :CtrlPClearCache<CR>
set wildignore+=*.pyc
set wildignore+=*_build/*
set wildignore+=*/coverage/*
" Settings for jedi-vim
" cd ~/.vim/bundle
" git clone https://github.com/davidhalter/jedi-vim.git
" NOTE: you should have jedi already installed.
" To install jedi: sudo pip install jedi
let g:jedi#usages_command = "<leader>z"
let g:jedi#popup_on_dot = 0
let g:jedi#popup_select_first = 0
map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
" Better navigating through omnicomplete option list
" See http://stackoverflow.com/questions/2170023/how-to-map-keys-for-popup-menu-in-vim
set completeopt=longest,menuone
function! OmniPopup(action)
if pumvisible()
if a:action == 'j'
return "\<C-N>"
elseif a:action == 'k'
return "\<C-P>"
endif
endif
return a:action
endfunction
inoremap <silent><C-j> <C-R>=OmniPopup('j')<CR>
inoremap <silent><C-k> <C-R>=OmniPopup('k')<CR>
" Python folding
" mkdir -p ~/.vim/ftplugin
" wget -O ~/.vim/ftplugin/python_editing.vim http://www.vim.org/scripts/download_script.php?src_id=5492
set nofoldenable