-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.vim
303 lines (210 loc) · 7.1 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
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
call plug#begin('$HOME/.config/nvim/plugged')
" @see https://www.gregjs.com/vim/2016/neovim-deoplete-jspc-ultisnips-and-tern-a-config-for-kickass-autocompletion/
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'padawan-php/deoplete-padawan', { 'do': 'composer install' }
Plug 'ternjs/tern_for_vim', { 'do': 'npm install', 'for': ['javascript', 'javascript.jsx'] }
Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern', 'for': ['javascript', 'javascript.jsx'] }
Plug 'othree/jspc.vim', { 'for': ['javascript', 'javascript.jsx'] }
Plug '1995eaton/vim-better-javascript-completion'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'sheerun/vim-polyglot'
Plug 'Yggdroot/indentLine'
Plug 'editorconfig/editorconfig-vim'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-surround'
Plug 'terryma/vim-multiple-cursors'
Plug 'airblade/vim-gitgutter'
Plug 'valloric/matchtagalways'
Plug 'mattn/emmet-vim'
Plug 'junegunn/vim-easy-align'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive'
Plug 'wesQ3/vim-windowswap'
Plug 'crusoexia/vim-monokai'
Plug 'mklabs/split-term.vim'
Plug 'wakatime/vim-wakatime'
call plug#end()
"
"
" GENERAL COMMANDS
"
" @see http://stackoverflow.com/questions/2001190/adding-a-command-to-vim
"
" save as sudo
ca w!! w !sudo tee "%"
" remove hidden characters '^M' from Windows® docs
command AdjustEndOfLine execute '%s/\r\(\n\)/\1/g'
" Tabs to spaces
command Tabs2Spaces execute ':1,$s/\t/ /g'
" 2 spaces to 4 spaces
command TwoSpaces2FourSpaces execute ':%s/^\s*/&&/g'
"
"
" GENERAL CONFIGS
"
"
" UTF-8 encoding
set encoding=utf-8
" Change <Leader>
let mapleader = ","
" Use dash in autocomplete
set iskeyword+=\-
" Store swap files in fixed location, not current directory
" http://stackoverflow.com/a/4331812/922143
set dir=~/.config/nvim/swap//,/tmp//,.
" Vertical splits open to the right
set splitright
" Autocomplete
augroup omni_complete
" clear commands before resetting
autocmd!
" Enable omnicomplete for supported filetypes
autocmd FileType css,scss,sass setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
augroup END
" Remap code completion to Ctrl+Space
" inoremap <Nul> <C-x><C-o>
" Undo leves
set history=300
set undolevels=300
" Don't break lines in the middle of words
set linebreak
" TABs
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
" Line numbers
set number
set relativenumber
" Identing
set autoindent
" Search
" Incremental search
set incsearch
" Ignore case in search
set ignorecase
" Highlighted search results
set hlsearch
" Highlighted search results; press Space to turn off highlighting
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" Highlight actual line
set cursorline
" When scrolling, keep cursor 5 lines away from screen border
set scrolloff=5
" Folding and unfolding
"
" za : toggle folding
" zM : fold everything
" zR : unfold everything
" zm & zr : get those folds just right
"
" http://stackoverflow.com/a/10644424/922143
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=0 "this is just what i use"
" Don't screw up folds when inserting text that might affect them,
" until leaving insert mode. Foldmethod is local to the window.
" http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
autocmd InsertEnter * let w:last_fdm=&foldmethod | setlocal foldmethod=manual
autocmd InsertLeave * let &l:foldmethod=w:last_fdm
" Sort selected lines
vnoremap <F9> :sort<CR>
" Easier moving of code blocks
vnoremap < <gv
vnoremap > >gv
" Abbreviations
cab W! w!
cab Q! q!
cab Wq wq
cab Wa wa
cab wQ wq
cab WQ wq
cab W w
cab Q q
" Theme
syntax on
colorscheme monokai
"
" PLUGINS CONFIGS
"
" deoplete
" Enable deoplete at startup
let g:deoplete#enable_at_startup = 1
" Disable auto-autocompletion
" let g:deoplete#disable_auto_complete = 1
" deoplete tab-complete
inoremap <expr><tab> pumvisible() ? "\<C-n>" : "\<C-j>"
inoremap <expr><s-tab> pumvisible() ? "\<C-p>" : "\<C-k>"
" Tern
" Deoplete config to play nice with multiple omnifunctions provided by third-party plugins
let g:deoplete#omni#functions = {}
let g:deoplete#omni#functions.javascript = [
\ 'tern#Complete',
\ 'jspc#omni'
\]
" Adjust which sources Deoplete pulls from when showing completions
set completeopt=longest,menuone,preview
let g:deoplete#sources = {}
let g:deoplete#sources['javascript.jsx'] = ['file', 'ultisnips', 'ternjs']
let g:tern#command = ['tern']
let g:tern#arguments = ['--persistent']
" gb keybinding for moving the cursor straight to a variable definition using Tern’s JS code analysis engine
autocmd FileType javascript nnoremap <silent> <buffer> gb :TernDef<CR>
" Automatically closing the scratch window at the top of the vim window on finishing a complete or leaving insert
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" Disable the preview entirely
" set completeopt-=preview"
" ctrlp
" Custom ignore folders & files
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|ico|git|svn|ttf|woff|woff2|jpg|png|gif))$'
" gitgutter
" The length of time Vim waits after you stop typing before it triggers the plugin
set updatetime=250
" NERDTree
" F3 to toggle NERDTree
map <F3> :NERDTreeToggle<CR>
" Ignore files on NERDTree
let NERDTreeIgnore = [
\'\.git[[dir]]',
\'\.sass-cache[[dir]]',
\'node_modules[[dir]]',
\'bower_components[[dir]]',
\'\.pyc$',
\'\.pyo$',
\'\.idea$',
\'\.vscode$',
\'\.tags$'
\]
" Show hidden files
let NERDTreeShowHidden=1
" Open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" NERD Commenter
" Make sure that you have filetype plugins enabled
filetype plugin on
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" indentLine
" Change Character Color
let g:indentLine_color_term = 239
" Change Indent Char
let g:indentLine_char = '┆'
" Remove indent lines from NERDTree
autocmd FileType help,nerdtree IndentLinesToggle
" editorconfig-vim
" Avoid loading EditorConfig for any remote files over ssh
let g:EditorConfig_exclude_patterns = ['scp://.*']
" Airline
let g:airline_powerline_fonts = 1
let g:airline_symbols = {}
let g:airline_symbols.branch = ''
let g:airline_section_b = '%{fugitive#head()}'
let g:airline#extensions#hunks#enabled = 0