summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2014-12-22 15:57:58 +0100
committerOlivier Gayot <duskcoder@gmail.com>2014-12-22 16:00:28 +0100
commit566f3a44516fd0c6f2012b2847e22890ccc1c064 (patch)
tree17b6ebaaa1daac033de3cd132b6b8bc25e274aca
parent4093af8ccf75723e12f40d8a84f59d3fbc2f6368 (diff)
vim: add the vimrc file
We should beware that this file is supposed to source a file related to the distribution. e.g. in this case: source archlinux.vim we might need to process that name or remove it completely Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r--user/.vimrc157
1 files changed, 157 insertions, 0 deletions
diff --git a/user/.vimrc b/user/.vimrc
new file mode 100644
index 0000000..88d22f8
--- /dev/null
+++ b/user/.vimrc
@@ -0,0 +1,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