-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
355 lines (309 loc) · 12.7 KB
/
init.vim
File metadata and controls
355 lines (309 loc) · 12.7 KB
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
set nocompatible " be iMproved
" -------
" Plugins
" -------
call plug#begin('~/.config/nvim/plugged')
" General
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-unimpaired'
Plug 'majutsushi/tagbar'
Plug 'vim-scripts/TaskList.vim'
Plug 'bling/vim-airline'
" Snippets
Plug 'SirVer/ultisnips'
Plug 'znotdead/vim-snippets'
Plug 'mhartington/vim-angular2-snippets'
" Fuzzy
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Completion
" Language Server Client
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" (Optional) Multi-entry selection UI.
" (Completion plugin option 1)
" Plug 'roxma/nvim-completion-manager'
" (Completion plugin option 2)
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'deoplete-plugins/deoplete-jedi' " Python completion
" Diff languages helpers
Plug 'scrooloose/syntastic'
Plug 'prettier/vim-prettier', {
\ 'do': 'npm install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue'] }
" RUST
Plug 'rust-lang/rust.vim'
" toml
Plug 'cespare/vim-toml'
" Typescript
Plug 'leafgarland/typescript-vim'
" Python
Plug 'jmcantrell/vim-virtualenv'
Plug 'fisadev/vim-isort'
Plug 'fs111/pydoc.vim'
Plug 'psf/black'
" HTML
Plug 'rstacruz/sparkup'
" Git
Plug 'tpope/vim-fugitive'
" Markdown
call plug#end()
" ------------------------------------------------------------------------------
" Virtualenv
" ------------------------------------------------------------------------------
" :VirtualEnvActivate
" :VirtualEnvDeactivate
" ------------------------------------------------------------------------------
" Pydoc
" ------------------------------------------------------------------------------
" ,pw - show docs for word
" ,pk - search by keyword
" :Pydoc <module>
" ------------------------------------------------------------------------------
" Syntastic
" ------------------------------------------------------------------------------
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_checkers=['flake8']
let g:syntastic_python_flake8_args='--max-line-length=100'
" ------------------------------------------------------------------------------
" GIT Fugitive settings
" ------------------------------------------------------------------------------
set statusline+=%{FugitiveStatusline()}
" ------------------------------------------------------------------------------
" Airline settings
" ------------------------------------------------------------------------------
let g:airline_powerline_fonts = 1
let g:airline_detect_modified = 1
let g:airline_detect_paste = 1
let g:airline_theme = 'dark'
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#left_sep = '|'
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#right_sep = '|'
let g:airline#extensions#tabline#right_alt_sep = '|'
"nmap <M-1> <Plug>AirlineSelectTab1
"nmap <M-2> <Plug>AirlineSelectTab2
"nmap <M-3> <Plug>AirlineSelectTab3
"nmap <M-4> <Plug>AirlineSelectTab4
"nmap <M-5> <Plug>AirlineSelectTab5
"nmap <M-6> <Plug>AirlineSelectTab6
"nmap <M-7> <Plug>AirlineSelectTab7
"nmap <M-8> <Plug>AirlineSelectTab8
"nmap <M-9> <Plug>AirlineSelectTab9
nmap <M-,> <Plug>AirlineSelectPrevTab
nmap <M-.> <Plug>AirlineSelectNextTab
let g:airline_extensions = ['syntastic', 'tabline']
" ------------------------------------------------------------------------------
" UltiSnips
" ------------------------------------------------------------------------------
let g:UltiSnipsExpandTrigger = "<c-j>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-p>"
let g:UltiSnipsListSnippets = "<c-k>" "List possible snippets based on current file
" ------------------------------------------------------------------------------
" Sparkup
" ------------------------------------------------------------------------------
" Ctrl+E, Ctrl+n
" ------------------------------------------------------------------------------
" Deoplete
" ------------------------------------------------------------------------------
let g:deoplete#enable_at_startup = 1
set completeopt+=noinsert
" ------------------------------------------------------------------------------
" NERDTree Settings
" ------------------------------------------------------------------------------
" Hide python cache files (.pyc) in NERDTree
let NERDTreeIgnore=['\.pyc']
" open NERDTree with start directory
nnoremap <F9> :NERDTreeToggle ~/projects/<CR>
let NERDTreeShowBookmarks=1
" automatically open NERDtree
autocmd vimenter * NERDTree
"-------------------------------------------------------------------------------
" unimpaired
"-------------------------------------------------------------------------------
" Text movimg with plugin unimpaired.vim
" Bubble single lines
nmap <M-Up> [e
nmap <M-Down> ]e
" Bubble multiple lines
vmap <M-Up> [egv
vmap <M-Down> ]egv
" ------------------------------------------------------------------------------
" Other settings
" ------------------------------------------------------------------------------
" colors
colorscheme darkmate
set termguicolors
"Invisible character colors
highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59
" insert empty lines in normal mode
nnoremap <Enter> o<ESC>
" Text indentation with Alt+Letf/Right and so on
nnoremap <M-Left> <<
nnoremap <M-Right> >>
vmap <M-Left> <gv
vmap <M-Right> >gv
nnoremap <M-h> <<
nnoremap <M-l> >>
vmap <M-h> <gv
vmap <M-l> >gv
" Visual
set showmatch " Show matching brackets.
set colorcolumn=100
""" Searching and Patterns
set ignorecase " Default to using case insensitive searches,
set smartcase " unless uppercase letters are used in the regex.
set hlsearch " Highlight searches by default.
set incsearch " Incrementally search while typing a /regex
""" Folding
set foldmethod=indent " By default, use syntax to determine folds
set foldlevelstart=99 " All folds open by default
set number " Display line numbers
set numberwidth=1 " using only 1 column (and 1 space) while possible
set background=dark
""" Messages, Info, Status
set vb t_vb= " Disable all bells. I hate ringing/flashing.
set confirm " Y-N-C prompt if closing with unsaved changes.
set showcmd " Show incomplete normal mode commands as I type.
set report=0 " : commands always print changed line count.
set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written.
set ruler " Show some info, even without statuslines.
set laststatus=2 " Always show statusline, even if only 1 window.
""" Tabs/Indent Levels
set tabstop=4 " <tab> inserts 4 spaces
set shiftwidth=4 " but an indent level is 2 spaces wide.
set softtabstop=4 " <BS> over an autoindent deletes both spaces.
set expandtab " Use spaces, not tabs, for autoindent/tab key.
set shiftround " rounds indent to a multiple of shiftwidth
set autoindent " Keep indentation level from previous line
set textwidth=99 "
""" Command Line
set history=1000 " Keep a very long command-line history.
set wildmenu " Menu completion in command mode on <Tab>
set wildmode=full " <Tab> cycles between all matching choices.
""" Per-Filetype Scripts
" NOTE: These define autocmds, so they should come before any other autocmds.
" That way, a later autocmd can override the result of one defined here.
filetype on " Enable filetype detection,
filetype indent on " use filetype-specific indenting where available,
filetype plugin on " also allow for filetype-specific plugins,
syntax on " and turn on per-filetype syntax highlighting.
""" OTHER SETTINGS
" set <leader> as ,
let mapleader = ","
" Empty highlight after search by leader - space
nnoremap <leader><space> :noh<cr>
" Execute file being edited with <Shift> + e:
map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>
" Shift+Insert will paste from system buffer (Control+C)
cmap <S-Insert> <C-R>+
exe 'inoremap <script> <S-Insert>' paste#paste_cmd['i']
" CTRL+S saves the buffer
nmap <C-s> :w<CR>
" CTRL+F format python with Black
map <C-F> :call black#Black()<cr>
imap <C-F> <c-o>:call black#Black()<cr>
" setup persisent undo
if has("undofile")
set undofile
set undodir=/tmp
endif
" ignore following files
set wildignore+=*.bak,*~,*.tmp,*.backup,*.swp
" close buffer
nmap <silent> <leader>d :bp\|bd #<CR>
" %s/from/to interactive.
" could be split, nosplit
set inccommand=nosplit
" comments. select lines and press <leader>cc or <leader>uc
augroup comment
autocmd!
autocmd FileType c,cpp,rust,typescript let b:comment_leader = '// '
autocmd FileType ruby,python let b:comment_leader = '# '
autocmd FileType conf,fstab,sh,bash let b:comment_leader = '# '
autocmd FileType tex let b:comment_leader = '% '
autocmd FileType mail let b:comment_leader = '> '
autocmd FileType vim let b:comment_leader = '" '
augroup END
noremap <silent> <leader>cc :<C-b>silent <C-e>norm ^i<C-r>=b:comment_leader<CR><CR>
noremap <silent> <leader>uc :<C-b>silent <C-e>norm ^xx<CR>
"-------------------------------------------------------------------------------
" Tagbar
"-------------------------------------------------------------------------------
nmap <F8> :TagbarToggle<CR>
"-------------------------------------------------------------------------------
" Taglist
"-------------------------------------------------------------------------------
" Taglist variables
" Display function name in status bar:
"let g:ctags_statusline=1
" Automatically start script
"let generate_tags=1
" Displays taglist results in a vertical window:
"let Tlist_Use_Horiz_Window=0
" Shorter commands to toggle Taglist display
"nnoremap TT :TlistToggle<CR>
"map <F4> :TlistToggle<CR>
" Various Taglist diplay config:
"let Tlist_Use_Right_Window = 1
"let Tlist_Compact_Format = 1
"let Tlist_Exit_OnlyWindow = 1
"let Tlist_GainFocus_On_ToggleOpen = 1
"let Tlist_File_Fold_Auto_Close = 1
"-------------------------------------------------------------------------------
" PYDOC
"-------------------------------------------------------------------------------
""" PYDOC path
" let g:pydoc_cmd=/usr/bin/pydoc
"-------------------------------------------------------------------------------
" Language Server
"-------------------------------------------------------------------------------
"let g:LanguageClient_serverCommands = {
" \ 'python': ['pyls', '-v'],
" \ }
"-------------------------------------------------------------------------------
" Tabstops by Language
"-------------------------------------------------------------------------------
autocmd Filetype html setlocal ts=2 sts=2 sw=2 tw=0
autocmd Filetype htmldjango setlocal ts=2 sts=2 sw=2 tw=0
autocmd Filetype javascript setlocal ts=2 sts=2 sw=2 tw=0
autocmd Filetype typescript setlocal ts=2 sts=2 sw=2 tw=0
autocmd Filetype python setlocal ts=4 sts=4 sw=4
"-------------------------------------------------------------------------------
" Fuzzy Finder
"-------------------------------------------------------------------------------
nnoremap <silent> <M-o> :FZF<CR>
vnoremap <silent> <M-o> :FZF<CR>
"-------------------------------------------------------------------------------
" Rip Grep with Fuzzy Finder
"-------------------------------------------------------------------------------
" Example: :Rg <smth> - find one mention in file
" Example: :Rga <smth> - find all mentions
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'export RIPGREP_CONFIG_PATH="./.ripgreprc" && rg --column --max-count=1 --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
command! -bang -nargs=* Rga
\ call fzf#vim#grep(
\ 'export RIPGREP_CONFIG_PATH="./.ripgreprc" && rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
"-------------------------------------------------------------------------------
" RUST related
"-------------------------------------------------------------------------------
let g:rustfmt_autosave = 1