1"
2" cream-settings.vim
3"
4" Cream -- An easy-to-use configuration of the famous Vim text  editor
5" [ http://cream.sourceforge.net ] Copyright (C) 2001-2011 Steve Hall
6"
7" License:
8" This program is free software; you can redistribute it and/or modify
9" it under the terms of the GNU General Public License as published by
10" the Free Software Foundation; either version 2 of  the  License,  or
11" (at your option) any later version.
12" [ http://www.gnu.org/licenses/gpl.html ]
13"
14" This program is distributed in the hope that it will be useful,  but
15" WITHOUT  ANY  WARRANTY;  without  even  the  implied   warranty   of
16" MERCHANTABILITY or FITNESS FOR A PARTICULAR  PURPOSE.  See  the  GNU
17" General Public License for more details.
18"
19" You should have received a copy of the GNU  General  Public  License
20" along with  this  program;  if  not,  write  to  the  Free  Software
21" Foundation,  Inc.,  59  Temple  Place  -  Suite  330,   Boston,   MA
22" 02111-1307, USA.
23"
24" Description:
25" * basic environmental settings required by most of Cream
26" * no global variables set here
27"
28
29" General {{{1
30
31" makes Vim "modeless"
32set insertmode
33
34"*** Do NOT use! (Individual options set elsewhere)
35"behave mswin
36"***
37
38" write ("nowrite" is a read-only/file viewer)
39set write
40
41" file to use for keyword completion (not spelling!)
42"set dictionary=/usr/dict/words
43
44" hold screen updating while executing macros
45" * nolazyredraw is slower
46" * nolazyredraw ensures better accuracy ;)
47" *   lazyredraw still allows "redraw!" to override within a function
48set nolazyredraw
49
50" Just use default
51"" GTK2 hack: <S-Space> is broken otherwise
52"if has("gui_gtk2")
53"    set imdisable
54"endif
55
56" Vim plugins {{{1
57
58" the loading of Vim plugins can be controled by the
59" g:CREAM_NOVIMPLUGINS variable
60if exists("g:CREAM_NOVIMPLUGINS")
61	if g:CREAM_NOVIMPLUGINS == 1
62		set noloadplugins
63	endif
64endif
65
66" Paths (misc, critical are set in vimrc) {{{1
67
68" set default search paths for files
69"set path=.,,
70
71"" set current directory equal to location of current buffer
72"" Source: http://vim.sourceforge.net/tips/tip.php?tip_id=64
73"" Author: William Lee, modified by ict@eh.org
74"function! Cream_cwd()
75"    let mydir = expand("%:p:h")
76"    if mydir !~ '^/tmp'
77"      exec "cd " . mydir
78"    endif
79"    unlet mydir
80"endfunction
81
82" set browse location
83" TODO: We use getcwd() and g:CREAM_CWD elsewhere to effectively
84"       accomplish the same thing. While this is automatic, Cream uses
85"       a more selective strategy to avoid setting a high latency
86"       directory active.
87set browsedir=buffer
88" can't use this, depends on too restrictive features (:help feature-list)
89"set autochdir
90
91" Windows and Buffers {{{1
92
93" confirm certain (verbose) operations to unsaved buffers
94set noconfirm
95" * Allow hidden buffers! When a new buffer is opened and then
96"   modified, we do not want to force the user to write it before they
97"   switch to another file/buffer. (We just want it to show up in the
98"   buffer list as modified.) So it should not be abandoned if
99"   unsaved, which is what ":set nohidden" does.
100set hidden
101" used to set buffers no longer displayed in a window (empty means
102" follow global 'set hidden')
103set bufhidden=
104" automatically save modifications to files when you use buffer/window
105" commands.
106set noautowrite
107" automatically save modifications to files when you use critical
108" (rxternal) commands.
109set noautowriteall
110
111" keep window sizes mostly equal
112set equalalways
113
114" height of help window -- zero disables (50%) (default=20)
115set helpheight=0
116" Create new windows below current one
117set splitbelow
118
119" turn off alternate file
120set cpoptions-=a
121
122" Window titling {{{1
123
124" window icon text--use defaults
125function! Cream_titletext()
126
127	" verify b:cream_nr
128	call Cream_buffer_nr()
129	" verify buffer name
130	call Cream_buffer_pathfile()
131
132	" modified
133	if getbufvar(b:cream_nr, "&modified") == 1
134		let mymod = "*"
135	else
136		let mymod = ""
137	endif
138
139	" filename
140	let myfile = fnamemodify(b:cream_pathfilename, ":t")
141
142	if     myfile == ""
143		let myfile = "[untitled]"
144	elseif Cream_buffer_isspecial() == 1
145		if Cream_buffer_ishelp() == 1
146			let myfile = "Help"
147		elseif myfile == "_opsplorer"
148			let myfile = "File Tree"
149		elseif isdirectory(bufname(b:cream_nr))
150			let myfile = "File Explorer"
151		elseif myfile == "__Calendar"
152			let myfile = "Calendar"
153		elseif myfile == "__Tag_List__"
154			let myfile = "Tag List"
155		elseif myfile == "-- EasyHtml --"
156			let myfile = "Item List"
157		endif
158	endif
159	let myfile = myfile . " "
160
161	" path
162	if     Cream_buffer_ishelp() == 1
163		let mypath = "(" . fnamemodify(b:cream_pathfilename, ":h") . ")"
164		" add trailing slash if doesn't exist
165		let mypath = Cream_path_addtrailingslash(mypath)
166	elseif b:cream_pathfilename == ""
167		let mypath = ""
168	elseif Cream_buffer_isspecial() == 1
169		let mypath = ""
170	else
171		" add trailing slash if doesn't exist
172		let mypath = Cream_path_addtrailingslash(fnamemodify(b:cream_pathfilename, ":h"))
173		let mypath = "(" . mypath . ")"
174	endif
175
176	"" limit total length (until titlelen gets fixed)
177	"if strlen(mypath . myfile . mymod) > 50
178	"    let mypath = "..." . strpart(mypath, strlen(mypath . myfile . mymod) - 47)
179	"endif
180
181	return mymod . myfile . mypath
182
183endfunction
184function! Cream_titletext_init()
185	set titlestring=%.999{Cream_titletext()}
186endfunction
187" broken
188set titlelen=0
189set title
190
191" Editing and Keyboard {{{1
192
193" place two spaces after a period
194set nojoinspaces
195
196" allow cursor positioning where there is no character. (Useful in Visual block
197" mode.) (Options are 'block', 'insert', 'all'.)
198set virtualedit=block
199
200
201" use a faster timeout setting
202set timeout
203set timeoutlen=300
204"set ttimeout
205"set ttimeoutlen=200
206
207" Menus  {{{1
208
209if has("gui_running")
210" GUI menus
211	" general Vim menu Settings
212
213	" menubar (initially off to improve loading speed, turned back on
214	" via autocmd after startup)
215	set guioptions-=m
216	" grey menu items when not active (rather than hide them)
217	set guioptions+=g
218
219	" hide toolbar for faster startup (init will turn on on VimEnter)
220	set guioptions-=T
221
222	" toolbar (Cream_toolbar_toggle() toggle function in cream-lib.vim)
223	function! Cream_toolbar_init()
224		" initialize
225		if !exists("g:CREAM_TOOLBAR")
226			let g:CREAM_TOOLBAR = 1
227		endif
228		" set
229		if g:CREAM_TOOLBAR == 1
230			" toolbar
231			set guioptions+=T
232		else
233			" no toolbar
234			set guioptions-=T
235		endif
236	endfunction
237
238	" allow tearoff menus
239	set guioptions-=t
240
241	" allows use of [ALT] key, in combination with others, to access GUI menus.
242	"*** Need to find a way to de-conflict these from language mappings ***
243	set winaltkeys=menu
244
245endif
246
247" M -- means "Don't source default menu"
248set guioptions+=M
249
250
251" Console menus
252
253set wildmenu
254set cpoptions-=<
255set wildcharm=<C-z>
256
257" Selection {{{1
258
259" allow "special" keys to begin select mode. (This option is useful
260" for enabling "windows-like" text selection.
261set keymodel=startsel,stopsel
262
263" end of line selection behavior
264set selection=exclusive
265
266" starts Select mode instead of Visual mode in the prescribed
267" conditions. (Options: mouse,cmd,key)
268"***       Use 'key' to replace selected text with a character! (non-mouse) ***
269"*** Don't use 'cmd' because we need visual mode for column editing! ***
270"***       Use 'cmd' because... ***
271"*** Don't use 'mouse' so that double-click selects can be pasted upon. (Bogus) ***
272set selectmode=key,mouse
273
274
275" Motion {{{1
276
277" allows backspacing" over indentation, end-of-line, and
278" start-of-line.
279set backspace=indent,eol,start
280
281" Allow jump commands for left/right motion to wrap to previous/next
282" line when cursor is on first/last character in the line.
283set whichwrap+=<,>,h,l,[,]
284
285
286" jump to first character with page commands ('no' keeps the cursor in the current column)
287
288"*** doesn't work for me
289set startofline
290" append <Home>/<End> to fix
291"***
292
293" Terminal {{{1
294
295"*** Now dynamically set in lib function Cream_errorbells()
296"	t_vb:  terminal's visual bell (See also 'visualbell')
297"set t_vb=
298"***
299
300" Wrap {{{1
301
302" do not indicate lines that have been wrapped. (Should show on last
303" column, not on first!)
304set cpoptions-=n
305
306" line break at spaces
307set linebreak
308" determine which characters cause a line break (default: set breakat=" ^I!@*-+;:,./?")
309set breakat=\ -
310
311
312" substitute spaces for a tab character
313" * Typically off. User can choose AutoWrap and QuickFormat to change.
314set noexpandtab
315" Inserts blanks if at the beginning of a line.
316set nosmarttab
317
318" see :help fo-table (notice that we're resetting, not adding!)
319" * DO NOT ADD "w" option... it completely hoses auto-wrap!
320"set formatoptions=tcrqn2m
321set formatoptions=tcrqm
322
323" Completion, Incrementing {{{1
324
325set showfulltag
326
327set nrformats=alpha
328
329" Case sensitivity {{{1
330
331set ignorecase
332
333" convert to case of current start
334set infercase
335
336
337" Mouse {{{1
338
339" window focus follows mouse (when multiple windows present). (Nice if you're an
340" expert, too confusing otherwise.)
341set nomousefocus
342set mousemodel=popup
343
344
345" Scrolling {{{1
346
347" minimum number of screen rows ('lines') to maintain context in
348" vertical cursor movements.
349set scrolloff=1
350" *** I have found this to screw up 'linebreak' with 'wordwrap',
351"     'breakat' and 'linebreak' ***
352"set sidescrolloff=5
353
354" show as much of a non-fitting line as possible
355set display=lastline
356
357
358" Command Line {{{1
359
360" mode indication on command line
361set noshowmode
362" sure do wish I could make these go away to "pop" open when necessary.
363set cmdheight=1
364set cmdwinheight=1
365
366" the char used for "expansion" on the command line. (Default value is <TAB>.)
367" * <C-Space> is mapped elsewhere, but for insertmode in the doc (NOT the command line.)
368set wildchar=<TAB>
369
370
371" Errors {{{1
372
373" Note: See library and autocommands for errorbell and visualbell
374" settings
375
376" default is "filnxtToO"
377" * Add 'I' to disable splash screen
378set shortmess=stOTI
379
380
381" Clipboard {{{1
382
383" use OS clipboard for general register
384"set clipboard+=unnamed
385
386if has("gui_running")
387	" Vim selection to OS clipboard
388	set guioptions-=a
389	" Vim selection to OS clipboard, modeless
390	set guioptions-=A
391endif
392
393
394" Folding {{{1
395
396"set foldmethod=marker
397
398" Filetype {{{1
399
400" turn on
401filetype plugin on
402
403" Backups, swap files, viewoptions, history and mksessions {{{1
404" * Move this section below path configuration if $CREAM is ever appended here.
405" * Location to place backup files. Perhaps we could create a more sophisticated
406"   approach here, such as automating the creation of a ./.bak ?
407
408" create backup file on save
409set backup
410" create backup before overwriting (erased if successful)
411set writebackup
412" set backup file extension (Sometimes prefer ".bak" but tilde is easier to see)
413set backupext=.~
414
415" use a swapfile (turned off in Cream_singleserver_init() for
416" single-server mode)
417set swapfile
418
419" * Hmmm... 'slash' is undocumented.
420" * Don't use 'options', it overwrites Cream initializations
421set viewoptions=folds,cursor,unix
422
423set history=200
424
425" mksession conditioning
426" * Also available: localoptions,options,sesdir
427" * Don't save 'options' -- we want auto re-detection of filetype and comment loading.
428" * "set sessionoptions+=tabpages" done elsewhere
429set sessionoptions=blank,buffers,curdir,folds,globals,help,resize,slash,unix,winpos,winsize
430
431" Bracket matching {{{1
432
433"set matchtime -- set at Cream_bracketmatch_init()
434let g:loaded_matchparen = 1
435
436" Search {{{1
437set incsearch
438
439" Diff {{{1
440
441if has("win32")
442	set diffexpr=MyDiff()
443endif
444
445" 1}}}
446" vim:foldmethod=marker
447