summaryrefslogtreecommitdiffstats
path: root/.vimrc
blob: 50258a3e13e9ac8f88a49d1a27791123931ae555 (plain) (blame)
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
"====== Plug Required Block and plugins
set nocompatible
filetype off
call plug#begin('~/.vim/bundle')
Plug 'editorconfig/editorconfig-vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-endwise'
Plug 'sheerun/vim-polyglot'
Plug 'junegunn/gv.vim'
Plug 'junegunn/limelight.vim'
Plug 'junegunn/goyo.vim'
Plug 'vim-scripts/bufexplorer.zip'
" Plug 'vim-scripts/indentpython.vim'
Plug 'ycm-core/YouCompleteMe', {
  \ 'do': '/usr/local/bin/python3 ./install.py --clangd-completer --ts-completer --rust-completer' }
Plug 'Valloric/MatchTagAlways'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'godlygeek/tabular'
Plug 'SirVer/ultisnips'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'ngmy/vim-rubocop'
Plug 'honza/vim-snippets'
Plug 'majutsushi/tagbar'
Plug 'kkoomen/vim-doge'
Plug 'nvie/vim-flake8'
Plug 'leafgarland/typescript-vim'
Plug 'Quramy/tsuquyomi'
Plug 'hashivim/vim-terraform'
Plug 'juliosueiras/vim-terraform-completion'
Plug 'prettier/vim-prettier', {
      \ 'do': 'yarn install' }
call plug#end()
syntax on
filetype plugin indent on
"====== End of Plug Required Block and plugins

let mapleader = ';' " define map leader
colorscheme xoria256 "set colorscheme

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim variables
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set encoding=utf-8               " set the encoding to utf-8
set t_Co=256                     " set terminal color 265
set clipboard=unnamed            " fix not copying between clipboard and vim
set backspace=indent,eol,start   " fix backspace not deleteing existing text
set number                       " set numbers column on the left
set complete-=i                  " Faster vim completion
set complete+=k                  " Dictionary word completion using Ctrl+N
set nrformats-=octal             " Increment numbers decimally using Ctrl+A and Ctrl+X
set autoindent                   " Auto indent
" set smartindent                  " Smart indet (causes problems having differnt files indentation)
set smarttab
set softtabstop=2                " indentation
set tabstop=2                    " indentation
set shiftwidth=2                 " indentation
set expandtab                    " convert tabs to spaces
set ttyscroll=3                  " speed up scrolling
set ttyfast                      " Optimize for fast terminal connections
set lazyredraw                   " to avoid scrolling problems
" set ttimeout                     " less timeout for faster navigation
" set ttimeoutlen=100              " time out for faster navigation
set incsearch                    " Make search act like search in modern browsers
set ignorecase                   " Ignore case when searching shortend ic
" set noignorecase                 " Case Senetive searching shortend noic
set smartcase                    " case-sensitive search if any caps
set hlsearch                     " Highlight search things shortend hls or nohls
set laststatus=2                 " Always show the status line
set ruler                        " Always show current position
set showcmd                      " display incomplete commands
set wildmenu                     " Turn on Wild menu
set wildmode=longest:full,full
set wildignore=*.o,*~,*.pyc      " Ignore compiled files
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set undofile                     " Save undo's after file closes
set undodir=$HOME/.vim/undo      " where to save undo histories
set undolevels=200               " How many undos
set undoreload=200               " number of lines to save for undo
set fileformats+=mac             " correct mac file format
set tabpagemax=50                " Set the maximum number of tabs allowed
set modelines=0                  " disable the modelines which i don't understand
set nomodeline                   " disable the modelines which i don't understand
set linebreak                    " Vim to wrap existing text as desired
set nowrap                       " let Vim Wrap lines or leave them as long as they get
set noeb vb t_vb=
" set cursorline                   " highlight current line
" set nocursorline                 " don't highlight current line
set splitbelow                   " position the preview window below current windows
set mouse=a                      " enable mouse movements, default set mouse=

" set vim startup faster
if !empty(&viminfo)
  set viminfo^=!
endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Fast saving and quiting
nmap <leader>w :w<cr>
nmap <leader>q :q<cr>

"Use <C-L> to clear the highlighting of :set hlsearch.
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>

"toggle folding
set foldmethod=indent
set foldlevelstart=20
nnoremap <space> za

"Easier window movement"
"=======================
nnoremap <silent> <leader>h :wincmd h<CR>
nnoremap <silent> <leader>j :wincmd j<CR>
nnoremap <silent> <leader>k :wincmd k<CR>
nnoremap <silent> <leader>l :wincmd l<CR>
nnoremap <silent> <leader>ml <C-W>L
nnoremap <silent> <leader>mk <C-W>K
nnoremap <silent> <leader>mh <C-W>H
nnoremap <silent> <leader>mj <C-W>J

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Omni complete functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set omnifunc=csscomplete#CompleteCSS
" set omnifunc=htmlcomplete#CompleteTags
" set omnifunc=phpcomplete#CompletePHP
" set omnifunc=javascriptcomplete#CompleteJS
" set omnifunc=pythoncomplete#Complete

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Specific FileTypes configurations
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.html.erb set filetype=html       " for ruby erb template files
autocmd BufNewFile,BufRead *.json.jbuilder set filetype=ruby  " for ruby json template files
autocmd BufNewFile,BufRead,BufReadPost *.tsx set syntax=javascript " better tsx highlighting than polyglot defaults
" autocmd FileType markdown setlocal spell                      " spell check markdown files
autocmd FileType gitcommit setlocal spell                     " spell check commits
autocmd FileType ruby setlocal nospell                        " disable spell checking for ruby documentation
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => MISC
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Highlight the 80, 120 columns
"=============================
highlight ColorColumn ctermbg=235 guibg=#2c2d27
let &colorcolumn="80,".join(range(121,130),",")
" let &colorcolumn="80"

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin maps
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"YouCompleteMe & vim-flake8
"==========================
let g:ycm_auto_hover=''
let g:ycm_enable_diagnostic_signs = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
" Python pipenv auto complete
let pipenv_venv_path = system('pipenv --venv')
if shell_error == 0
  let venv_path = substitute(pipenv_venv_path, '\n', '', '')
  let g:ycm_python_binary_path = venv_path . '/bin/python'
  let g:flake8_cmd = venv_path . '/bin/flake8'
else
  let g:ycm_python_binary_path = '/usr/local/bin/python3'
endif

"polyglot"
"=============
" let g:polyglot_disabled = ['typescript']

"NerdTree"
"=========
nnoremap <leader>nt :NERDTreeToggle<cr>
nnoremap <leader>nn :NERDTree<cr>

"NerdCommenter"
"=============
let NERDSpaceDelims = 1 " add a space after comment delimiter

"BufExp"
"======
let g:bufExplorerShowRelativePath=1  " Show relative paths.
let g:bufExplorerSortBy='fullpath'   " Sort by file path.

"Vim-airline
"===========
let g:airline_theme='wombat'
let g:airline_powerline_fonts = 0
let g:airline_symbols_ascii = 1

"seperators
let g:airline_left_sep = ''
let g:airline_right_sep = ''

"modes
" let g:airline_section_b=""
let g:airline_section_x=""
let g:airline_section_y=""
" let g:airline_section_gutter=""

"extensions
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#tabline#enabled = 0

"Gitgutter
"=========
set signcolumn=yes
set updatetime=100
let g:gitgutter_map_keys = 0
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
" let g:gitgutter_async = 0
highlight SignColumn guibg=#1c1c1c ctermbg=233
highlight GitGutterAdd    guifg=#009900 guibg=#1c1c1c ctermfg=2 ctermbg=233
highlight GitGutterChange guifg=#bbbb00 guibg=#1c1c1c ctermfg=3 ctermbg=233
highlight GitGutterDelete guifg=#ff2222 guibg=#1c1c1c ctermfg=1 ctermbg=233

"UltiSnips
"=========
let g:UltiSnipsExpandTrigger = "<c-b>"
let g:UltiSnipsJumpForwardTrigger = '<Down>'
let g:UltiSnipsJumpBackwardTrigger = '<Up>'

"CtrlP
"=====
let g:ctrlp_custom_ignore = '\v[\/](coverage|doc|vendor|tmp|.tmp|bower_components|node_modules|dist|spec/fixtures/vcr_cassettes)$'

"MatchTagAlways
"==============
let g:mta_filetypes = { 'html' : 1 }

"RuboCop
"=======
let g:vimrubocop_keymap = 0
let g:vimrubocop_rubocop_cmd = 'bundle exec rubocop '
nmap <Leader>r :RuboCop<CR>
nmap <Leader>R :RuboCop -a<CR>

"Limelight
"=========
nmap <leader>f :Limelight!!<cr>

"Goyo
"====
" nmap <leader>g :Goyo<cr>

"Tagbar
"======
nmap <F8> :TagbarToggle<CR>