-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
252 lines (224 loc) · 7.64 KB
/
init.vim
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
"" Plugins ========================
call plug#begin('~/.vim/plugged')
Plug 'zerowidth/vim-copy-as-rtf'
Plug 'godlygeek/tabular'
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
let g:deoplete#enable_at_startup = 1
let g:LanguageClient_serverCommands = {
\ 'vue': ['vls'],
\ }
" PHP autocomplete source
Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install'}
" JavaScript autocomplete source
Plug 'carlitux/deoplete-ternjs', { 'do': 'sudo npm install -g tern' }
let g:deoplete#sources#ternjs#filetypes = [
\ 'jsx',
\ 'javascript.jsx',
\ 'vue',
\ 'ts'
\ ]
" Go autocomplete source
Plug 'zchee/deoplete-go', { 'do': 'make'}
Plug 'scrooloose/nerdcommenter'
let g:ft = ''
function! NERDCommenter_before()
if &ft == 'vue'
let g:ft = 'vue'
let stack = synstack(line('.'), col('.'))
if len(stack) > 0
let syn = synIDattr((stack)[0], 'name')
if len(syn) > 0
exe 'setf ' . substitute(tolower(syn), '^vue_', '', '')
endif
endif
endif
endfunction
function! NERDCommenter_after()
if g:ft == 'vue'
setf vue
let g:ft = ''
endif
endfunction
Plug 'scrooloose/nerdtree'
map <C-n><C-n> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif""""
let g:NERDTreeIgnore=['.*.swp', '.tern-port']
let g:NERDTreeWinSize=25
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
let g:fzf_commits_log_options = '--graph --color=always
\ --format="%C(yellow)%h%C(red)%d%C(reset)
\ - %C(bold green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)"'
"Plug 'mileszs/ack.vim'
"if executable('ag')
"let g:ackprg = 'ag --vimgrep'
"endif
Plug 'mhinz/vim-grepper'
nnoremap <leader>g :GrepperRg<Space>
nnoremap gr :Grepper -cword -noprompt<CR>
xmap gr <plug>(GrepperOperator)
Plug 'tpope/vim-surround'
Plug 'ludovicchabant/vim-gutentags'
set statusline+=%{gutentags#statusline()}
Plug 'majutsushi/tagbar'
nmap <leader>te :TagbarOpenAutoClose<CR>
Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger = '<C-j>'
Plug 'honza/vim-snippets'
Plug 'tpope/vim-abolish'
Plug 'Raimondi/delimitMate'
Plug 'mattn/emmet-vim'
Plug 'dense-analysis/ale'
let g:ale_linters = {
\ 'js': ['eslint'],
\ 'jsx': ['eslint'],
\ 'vue': ['eslint'],
\ 'php': ['php', 'phpcs'],
\}
" Run both javascript and vue linters for vue files.
let g:ale_linter_aliases = {'vue': ['javascript', 'vue']}
let g:ale_php_phpcs_use_global = 1
let g:ale_php_phpcs_standard = 'PSR2'
let g:ale_php_phpcs_executable = '/Users/martin/.composer/vendor/bin/phpcs'
let g:ale_php_cs_fixer_executable = '/Users/martin/.composer/vendor/bin/php-cs-fixer'
let g:ale_php_cs_fixer_use_global = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'php': ['php_cs_fixer'],
\ 'js': ['eslint'],
\}
" Language support
Plug 'pangloss/vim-javascript'
Plug 'Quramy/vim-js-pretty-template'
Plug 'posva/vim-vue'
" Always rehighlight Vue files when opening
autocmd FileType vue syntax sync fromstart
Plug 'fatih/vim-go'
Plug 'StanAngeloff/php.vim'
Plug 'lumiliet/vim-twig'
Plug 'mustache/vim-mustache-handlebars'
Plug 'metakirby5/codi.vim'
Plug 'mattn/webapi-vim'
Plug 'rust-lang/rust.vim'
Plug 'joonty/vdebug'
let g:vdebug_options = {
\ "path_maps": {},
\ "break_on_open": 0
\}
let g:vdebug_options["path_maps"]['/var/www/app/']='/Users/msotirov/Sites/dapp-vagrant/app/'
Plug 'janko/vim-test'
Plug 'editorconfig/editorconfig-vim'
Plug 'leafgarland/typescript-vim'
Plug 'dart-lang/dart-vim-plugin'
Plug 'thosakwe/vim-flutter'
Plug 'Yggdroot/indentLine'
Plug 'tveskag/nvim-blame-line'
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
""" General Settings ==============
set number
set mouse=a
set relativenumber
set cursorline
set clipboard=unnamed
set hidden
set tabstop=4 shiftwidth=4 expandtab
autocmd Filetype javascript setlocal ts=2 sw=2 expandtab
autocmd Filetype vue setlocal ts=2 sw=2 expandtab
autocmd Filetype yaml setlocal ts=2 sw=2 expandtab
autocmd Filetype json setlocal ts=2 sw=2 expandtab
autocmd Filetype cucumber setlocal ts=2 sw=2 expandtab
autocmd Filetype typescript setlocal ts=2 sw=2 expandtab
au BufNewFile,BufRead,BufReadPost *.xml.dist set syntax=XML
au BufNewFile,BufRead,BufReadPost *.html.tera set syntax=twig
set hlsearch is ignorecase scs
nmap <silent> <C-n> :noh<CR>
hi CursorLineNR cterm=bold ctermfg=100
set fillchars+=vert:│
highlight VertSplit ctermbg=NONE guibg=NONE
set fileencoding=utf8
colorscheme base16-eighties
" set the color theme via the iTerm theme
if has("nvim")
set termguicolors
endif
""" Swap files ===================
set backupdir=~/.vim/swap
set directory=~/.vim/swap
""" Drupal Support ================
if has("autocmd")
" Uncomment the following to have Vim jump to the last position when
" reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" Set Drupal files as php
augroup module
autocmd BufRead,BufNewFile *.module set filetype=php
autocmd BufRead,BufNewFile *.php set filetype=php
autocmd BufRead,BufNewFile *.install set filetype=php
autocmd BufRead,BufNewFile *.test set filetype=php
autocmd BufRead,BufNewFile *.inc set filetype=php
autocmd BufRead,BufNewFile *.profile set filetype=php
autocmd BufRead,BufNewFile *.theme set filetype=php
augroup END
" Source vimrc file after saving it
" autocmd bufwritepost .vimrc source $MYVIMRC
endif
""" Shortcuts =====================
let mapleader = ","
let maplocalleader = ","
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
inoremap jk <esc>
inoremap <esc> <nop>
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" custom search command
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
nnoremap <leader>f :Find<Space>
nnoremap \ :Find<Space>
"nnoremap <leader>f :Ack!<Space>
"nnoremap <leader>F :AckFromSearch<cr>
" Tabular
nnoremap <leader>a :Tabularize /
vnoremap <leader>a :Tabularize /
" Classic Tab indents
nnoremap <Tab> >>_
nnoremap <S-Tab> <<_
inoremap <S-Tab> <C-D>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Switch splits easier
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" fzf
nnoremap <leader>o :Files<CR>
nnoremap <leader><space> :Buffers<CR>
nnoremap <leader>r :Rg<CR>
nnoremap <leader>! :Rg!<CR>
nnoremap <leader>c :Commits<CR>
nnoremap <leader>b :BCommits<CR>
" Align on paste
:nnoremap p p=`]
" snippet expansion
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)