Mercurial > ec-dotfiles
annotate rc/vimrc @ 709:0466907e566a
[vimrc] adjust configs
author | nanaya <me@nanaya.net> |
---|---|
date | Sun, 18 Dec 2022 22:46:25 +0900 |
parents | a161ebf80311 |
children | 42e58cea7821 |
rev | line source |
---|---|
607 | 1 if $TERM == 'screen' |
2 set t_Co=256 | |
3 endif | |
4 | |
525
1dd96a55b7ac
Invoke nocompatible earliest so it doesn't override anything preceeded it.
edogawaconan <me@myconan.net>
parents:
503
diff
changeset
|
5 set nocompatible |
424 | 6 set showmode " shows mode insert/replace/visual |
7 set showcmd " shows last command on screen | |
8 set nomodeline " disallow automatic vim command execution on arbitrary file | |
3 | 9 set autoindent |
10 set lazyredraw | |
424 | 11 set vb t_vb= " disables visual bell |
3 | 12 set ruler |
424 | 13 set backspace=2 " make backspace work like most other apps |
3 | 14 set esckeys |
15 set noerrorbells | |
637 | 16 set backupcopy=yes |
641
84a1e86d1afc
[vimrc] Prevent pointer to stick at the bottom of screen
nanaya <me@nanaya.pro>
parents:
637
diff
changeset
|
17 set scrolloff=5 |
680
a34ee4c7d0ce
[vimrc] Newer vim seem to have mouse enabled by default?
nanaya <me@nanaya.pro>
parents:
671
diff
changeset
|
18 set mouse= " disables mouse usage |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
19 |
574 | 20 set softtabstop=4 tabstop=4 shiftwidth=4 expandtab |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
21 |
535
70d4fb4f7d9f
copyindent instead of expandtab.
edogawaconan <me@myconan.net>
parents:
531
diff
changeset
|
22 set copyindent |
32 | 23 set title |
531 | 24 set incsearch |
25 set ignorecase | |
26 set smartcase | |
424 | 27 set hlsearch |
28 set ls=2 " always show status line | |
556 | 29 |
577 | 30 set hidden " it's buffer time? |
31 | |
648 | 32 set list listchars=tab:>-,trail:.,extends:>,nbsp:? |
570
3bd22b75cdc4
Make sure autocmd is executed when vim has it.
nanaya <me@myconan.net>
parents:
565
diff
changeset
|
33 |
424 | 34 set number |
35 | |
529
de3ff51840a3
Skip clipboard loading for speedup in current setup.
edogawaconan <me@myconan.net>
parents:
525
diff
changeset
|
36 " http://stackoverflow.com/questions/14635295/vim-takes-a-very-long-time-to-start-up |
de3ff51840a3
Skip clipboard loading for speedup in current setup.
edogawaconan <me@myconan.net>
parents:
525
diff
changeset
|
37 set clipboard=exclude:.* |
de3ff51840a3
Skip clipboard loading for speedup in current setup.
edogawaconan <me@myconan.net>
parents:
525
diff
changeset
|
38 |
571 | 39 if has("eval") |
40 execute pathogen#infect() | |
424 | 41 endif |
571 | 42 |
682 | 43 filetype plugin on |
44 filetype indent off | |
33 | 45 |
46 map <C-t><up> :tabr<cr> | |
47 map <C-t><down> :tabl<cr> | |
48 map <C-t><left> :tabp<cr> | |
49 map <C-t><right> :tabn<cr> | |
35
a8dc309a1b8a
Misc adjusments for vim keys
Edho Prima Arief <me@myconan.net>
parents:
33
diff
changeset
|
50 map <C-t>p :tabp<cr> |
a8dc309a1b8a
Misc adjusments for vim keys
Edho Prima Arief <me@myconan.net>
parents:
33
diff
changeset
|
51 map <C-t>n :tabn<cr> |
33 | 52 map <C-t><C-t> :NERDTreeToggle<cr> |
53 map <C-t><C-m> :NERDTreeMirror<cr> | |
54 | |
531 | 55 " clears out highlight |
635
5d3ce722285a
Use function keys for some functions
nanaya <me@nanaya.pro>
parents:
626
diff
changeset
|
56 nmap <esc>[13~ <esc>:nohlsearch<cr> |
659
be98916b55df
[vimrc] Support xorg native function keys
nanaya <me@nanaya.pro>
parents:
650
diff
changeset
|
57 nmap <F3> <esc>:set paste!<cr> |
531 | 58 |
59 " toggles paste mode | |
635
5d3ce722285a
Use function keys for some functions
nanaya <me@nanaya.pro>
parents:
626
diff
changeset
|
60 nmap <esc>[14~ <esc>:set paste!<cr> |
659
be98916b55df
[vimrc] Support xorg native function keys
nanaya <me@nanaya.pro>
parents:
650
diff
changeset
|
61 nmap <F4> <esc>:set paste!<cr> |
531 | 62 |
63 " removes prefix for windows copypasta | |
635
5d3ce722285a
Use function keys for some functions
nanaya <me@nanaya.pro>
parents:
626
diff
changeset
|
64 nmap <esc>[15~ <esc>:set number! list!<cr> |
659
be98916b55df
[vimrc] Support xorg native function keys
nanaya <me@nanaya.pro>
parents:
650
diff
changeset
|
65 nmap <F5> <esc>:set number! list!<cr> |
424 | 66 |
467 | 67 " format JSON |
68 map <leader>j <esc>:%!python -m json.tool<cr> | |
69 | |
531 | 70 " visual navigation instead of logical |
71 nmap j gj | |
72 nmap k gk | |
73 | |
33 | 74 "autocmd VimEnter * NERDTree |
75 "autocmd BufEnter * NERDTreeMirror | |
76 | |
329
ea82caf6c059
Added test to verify vim version (lite or full).
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
77 if has('syntax') |
ea82caf6c059
Added test to verify vim version (lite or full).
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
78 syntax on |
650
6ca63cec0879
[vim] Disable foldmethod to speed up things
nanaya <me@nanaya.pro>
parents:
648
diff
changeset
|
79 set foldmethod=manual |
432 | 80 set nofoldenable |
446
3022c5d1f8ed
Back to dark theme for compatibility with non-personal systems.
Edho Arief <edho@myconan.net>
parents:
432
diff
changeset
|
81 set background=dark |
554 | 82 |
666
f5e12f656c03
[vimrc] move color adjustment closer to colorscheme definition
nanaya <me@nanaya.pro>
parents:
665
diff
changeset
|
83 if has("autocmd") |
667
6887e66d83b4
[vim] The specialthing color is way better using the provided theme
nanaya <me@nanaya.pro>
parents:
666
diff
changeset
|
84 "autocmd colorscheme * highlight specialkey ctermfg=gray |
666
f5e12f656c03
[vimrc] move color adjustment closer to colorscheme definition
nanaya <me@nanaya.pro>
parents:
665
diff
changeset
|
85 endif |
f5e12f656c03
[vimrc] move color adjustment closer to colorscheme definition
nanaya <me@nanaya.pro>
parents:
665
diff
changeset
|
86 |
709 | 87 let g:ctrlp_clear_cache_on_exit = 0 |
88 let g:ctrlp_prompt_mappings = { | |
89 \ 'PrtClearCache()': ['<F5>', '<esc>[15~'], | |
90 \ } | |
708 | 91 packadd! ctrlp.vim |
709 | 92 |
93 let g:srcery_bg_passthrough=1 | |
704
1e0f578f6752
Update vendor and add support for vim packs
nanaya <me@nanaya.net>
parents:
687
diff
changeset
|
94 packadd! srcery-vim |
662
f280738a90a6
[vim] vendor theme and add some more
nanaya <me@nanaya.pro>
parents:
659
diff
changeset
|
95 colorscheme srcery |
329
ea82caf6c059
Added test to verify vim version (lite or full).
Edho Arief <edho@myconan.net>
parents:
315
diff
changeset
|
96 endif |
350 | 97 |
98 if has("autocmd") | |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
99 function In2() |
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
100 set softtabstop=2 tabstop=2 shiftwidth=2 expandtab |
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
101 endfunction |
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
102 |
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
103 function In4() |
574 | 104 set softtabstop=4 tabstop=4 shiftwidth=4 expandtab |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
105 endfunction |
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
106 |
574 | 107 function In4t() |
108 set softtabstop=4 tabstop=4 shiftwidth=4 noexpandtab | |
109 endfunction | |
563
7cac401e5c78
Add configurable to always assume two spaces/no tab in vim.
nanaya <me@myconan.net>
parents:
560
diff
changeset
|
110 |
545
c9ea8dd9d382
Remove unnecessary json configs.
edogawaconan <me@myconan.net>
parents:
544
diff
changeset
|
111 " required by syntax file |
c9ea8dd9d382
Remove unnecessary json configs.
edogawaconan <me@myconan.net>
parents:
544
diff
changeset
|
112 " reference: https://github.com/elzr/vim-json/blob/master/ftplugin/json.vim |
c9ea8dd9d382
Remove unnecessary json configs.
edogawaconan <me@myconan.net>
parents:
544
diff
changeset
|
113 let g:vim_json_syntax_conceal = 1 |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
114 |
539
05785a85d603
Fix json syntax highlighter config.
edogawaconan <me@myconan.net>
parents:
538
diff
changeset
|
115 autocmd BufNewFile,BufRead *.json set filetype=json |
05785a85d603
Fix json syntax highlighter config.
edogawaconan <me@myconan.net>
parents:
538
diff
changeset
|
116 autocmd BufNewFile,BufRead *.jsonp set filetype=json |
541 | 117 autocmd BufRead,BufNewFile *.blade.php set filetype=blade |
118 autocmd BufRead,BufNewFile *.coffee set filetype=coffee | |
119 autocmd BufRead,BufNewFile *.erb set filetype=eruby | |
120 autocmd BufRead,BufNewFile *.less set filetype=less | |
121 autocmd BufRead,BufNewFile *.scss set filetype=scss | |
122 autocmd BufRead,BufNewFile *.slim set filetype=slim | |
123 autocmd BufRead,BufNewFile Gemfile set filetype=ruby | |
560 | 124 autocmd BufRead,BufNewFile Vagrantfile set filetype=ruby |
541 | 125 autocmd BufRead,BufNewFile config.ru set filetype=ruby |
126 autocmd BufRead,BufNewFile supervisord.conf set filetype=dosini | |
622 | 127 autocmd BufRead,BufNewFile php-fpm.conf set filetype=dosini |
128 autocmd BufRead,BufNewFile */php-fpm.d/* set filetype=dosini | |
620 | 129 " stolen from https://github.com/leafgarland/typescript-vim/blob/master/ftdetect/typescript.vim |
130 " use `set filetype` to override default filetype=xml for *.ts files | |
131 autocmd BufNewFile,BufRead *.ts set filetype=typescript | |
671 | 132 autocmd BufNewFile,BufRead *.tsx set filetype=typescriptreact |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
133 |
596 | 134 autocmd BufRead,BufNewFile *.nginx set ft=nginx |
135 autocmd BufRead,BufNewFile */etc/nginx/* set ft=nginx | |
136 autocmd BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx | |
137 autocmd BufRead,BufNewFile */opt/nginx/conf/* set ft=nginx | |
138 autocmd BufRead,BufNewFile nginx.conf set ft=nginx | |
139 | |
550 | 140 autocmd FileType coffee call In2() |
626 | 141 autocmd FileType css call In2() |
550 | 142 autocmd FileType eruby call In2() |
544
75c30f2b4694
Add special setting for ruby, global default to 4/noet (ruby is 2/et).
edogawaconan <me@myconan.net>
parents:
542
diff
changeset
|
143 autocmd FileType ruby call In2() |
550 | 144 autocmd FileType scss call In2() |
575 | 145 autocmd FileType less call In2() |
550 | 146 autocmd FileType yaml call In2() |
616
dc2070cb5d71
Default json to 2 spaces indentation
nanaya <me@nanaya.pro>
parents:
607
diff
changeset
|
147 autocmd FileType json call In2() |
617 | 148 autocmd FileType javascript call In2() |
624 | 149 autocmd FileType typescript call In2() |
637 | 150 autocmd FileType typescriptreact call In2() |
596 | 151 autocmd FileType nginx setlocal commentstring=#\ %s |
602 | 152 autocmd FileType nginx setlocal iskeyword& |
687 | 153 |
154 " https://vimdoc.sourceforge.net/htmldoc/change.html#fo-table | |
155 " disable comment auto format | |
156 autocmd BufRead,BufNewFile * setlocal formatoptions-=c | |
157 autocmd BufRead,BufNewFile * setlocal formatoptions-=r | |
158 autocmd BufRead,BufNewFile * setlocal formatoptions-=o | |
350 | 159 endif |
412
7ceec4404caf
Add restore cursor position for vim.
Edho Arief <edho@myconan.net>
parents:
410
diff
changeset
|
160 |
448
e0e8de4135bc
Testing for function never returns true. Replaced with autocmd.
Edho Arief <edho@myconan.net>
parents:
446
diff
changeset
|
161 if has('autocmd') |
418
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
162 "Restore cursor position |
645 | 163 set viminfo='50,\"1000,<1000,:100,%,h,n~/.viminfo |
418
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
164 function! ResCur() |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
165 if line("'\"") <= line("$") |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
166 normal! g`" |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
167 return 1 |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
168 endif |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
169 endfunction |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
170 augroup resCur |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
171 autocmd! |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
172 autocmd BufWinEnter * call ResCur() |
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
173 augroup END |
496
6bdf99bfbe97
Newer git use different filename, I think.
edogawaconan <me@myconan.net>
parents:
494
diff
changeset
|
174 autocmd BufWinEnter */.git/COMMIT_EDITMSG exe "normal! gg" |
451
abb434518e1f
Always start editing git commit message from line 1.
Edho Arief <edho@myconan.net>
parents:
448
diff
changeset
|
175 autocmd BufWinEnter .git/COMMIT_EDITMSG exe "normal! gg" |
418
c0ac21407903
Disable features on vim basic.
Edho Arief <edho@myconan.net>
parents:
412
diff
changeset
|
176 endif |
424 | 177 |
178 if has('statusline') | |
179 " Status line detail: | |
180 " %f file path | |
181 " %y file type between braces (if defined) | |
182 " %([%R%M]%) read-only, modified and modifiable flags between braces | |
183 " %{'!'[&ff=='default_file_format']} | |
184 " shows a '!' if the file format is not the platform | |
185 " default | |
186 " %{'$'[!&list]} shows a '*' if in list mode | |
187 " %{'~'[&pm=='']} shows a '~' if in patchmode | |
188 " (%{synIDattr(synID(line('.'),col('.'),0),'name')}) | |
189 " only for debug : display the current syntax item name | |
190 " %= right-align following items | |
191 " #%n buffer number | |
192 " %l/%L,%c%V line number, total number of lines, and column number | |
193 function SetStatusLineStyle() | |
194 if &stl == '' || &stl =~ 'synID' | |
195 let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]}%{'~'[&pm=='']}%=#%n %l/%L,%c%V " | |
196 else | |
197 let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]} (%{synIDattr(synID(line('.'),col('.'),0),'name')})%=#%n %l/%L,%c%V " | |
198 endif | |
199 endfunc | |
200 " Switch between the normal and vim-debug modes in the status line | |
201 nmap _ds :call SetStatusLineStyle()<CR> | |
202 call SetStatusLineStyle() | |
203 " Window title | |
204 if has('title') | |
493
1ad9091c464e
Properly set window name for vim.
edogawaconan <me@myconan.net>
parents:
476
diff
changeset
|
205 if &term == "screen" |
1ad9091c464e
Properly set window name for vim.
edogawaconan <me@myconan.net>
parents:
476
diff
changeset
|
206 set t_ts=]0; |
1ad9091c464e
Properly set window name for vim.
edogawaconan <me@myconan.net>
parents:
476
diff
changeset
|
207 set t_fs= |
1ad9091c464e
Properly set window name for vim.
edogawaconan <me@myconan.net>
parents:
476
diff
changeset
|
208 endif |
494 | 209 set title |
210 let &titlestring = $user | |
424 | 211 endif |
212 endif | |
618 | 213 |
619 | 214 if filereadable($HOME."/.vimrc.local") |
215 source $HOME/.vimrc.local | |
618 | 216 endif |