-
Notifications
You must be signed in to change notification settings - Fork 5
/
gvimrc
125 lines (109 loc) · 3.66 KB
/
gvimrc
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
let s:on_windows = has('win32') || has('win64')
let s:on_unix = has('unix')
let s:on_mac = 0
let s:on_linux = 0
if s:on_unix
let s:uname = system("printf \"$(uname)\"")
if !v:shell_error
if s:uname == "Darwin"
let s:on_mac = 1
endif
if s:uname == "Linux"
let s:on_linux = 1
endif
endif
endif
" ---
" Text formatting
" how to load various color schemes
" the called function will run after the CLI color scheme is loaded, so
" each function just needs to overwrite any values that are different
" an empty function means it doesn’t need to change anything compared to CLI
function! s:LoadGUIColorSchemeWombat()
colorscheme wombat
" halve guibg value of MatchParen so MP is easier to tell apart from Cursor
highlight MatchParen guibg=#423d37
endfunction
function! s:LoadGUIColorSchemeSolarized()
endfunction
function! s:LoadGUIColorSchemeSolarizedLight()
call s:LoadGUIColorSchemeSolarized()
" make MatchParen less confusable with Cursor by blending its guibg 50% with Normal guibg
highlight MatchParen guibg=#c8cbc2
" add highlighting for Noise highlight group, used in JS and CSS highlighters
" highlight as base00, one step less contrasty than text
highlight Noise guifg=#839496
endfunction
function! s:LoadGUIColorSchemeSolarizedDark()
call s:LoadGUIColorSchemeSolarized()
" make MatchParen less confusable with Cursor by blending its guibg 50% with Normal guibg
highlight MatchParen guibg=#2c4c55
" add highlighting for Noise highlight group, used in JS and CSS highlighters
" highlight as base00, one step less contrasty than text
highlight Noise guifg=#657b83
endfunction
"call s:LoadGUIColorSchemeWombat()
call s:LoadGUIColorSchemeSolarizedLight()
if s:on_windows
set guifont=Consolas:h11:cANSI
" looks good in GVim on Windows 7
" why do I have cANSI instead of cDEFAULT again?
" below font has more Unicode characters on Windows, but uglier otherwise
"set guifont=DejaVu_Sans_Mono:h10
elseif s:on_linux
" looks good in GVim on Ubuntu 17.10:
set guifont=Consolas\ 12
" looks good in GVim on Ubuntu 17.04:
"set guifont=Consolas\ 13
else
set guifont=Consolas:h16
" looks good in MacVim on Mac OS X
endif
" TODO using commas, add fallback fonts, such as Ubuntu Mono and Monaco
" ---
" GUI controls
if !s:on_mac
" hide toolbar
set guioptions-=T
else
" not hiding MacVim toolbar yet; investigating substitute for its session-related
" buttons first
" see `:help Session`
endif
" on Linux, don’t show a tilted arrow mouse cursor in Visual mode
set mouseshape-=v:rightup-arrow
set mouseshape+=v:arrow
" ---
" keyboard shortcuts (mappings)
if s:on_windows || s:on_linux
" Ctrl-V to paste in Insert, Command-line, Select modes
" TODO move this one shortcut into .vimrc – they are still useful in the console
noremap! <C-v> <C-r><C-o>+
snoremap <C-v> <C-g>"+p
" Ctrl-S to save, using the file browsing dialog for unsaved files
function! s:SaveWithGUI()
let l:current_buffer_path = expand('%:p')
if len(l:current_buffer_path) == 0
browse confirm saveas
else
write
" I chose `write` over `update`.
" `write` behavior is used by Sublime Text, VS Code, gedit,
" and nano.
" `update` behavior is used by Emacs.
endif
endfunction
nnoremap <silent> <C-s> :call <sid>SaveWithGUI()<CR>
" Ctrl-T to open a new tab
" If I want to go back to the previous tag, I’ll use `:pop` or Ctrl-O.
nnoremap <C-t> :tabnew<CR>
vnoremap <C-t> <Esc>:tabnew<CR>
onoremap <C-t> <Esc>:tabnew<CR>
endif
" I don’t write equivalent mappings for MacVim here
" because it already provides them by default.
" mappings usable on all OSs:
" move back and forward in the jump list using the
" Back and Forward mouse buttons
nnoremap <X1Mouse> <C-O>
nnoremap <X2Mouse> <C-I>