From 47564007ee05797e60cc7ece36dc000891c12412 Mon Sep 17 00:00:00 2001 From: Philippe Huerlimann Date: Thu, 7 Jun 2012 18:47:45 +0200 Subject: [PATCH] Added all the files --- .gitignore | 2 + ftplugin/gitcommit.vim | 1 + ftplugin/mail.vim | 2 + ftplugin/python.vim | 6 + vimrc | 136 ++++++++ xpt_personal/ftplugin/cpp/cpp.xpt.vim | 452 ++++++++++++++++++++++++++ xpt_personal/ftplugin/sh/sh.xpt.vim | 46 +++ xpt_personal/ftplugin/tex/tex.xpt.vim | 163 ++++++++++ 8 files changed, 808 insertions(+) create mode 100644 .gitignore create mode 100644 ftplugin/gitcommit.vim create mode 100644 ftplugin/mail.vim create mode 100644 ftplugin/python.vim create mode 100644 vimrc create mode 100644 xpt_personal/ftplugin/cpp/cpp.xpt.vim create mode 100644 xpt_personal/ftplugin/sh/sh.xpt.vim create mode 100644 xpt_personal/ftplugin/tex/tex.xpt.vim diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6feb037 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +spell +bundle diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim new file mode 100644 index 0000000..7c98e62 --- /dev/null +++ b/ftplugin/gitcommit.vim @@ -0,0 +1 @@ +set spell spelllang=en diff --git a/ftplugin/mail.vim b/ftplugin/mail.vim new file mode 100644 index 0000000..145e58b --- /dev/null +++ b/ftplugin/mail.vim @@ -0,0 +1,2 @@ +" limit textwidth when writing E-Mails in mutt and enable spellchecking +set tw=72 spell spelllang=de_ch diff --git a/ftplugin/python.vim b/ftplugin/python.vim new file mode 100644 index 0000000..6c0572e --- /dev/null +++ b/ftplugin/python.vim @@ -0,0 +1,6 @@ +let g:syntastic_python_checker = 'flake8' +set colorcolumn=80 +highlight ColorColumn ctermbg=red + +nnoremap r :!python2 ./manage.py runserver +nnoremap f :call Flake8() diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..b261abb --- /dev/null +++ b/vimrc @@ -0,0 +1,136 @@ +" Vundle setup +set nocompatible +filetype off + +" make vundle use git:// instead of http{,s}:// +" makes things a lot faster +let g:vundle_default_git_proto = 'git' +set rtp+=~/.vim/bundle/vundle/ +call vundle#rc() + +" Bundles to install +" let Vundle manage Vundle +Bundle 'gmarik/vundle' + +" Plugins +" The ones that I currently don't use are commented out +Bundle 'altercation/vim-colors-solarized' +Bundle 'ap/vim-css-color' +Bundle 'avakhov/vim-yaml' +"Bundle 'digitaltoad/vim-jade' +Bundle 'drmingdrmer/xptemplate' +Bundle 'ervandew/supertab' +Bundle 'fmoralesc/vim-pad' +Bundle 'fs111/pydoc.vim' +"Bundle 'guileen/vim-node' +"Bundle 'juvenn/mustache.vim' +Bundle 'kien/ctrlp.vim' +"Bundle 'klen/python-mode' +Bundle 'leshill/vim-json' +Bundle 'Lokaltog/vim-powerline' +Bundle 'majutsushi/tagbar' +Bundle 'mileszs/ack.vim' +Bundle 'nvie/vim-flake8' +Bundle 'othree/html5.vim' +"Bundle 'pangloss/vim-javascript' +Bundle 'Raimondi/delimitMate' +Bundle 'Rip-Rip/clang_complete' +Bundle 'scrooloose/nerdcommenter' +Bundle 'sjl/gundo.vim' +"Bundle 'sontek/rope-vim' +Bundle 'thinca/vim-localrc' +Bundle 'tpope/vim-fugitive' +Bundle 'tpope/vim-repeat' +Bundle 'tpope/vim-surround.git' +Bundle 'matchit.zip' +Bundle 'slimv.vim' +"Bundle 'xolox/vim-lua-ftplugin' + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" set leader +let mapleader = "," + +" Always show the statusline +set laststatus=2 + +" avoid key conflict +let g:SuperTabMappingForward = 'supertabKey' + +" xpt settings +let g:xptemplate_fallback = 'supertabKey' +let g:xptemplate_vars="$email=phihue@gmail.com&$author=Philippe Huerlimann" +set runtimepath+=~/.vim/xpt_personal + +" xpt uses as trigger key +let g:xptemplate_key = '' + +" use / to navigate through pum. Optional +let g:xptemplate_pum_tab_nav = 1 + +" powerline settings +let g:Powerline_symbols = 'unicode' +" Sadly I can't get this costum font to work +"let g:Powerline_symbols = 'fancy' + +" Delimate settings +" expand newline and spaces +let delimitMate_expand_cr = 1 +let delimitMate_expand_space = 1 + +" set lines horizontal and vertical line for the cursor +set cursorcolumn +set cursorline + +" turn on filetype specific stuff +filetype plugin indent on + +" colors +" solarized.vim exists +let g:solarized_termcolors=256 +colorscheme solarized +set background=dark + +syntax on + +" turn on those nice numbers on the left side +set number + +" and make them relative +set relativenumber + +"Incremental search +set incsearch + +" smartsearch +set ignorecase +set smartcase + +" folding +set foldmethod=syntax + +" tab settings +set expandtab +set smarttab +set tabstop=4 +set shiftwidth=4 +set softtabstop=4 + +" gui options +if has('gui_running') + set guioptions=aAceif +endif + +" Bindings +cnoremap vr tabedit ~/.vim +nnoremap c :set relativenumber +nnoremap : +nnoremap :GundoToggle +nnoremap :TagbarToggle + +" local vimrc +call localrc#load('.local.vimrc', getcwd()) + +" ctrlp should change working directory +let g:ctrlp_working_path_mode = 0 diff --git a/xpt_personal/ftplugin/cpp/cpp.xpt.vim b/xpt_personal/ftplugin/cpp/cpp.xpt.vim new file mode 100644 index 0000000..c8d5d59 --- /dev/null +++ b/xpt_personal/ftplugin/cpp/cpp.xpt.vim @@ -0,0 +1,452 @@ + +XPTemplate priority=personal + +let s:f = g:XPTfuncs() + +function! s:f.year(...) + return strftime("%Y") +endfunction + +function! InsertNameSpace(beginOrEnd) + let dir = expand('%:p:h') + let ext = expand('%:e') + if ext == 'cpp' + let dir = FSReturnCompanionFilenameString('%') + let dir = fnamemodify(dir, ':h') + endif + let idx = stridx(dir, 'include/') + let nsstring = '' + if idx != -1 + let dir = strpart(dir, idx + strlen('include') + 1) + let nsnames = split(dir, '/') + let nsdecl = join(nsnames, ' { namespace ') + let nsdecl = 'namespace '.nsdecl.' {' + if a:beginOrEnd == 0 + let nsstring = nsdecl + else + for i in nsnames + let nsstring = nsstring.'} ' + endfor + let nsstring = nsstring . '// end of namespace '.join(nsnames, '::') + endif + let nsstring = nsstring + endif + + return nsstring +endfunction + +function! InsertNameSpaceBegin() + return InsertNameSpace(0) +endfunction + +function! InsertNameSpaceEnd() + return InsertNameSpace(1) +endfunction + +function! GetNSFName(snipend) + let dirAndFile = expand('%:p') + let idx = stridx(dirAndFile, 'include') + if idx != -1 + let fname = strpart(dirAndFile, idx + strlen('include') + 1) + else + let fname = expand('%:t') + endif + if a:snipend == 1 + let fname = expand(fname.':r') + endif + + return fname +endfunction + +function! GetNSFNameDefine() + let dir = expand('%:p:h') + let ext = toupper(expand('%:e')) + let idx = stridx(dir, 'include') + if idx != -1 + let subdir = strpart(dir, idx + strlen('include') + 1) + let define = substitute(subdir, '/', '_', 'g') + let define = define ."_".expand('%:t:r')."_" . ext + let define = toupper(define) + let define = substitute(define, '^_\+', '', '') + return define + else + return toupper(expand('%:t:r'))."_" . ext + endif +endfunction + +function! GetHeaderForCurrentSourceFile() + let header=FSReturnCompanionFilenameString('%') + if stridx(header, '/include/') == -1 + let header = substitute(header, '^.*/include/', '', '') + else + let header = substitute(header, '^.*/include/', '', '') + endif + + return header +endfunction + +function! s:f.getNamespaceFilename(...) + return GetNSFName(0) +endfunction + +function! s:f.getNamespaceFilenameDefine(...) + return GetNSFNameDefine() +endfunction + +function! s:f.getHeaderForCurrentSourceFile(...) + return GetHeaderForCurrentSourceFile() +endfunction + +function! s:f.insertNamespaceEnd(...) + return InsertNameSpaceEnd() +endfunction + +function! s:f.insertNamespaceBegin(...) + return InsertNameSpaceBegin() +endfunction + +function! s:f.returnSkeletonsFromPrototypes(...) + return protodef#ReturnSkeletonsFromPrototypesForCurrentBuffer({ 'includeNS' : 0}) +endfunction + +function! s:f.insertVariableAtTheEnd(type, varname) +endfunction + +XPT var hint=Creates\ accessors\ for\ a\ variable +/** + * Returns the value of the `variableName^ variable. + * + * @return A const reference to the `variableName^. + */ +const `variableType^& get`variableName^() const; + +/** + * Sets the value of the `variableName^ variable. + * + * @param value The value to set for `variableName^. + */ +void set`variableName^(const `variableType^& value); +`variableType^ m_`variableName^SV('\(.\)','\l\1','')^^; + + +XPT test hint=Unit\ test\ cpp\ file\ definition +// +// `getNamespaceFilename()^ +// +// +// Copyright (c) `year()^ +// + +class `fileRoot()^ : public ... +{ + CPPUNIT_TEST_SUITE(`fileRoot()^); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); + +public: + void test`Function^() + { + `cursor^ + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(`fileRoot()^); + + +XPT tf hint=Test\ function\ definition +void test`Name^() +{ + `cursor^ +} + + +XPT namespace hint=Namespace +namespace `name^ +{ + `cursor^ +} + + +XPT usens hint=using\ namespace +using namespace `name^; + + +XPT try hint=Try/catch\ block +try +{ + `what^ +}`...^ +catch (`Exception^& e) +{ + `handler^ +}`...^ + + +XPT tsp hint=Typedef\ of\ a\ smart\ pointer +typedef std::tr1::shared_ptr<`type^> `type^Ptr; + + +XPT tcsp hint=Typedef\ of\ a\ smart\ const\ pointer +typedef std::tr1::shared_ptr `type^CPtr; + + +XPT lam hint=Lambda +[`&^](`param^`...^, `param^`...^) { `cursor^ } + +XPT initi hint=Initializer\ list\ for\ non-strings +{ `i^`...^, `i^`...^ } + +XPT inits hint=Initializer\ list\ for\ strings +{ "`s^"`...^, "`s^"`...^ } + +XPT m hint=Member\ variable +`int^ m_`name^; + +XPT imp hint=specific\ C++\ implementation\ file +// +// `getNamespaceFilename()^ +// +// Copyright (c) `year()^ `$author^ <`$email^> +// + +#include "`getHeaderForCurrentSourceFile()^" + +`insertNamespaceBegin()^ + +`returnSkeletonsFromPrototypes()^`cursor^ +`insertNamespaceEnd()^ + + +XPT h hint=specific\ C++\ header\ file +// +// `getNamespaceFilename()^ +// +// Copyright (c) `year()^ `$author^ <`$email^> +// + +#ifndef `getNamespaceFilenameDefine()^ +#define `getNamespaceFilenameDefine()^ + +`insertNamespaceBegin()^ + +/** + * @brief `classDescription^ + */ +class `fileRoot()^ +{ +public: + /** + * Constructor + */ + `fileRoot()^(); + + /** + * Destructor + */ + virtual ~`fileRoot()^(); + + `cursor^ +private: +}; + +`insertNamespaceEnd()^ + +#endif // `getNamespaceFilenameDefine()^ + + +XPT functor hint=Functor\ definition +struct `FunctorName^ +{ + `void^ operator()(`argument^`...^, `arg^`...^)` const^ +} + + +XPT class hint=Class\ declaration +class `className^ +{ +public: + `explicit ^`className^(`argument^`...^, `arg^`...^); + virtual ~`className^(); + `cursor^ +private: +}; + + +XPT wcerr hint=Basic\ std::wcerr\ statement +std::wcerr << `expression^`...^ << `expression^`...^ << std::endl; + + +XPT wcout hint=Basic\ std::wcout\ statement +std::wcout << `expression^`...^ << `expression^`...^ << std::endl; + + +XPT cerr hint=Basic\ std::cerr\ statement +std::cerr << `expression^`...^ << `expression^`...^ << std::endl; + + +XPT cout hint=Basic\ std::cout\ statement +std::cout << `expression^`...^ << `expression^`...^ << std::endl; + + +XPT outcopy hint=Using\ an\ iterator\ to\ outout\ to\ stdout +std::copy(`list^.begin(), `list^.end(), std::ostream_iterator<`std::string^>(std::cout, \"\\n\")); + + +XPT cf wrap=message hint=CPPUNIT_FAIL +CPPUNIT_FAIL("`message^"); + + +XPT ca wrap=condition hint=CPPUNIT_ASSERT +CPPUNIT_ASSERT(`condition^); + + +XPT cae hint=CPPUNIT_ASSERT_EQUAL +CPPUNIT_ASSERT_EQUAL(`expected^, `actual^); + + +XPT cade hint=CPPUNIT_ASSERT_DOUBLES_EQUAL +CPPUNIT_ASSERT_DOUBLES_EQUAL(`expected^, `actual^, `delta^); + + +XPT cam hint=CPPUNIT_ASSERT_MESSAGE +CPPUNIT_ASSERT_MESSAGE(`message^, `condition^); + + +XPT cat hint=CPPUNIT_ASSERT_THROW +CPPUNIT_ASSERT_THROW(`expression^, `ExceptionType^); + + +XPT cant wrap=expression hint=CPPUNIT_ASSERT_NO_THROW +CPPUNIT_ASSERT_NO_THROW(`expression^); + + +XPT sc wrap=value hint=static_cast<>\(\) +static_cast<`to_type^>(`value^) + + +XPT rc wrap=value hint=reinterpret_cast<>\(\) +reinterpret_cast<`to_type^>(`value^) + + +XPT cc wrap=value hint=const_cast<>\(\) +const_cast<`to_type^>(`value^) + + +XPT dc wrap=value hint=dynamic_cast<>\(\) +dynamic_cast<`to_type^>(`value^) + + +XPT { wrap=code hint={\ indented\ code\ block\ } +{ + `code^ +} + + +XPT {_ wrap=code hint={\ inline\ code\ block\ } +{ `code^ } + + +XPT \( wrap=code hint=\(\ indented\ code\ block\ \) +( + `code^ +) + + +XPT \(_ wrap=code hint=\(\ inline\ code\ block\ \) +( `code^ ) + + +XPT bindf hint=boost::bind\ function\ call +boost::bind(`function^, `param^`...^, `param^`...^) + + +XPT bindftor hint=boost::bind\ function\ object +XSET ftortype|post=S(S(V(), '.*', "<&>", ''), '', '', '') +boost::bind`ftortype^(`functor^, `param^`...^, `param^`...^) + + +XPT bindmem hint=boost::bind\ member\ function +boost::bind(&`class^::`function^, `instance^, `param^`...^, `param^`...^) + + +XPT vec hint=std::vector +std::vector<`type^> + + +XPT map hint=std::map +std::map<`typeA^, `typeB^> + + +XPT typedef hint=typedef\ 'type'\ 'called' +typedef `type^ `called^ + + +XPT s hint=std::string +std::string + + +XPT foriter hint=for\ \(type::iterator\ i\ =\ var.begin;\ i\ !=\ var.end;\ ++i\) +for (`type^::iterator = `i^ = `var^.begin(); `i^ != `var^.end(); ++i) +{ + `cursor^ +} + + +XPT forciter hint=for\ \(type::const_iterator\ i\ =\ var.begin;\ i\ !=\ var.end;\ ++i\) +for (`type^::const_iterator = `i^ = `var^.begin(); `i^ != `var^.end(); ++i) +{ + `cursor^ +} + + +XPT forriter hint=for\ \(type::reverse_iterator\ i\ =\ var.begin;\ i\ !=\ var.end;\ ++i\) +for (`type^::reverse_iterator = `i^ = `var^.begin(); `i^ != `var^.end(); ++i) +{ + `cursor^ +} + + +XPT copy hint=std::copy\(src.begin,\ src.end,\ dest.begin\) +std::copy(`src^.begin(), `src^.end(), `dest^.begin()) + + +XPT foreach hint=std::for_each\(seq.begin,\ seq.end,\ function\) +std::for_each(`seq^.begin(), `seq^.end(), `function^) + + +XPT find hint=std::find\(seq.begin,\ seq.end,\ value\) +std::find(`seq^.begin(), `seq^.end(), `value^) + + +XPT findif hint=std::find_if\(seq.begin,\ seq.end,\ predicate\) +std::find_if(`seq^.begin(), `seq^.end(), `predicate^) + + +XPT transform hint=std::transform\(seq.begin,\ seq.end,\ result.begin,\ unary_operator\) +std::transform(`seq^.begin(), `seq^.end(), `result^.begin(), `unary_operator^) + + +XPT replace hint=std::replace\(seq.begin,\ seq.end,\ oldvalue,\ newvalue\) +std::replace(`seq^.begin(), `seq^.end(), `oldvalue^, `newvalue^) + + +XPT replaceif hint=std::replace_if\(seq.begin,\ seq.end,\ predicate,\ newvalue\) +std::replace(`seq^.begin(), `seq^.end(), `predicate^, `newvalue^) + + +XPT sort hint=std::sort\(seq.begin,\ seq.end,\ predicate\) +std::replace(`seq^.begin(), `seq^.end(), `predicate^) + + +XPT fun hint=function\ definition +XSET class|post=S(V(), '.*[^:]', '&::', '') +`int^ `class^`name^(`param^`...^, `param^`...^)` const^ +{ + `cursor^ +} + + +XPT funh hint=function\ declaration +`int^ `class^`name^(`param^`...^, `param^`...^)` const^; + + diff --git a/xpt_personal/ftplugin/sh/sh.xpt.vim b/xpt_personal/ftplugin/sh/sh.xpt.vim new file mode 100644 index 0000000..16188c1 --- /dev/null +++ b/xpt_personal/ftplugin/sh/sh.xpt.vim @@ -0,0 +1,46 @@ +XPTemplate priority=personal + +XPTinclude + \ _common/personal + +let s:f = g:XPTfuncs() + +XPT optparse hint=BASH\ option\ parsing +opts=$(getopt -o h`short^ --long host,`long^ -n "${0##*/}" -- "$@") +if [ $? != 0 ]; then exit 1; fi + +mydir="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +me=${BASH_SOURCE[0]} +me=${me##*/} + +function usage +{ + cat <