-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
219 lines (189 loc) · 6.11 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
set nocompatible
call pathogen#runtime_append_all_bundles()
let g:ale_linters = {
\ 'json': ['jsonlint'],
\ 'jsonc': ['jsonlint'],
\ 'typescript': ['eslint', 'tsserver'],
\ 'javascript': ['eslint', 'tsserver'],
\ 'javascriptreact': ['eslint', 'tsserver'],
\ 'typescriptreact': ['eslint', 'tsserver'],
\ 'vue': ['volar']
\}
" Do not lint or fix minified files.
let g:ale_pattern_options = {
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
\}
let g:ale_vue_volar_executable = 'vue-language-server'
let g:ale_open_list = 1 " Show quickfix window when errors occur
let g:ale_keep_list_window_open = 0
let g:ale_completion_enabled = 0
let g:ale_hover_cursor = 0
let g:ale_lint_on_text_changed = 'never' " Only lint on bufenter, save
" 256 color term
set t_Co=256
" Better colour scheme
colorscheme one
filetype plugin indent on " Activate auto filetype detection
autocmd filetype nerdtree,taglist,qf setlocal nonumber colorcolumn= " Kill line numbers, color column in some buffers
autocmd filetype make setlocal noexpandtab
" In Javascriptish languages, show type definition on hover with buffer's
" syntax highligihting
augroup MyYCMCustom
autocmd!
autocmd FileType json,javascript,javascriptreact,typescript,typescriptreact let b:ycm_hover = {
\ 'command': 'GetType',
\ 'syntax': &filetype
\ }
augroup END
" Enable truecolor support when running inside of Tmux (which is to say,
" always)
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
syntax enable
set encoding=UTF-8
set statusline=%F%h%m%r%=[%b\ 0x%02B]\ \ \ %l,%c%V\ %P
set ignorecase " Don't care about case...
set smartcase " ... unless the query contains upper case characters
set nowrap " No fake carriage returns
set showcmd " Show command in statusline as it's being typed
set showmatch " Jump to matching bracket
set ruler " Show row,col %progress through file
set visualbell " Don't yell at me
set imd " The input managerwhich seems to hate Dvorak.
set ff=unix " Read/Write/Breathe Unix
set scrolloff=3 " Keep 3 lines of context around the cursor
set clipboard=unnamed " Use system clipboard for yank/paste
set directory=/tmp " Single location for swap files
set number " Set line numbering
set mousefocus " Follow mouse focus
set splitright " Open splits on the right
set splitbelow " Open splits below
set foldmethod=syntax " Code folding!
set foldlevel=20
set fillchars=fold:\
set backupcopy=yes " File watchers get fussy if this is off
set completeopt=menu,longest,popup " Show longest match, at lest one option
set colorcolumn=80 " highlight line 80
set synmaxcol=3000 " Only syntax highlight up to column x
set wildmenu " Better edit menu navigation
set wildmode=full,longest " Configure autocomplete list for fs navigation
set listchars=tab:▸\
set mouse=a " Use mouse in normal and visual modes
set laststatus=2 " Display statusline
set incsearch " Use incremental search
set autoindent " Enable automatic indenting for files with ft set
set ttymouse=xterm2 " Mouse + tmux/screen == happy
set bs=2 " Backspace like the good lord intended
" Sane tabbing
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
" Persistent undo - http://amix.dk/blog/post/19548
set undofile
set undodir=/tmp
set undolevels=1000
set undoreload=10000
"Manually mapping keypad keycodes for iTerm & OSX
set t_K6=Ok
set t_K7=Om
set t_K8=Oo
set t_K9=Oj
set t_KA=OM
set t_KB=On
set t_KC=Op
set t_KD=Oq
set t_KE=Or
set t_KF=Os
set t_KG=Ot
set t_KH=Ou
set t_KI=Ov
set t_KJ=Ow
set t_KK=Ox
set t_KL=Oy
let mapleader = "," " Leader mapping
" YouCompleteMe
map <leader>d :YcmCompleter GoTo<CR>
map <leader>D :YcmCompleter GetDoc<CR>
map <leader>r :YcmCompleter GoToReferences<CR>
map <leader>R :YcmCompleter RefactorRename
" FZF
map <c-t> :Files<CR>
map <leader>h :History:<CR>
map <leader>H :Help<CR>
" Pipe current document through markdown
map <leader>m :%!multimarkdown<CR>
" Let's get nerdy
map <leader>n :NERDTreeToggle<CR>
nmap <leader>/ <Plug>CommentaryLine
xmap <leader>/ <Plug>Commentary
" Navigation shortcuts
map <leader>] :tabn<CR>
map <leader>[ :tabp<CR>
nmap <leader> <C-x><C-o>
map <leader><Left> h
map <leader><Right> l
map <leader><Up> k
map <leader><Down> j
" Toggle search highlighting
nmap ; :set invhlsearch<CR>
" Folding is cool... sometimes.
nnoremap <Space> za
map <S-Left> :foldclose<CR>
map <S-Right> :foldopen<CR>
" Because I can't type worth poo
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
cmap Q q
" Change indent continuously (Awesome)
vmap < <gv
vmap > >gv
"Mapping option left/right
map [C w
map [D b
map [1;3C w
map [1;3D b
imap [C wa
imap [D bi
imap [1;3C wa
imap [1;3D bi
if &term =~ '^screen'
" tmux will send xterm-style keys when its xterm-keys option is on
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
" Toggle invisibles and trailing characters
nmap <leader>l :call Whitespace()<CR>
function! Whitespace()
" Set up the color for our highlight group and tab characters
highlight ExtraWhitespace ctermbg=red guibg=red
set list! " Toggle the current list setting
if &list == 0 " If list is off, hide trailing whitespace
syntax clear ExtraWhitespace
else " else highlight
syntax match ExtraWhitespace /\s\+\%#\@<!$/ containedin=ALL
endif
endfunction
" Switch between dark and light backgrounds
nmap \ :call ToggleBG()<CR>
function! ToggleBG()
if &background == 'light'
set background=dark
else
set background=light
endif
endfunction
autocmd VimEnter * call SetTheme()
function! SetTheme()
let result = system('defaults read -g AppleInterfaceStyle 2>/dev/null')
if v:shell_error
set background=light
else
set background=dark
endif
endfunction