-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
303 lines (241 loc) · 8.11 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
let $PATH .= ':/home/soyuka/.nvm/versions/node/v12.16.1/bin'
filetype off
call plug#begin()
Plug 'christoomey/vim-tmux-navigator'
Plug 'ap/vim-css-color'
" Colorscheme
Plug 'joshdick/onedark.vim'
Plug 'scrooloose/nerdtree'
Plug 'ryanoasis/vim-devicons'
" Lightline FTW
Plug 'itchyny/lightline.vim'
" buffer manager <3, replaced by buftabline 05/11/2020 oO
" Plug 'fholgado/minibufexpl.vim'
Plug 'ap/vim-buftabline'
" Replaces :MBEbd from minibufexpl cause it is bugged
Plug 'qpkorr/vim-bufkill'
" Signature when <C-Y>
Plug 'Shougo/echodoc.vim'
" Syntax
Plug 'sheerun/vim-polyglot'
" Html close tags
Plug 'docunext/closetag.vim'
" Auto close )'"`
Plug 'jiangmiao/auto-pairs'
" gcc comment
Plug 'tomtom/tcomment_vim'
" Wrap args
Plug 'FooSoft/vim-argwrap'
" Language server support
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'ak5/vim-lsp-typescript'
" Plug 'felixfbecker/php-language-server', {'do': 'composer install && composer run-script parse-stubs'}
" Typescript plugin for auto imports
" Plug 'Quramy/tsuquyomi'
Plug 'Quramy/vim-js-pretty-template'
" Phpactor for namespace import
Plug 'phpactor/phpactor', {'for': 'php', 'tag': '*', 'do': 'composer install --no-dev -o'}
" SQL plug
Plug 'shmup/vim-sql-syntax', {'for': 'sql'}
" fzf
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" git gutter
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
Plug 'dpelle/vim-Grammalecte'
" Plug 'fatih/vim-go'
call plug#end()
" My config
" argwrap
let g:argwrap_tail_comma = 1
nmap <Leader>w :ArgWrap<CR>
set tags+=tags,tags.vendor
" OS determination
let g:OS = 'linux'
let os = substitute(system('uname'), '\n', '', '')
if os == 'Darwin' || os == 'Mac'
let g:OS = 'osx'
endif
" Colors
" Disable Background Color Erase when within tmux - https://stackoverflow.com/q/6427650/102704
if &term =~ '256color'
set t_ut=
endif
" set Vim-specific sequences for RGB colors
" see https://github.com/vim/vim/issues/993#issuecomment-255651605
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" italic fix
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
if has("termguicolors")
set termguicolors
endif
source ~/.vim/color.black
syntax on
" Settings
set nocompatible
set number " enable line numbers
set showcmd
set scrolloff=5 " keep at least 5 lines above/below
set sidescrolloff=5 " keep at least 5 lines left/right
set showmatch
" set colorcolumn=81
set hidden " allow the use of unsaved buffer
set prompt " prompt on saving
set backspace=indent,eol,start " Better handling of backspace key
set nostartofline " Emulate typical editor navigation behaviour
set diffopt=vertical,context:4
set dir=/tmp
set nobackup
set nowritebackup
set backupcopy=yes " When watching things with webpack etc
set autoindent
" Spaces are better than a tab character
set expandtab
" global tab config
set ts=2 sw=2
set smarttab
set shiftround
set ignorecase
set incsearch
set smartcase
set spelllang=en
" set nospell
set spellsuggest=5
set showmode
set laststatus=2
" split more naturally
set splitright
set splitbelow
set cul " highlight current line
" Configure invisible characters
set nolist
" set listchars=trail:·,eol:¬,tab:┊\
set noautochdir
" basically :lcd %:p:h in every buffer (https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file)
" autocmd BufEnter * silent! lcd %:p:h
" wrap to previous line when cursor reach eol/beginning
set whichwrap+=<,>,h,l,[,]
" Key mapping
noremap ; :
" F/T forward backward
noremap , ;
" noremap <lt> ,
" Mapping space to leader key
map <Space> <Leader>
"semicolons helper
nnoremap <Leader>; A;<esc>
"paste helper
nnoremap <Leader>p :set paste!<CR>
"paste helper
nnoremap <Leader>s :sort /^\s*\(' \)\?/<CR>
" Replaces tabs with spaces
nnoremap <Leader>t :0,$s/\t/ /g<CR>
xmap <Leader>y y:call system("wl-copy", @")<CR>
nnoremap <S-L> :bnext<CR>
nnoremap <S-H> :bprev<CR>
" Delete buffer but leave window open
nnoremap <Leader>q :BD<CR>
" Navigate between splits more naturally
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
nnoremap <S-J> }
nnoremap <S-K> {
vnoremap <S-J> }
vnoremap <S-K> {
" Key mapping to expand foldings
nnoremap <C-o> za
nnoremap <C-S-O> zR
nnoremap <C-c> zM
" Coc for lightline
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
autocmd FileType crontab setlocal nobackup nowritebackup
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.scss set filetype=scss.css " ultisnips css for scss
autocmd BufRead,BufNewFile *.css source ~/.vim/ftplugin/css.vim
autocmd BufRead,BufNewFile *.php source ~/.vim/ftplugin/php.vim
autocmd BufRead,BufNewFile *.yaml,*.yml source ~/.vim/ftplugin/php.vim
autocmd BufRead,BufNewFile *.js source ~/.vim/ftplugin/javascript.vim
autocmd BufRead,BufNewFile *.json source ~/.vim/ftplugin/javascript.vim
autocmd BufRead,BufNewFile *.ts set filetype=typescript
autocmd BufRead,BufNewFile *.html source ~/.vim/ftplugin/html.vim
autocmd BufRead,BufNewFile *.feature set ts=2 sw=2
autocmd BufRead,BufNewFile *.rs set ts=4 sw=4
" Echo doc
let g:echodoc#enable_at_startup = 1
let g:echodoc#type = "popup"
" NERDTree options
" Chdir to current file
let g:NERDTreeChDirMode=1
let g:NERDTreeShowBookmarks=1
" NERDTree window size
let g:NERDTreeWinSize=35
let g:NERDTreeBookmarksFile = $HOME ."/.vim/bookmarks"
let g:NERDTreeShowHidden=1
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeMinimalUI=1
let g:DevIconsEnableFolderPatternMatching = 0
let g:WebDevIconsNerdTreeAfterGlyphPadding = ' '
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
let g:WebDevIconsNerdTreeBeforeGlyphPadding = ''
let g:WebDevIconsNerdTreeGitPluginForceVAlign = 0
let g:WebDevIconsUnicodeDecorateFolderNodesDefaultSymbol = ''
" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" map NERDTree to ' n'
map <Leader>n :NERDTreeToggle<CR>
map <Leader>c :NERDTreeFind<CR>
" Comment block
vmap gb :TCommentBlock<CR>
" \ 'colorscheme': 'onedark',
let g:lock = "🔒""
let g:lightline = {
\ 'colorscheme': 'one',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"'.g:lock.'":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'component_function': {
\ 'cocstatus': 'coc#status',
\ }
\ }
nnoremap <C-p> :FZF<CR>
nnoremap <C-b> :Buffers<CR>
nnoremap <C-g> :Rg<CR>
" LSP (language server) Plugin
let g:lsp_diagnostics_enabled = 0
setlocal omnifunc=lsp#complete
nmap <Leader>o <plug>(lsp-definition)
nmap <Leader>K <plug>(lsp-hover)
map <Leader>g :GitGutterToggle<CR>
source ~/.vim/no_distraction_mode
nnoremap <F12> :call ToggleNoDistractionMode()<CR>
" cnoremap - tells Vim that the following mappings that is used when in command-line mode
" w!! - the mapping (shortcut) itself.
" execute '<command>' - executes a command between the quotes
" silent! - run it silently
" write !sudo tee % >/dev/null - the magic trick which would take another email to explain
" <bar> edit! - this calls the edit command to reload the buffer and then avoid messages such as "the buffer has changed".
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
" notes and todo
" todo: from @greg0ire vnoremap <leader>l :<c-u>exe '!git log -L' line("'<").','.line("'>").':'.expand('%')<CR>"'")"'")
" Command that searches the word under the cursor
" vnoremap <C-n> y:%s/<C-R>=escape(@",'/\')<CR>/
" vim:ft=vim:tabstop=2:shiftwidth=2:softtabstop=2:smarttab:shiftround:expandtab