-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc
244 lines (192 loc) · 7.91 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
filetype off " required!
set nocompatible " be iMproved
" Get over Ex mode
nnoremap Q <nop>
" ==========================================
" Vundle configs ---------------------------
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" ------------------------------------------
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
" My Plugins here:
" original repos on github
Plugin 'scrooloose/nerdcommenter.git'
Plugin 'scrooloose/nerdtree.git'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'tpope/vim-endwise.git'
Plugin 'godlygeek/tabular'
"Plugin 'claco/jasmine.vim.git'
"Plugin 'groenewege/vim-less'
Plugin 'tpope/vim-rvm'
Plugin 'vim-ruby/vim-ruby.git'
Plugin 'tpope/vim-rails.git'
Plugin 'slim-template/vim-slim'
Plugin 'pangloss/vim-javascript'
Plugin 'briancollins/vim-jst'
Plugin 'kchmck/vim-coffee-script'
Plugin 'tpope/vim-ragtag.git'
Plugin 'elixir-lang/vim-elixir'
Plugin 'dense-analysis/ale'
Plugin 'Pychimp/vim-luna'
Plugin 'altercation/vim-colors-solarized.git'
" ------------------------------------------
" All of your Plugins must be added before the following line
call vundle#end() " required
" ==========================================
filetype on " Enable filetype detection
filetype plugin on " Enable filetype-specific plugins
set cindent "To make html code indent properly. No idea why this works.
"http://stackoverflow.com/questions/815548/how-do-i-tidy-up-an-html-files-indentation-in-vi
filetype indent on " Enable filetype-specific indenting
syntax on " Enable syntax highlighting
set lazyredraw " redraw only when we need to.
set wildmenu " visual autocomplete for command menu
" status-line setup
set statusline=%m\ " file is modified
set statusline+=%f " tail of the filename
set statusline+=%= " left/right separator
set statusline+=%y\ " filetype
set statusline+=%c, " cursor column
set statusline+=%l/%L " cursor line/total lines
set statusline+=\ %P " percent through file
set laststatus=2 " always show status-line
set showcmd " show (partial) command in the last line of the screen
" this also shows visual selection info
function! MyTabLabel(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
return bufname(buflist[winnr - 1])
endfunction
function! MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
" select the highlighting
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
" set the tab page number (for mouse clicks)
let s .= '%' . (i + 1) . 'T'
" the label is made by MyTabLabel()
let s .= ' ' . (i + 1) . ':%{MyTabLabel(' . (i + 1) . ')} '
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
" right-align the label to close the current tab page
if tabpagenr('$') > 1
let s .= '%=%#TabLine#%999Xclose'
endif
return s
endfunction
set tabline=%!MyTabLine()
nnoremap <C-t>n :tabnew<CR>
" Toggle column with line numbers
map <Leader>ln :set number!<CR>
" Toggle column with distance in lines
map <Leader>lr :set relativenumber!<CR>
" Initialize showing line numbers
set number " Show line number
set encoding=utf-8 " Define file to utf-8
"Add utf-8 shebang line
noremap <D-1> :0put = '#-*- coding: utf-8 -*-'<CR>
set nowrap
set autoindent
set expandtab " Convert tabs char to spaces.
set tabstop=2 shiftwidth=2 softtabstop=2 " Set default tab size to 2
" RagTag init.
let g:ragtag_global_maps = 1
" Custom tab format, basend on languange conventions.
autocmd FileType javascript setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd BufWritePre * :%s/\s\+$//e " Remove trailing spaces
" Enable custom syntax highlight
autocmd BufNewFile,BufRead {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set filetype=ruby
autocmd BufNewFile,BufRead {Gruntfile,*.json} set filetype=javascript
" Config erb to correct filetype
autocmd BufNewFile,BufRead *.js.erb set filetype=javascript
autocmd BufNewFile,BufRead *.less.erb set filetype=less
autocmd BufNewFile,BufRead *.js.coffee set filetype=coffee
set showmatch "Show braces matchs
" This makes files with long lines freezing slow
" http://stackoverflow.com/questions/4775605/vim-syntax-highlight-improve-performance#comment11224954_7187629
"set cursorline "highlight current line
set incsearch "Select search match while typing
" Directories for swp files
set backupdir=~/.vim/backup
set directory=~/.vim/backup
" Dear Vim,
" We've reach year 2017.
" We have SCMs.
" Don't bother creating backup files
" Love,
" Me
set nobackup
set nowritebackup
set noswapfile
"set clipboard=unnamed "http://vim.wikia.com/wiki/Accessing_the_system_clipboard
"NERDTree Toggle using \][ keymap
noremap <Leader>][ :NERDTreeToggle<CR>
let g:NERDTreeChDirMode=2 "This changes current dir, so sync CommandT to look the same path as NERDTree is.
" NERDTree find current buffer on tree
noremap <leader>] :NERDTreeFind<cr>
noremap <Leader>pr :ClearCtrlPCache<CR>:CtrlP pwd<CR>
" NERD Commenter: <Leader>c to toggle comments
map <Leader>c <plug>NERDCommenterToggle
" CTags: <Leader>]r to refresh exuberant ctags file
set tags+=.git/tags
function! RefreshCTags()
silent !ctags -R -f .git/tags .
redraw!
endfunction
" Refresh ctags
noremap <Leader>]r :call RefreshCTags()<CR>
" ALE ------------------------------------------------
" https://github.com/dense-analysis/ale/issues/1403
"let g:ale_ruby_rubocop_executable = 'bin/rubocop' " - Work with binstub
" Enable ESLint only for JavaScript.
"let b:ale_linters = ['rubocop']
" Set specific linters
let g:ale_linters = {
\ 'ruby': ['rubocop', 'ruby']
\}
let g:ale_ruby_rubocop_executable = get(systemlist('which rubocop'), 0, '')
let g:ale_ruby_rubocop_options = '--config ' . getcwd() . '/.rubocop.yml --force-exclusion'
let g:ale_set_balloons = 1
" https://techandfi.com/rubocop-vim/
" Only run linters named in ale_linters settings.
"let g:ale_linters_explicit = 1
" How can I run linters only when I save files?
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_insert_leave = 0
" You can disable this option too
" if you don't want linters to run on opening a file
let g:ale_lint_on_enter = 0
" ----------------------------------------------------
" RVM ------------------------------------------------
set statusline+=%{rvm#statusline()} " RVM
" ----------------------------------------------------
" Global ignore file and directories -----------------
set wildignore+=.git,.hg " Version control
set wildignore+=*.orig " Merge resolution files
set wildignore+=vendor " Rails
set wildignore+=*/doc/app/* " Rails docs
set wildignore+=tmp " Thinking of Rails tmp. But, will work for more
set wildignore+=log " Thinking of Rails log. But, will work for more
set wildignore+=_site " Jekyll
if has("mac")
set wildignore+=.DS_Store " OSX bullshit
endif
" ----------------------------------------------------
" Search ---------------------------------------------
" Grep opening on Location List
set grepprg=grep\ -nr\ --color='auto'\ --exclude-dir=tmp\ --exclude-dir=log\ --exclude-dir=doc\ --exclude-dir=.git\ --exclude-dir=node_modules\ --exclude-dir=.sass-cache\ --exclude-dir=coverage
" https://chase-seibert.github.io/blog/2013/09/21/vim-grep-under-cursor.html
command! -nargs=+ GrepProject execute 'silent lgrep! -I -r -n --exclude-dir=git . -e ' shellescape('<args>') | lopen 20 | execute 'silent /<args>'
autocmd FileType qf nnoremap <buffer> <Enter> :.ll<Enter>:lclose<Enter>
" ----------------------------------------------------
" CtrlP ignore
"let g:ctrlp_custom_ignore = '|DS_Store\|git'
let g:ctrlp_custom_ignore = '\v[\/](bower_components|node_modules)$'
colorscheme luna-term " Set color scheme