-
Notifications
You must be signed in to change notification settings - Fork 10
/
.vimrc
362 lines (308 loc) · 9.84 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
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
"filetype off
syntax on
let g:javascript_plugin_flow = 1
let g:polyglot_disabled = ['jsx']
" vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()
Plug 'chemzqm/vim-jsx-improve'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-ragtag'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-dadbod'
Plug 'thoughtbot/vim-rspec'
Plug 'fatih/vim-go'
Plug 'knsh14/vim-github-link'
Plug 'itchyny/lightline.vim'
Plug 'preservim/nerdtree'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Plug 'vim-syntastic/syntastic'
Plug 'mbbill/undotree'
Plug 'itchyny/lightline.vim'
Plug 'morhetz/gruvbox'
Plug 'edkolev/tmuxline.vim'
Plug 'shinchu/lightline-gruvbox.vim'
Plug 'Quramy/vison'
Plug 'dart-lang/dart-vim-plugin'
Plug 'hankchiutw/flutter-reload.vim'
" Plug 'dense-analysis/neural'
" Plug 'dense-analysis/ale'
Plug 'thosakwe/vim-flutter'
Plug 'natebosch/vim-lsc'
Plug 'natebosch/vim-lsc-dart'
" Svelte
Plug 'evanleck/vim-svelte'
Plug 'pangloss/vim-javascript'
Plug 'HerringtonDarkholme/yats.vim'
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'codechips/coc-svelte', {'do': 'npm install'}
Plug 'prettier/vim-prettier', { 'do': 'npm install' }
Plug 'Shougo/context_filetype.vim'
call plug#end()
if exists('$TMUX')
let g:tmuxline_preset = 'full'
autocmd VimEnter * Tmuxline lightline
endif
set background=dark
colorscheme gruvbox
let g:lightline = {}
let g:lightline.colorscheme = 'gruvbox'
"LSC
nmap <silent> <C-k> :lbefore<CR>
nmap <silent> <C-j> :lafter<CR>
let g:lsc_auto_map = {'defaults': v:true, 'NextReference': '', 'PreviousReference': ''}
let g:lsc_server_commands = { 'ruby': { 'command': 'ruby-lsp', 'log_level': -1, 'suppress_stderr': v:true } }
filetype plugin indent on
"set modelines=0
set nocompatible
set tabstop=2
set softtabstop=2
set smarttab
set shiftwidth=2
set expandtab
set spelllang=en_gb
set autoindent
set encoding=utf-8
" We have a statusline that does this
set noshowmode
set showcmd
" From http://items.sjbach.com/319/configuring-vim-right
set hidden
let mapleader = ","
let maplocalleader = ","
set history=1000
set wildmenu
set wildmode=list:longest
set ignorecase
set smartcase
set title
set ttyfast
"set cursorline
set scrolloff=3
set backupdir=~/.vim/backups,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim/backups,~/.tmp,~/tmp,/var/tmp,/tmp
nnoremap <tab> %
vnoremap <tab> %
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
set gdefault
set backspace=indent,eol,start
let g:omni_sql_default_compl_type = 'syntax'
"" fix regex handling
"nnoremap / /\v
"vnoremap / /\v
" File-type highlighting and configuration.
" Run :filetype (without args) to see what you may have
" to turn on yourself, or just set them all to be sure.
set incsearch
set shortmess=atI
set visualbell
autocmd FileType make set noexpandtab
autocmd FileType python set noexpandtab
set ruler
set number
set hlsearch
syntax on
map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
map <C-P> :GFiles<CR>
map <C-G> :Rg<CR>
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case
\ -g "*.{js,ts,tsx,json,php,md,styl,jade,html,config,py,cpp,c,go,hs,rb,conf,tf,rake,*haml,*erb,sass,sql,yml,shader,glsl,proto,dart,vim,ts,tsx,svelte}"
\ -g "!*.{min.js,swp,o,zip,tfstate,gr.dart,freezed.dart,pb.dart,pbtwirp.dart}"
\ -g "!**app/assets/javascripts/**/*js"
\ -g "!{.git,node_modules,vendor}/*"
\ -g "!{sustained/data,sainsburys/products/data,bbcgoodfood/data,spec/fixtures/vcr_cassettes}/*"
\ -- '.shellescape(<q-args>), 1,
\ fzf#vim#with_preview(), <bang>0)
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
map <leader>gl :Commits<CR>
" From http://biodegradablegeek.com/2007/12/using-vim-as-a-complete-ruby-on-rails-ide/
set cf " Enable error files & error jumping.
set clipboard+=unnamed " Yanks go on clipboard instead.
set autowrite " Writes on make/shell commands
set showmatch
set laststatus=2
"Save on losing focus
"au FocusLost * :wa
"My own keybindings
map <leader>gd :Git diff<CR>
map <leader>gs :Git status<CR>
map <leader>gc :Git commit<CR>
nnoremap <leader><space> :noh<cr>
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
nnoremap <leader>r :.w !bash<cr>
map <leader>id cc<ESC>!!date +'\%Y-\%m-\%d \%T \%z'<CR>idate: <ESC>
" map <leader>rs :Dispatch rspec %<CR>
" map <leader>ra :Dispatch rspec<CR>
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
map <leader>rf :call RunCurrentSpecFile()<CR>
map <leader>rs :call RunNearestSpec()<CR>
map <leader>ra :call RunAllSpecs()<CR>
"map <leader>pc :ColorHEX<CR>
"map <leader>rs :wa\|!rspec %<CR>
"map <leader>rc :wa\|!cucumber %<CR>
"map <leader>ras :wa\|!rspec spec<CR>
"map <leader>rac :wa\|!cucumber<CR>
"map <leader>zt :wa\|!zeus test %<CR>
"map <leader>zc :wa\|!zeus cucumber %<CR>
"map <leader>zm :wa\|!zeus r script/rails g migration
map <leader>vimrc :tabedit ~/.vimrc<CR>
map <leader>f yiw:Rg <C-R>"<CR>
map <leader>t :Tags<cr>
map <leader>b :Buffers<cr>
" Use .as for ActionScript files, not Atlas files.
au BufNewFile,BufRead *.as set filetype=actionscript
au BufNewFile,BufRead *.ru set filetype=ruby
au BufNewFile,BufRead Gemfile set filetype=ruby
au BufNewFile,BufRead *.md set filetype=mkd
" Understand :W as :w
command! W :w
" Show unwanted whitespace
set listchars=tab:->,trail:·,extends:>
set list!
" Status line
set statusline=%f\ %(%m%r%h\ %)%([%Y]%)%=%<%-20{getcwd()}\ %l/%L\ ~\ %p%%\ \
""Convert hashes to ruby 1.9
"map <leader>H :%s/:\(\w\+\) =>/\1:<CR>``
"json == javascript
"autocmd BufNewFile,BufRead *.json set ft=javascript
"
" Shaders are 'C' for now
autocmd BufNewFile,BufRead *.vertexshader set ft=cpp
autocmd BufNewFile,BufRead *.fragmentshader set ft=cpp
" autocmd BufNewFile,BufRead *.proto set ft=cpp
" rabl files are ruby
autocmd BufNewFile,BufRead *.rabl set ft=ruby
" rcss are css and rml are html
autocmd BufNewFile,BufRead *.rcss set ft=css
autocmd BufNewFile,BufRead *.rml set ft=html
autocmd BufNewFile,BufRead *.sibilant set ft=clojure
" Ignore *.o files in CommandT
set wildignore+=*.o,*.obj,.git,*.mf,*.pb,*.pdf,*.jpg,*.gif,*.png,*/public/js/*
"%% expands to current path
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
map <leader>wc :!wc %<cr>
set shell=/bin/bash
" use par for formatting
map <leader>q gqq<CR>
"set formatprg=par
" map
nnoremap <F5> :UndotreeToggle<CR>
"" syntastic options for sol
let g:syntastic_cpp_checkers = []
"" Configure Neural
" let g:neural = {
" \ 'source': {
" \ 'openai': {
" \ 'api_key': $OPENAI_API_KEY,
" \ },
" \ },
" \}
" let g:neural.selected = 'chatgpt'
let g:go_dispatch_enabled = 1 " vim-go
" Prettier Settings
let g:prettier#quickfix_enabled = 0
let g:prettier#autoformat = 1
let g:prettier#autoformat_require_pragma = 0
au BufWritePre *.css,*.svelte,*.pcss,*.html,*.ts,*.js,*.json PrettierAsync
if !exists('g:context_filetype#same_filetypes')
let g:context_filetype#filetypes = {}
endif
let g:context_filetype#filetypes.svelte =
\ [
\ {'filetype' : 'javascript', 'start' : '<script>', 'end' : '</script>'},
\ {
\ 'filetype': 'typescript',
\ 'start': '<script\%( [^>]*\)\? \%(ts\|lang="\%(ts\|typescript\)"\)\%( [^>]*\)\?>',
\ 'end': '',
\ },
\ {'filetype' : 'css', 'start' : '<style \?.*>', 'end' : '</style>'},
\ ]
let g:ft = ''
" NERDCommenter settings
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDCustomDelimiters = { 'html': { 'left': '' } }
" Align comment delimiters to the left instead of following code indentation
let g:NERDDefaultAlign = 'left'
fu! NERDCommenter_before()
if (&ft == 'html') || (&ft == 'svelte')
let g:ft = &ft
let cfts = context_filetype#get_filetypes()
if len(cfts) > 0
if cfts[0] == 'svelte'
let cft = 'html'
elseif cfts[0] == 'scss'
let cft = 'css'
else
let cft = cfts[0]
endif
exe 'setf ' . cft
endif
endif
endfu
fu! NERDCommenter_after()
if (g:ft == 'html') || (g:ft == 'svelte')
exec 'setf ' . g:ft
let g:ft = ''
endif
endfu
" COC
" " nmap ff (coc-format-selected)
" nmap <leader>rn (coc-rename)
" nmap gd (coc-definition)
" nmap gy (coc-type-definition)
" nmap gi (coc-implementation)
" nmap gr (coc-references)
" set updatetime=300
" set shortmess+=c " don't give |ins-completion-menu| messages.
" " Make <CR> to accept selected completion item or notify coc.nvim to format
" " <C-g>u breaks current undo, please make your own choice
" inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
" \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" set signcolumn=yes
" nmap <silent> <C-k> <Plug>(coc-diagnostic-prev)
" nmap <silent> <C-j> <Plug>(coc-diagnostic-next)
" " GoTo code navigation
" nmap <silent> gd <Plug>(coc-definition)
" nmap <silent> gy <Plug>(coc-type-definition)
" nmap <silent> gi <Plug>(coc-implementation)
" nmap <silent> gr <Plug>(coc-references)
" " Use K to show documentation in preview window
" nnoremap <silent> K :call ShowDocumentation()<CR>
" function! ShowDocumentation()
" if CocAction('hasProvider', 'hover')
" call CocActionAsync('doHover')
" else
" call feedkeys('K', 'in')
" endif
" endfunction
" nnoremap <silent> <leader>yd :call StatusDiagnosticToClipboard()<CR>
" function! StatusDiagnosticToClipboard()
" call setreg('+','')
" let diagList=CocAction('diagnosticList')
" let line=line('.')
" for diagItem in diagList
" if line == diagItem['lnum']
" let str=diagItem['message']
" call setreg('+',str)
" return
" endif
" endfor
" endfunction