-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
239 lines (206 loc) · 6.55 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
" plugins
call plug#begin()
" theme
Plug 'tomasr/molokai'
Plug 'kien/rainbow_parentheses.vim'
" gutter
Plug 'airblade/vim-gitgutter'
" airline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" syntax
" jsx-pretty BEFORE polyglot
" https://github.com/MaxMEllon/vim-jsx-pretty/issues/69
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'sheerun/vim-polyglot'
Plug 'leafgarland/typescript-vim'
Plug 'posva/vim-vue'
Plug 'pangloss/vim-javascript'
Plug 'cespare/vim-toml'
Plug 'rust-lang/rust.vim'
" checkers
Plug 'w0rp/ale'
" autocomplete
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
Plug 'wokalski/autocomplete-flow'
" neosnippets
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'pbondoer/vim-snippets'
" header
Plug 'pbondoer/vim-42header'
call plug#end()
" no arrow keys!
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" stuff i can't put in a category
if !has('nvim')
set nocompatible " needed for plug in vim
set ttyfast " make vim faster if using vim
endif
set backspace=indent,eol,start " fix backspace
set laststatus=2 " force displaying a statusbar
set nostartofline " prevent cursor from changing columns
set hidden " hide buffer when opening new ones
set visualbell " show a visual bell instead of beeping
set noerrorbells " dont beep
set confirm " prompt when failing to save
set lazyredraw " doesn't redraw when executing commands that havent been typed
set encoding=utf-8 " unicode!
" syntax & indent
syntax on " enable syntax highlighting
filetype indent plugin on " file-type detection
set shiftwidth=2 " shift by 2 every indent
set softtabstop=2
set tabstop=2 " display as 2 spaces
set expandtab " use spaces
" environment specific overrides
if $ENV ==? '42'
set shiftwidth=4 " shift by 4 every indent
set softtabstop=4
set tabstop=4 " display as 4 spaces
set noexpandtab " use tabs
elseif $ENV ==? $WORK_ENV
set shiftwidth=2 " shift by 2 every indent
set softtabstop=2
set tabstop=2 " display as 2 spaces
set expandtab " use spaces
endif
set autoindent " auto-indent new lines
set copyindent " copy indent from previous lines
set shiftround " use multiple of shiftwidth when indenting with < and >
" display
set ruler " display a ruler in the status line
set cursorline " highlight current line
set number " show line numbers
set colorcolumn=80 " display a column at 80
set list " show invisible characters, see next option
set listchars=trail:~,extends:>,tab:▸·,eol:↵
set textwidth=80 " auto-wrap at 80
set showmatch " show matching group pair (parenthesis, etc.)
set background=dark " tell vim that we have a dark background
" search
set incsearch " scroll to nearest match when searching
set hlsearch " highlight searches
set ignorecase " ignore case when searching, needed for next option
set smartcase " smart-case searching
" backup, swap, undo, autosave
set backupdir=~/.vim/backup
set directory=~/.vim/swap
if exists("&undodir")
set undodir=~/.vim/undo
endif
autocmd BufLeave,FocusLost * silent! wall " autosave when losing focus
set autowriteall " save upon switching buffers
" history & undos
set history=1000 " remembers lots
set undolevels=1000 " (lots)
" commands
set wildmenu " allow TAB-completion in commands
set wildignore=*.swp,*.o,.git,*~ " ignore pattern for wildcards
set showcmd " display current command
set cmdheight=1 " use 2 columns for the command line
set notimeout ttimeout ttimeoutlen=20 " 20ms timeout
" splits
set splitbelow " saner defaults
set splitright " same as above
" other stuff
set pastetoggle=<F2> " toggle pasting from external source
" quickly yank till the end of a line
map Y y$
" ctrl-L removes highlight on redraw
nnoremap <C-L> :nohl<CR><C-L>
" relative numbers
if exists('+relativenumber')
set rnu
autocmd InsertEnter * :set nornu
autocmd InsertLeave * :set rnu
endif
" plugin: rainbow parantheses
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
let g:rbpt_colorpairs = [
\ ['red', 'firebrick3'],
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ]
" plugin: javascript
let g:javascript_plugin_flow = 1
let g:javascript_plugin_jsdoc = 1
" jsx
let g:vim_jsx_pretty_colorful_config = 1
" polyglot
let g:polyglot_disabled = ['markdown', 'typescript', 'jsx', 'rust', 'toml']
" pretty colors
if !empty(globpath(&rtp, 'colors/molokai.vim'))
colorscheme molokai
endif
" airline
let g:airline_theme = "molokai"
let g:airline_powerline_fonts = 0
let g:airline_left_sep=''
let g:airline_right_sep=''
let g:airline#extensions#ale#enabled = 1
" ale
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %severity% > %s'
let g:ale_linters = {
\ 'javascript': ['eslint', 'flow'],
\ 'typescript': ['tsserver', 'tslint'],
\ 'markdown': ['markdownlint'],
\ 'rust': ['rls', 'cargo'],
\ 'bash': ['shellcheck'],
\ 'sh': ['shellcheck'],
\ }
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier'],
\ 'markdown': ['prettier'],
\ 'scss': ['prettier'],
\ 'rust': ['rustfmt'],
\ 'vim': ['remove_trailing_lines', 'trim_whitespace'],
\ }
let g:ale_completion_enabled = 1
let g:ale_close_preview_on_insert = 1
let g:ale_lint_on_text_changed = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_insert_leave = 1
" ale_rust
let g:ale_rust_cargo_use_clippy = executable('cargo-clippy')
let g:ale_rust_cargo_check_tests = 1
let g:ale_rust_rls_toolchain = 'stable'
" python support
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
" deoplete
let g:deoplete#enable_at_startup = 1
" neosnippet
imap <c-k> <Plug>(neosnippet_expand_or_jump)
smap <c-k> <Plug>(neosnippet_expand_or_jump)
xmap <c-k> <Plug>(neosnippet_expand_target)
vmap <c-k> <Plug>(neosnippet_expand_target)
let g:neosnippet#snippets_directory = globpath(&rtp, 'snippets')
" <3 from lemon