blob: 88d22f8751bd2a07d6c2bee252b3670f5f832c5d (
plain)
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
|
" All system-wide defaults are set in $VIMRUNTIME/archlinux.vim (usually just
" /usr/share/vim/vimcurrent/archlinux.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since archlinux.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing archlinux.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! archlinux.vim
set nocompatible
" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
filetype plugin indent on
endif
if has("gui_running")
color torte
set guioptions-=m
set guioptions-=T
set guioptions-=R
set guioptions-=r
endif
set modeline
set showmatch " Show matching brackets.
set showmode
set autowrite " Automatically save before commands
set shiftwidth=4
set tabstop=4
set expandtab
set nonumber " this takes too much cols
set hlsearch
set splitbelow
set splitright
set showcmd
set ruler
set foldmethod=marker
set background=dark
set backspace=start " this fixes the weird behaviour of the backspace key
set title
set encoding=utf-8
set mouse="" " disable mouse support
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
"set spell
set path+=include/
set path+=src/
set tags+=/usr/include/tags
function! s:insert_auto_include_protector()
let header_name = substitute(toupper(expand("%:t")), "\\.", "_", "g")
execute ":set paste"
execute "normal! i#ifndef " . header_name
execute "normal! o#define " . header_name
execute "normal! 3o"
execute "normal! o#endif /* " . header_name . " */"
execute "normal! 2k"
execute ":set nopaste"
endfunction
autocmd BufNewFile *.{h,hpp,hh} call <SID>insert_auto_include_protector()
function! s:insert_auto_makefile()
call inputsave()
let language = confirm('Makefile', "&C\nC&++\n&Empty", 1)
call inputrestore()
if language == 1
let compiler = "CC"
let default_compiler = "gcc"
let compiler_flags = "CFLAGS"
let default_compiler_flags = "-W -Wall -std=c99 -Wextra"
let source_extension = ".c"
elseif language == 2
let compiler = "CXX"
let default_compiler = "g++"
let compiler_flags = "CXXFLAGS"
let default_compiler_flags = "-W -Wall -Wextra"
let source_extension = ".cpp"
else
return
endif
let exe_name = "a.out"
execute "set paste"
execute "normal! i".compiler." ?= ".default_compiler
execute "normal! o".compiler_flags." += ".default_compiler_flags
execute "normal! oNAME = ".exe_name
execute "normal! oSRC = "
execute "normal! o"
execute "normal! oall: depend $(NAME)"
execute "normal! o"
execute "normal! odepend: .depend"
execute "normal! o"
execute "normal! o.depend: $(SRC)"
execute "normal! o @$(RM) .depend"
execute "normal! o @$(".compiler.") $(CFLAGS) -MM $^ > .depend"
execute "normal! o"
execute "normal! oinclude .depend"
execute "normal! o"
execute "normal! oOBJ = $(SRC:".source_extension."=.o)"
execute "normal! o"
execute "normal! o$(NAME): $(OBJ)"
execute "normal! o $(".compiler.") -o $@ $^ $(LDFLAGS)"
execute "normal! o"
execute "normal! oclean:"
execute "normal! o $(RM) $(OBJ)"
execute "normal! o"
execute "normal! ofclean: clean"
execute "normal! o $(RM) $(NAME)"
execute "normal! o"
execute "normal! ore: fclean all"
execute "normal! o"
execute "normal! o.PHONY: all depend clean fclean all re"
execute ":set nopaste"
endfunction
autocmd BufNewFile {Makefile,makefile} call <SID>insert_auto_makefile()
" Workaround to avoid color problems at startup
if &term =~ "xterm"
set term=xterm-256color
endif
if v:version > 700
set cursorline
hi CursorLine cterm=none ctermbg=17
endif
hi Comment cterm=none ctermfg=blue ctermbg=none
hi Folded cterm=none ctermfg=blue ctermbg=none
hi StorageClass cterm=bold ctermfg=yellow
hi Namespace cterm=none ctermfg=red ctermbg=none
hi VertSplit cterm=none ctermfg=blue
|