-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc_v1
238 lines (211 loc) · 7.01 KB
/
vimrc_v1
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
" DEFAULT PLUGINS
runtime macros/matchit.vim
" DEFAULT SETTINGS
set nocompatible
set number
set clipboard=unnamedplus
set path+=**
set shiftwidth=2
set tabstop=2
set expandtab
set autoindent
set smartindent
set cindent
set re=1
set hidden
syntax enable
" PLUGINS
" vim-plug installation
" for vim:
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" for neovim
" sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'rodjek/vim-puppet'
Plug 'hashivim/vim-terraform'
Plug 'vim-ruby/vim-ruby'
Plug 'SirVer/ultisnips'
Plug 'Yggdroot/indentLine'
Plug 'airblade/vim-gitgutter'
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'chiel92/vim-autoformat'
" Plug 'davydovanton/vim-html2slim'
Plug 'dense-analysis/ale'
Plug 'godlygeek/tabular'
Plug 'idanarye/vim-merginal'
Plug 'jiangmiao/auto-pairs'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/gv.vim'
Plug 'kana/vim-textobj-user'
Plug 'kchmck/vim-coffee-script'
Plug 'morhetz/gruvbox'
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
Plug 'ryanoasis/vim-devicons'
Plug 'sainnhe/gruvbox-material'
Plug 'sainnhe/sonokai'
Plug 'scrooloose/nerdtree'
Plug 'sickill/vim-monokai'
Plug 'slim-template/vim-slim'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dadbod'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-utils/vim-ruby-fold'
Plug 'rlue/vim-fold-rspec'
Plug 'vimwiki/vimwiki'
Plug 'mattn/emmet-vim'
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
call plug#end()
" colorscheme monokai
colorscheme gruvbox-material
autocmd BufNewFile,BufRead *.slim set ft=slim
autocmd StdinReadPre * let s:std_in=1
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | exe "normal! \<c-w>\<c-w>" | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
au BufEnter * if bufname('#') =~ 'NERD_tree' && bufname('%') !~ 'NERD_tree' && winnr('$') > 1 | b# | exe "normal! \<c-w>\<c-w>" | :blast | endif
nnoremap <C-\> :NERDTreeFind %<CR> <c-w><c-w>
let ruby_operators = 1
let ruby_pseudo_operators = 1
let g:airline_theme='google_dark'
let g:airline_powerline_fonts = 1
let g:fzf_buffers_jump = 1
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val, "lnum": 1 }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'
let g:deoplete#enable_at_startup = 1
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:ale_set_highlights = 1
let g:ale_linters = {
\ 'ruby': ['rubocop'],
\ 'python': ['flake8', 'pylint'],
\ 'javascript': ['eslint'],
\}
let g:ale_fixers = {
\ 'ruby': ['rubocop'],
\}
let g:ale_fix_on_save = 0
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
function! LinterStatus() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '✨ all good ✨' : printf(
\ '😞 %dW %dE',
\ all_non_errors,
\ all_errors
\)
endfunction
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
set hidden
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio']
\ }
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
highlight ALEWarning ctermbg=DarkMagenta
set statusline=
set statusline+=%m
set statusline+=\ %f
set statusline+=%=
set statusline+=\ %{LinterStatus()}
nnoremap <C-Space> :Buffers<Cr>
nnoremap <C-p> :Files!<Cr>
nnoremap <C-f> :Ag!<Space>
nnoremap <C-Space> :Buffers<Cr>
nnoremap <C-c> :GV<Cr>
nnoremap <silent> <expr> <Leader><Leader> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":FZF\<cr>"
nnoremap tn :tabnew<Space>
nnoremap tk :tabnext<CR>
nnoremap tj :tabprev<CR>
nnoremap th :tabfirst<CR>
nnoremap tl :tablast<CR>
nnoremap gs :tab G<CR>
nnoremap gb :G blame<CR>
vnoremap gb :G blame<CR>
nnoremap <F5> "=strftime("================== %c ==================")<CR>P
inoremap <F5> <C-R>=strftime("================== %c ==================")<CR>
" fold settings
" ------------
" toggle folding with za.
" fold everything with zM
" unfold everything with zR.
" zm and zr can be used too
set foldmethod=syntax "fold based on syntax (except for haml below)
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
autocmd BufNewFile,BufRead *.haml setl foldmethod=indent nofoldenable
autocmd! FileType nofile setl foldmethod=indent nofoldenable
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" Toggles folds being enabled for this vim session
function! FoldToggle()
if(&foldenable == 1)
au WinEnter * set nofen
au WinLeave * set nofen
au BufEnter * set nofen
au BufLeave * set nofen
:set nofen
else
au WinEnter * set fen
au WinLeave * set fen
au BufEnter * set fen
au BufLeave * set fen
:set fen
endif
endfunc
nnoremap <Leader>nf :call FoldToggle()<CR>
augroup fugitive_ext
autocmd!
" Browse to the commit under my cursor
autocmd FileType fugitiveblame nnoremap <buffer> <localleader>gb :execute ":.Gbrowse )<cr>
augroup END