├── .gitignore ├── .rspec ├── .travis.yml ├── CONTRIBUTORS ├── Gemfile ├── License.md ├── README.md ├── Rakefile ├── VimFlavor ├── addon-info.json ├── after └── template │ ├── c │ ├── assert.template │ ├── comment.template │ ├── internals │ │ └── c-header-content.template │ ├── rand_init.template │ └── realloc.template │ ├── cpp │ ├── abs-rel.template │ ├── abstract-class.template │ ├── array_size.template │ ├── assignment-operator.template │ ├── auto_ptr-instance.template │ ├── auto_ptr.template │ ├── b-e.template │ ├── base-class-non-virtual.template │ ├── base-class.template │ ├── benchmark.template │ ├── bool-operator.template │ ├── catch.template │ ├── cerr.template │ ├── chrono-how-long.template │ ├── cin.template │ ├── class.template │ ├── clonable-class.template │ ├── copy-and-swap.template │ ├── copy-back_inserter.template │ ├── copy-constructor.template │ ├── copy.template │ ├── cout.template │ ├── default-constructor.template │ ├── destructor.template │ ├── empty-exception-class.template │ ├── ends_with.template │ ├── entity-class.template │ ├── enum.template │ ├── enum2-impl.template │ ├── enum2.template │ ├── erase-remove.template │ ├── exception-class.template │ ├── file.template │ ├── for-enum.template │ ├── for-iterator.template │ ├── for-range.template │ ├── fori.template │ ├── foriN.template │ ├── forward.template │ ├── getter.template │ ├── init-constructor.template │ ├── interface.template │ ├── internals │ │ ├── abs-rel-shared.template │ │ ├── attribute.template │ │ ├── class-skeleton.template │ │ ├── formatted-comment.template │ │ ├── function-comment.template │ │ ├── function.template │ │ ├── get-b-e.template │ │ ├── get-class-name.template │ │ ├── includes.template │ │ ├── list-constructors.template │ │ ├── namespace-name.template │ │ ├── shall_explicit_defaults.template │ │ ├── stream-common.template │ │ ├── stream-implementation.template │ │ └── stream-signature.template │ ├── iss.template │ ├── list.template │ ├── map.template │ ├── namespace.template │ ├── noncopyable.template │ ├── operator-binary.template │ ├── oss.template │ ├── otb-sug-latex.template │ ├── otb-sug-snippet.template │ ├── path.template │ ├── ptr_vector.template │ ├── ref_setter.template │ ├── scoped_ptr.template │ ├── set.template │ ├── setter.template │ ├── shared_ptr.template │ ├── singleton.template │ ├── sort.template │ ├── starts_with.template │ ├── static_assert.template │ ├── stream-extractor.template │ ├── stream-inserter.template │ ├── string.template │ ├── swap-function.template │ ├── throw.template │ ├── traits.template │ ├── try.template │ ├── typeid.template │ ├── unique_ptr.template │ ├── unordered_map.template │ ├── unordered_set.template │ ├── utf8.template │ ├── value-class.template │ ├── vector.template │ ├── weak_ptr.template │ └── while-getline.template │ └── dox │ ├── author.template │ ├── code.template │ ├── em.template │ ├── file.template │ ├── function.template │ ├── group.template │ ├── html.template │ ├── ingroup.template │ ├── since.template │ └── tt.template ├── autoload └── lh │ ├── cpp.vim │ ├── cpp │ ├── AnalysisLib_Class.vim │ ├── AnalysisLib_Function.vim │ ├── GotoFunctionImpl.vim │ ├── UnmatchedFunctions.vim │ ├── abs_rel.vim │ ├── analyse.vim │ ├── constructors.vim │ ├── enum.vim │ ├── ftplugin.vim │ ├── include.vim │ ├── libclang.vim │ ├── macros.vim │ ├── option.vim │ ├── override.vim │ ├── refactor.vim │ ├── scope.vim │ ├── snippets.vim │ ├── style.vim │ ├── tags.vim │ ├── types.vim │ └── understand.vim │ └── dox.vim ├── doc ├── API.md ├── Doxygen.md ├── Enums.md ├── TODO.md ├── c.html ├── lh-cpp-readme.txt ├── options.md ├── screencast-select-function.gif ├── screencast-snippet-baseNV-class.gif ├── snippets.md └── types.md ├── ftplugin ├── c │ ├── LoadHeaderFile.vim │ ├── c_AddInclude.vim │ ├── c_Doxygen.vim │ ├── c_UnmatchedFunctions.vim │ ├── c_complete_include.vim │ ├── c_doc.vim │ ├── c_gcov.vim │ ├── c_menu.vim │ ├── c_mu-template_api.vim │ ├── c_navigate_functions.vim │ ├── c_pvs-2-qf.vim │ ├── c_set.vim │ ├── c_show_scope.vim │ ├── c_snippets.vim │ ├── c_stl.vim │ ├── c_switch-enum.vim │ ├── flistmaps.vim │ ├── keep_pound_if_path.vim │ ├── previewWord.vim │ └── word.list ├── cpp │ ├── changelog │ ├── cpp_AddMissingScope.vim │ ├── cpp_BuildTemplates.vim │ ├── cpp_Constructor.vim │ ├── cpp_Enum.vim │ ├── cpp_FindContextClass.vim │ ├── cpp_GotoFunctionImpl.vim │ ├── cpp_InsertAccessors.vim │ ├── cpp_Inspect.vim │ ├── cpp_Override.vim │ ├── cpp_options-commands.vim │ ├── cpp_options.vim │ ├── cpp_refactor.vim │ ├── cpp_set.vim │ └── cpp_snippets.vim └── idl_set.vim ├── mkVba └── mk-lh-cpp.vim ├── plugin ├── homeLikeVC++.vim └── omap-param.vim ├── script └── PVS2qf.xsl ├── spec ├── abstract-class_spec.rb ├── base-class-NV_spec.rb ├── base-class_spec.rb ├── class-with-attributes_spec.rb ├── clonable-class_spec.rb ├── constructor-command_spec.rb ├── deps_spec.rb ├── empty-exception-class_spec.rb ├── exception-class_spec.rb ├── spe_func_spec.rb ├── spec_helper.rb ├── value-class-with-attributes_spec.rb └── value-class_spec.rb ├── syntax ├── c-assign-in-condition.vim ├── c-fallthrough-case.vim ├── c.vim ├── cpp-badcatch.vim ├── cpp-c-cast.vim ├── cpp-cxxtest.vim ├── cpp-funcdef.vim ├── cpp-throw-spec.vim └── cpp.vim └── tests ├── VimFlavor └── lh ├── analysis.vim ├── cpp-TU-override.cpp ├── cpp-TU.cpp ├── omap-param.vim ├── snippets.vim ├── test-flavours.vim └── test-types.vim /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | *.sw* 3 | *~ 4 | *.pyc 5 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | --format documentation 4 | -I ~/.vim-flavor/repos/LucHermitte_vim-UT/spec 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: ruby 3 | cache: bundler 4 | rvm: 5 | - 2.1.5 6 | script: bundle exec rake ci 7 | compiler: 8 | - gcc # for ctags 9 | addons: 10 | apt: 11 | packages: 12 | - vim-gtk 13 | addons: 14 | apt: 15 | packages: 16 | - vim-gtk 17 | before_install: 18 | - git clone https://github.com/universal-ctags/ctags.git 19 | - (cd ctags && ./autogen.sh && ./configure --prefix="$HOME" && make -j 4 install) 20 | before_script: 21 | - "export PATH=$PATH:$HOME/bin" 22 | services: 23 | - xvfb 24 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | The following people have contributed to lh-cpp 2 | 3 | # Direct contributors 4 | Luc Hermitte, maintainer, 2002(?)-2018 5 | Leif Wickland, original mapping for `GOTOIMPL` (VIM-TIP#335) 6 | Robert KellyIV, first plugin version of `GOTOIMPL`, plus contributions to present code, 2002 7 | Olivier Teuliere, highlight function definitions, 2004 (https://vim.wikia.com/wiki/Highlighting_of_method_names_in_the_definition) 8 | Sven Speckmaier, Apply styles to `GOTOIMPL`, 2016, PR#4 9 | fwSmit, Fix missing dep in doc, 2018, PR#9 10 | 11 | Discl. I'm likely to have forgottent old contributors, drop me an email 12 | if you're one of them. 13 | 14 | # Plugins imported from other projects: 15 | Charles E. Campbell, Jr., initial flistmaps definition 16 | Georgi Slavchev , previewWord initial definition, 2002 (https://vim.wikia.com/wiki/Function_signature_previewer) 17 | 18 | 19 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rspec', '~> 3.1.0' 4 | gem 'vimrunner', '~> 0.3.1' 5 | gem 'rake', '~> 10.3.2' 6 | gem 'vim-flavor', '~> 2.1.1' 7 | -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | Copyright 2001-2015, Luc Hermitte 2 | 3 | # Scripts License 4 | 5 | All scripts (VimL, templates, bash, perl, etc.) from lh-vim are 6 | distributed under FSF's GPLv3 license. 7 | 8 | See http://www.gnu.org/licenses/gpl.txt for more information. 9 | 10 | 11 | # License exception for generated code 12 | 13 | Many lh-vim scripts generate code. Unless specified otherwise, the code generated is under the following license exception. 14 | 15 | 16 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 17 | 18 | This Exception is an additional permission under section 7 of the GNU General Public License, version 3 ("GPLv3"). It applies to a given file that bears a notice placed by the copyright holder of the file stating that the file is governed by GPLv3 along with this Exception. 19 | 20 | The purpose of this Exception is to allow distribution of lh-vim's typical output under terms of the recipient's choice (including proprietary). 21 | 22 | ## 0. Definitions. 23 | "Covered Code" is the source or object code of a version of lh-vim that is a covered work under this License. 24 | 25 | "Normally Copied Code" for a version of lh-vim means all parts of its Covered Code which that version can copy from its code (i.e., not from its input file) into its minimally verbose, non-debugging and non-tracing output. 26 | 27 | "Ineligible Code" is Covered Code that is not Normally Copied Code. 28 | 29 | ## 1. Grant of Additional Permission. 30 | You have permission to propagate output of lh-vim, even if such propagation would otherwise violate the terms of GPLv3. However, if by modifying lh-vim you cause any Ineligible Code of the version you received to become Normally Copied Code of your modified version, then you void this Exception for the resulting covered work. If you convey that resulting covered work, you must remove this Exception in accordance with the second paragraph of Section 7 of GPLv3. 31 | 32 | ## 2. No Weakening of lh-vim Copyleft. 33 | 34 | The availability of this Exception does not imply any general presumption that third-party software is unaffected by the copyleft requirements of the license of lh-vim. 35 | 36 | Disclaimer: This lh-vim license exception is directly derived from [AUTOCONF CONFIGURE SCRIPT EXCEPTION](http://www.gnu.org/licenses/autoconf-exception.html) to GPLv3 license. 37 | 38 | # License for documentation 39 | 40 | The documentation of lh-vim scripts distributed along the scripts, and of the wiki pages here are under the Creative Commons license ([CC by SA 3.0](http://creativecommons.org/licenses/by-sa/3.0/)) 41 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | require 'rspec/core/rake_task' 4 | 5 | RSpec::Core::RakeTask.new(:spec) 6 | 7 | task :ci => [:dump, :install, :test] 8 | 9 | task :default => :spec 10 | 11 | task :dump do 12 | sh 'vim --version' 13 | end 14 | 15 | task :test => :spec 16 | 17 | task :spec do 18 | # 'spec' is implicitly run as well 19 | sh 'rspec ~/.vim-flavor/repos/LucHermitte_vim-UT/spec' 20 | end 21 | 22 | 23 | task :install do 24 | sh 'cat VimFlavor >> tests/VimFlavor' 25 | sh 'cd tests && bundle exec vim-flavor install' 26 | end 27 | -------------------------------------------------------------------------------- /VimFlavor: -------------------------------------------------------------------------------- 1 | flavor 'LucHermitte/lh-vim-lib', '>= 4.1.0' 2 | flavor 'LucHermitte/lh-brackets', '>= 3.1.1' 3 | flavor 'LucHermitte/lh-style' 4 | flavor 'LucHermitte/lh-dev' 5 | flavor 'LucHermitte/mu-template', '>= 4.3.1' 6 | flavor 'LucHermitte/VimFold4C', '>= 3.0.9' 7 | flavor 'LucHermitte/alternate-lite', '>= 0.1.0' 8 | -------------------------------------------------------------------------------- /addon-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "lh-cpp", 3 | "version" : "dev", 4 | "author" : "Luc Hermitte ", 5 | "maintainer" : "Luc Hermitte ", 6 | "repository" : {"type": "git", "url": "git@github.com:LucHermitte/lh-cpp.git"}, 7 | "dependencies" : { 8 | "lh-vim-lib" : {"type" : "git", "url" : "git@github.com:LucHermitte/lh-vim-lib.git"}, 9 | "lh-brackets" : {"type": "git", "url": "git@github.com:LucHermitte/lh-brackets.git"}, 10 | "lh-dev" : {"type": "git", "git": "git@github.com:LucHermitte/lh-dev.git"}, 11 | "mu-template@lh" : {"type": "git", "url": "git@github.com:LucHermitte/mu-template.git"}, 12 | "alternate-lite" : {"type": "git", "url": "git@github.com:LucHermitte/alternate-lite.git"}, 13 | "VimFold4C" : {"type": "git", "url": "git@github.com:LucHermitte/VimFold4C.git"} 14 | }, 15 | "description" : "C&C++ ftplugins suite", 16 | "homepage" : "http://github.com/LucHermitte/lh-cpp" 17 | } 18 | 19 | -------------------------------------------------------------------------------- /after/template/c/assert.template: -------------------------------------------------------------------------------- 1 | VimL:" assert File Template, Luc Hermitte, 24th Sep 2015 2 | VimL:" hint: assert() 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add(&ft == "cpp" ? "" : "")') 8 | assert(¡s:Surround(1, '<+assertion+>')¡);<+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/c/comment.template: -------------------------------------------------------------------------------- 1 | VimL:" comment File Template, Luc Hermitte , mer. 20 juil. 2016 11:30:01 CEST 2 | VimL:" hint: #if 0 (#else) #endif 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: let s:reindent = 1 8 | MuT: if s:content.count0 == 0 9 | #if 0 10 | <+s:Surround(1, lh#marker#txt("code;"))+> 11 | #endif 12 | MuT: else 13 | MuT: let s:commented_lines = split(s:SurroundRaw(s:content.count0, lh#marker#txt("code;")), "\n") 14 | VimL: " We store the lines into surround1&2 in order to avoid style application as s:Surround disables it 15 | VimL: let s:content.surround1 = join(s:commented_lines[: (s:content.count0-1)], "\n") 16 | VimL: let s:content.surround2 = join(s:commented_lines[(s:content.count0) :], "\n") 17 | #if 1 18 | <+s:Surround(1, lh#marker#txt("code;"))+> 19 | #else 20 | <+s:Surround(2, lh#marker#txt("code;"))+> 21 | #endif 22 | MuT: endif 23 | 24 | -------------------------------------------------------------------------------- /after/template/c/internals/c-header-content.template: -------------------------------------------------------------------------------- 1 | VimL:" Typical C++ header content, Luc Hermitte, 05th Sep 2019 2 | VimL:" override content for header files for OTK like projects 3 | VimL: let s:default_text = empty(s:Args()) ? "" : (s:Args()[0]) 4 | VimL: call s:Include('namespace-name', 'cpp/internals') 5 | MuT: if !empty(s:namespace) 6 | VimL: call s:Include('namespace', 'cpp', {'content': s:default_text, 'included': 1}) 7 | MuT: else 8 | <+default_text+> 9 | MuT: endif 10 | VimL: call s:Include('post-namespace-header-content', 'cpp/internals') 11 | -------------------------------------------------------------------------------- /after/template/c/rand_init.template: -------------------------------------------------------------------------------- 1 | VimL:" rand_init File Template, Luc Hermitte, 28th Oct 2014 2 | VimL:" hint: srand(time(NULL)); 3 | VimL: let s:reindent = 1 4 | VimL: call s:AddPostExpandCallback('lh#dev#import#add_c_std("time")') 5 | VimL: call s:AddPostExpandCallback('lh#dev#import#add_c_std("stdlib")') 6 | srand(time(NULL)); 7 | -------------------------------------------------------------------------------- /after/template/c/realloc.template: -------------------------------------------------------------------------------- 1 | VimL:" realloc File Template, Luc Hermitte, 20th Aug 2012 2 | VimL:" hint: new_p = realloc(pn size); if (!new_p) {free(p); +reset all 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: silent! unlet s:_args 7 | VimL: let s:_args = empty(s:Args()) ? {} : (s:Args()[0]) 8 | VimL: if (! has_key(s:_args, "ptr")) | let s:_args.ptr = lh#marker#txt("p") | endif 9 | VimL: if (! has_key(s:_args, "lhs")) | let s:_args.lhs = "new_".s:_args.ptr | endif 10 | VimL: if (! has_key(s:_args, "type")) | let s:_args.type = lh#marker#txt("T") | endif 11 | VimL: if (! has_key(s:_args, "count")) | let s:_args.count = lh#marker#txt("count")| endif 12 | VimL: if (! has_key(s:_args, "size")) | let s:_args.size = s:_args.count." * sizeof(".s:_args.type.")" | endif 13 | VimL: if (! has_key(s:_args, "realloc")) | let s:_args.realloc = "realloc" | endif 14 | VimL: if (! has_key(s:_args, "free")) | let s:_args.free = "free" | endif 15 | VimL: if (! has_key(s:_args, "macro")) | let s:_args.macro = "" | endif 16 | VimL: if (! has_key(s:_args, "false")) | let s:_args.false = "false" | endif 17 | <+s:_args.type+> *<+s:_args.lhs+> = (<+s:_args.type+> *) <+s:_args.realloc+>(<+s:_args.ptr+>, <+s:_args.size+>);<+s:_args.macro+> 18 | if (! <+s:_args.lhs+>) {<+s:_args.macro+> 19 | <+s:_args.free+>(<+s:_args.ptr+>);<+s:_args.macro+> 20 | <+s:_args.ptr+> = NULL;<+s:_args.macro+> 21 | <+s:_args.count+> = 0;<+s:_args.macro+> 22 | <+error_message+>;<+s:_args.macro+> 23 | return <+s:_args.false+>;<+s:_args.macro+> 24 | }<+s:_args.macro+> 25 | <+s:_args.ptr+> = <+s:_args.lhs+>; 26 | -------------------------------------------------------------------------------- /after/template/cpp/abstract-class.template: -------------------------------------------------------------------------------- 1 | VimL:" abstract-class File Template, Luc Hermitte , 25th Nov 2015 2 | VimL:" hint: Abstract (base) class to inherit from 3 | MuT: let s:destructor = s:Param('destructor', {}) 4 | VimL: " -- Override any previous setting on visibility and 'how' 5 | VimL: let s:destructor['visibility'] = 'public' 6 | VimL: let s:destructor['how'] = 'pure' 7 | VimL: " --- Defines Doxygen comments 8 | MuT: let s:parameters = s:Param('cls_parameters', {}) 9 | VimL: call lh#dict#add_new(s:parameters, {'comments': {}}) 10 | MuT: let s:cls_comments = s:parameters.comments 11 | VimL: " Don't add "Abstract" if this is an interface 12 | MuT: if index(get(s:cls_comments, 'semantics', []), 'Interface') < 0 13 | VimL: let s:cls_comments.semantics = get(s:cls_comments, 'semantics', [])+['Abstract'] 14 | MuT: endif 15 | VimL: " --- Insert the skeleton built 16 | VimL: call s:Include('base-class', 'cpp', {'cls_parameters': s:parameters}) 17 | -------------------------------------------------------------------------------- /after/template/cpp/array_size.template: -------------------------------------------------------------------------------- 1 | VimL:" array_size definition File Template, Luc Hermitte, 25th Apr 2014 2 | VimL:" hint: std::extent::value 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | MuT: let s:array_size = lh#ft#option#get('array_size', &ft) 8 | MuT: if lh#option#is_unset(s:array_size) && lh#cpp#use_cpp17() 9 | MuT: let s:array_size = {'file': '', 'funcname': 'std::size(%1)'} 10 | MuT: endif 11 | MuT: if lh#option#is_set(s:array_size) 12 | VimL: call s:AddPostExpandCallback('lh#dev#import#add(s:array_size.file)') 13 | MuT: let s:_array_size = s:array_size.funcname 14 | MuT: elseif lh#cpp#use_cpp11() 15 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 16 | MuT: let s:_array_size = 'std::extent::value' 17 | MuT: let s:restore_style = lh#on#exit().restore('s:content.can_apply_style') 18 | VimL: let s:content.can_apply_style = 0 19 | // You may want instead to define the missing std::size() in a header file 20 | // template 21 | // constexpr std::size_t size(T (&)[N]) noexcept { return N ;} 22 | // And include this file instead. 23 | // In you have such a file ready to be used, please set 24 | // let b:cpp_array_size = {'file': 'theheader to include', 'funcname': 'std::size(%1)' } 25 | // in your vim project configuration file (_vimrc_local.vim...) 26 | VimL: call s:restore_style.finalize() 27 | MuT: else 28 | MuT: let s:restore_style = lh#on#exit().restore('s:content.can_apply_style') 29 | VimL: let s:content.can_apply_style = 0 30 | // You may want instead to define the following in a header file 31 | // and include this file instead. 32 | // Then set 33 | // let b:cpp_array_size = {'file': 'theheader to include', 'funcname': 'array_size(%1)' } 34 | // in your vim project configuration file (_vimrc_local.vim...) 35 | VimL: call s:restore_style.finalize() 36 | namespace{ 37 | template 38 | char (&array_size_helper(T (&)[N]))[N]; 39 | }// namespace 40 | #define array_size(array) (sizeof ::array_size_helper(array)) 41 | MuT: let s:_array_size = 'array_size(%1)' 42 | MuT: endif 43 | <+lh#fmt#printf(s:_array_size, s:Surround(1, s:Param("array", lh#marker#txt('array'))))+> 44 | -------------------------------------------------------------------------------- /after/template/cpp/assignment-operator.template: -------------------------------------------------------------------------------- 1 | VimL:" assignment-operator File Template, Luc Hermitte, 21st Aug 2011 2 | VimL:" hint: T& operator=(T const&); 3 | VimL: "TODO: support noexcept 4 | VimL: let s:marker_open = "<+" 5 | VimL: let s:marker_close = "+>" 6 | VimL: let s:reindent = 1 7 | VimL: call s:Include('get-class-name', 'cpp/internals') 8 | VimL: let s:how = get(s:Param("assignment-operator", {}), "how", "") 9 | MuT: if s:how =~ "deleted\\|defaulted" 10 | <+s:clsname+>& operator=(<+s:clsname+> const&) <+lh#cpp#snippets#{s:how}()+>; 11 | MuT: else 12 | MuT: let s:use_copyandswap0 = s:Param('use_copy_and_swap', lh#option#get('cpp_use_copy_and_swap')) 13 | VimL: let s:use_copyandswap = lh#option#is_set(s:use_copyandswap0) ? s:use_copyandswap0 : lh#ui#confirm("Use copy-and-swap idiom?", "Yes\nNo", 1) 14 | MuT: if 1 == s:use_copyandswap 15 | VimL: call s:Include("copy-and-swap","cpp", s:clsname) 16 | MuT: else 17 | VimL: let s:rhs = lh#naming#param("rhs") 18 | VimL: let s:fn_comments = { } 19 | VimL: let s:fn_comments.brief = "Assignment operator" 20 | VimL: let s:fn_comments.param = [{"dir": "in", "name": (s:rhs), "text": "source data to be copied." } ] 21 | VimL: let s:fn_comments.throw = {"optional": 1} 22 | VimL: call s:Include("function-comment", "cpp/internals",s:fn_comments) 23 | MuT: let s:attributes = s:Param("attributes", lh#option#unset()) 24 | MuT: if lh#option#is_set(s:attributes) && !empty(s:attributes) 25 | MuT: let s:definition = '{'.join(map(copy(s:attributes), 'lh#naming#member(v:val.name)." = ".lh#cpp#snippets#duplicate_param(s:rhs.".".lh#naming#member(v:val.name), v:val.type).";"'), "\n").'}' 26 | MuT: else 27 | MuT: let s:definition = ';' 28 | MuT: endif 29 | <+s:clsname+>& operator=(<+s:clsname+> const& <+s:rhs+>)<+s:definition+> 30 | MuT: endif 31 | MuT: endif 32 | -------------------------------------------------------------------------------- /after/template/cpp/auto_ptr-instance.template: -------------------------------------------------------------------------------- 1 | VimL:" unique_ptr File Template, Luc Hermitte, 22nd May 2014 2 | VimL:" hint: std::auto_ptr ptr(new T(args)); 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::auto_ptr<¡s:Surround(1, '<+type+>')¡> <+ptr+>(new ¡s:Surround(1, '<+type+>')¡(<+args+>)); 9 | -------------------------------------------------------------------------------- /after/template/cpp/auto_ptr.template: -------------------------------------------------------------------------------- 1 | VimL:" unique_ptr File Template, Luc Hermitte, 22nd May 2014 2 | VimL:" hint: std::auto_ptr<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::auto_ptr<¡s:Surround(1, '<+type+>')¡><+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/b-e.template: -------------------------------------------------------------------------------- 1 | VimL:" b-e File Template, Luc Hermitte, 30th Jun 2011 2 | VimL:" hint: <+container+>.begin(), <+container+>.end() 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: call s:Include('get-b-e', 'cpp/internals') 6 | <+s:begin+>, <+s:end+><++> 7 | -------------------------------------------------------------------------------- /after/template/cpp/base-class-non-virtual.template: -------------------------------------------------------------------------------- 1 | VimL:" base-class-non-virtual File Template, Luc Hermitte , 25th Nov 2015 2 | VimL:" hint: Base class to inherit from, but not delete -- Non-copiable entity 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: " Set default-constructor to protected if not already set 8 | MuT: let s:default_constructor = s:Param('default-constructor', {}) 9 | VimL: call lh#dict#add_new(s:default_constructor, {'visibility': 'protected'}) 10 | VimL: " Force destructor to protected, (and not how) 11 | VimL: let s:destructor = s:Param('destructor', {}) 12 | VimL: let s:destructor['visibility'] = 'protected' 13 | VimL: call s:Include('entity-class', 'cpp') 14 | -------------------------------------------------------------------------------- /after/template/cpp/base-class.template: -------------------------------------------------------------------------------- 1 | VimL:" base-class File Template, Luc Hermitte , 25th Nov 2015 2 | VimL:" hint: Base class to inherit from -- Not necessarily abstract, Non-copiable entity 3 | VimL: " Set default-consructor to protected if not already set 4 | MuT: let s:default_constructor = s:Param('default-constructor', {}) 5 | VimL: call lh#dict#add_new(s:default_constructor, {'visibility': 'protected'}) 6 | VimL: " Set destructor to public, (and no how), if not already set 7 | MuT: let s:destructor = s:Param('destructor', {}) 8 | VimL: call lh#dict#add_new(s:destructor, {'how': ''}) 9 | VimL: call lh#dict#add_new(s:destructor, {'visibility': 'public'}) 10 | VimL: " Force virtual! 11 | VimL: let s:destructor['virtual'] = 1 12 | VimL: call s:Include('entity-class', 'cpp') 13 | -------------------------------------------------------------------------------- /after/template/cpp/benchmark.template: -------------------------------------------------------------------------------- 1 | VimL:" google-benchmark File Template, Luc Hermitte, 27th Oct 2015 2 | VimL:" hint: static void BM_<+test+>(benchmark::State & state) { 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | static void BM_<+bench+>(benchmark::State & state) { 8 | while (state.KeepRunning()) { 9 | <++> 10 | } 11 | } 12 | BENCHMARK(BM_<+bench+>); 13 | -------------------------------------------------------------------------------- /after/template/cpp/bool-operator.template: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/after/template/cpp/bool-operator.template -------------------------------------------------------------------------------- /after/template/cpp/catch.template: -------------------------------------------------------------------------------- 1 | VimL:"{catch(...){...}} Template-File, Luc Hermitte 2 | VimL:" hint: catch(...){...} 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | catch(<+...+>){ 9 | ¡s:Surround(1, '<+catch-code+>')¡ 10 | }<++> 11 | -------------------------------------------------------------------------------- /after/template/cpp/cerr.template: -------------------------------------------------------------------------------- 1 | VimL:" cerr File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::cerr 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::cerr << <++>; 9 | -------------------------------------------------------------------------------- /after/template/cpp/chrono-how-long.template: -------------------------------------------------------------------------------- 1 | VimL:" chrono-how-long File Template, Luc Hermitte , 24th Apr 2019 2 | VimL:" hint: Compute duration 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: let s:reindent = 1 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | const auto <+start+> = std::chrono::system_clock::now(); 10 | ¡s:Surround(1, '<++>')¡ 11 | const auto <+end+> = std::chrono::system_clock::now(); 12 | const auto elapsed_seconds = std::chrono::duration(<+end+> - <+start+>).count(); 13 | -------------------------------------------------------------------------------- /after/template/cpp/cin.template: -------------------------------------------------------------------------------- 1 | VimL:" cin File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::cin 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::cin >> <++>; 9 | -------------------------------------------------------------------------------- /after/template/cpp/class.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ Class Template, Luc Hermitte 2 | VimL:" hint: Simplistic class snippet -- unaware of semantics 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | MuT: let s:parameters = s:Param('cls_parameters', {}) 9 | VimL: " --- in case the class name is already known, no need to extract it 10 | VimL: call s:Include('get-class-name', 'cpp/internals') 11 | VimL: " --- Defines Doxygen comments 12 | MuT: let s:cls_comments = lh#dict#add_new(s:parameters, {'comments': {}}).comments 13 | MuT: let s:cls_comments = s:parameters.comments 14 | VimL: " --- Insert the skeleton built 15 | VimL: call s:Include('class-skeleton', 'cpp/internals', s:parameters) 16 | -------------------------------------------------------------------------------- /after/template/cpp/clonable-class.template: -------------------------------------------------------------------------------- 1 | VimL:" clonable-class File Template, Luc Hermitte , 27th Nov 2015 2 | VimL:" hint: Base class with clone function -- duplicable object within a hierarchy 3 | MuT: "let s:clsname = s:Param('clsname', lh#marker#txt(lh#naming#type(expand('%:t:r')))) 4 | VimL: call s:Include('get-class-name', 'cpp/internals') 5 | MuT: let s:functions = s:Param('functions', lh#cpp#snippets#new_function_list()) 6 | MuT: let s:parents = s:Param('parents', []) 7 | MuT: let s:pub_parents = filter(copy(s:parents), '!empty(lh#cpp#snippets#_filter_functions(v:val, "public"))') 8 | MuT: let s:clone_funcname = lh#naming#function('clone') 9 | VimL: " s:clsname in not yet under ctags DB, but fortunately we know the first level parents 10 | MuT: let s:root_clones = lh#cpp#override#root_function(lh#list#flatten(map(copy(s:pub_parents), 'keys(v:val)')), s:clone_funcname) 11 | VimL: let g:root_clones = s:root_clones 12 | MuT: if !empty(s:root_clones) 13 | MuT: let s:override = ' '.lh#cpp#snippets#override() 14 | MuT: let s:static_type = s:root_clones[-1].class 15 | VimL: call s:functions.insert({'kind': 'init-constructor', 'parameters': lh#option#unset()}) 16 | VimL: " Remove default-consructor unless already set visible 17 | MuT: let s:default_constructor = s:Param('default-constructor', {}) 18 | VimL: call lh#dict#add_new(s:default_constructor, {'visibility': 'none'}) 19 | MuT: else 20 | MuT: let s:override = '' 21 | MuT: let s:static_type = s:clsname 22 | MuT: endif 23 | MuT: let s:ret_type = lh#cpp#snippets#return_ptr_type(s:static_type) 24 | MuT: let s:copy_constructor = s:Param('copy-constructor', {}) 25 | VimL: let s:copy_constructor.visibility = 'protected' 26 | VimL: " TODO "how" will eventually depend on detected non-copyable attributes 27 | VimL: let s:copy_constructor.how = 'defaulted' 28 | VimL: " TODO: if abstract class => pure virtual clone function 29 | VimL: call s:functions.add([{'signature': 'virtual '.s:ret_type.' '.s:clone_funcname.'() const'.s:override, 'implementation': 'return '.lh#cpp#snippets#make_ptr(s:clsname, s:static_type, '*this').';'}]) 30 | VimL: " --- Defines Doxygen comments 31 | MuT: let s:parameters = s:Param('cls_parameters', {}) 32 | VimL: call lh#dict#add_new(s:parameters, {'comments': {}}) 33 | MuT: let s:cls_comments = s:parameters.comments 34 | VimL: let s:cls_comments.semantics = get(s:cls_comments, 'semantics', [])+['Clonable (but not assignable)'] 35 | VimL: " --- Insert the skeleton built 36 | VimL: call s:Include('base-class', 'cpp') 37 | -------------------------------------------------------------------------------- /after/template/cpp/copy-and-swap.template: -------------------------------------------------------------------------------- 1 | VimL:" copy-and-swap File Template, Luc Hermitte, 21st Aug 2011 2 | VimL:" hint: assign op + swap 3 | VimL: " todo: recognize C++11 in order to add the proper nothrow specification 4 | VimL: let s:marker_open = '<+' 5 | VimL: let s:marker_close = '+>' 6 | VimL: let s:reindent = 1 7 | VimL: " in case the class name is already known, no need to extract it 8 | VimL: call s:Include('get-class-name', 'cpp/internals') 9 | VimL:" 10 | VimL: let s:rhs = lh#naming#param("rhs") 11 | VimL: let s:fn_comments = lh#dox#new_function("Assignment operator") 12 | VimL: let s:fn_comments.text = [] 13 | VimL: let s:fn_comments.note = [] " => empty line 14 | VimL: let s:fn_comments.note += ["based on copy-and-swap idiom, with copy-elision exploited"] 15 | VimL: let s:fn_comments.note += ["exception-safe"] 16 | VimL: let s:fn_comments.param = [{"dir": "in", "name": (s:rhs), "text": "source data to be copied." } ] 17 | VimL: let s:fn_comments.throw = {"optional": 1} 18 | VimL: call s:Include("function-comment", "cpp/internals",s:fn_comments) 19 | <+s:clsname+>& operator=(<+s:clsname+> <+s:rhs+>){ 20 | this->swap(<+s:rhs+>); 21 | return *this; 22 | } 23 | VimL: call s:Include('swap-function', 'cpp') 24 | -------------------------------------------------------------------------------- /after/template/cpp/copy-back_inserter.template: -------------------------------------------------------------------------------- 1 | VimL:" copy-back_inserter File Template, Luc Hermitte, 23rd May 2014 2 | VimL:" hint: std::copy(orig.begin(), orig.end(), std::back_inserter(dest)); 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: let s:reindent = 1 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 10 | VimL: let s:orig = s:Surround(1, s:Param('origin', lh#marker#txt('origin'))) 11 | VimL: let s:dest = s:Surround(2, s:Param('destination', lh#marker#txt('destination'))) 12 | std::copy(<+s:orig+>.begin(),<+s:orig+>.end(), std::back_inserter(<+s:dest+>)); 13 | VimL: unlet s:orig 14 | VimL: unlet s:dest 15 | -------------------------------------------------------------------------------- /after/template/cpp/copy-constructor.template: -------------------------------------------------------------------------------- 1 | VimL:" copy-constructor File Template, Luc Hermitte, 21st Aug 2011 2 | VimL:" hint: T(T const&); 3 | VimL: let s:marker_open = "<+" 4 | VimL: let s:marker_close = "+>" 5 | VimL: let s:reindent = 1 6 | VimL: call s:Include('get-class-name', 'cpp/internals') 7 | VimL: let s:how = get(s:Param("copy-constructor", {}), "how", "") 8 | MuT: if s:how =~ "deleted\\|defaulted" 9 | <+s:clsname+>(<+s:clsname+> const&) <+lh#cpp#snippets#{s:how}()+>; 10 | MuT: else 11 | VimL: let s:lead = lh#dox#comment_leading_char()." " 12 | VimL: let s:param = lh#naming#param("rhs") 13 | VimL: let s:fn_comments = { } 14 | VimL: let s:fn_comments.brief = "Copy constructor." 15 | VimL: let s:fn_comments.throw = {"optional": 1} 16 | VimL: " let s:fn_comments.text = [] 17 | VimL: let s:fn_comments.param = [{"dir": "in", "name": (s:param), "text": "source data to be copied." } ] 18 | VimL: call s:Include("function-comment", "cpp/internals",s:fn_comments) 19 | MuT: let s:attributes = s:Param("attributes", lh#option#unset()) 20 | MuT: if lh#option#is_set(s:attributes) && !empty(s:attributes) 21 | MuT: let s:definition = (len(s:attributes)>1?"\n": "").": ".join(map(copy(s:attributes), 'lh#naming#member(v:val.name)."(".lh#cpp#snippets#duplicate_param(s:param.".".lh#naming#member(v:val.name), v:val.type).")"'), "\n, ").'{}' 22 | MuT: else 23 | MuT: let s:definition = ';' 24 | MuT: endif 25 | <+s:clsname+>(<+s:clsname+> const& <+s:param+>)<+s:definition+> 26 | MuT: endif 27 | -------------------------------------------------------------------------------- /after/template/cpp/copy.template: -------------------------------------------------------------------------------- 1 | VimL:" std::copy File Template, Luc Hermitte, 04th Nov 2015 2 | VimL:" hint: std::copy(first, last, dest) 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | MuT: let s:container = s:SurroundableParam('container', 1) 9 | std::copy(<+s:container+>.begin(),<+s:container+>.end(), <+dest+>); 10 | VimL: unlet s:container 11 | -------------------------------------------------------------------------------- /after/template/cpp/cout.template: -------------------------------------------------------------------------------- 1 | VimL:" cout File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::cout 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::cout << <++>; 9 | -------------------------------------------------------------------------------- /after/template/cpp/default-constructor.template: -------------------------------------------------------------------------------- 1 | VimL:" default-constructor File Template, Luc Hermitte, 21st Aug 2011 2 | VimL:" hint: T(); 3 | VimL: let s:marker_open = "<+" 4 | VimL: let s:marker_close = "+>" 5 | VimL: let s:reindent = 1 6 | VimL: call s:Include('get-class-name', 'cpp/internals') 7 | VimL: let s:lead = lh#dox#comment_leading_char().' ' 8 | VimL: let s:default_constructor = s:Param('default-constructor', {}) 9 | VimL: let s:how = get(s:default_constructor, 'how', '') 10 | MuT: if s:how !~ 'defaulted\|deleted' 11 | MuT: let s:fn_comments = get(s:default_constructor, 'comments', {}) 12 | VimL: call lh#dict#add_new(s:fn_comments, {'brief': 'Default constructor.'}) 13 | VimL: call lh#dict#add_new(s:fn_comments, {'throw': {'optional': 1}}) 14 | VimL: call s:Include('function-comment', 'cpp/internals',s:fn_comments) 15 | MuT: else 16 | VimL: let s:how = ' '.lh#cpp#snippets#{s:how}() 17 | MuT: endif 18 | <+s:clsname+>()<+s:how+>; 19 | -------------------------------------------------------------------------------- /after/template/cpp/destructor.template: -------------------------------------------------------------------------------- 1 | VimL:" destructor File Template, Luc Hermitte, 23rd Mar 2012 2 | VimL:" hint: ~T(); 3 | VimL: let s:marker_open = "<+" 4 | VimL: let s:marker_close = "+>" 5 | VimL: let s:reindent = 1 6 | VimL: call s:Include('get-class-name', 'cpp/internals') 7 | MuT: let s:destructor = s:Param('destructor', lh#option#unset()) 8 | MuT: if lh#option#is_set(s:destructor) 9 | MuT: let s:virtual = get(s:destructor, 'virtual', 0) 10 | MuT: let s:how = get(s:destructor, 'how', '') 11 | VimL: let s:visibility = get(s:destructor, 'visibility', 'public') 12 | VimL: " Let's suppose s:clsname is set 13 | MuT: else 14 | MuT: let s:virtual = lh#marker#txt('virtual ') 15 | VimL: let s:how = '' 16 | VimL: " TODO: autodetect last visibility 17 | VimL: let s:visibility = 'public' 18 | MuT: endif 19 | MuT: let s:virtual = type(s:virtual) == type('str') ? s:virtual : ((s:virtual) ? 'virtual ' : '') 20 | MuT: let s:how = s:how =~ '\vpure|deleted|defaulted' ? ' '.lh#cpp#snippets#{s:how}() : '' 21 | MuT: let s:fn_comments = get(s:destructor, 'comments', {}) 22 | VimL: call lh#dict#add_new(s:fn_comments, {'brief': substitute(s:virtual.'Destructor.', '\v(.)(.*)', '\u\1\L\2', '')}) 23 | MuT: if s:visibility == 'protected' 24 | VimL: let s:fn_comments.note = ['This class is not meant to be destroyed polymorphically'] 25 | MuT: elseif empty(s:virtual) 26 | VimL: let s:fn_comments.warning = ['this class is not meant to be publicly inherited'] 27 | MuT: endif 28 | VimL: call lh#dict#add_new(s:fn_comments, {'throw': 'Nothing'}) 29 | VimL: " let s:fn_comments.text = [] 30 | VimL: call s:Include('function-comment', 'cpp/internals',s:fn_comments) 31 | <+s:virtual+>~<+s:clsname+>()<+s:how+>; 32 | -------------------------------------------------------------------------------- /after/template/cpp/empty-exception-class.template: -------------------------------------------------------------------------------- 1 | VimL:" empty-exception-class File Template, Luc Hermitte , 27th Nov 2015 2 | VimL:" hint: Minimalist exception class 3 | VimL: let s:default_constructor = s:Param("default-constructor", {"visibility": "none"}) 4 | VimL: let s:destructor = s:Param("destructor", {}) 5 | VimL: let s:destructor.virtual = 1 6 | MuT: let s:parents = s:Param("parents", []) 7 | MuT: let s:default_exception = lh#option#get('cpp_root_exception', {"std::runtime_error": {"includes": ""}}) 8 | MuT: let s:parent_exception = s:Param("root-exception", s:default_exception) 9 | VimL: let s:parents += [s:parent_exception] 10 | VimL: call s:Include('list-constructors', 'cpp/internals') 11 | MuT: let s:functions = s:Param("functions", lh#cpp#snippets#new_function_list()) 12 | MuT: if lh#cpp#use_cpp11() && empty(s:constructors) 13 | VimL: call s:functions.insert({"signature": "using ". lh#cpp#snippets#constructor_name(s:parent_exception) }) 14 | MuT: else 15 | VimL: " override any previous "parameters" argument 16 | VimL: " TODO: search for new attributes => parameters ; and merge with parent parameters 17 | VimL: call s:functions.insert({"kind": "init-constructor", 'parameters': lh#option#unset()}) 18 | MuT: endif 19 | VimL: " --- in case the class name is already known, no need to extract it 20 | VimL: call s:Include('get-class-name', 'cpp/internals') 21 | VimL: " --- Defines Doxygen comments 22 | MuT: let s:parameters = s:Param('cls_parameters', {}) 23 | VimL: call lh#dict#add_new(s:parameters, {'comments': {}, 'copyable': 1}) 24 | MuT: let s:cls_comments = s:parameters.comments 25 | VimL: let s:cls_comments.semantics = get(s:cls_comments, 'semantics', []) 26 | VimL: let s:cls_comments.semantics += ['Exception class', 'Copyable'] 27 | VimL: " --- Insert the skeleton built 28 | VimL: call s:Include('class-skeleton', 'cpp/internals', s:parameters) 29 | -------------------------------------------------------------------------------- /after/template/cpp/ends_with.template: -------------------------------------------------------------------------------- 1 | VimL:" ends_with File Template, Luc Hermitte , 28th May 2014 2 | VimL:" hint: boost::algorithm::ends_with 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | boost::algorithm::ends_with(<+input+>, <+prefix_searched+>) 9 | -------------------------------------------------------------------------------- /after/template/cpp/entity-class.template: -------------------------------------------------------------------------------- 1 | VimL:" entity-class File Template, Luc Hermitte , lun. 19 déc. 2016 17:14:18 CET 2 | VimL:" hint: Entity class -- non copyable 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | MuT: let s:parameters = s:Param('cls_parameters', {}) 8 | VimL: call lh#dict#add_new(s:parameters, {'noncopyable': 1, 'comments': {}}) 9 | VimL: " --- in case the class name is already known, no need to extract it 10 | VimL: call s:Include('get-class-name', 'cpp/internals') 11 | VimL: " --- Defines Doxygen comments 12 | MuT: let s:cls_comments = s:parameters.comments 13 | VimL: let s:cls_comments.semantics = get(s:cls_comments, 'semantics', []) 14 | MuT: if match(s:cls_comments.semantics, 'Clonable') < 0 15 | VimL: let s:cls_comments.semantics += ['Entity','Non-copyable'] 16 | MuT: endif 17 | VimL: " --- Insert the skeleton built 18 | VimL: call s:Include("class-skeleton", "cpp/internals", s:parameters) 19 | -------------------------------------------------------------------------------- /after/template/cpp/enum.template: -------------------------------------------------------------------------------- 1 | VimL:" Enum definition Template, Luc Hermitte 2 | VimL: let s:value_start = '¡' 3 | VimL:" hint: struct Enum { enum type { ... } }; 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: let s:enum_name = inputdialog('Name of the enum class ?', lh#marker#txt(expand('%:t:r'))) 9 | struct ¡s:enum_name¡ { 10 | enum type { <+values+>, MAX__ }; 11 | static type next(type e_) { 12 | assert(e_ < MAX__); 13 | return type(e_+1); 14 | } 15 | static char const* to_string(type e_); 16 | static type to_enum(std::string const& s_); 17 | }; 18 | 19 | inline 20 | ¡s:enum_name¡::type& operator++(¡s:enum_name¡::type& e_) { 21 | return e_ = ¡s:enum_name¡::next(e_); 22 | } 23 | 24 | inline 25 | ¡s:enum_name¡::type operator++(¡s:enum_name¡::type&e_, int) { 26 | const ¡s:enum_name¡::type tmp = e_; 27 | e_ = ¡s:enum_name¡::next(e_); 28 | return tmp; 29 | } 30 | -------------------------------------------------------------------------------- /after/template/cpp/enum2-impl.template: -------------------------------------------------------------------------------- 1 | VimL:" enum2-impl File Template, Luc Hermitte, 23rd Apr 2014 2 | VimL:" hint: enum2 code that goes into .cpp files 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: " let g:args = s:args 8 | MuT: let s:enum_name = s:Param('name', lh#marker#txt(lh#naming#type(expand('%:t:r')))) 9 | MuT: let s:scope = s:Param('scope', '') 10 | MuT: let s:values = map(s:Param('values', [lh#marker#txt('values')]), '"\"".v:val."\""') 11 | MuT: let s:lhs_ = lh#naming#param("lhs") 12 | MuT: let s:rhs_ = lh#naming#param("rhs") 13 | MuT: let s:value_ = lh#naming#param("value") 14 | MuT: let s:m_value = lh#naming#member("value") 15 | MuT: let s:tmp = lh#naming#local("tmp") 16 | MuT: let s:range = s:Param('range', lh#naming#function("range")) 17 | MuT: let s:RangeType = s:Param('RangeType', lh#naming#type("range")) 18 | MuT: let s:iterable = s:Param("iterable", 0) 19 | MuT: let s:to_string = lh#naming#function("to_string") 20 | MuT: let s:to_internal = lh#naming#function("to_internal") 21 | MuT: let s:max = lh#naming#function("max") 22 | MuT: let s:type = lh#naming#type("type") 23 | MuT: let s:str_param = lh#naming#param("s") 24 | MuT: let s:k_strings = lh#naming#constant(s:enum_name.'_strings') 25 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 26 | MuT: let s:restore_options = lh#on#exit().restore_option('cpp_begin_end_style') 27 | MuT: if lh#cpp#use_cpp11() 28 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 29 | VimL: let b:cpp_begin_end_style = lh#option#get('cpp_begin_end_style', 'std') 30 | MuT: else 31 | VimL: let b:cpp_begin_end_style = lh#option#get('cpp_begin_end_style', 'boost') 32 | MuT: endif 33 | VimL: call s:Include('get-b-e', 'cpp/internals', {'container': '::'.s:k_strings}) 34 | 35 | namespace { // Anonymous namespace 36 | typedef char const* const* strings_iterator; 37 | static char const* const <+s:k_strings+>[] = 38 | { <+join(s:values, ', ')+> }; 39 | } // Anonymous namespace // namespaces 40 | 41 | 42 | <+s:scope+><+s:enum_name+>::<+s:enum_name+>(std::string const& <+s:str_param+>) 43 | { 44 | strings_iterator const <+s:enum_name+>_it = std::find(<+s:begin+>,<+s:end+>, <+s:str_param+>); 45 | if (<+s:enum_name+>_it == <+s:end+>) { 46 | VimL: call s:Include('throw', 'cpp', '"Cannot decode '.s:enum_name.' name `"+'.s:str_param.'+"`"') 47 | } 48 | <+s:m_value+> = <+s:type+>(std::distance(<+s:begin+>, <+s:enum_name+>_it)); 49 | assert(<+s:m_value+> < MAX__); 50 | } 51 | 52 | VimL: call s:Include('array_size', 'cpp') 53 | 54 | char const* <+s:scope+><+s:enum_name+>::<+s:to_string+>() const 55 | { 56 | VimL: call s:Include('static_assert', 'cpp', {'condition': 'MAX__ == '.lh#fmt#printf(s:_array_size,'::'.s:k_strings), 'message': '"Array size mismatches number of elements in enum"'}) 57 | assert(<+s:m_value+> != UNDEFINED__); // Yes, I know UNDEFINED__ > MAX__ 58 | assert(<+s:m_value+> < MAX__); 59 | return <+s:k_strings+>[<+s:m_value+>]; 60 | } 61 | MuT: if s:iterable && lh#cpp#use_cpp11() 62 | 63 | /*static*/ <+s:scope+><+s:enum_name+>::<+s:RangeType+> <+s:scope+><+s:enum_name+>::<+s:range+>() { return <+s:RangeType+>(); } 64 | MuT: endif 65 | 66 | VimL: silent! unlet s:values 67 | VimL: call s:restore_options.finalize() 68 | -------------------------------------------------------------------------------- /after/template/cpp/erase-remove.template: -------------------------------------------------------------------------------- 1 | VimL:" erase-remove File Template, Luc Hermitte, 06th Nov 2012 2 | VimL:" hint: erase-remove idiom 3 | VimL: let s:reindent = 1 4 | VimL: let s:marker_open = '<+' 5 | VimL: let s:marker_close = '+>' 6 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 7 | MuT: let s:container = s:SurroundableParam('container', 1) 8 | <+s:container+>.erase(std::remove<+_if+>(<+s:container+>.begin(), <+s:container+>.end(), <+what+>), <+s:container+>.end()); 9 | VimL: unlet s:container 10 | -------------------------------------------------------------------------------- /after/template/cpp/exception-class.template: -------------------------------------------------------------------------------- 1 | VimL:" exception-class File Template, Luc Hermitte , 25th Nov 2015 2 | VimL:" hint: Value Class ((implicitly) copyable, no hierarchy) 3 | VimL:" NOTE: when we define our own exception types, we do much more than just inherit from a standard exception type 4 | VimL: " There is an init constructor, no need to delete the default constructor. 5 | VimL: let s:default_constructor = s:Param("default-constructor", {"visibility": "none"}) 6 | MuT: let s:functions = s:Param("functions", lh#cpp#snippets#new_function_list()) 7 | VimL: call s:functions.add([{"signature": "virtual char const* what() const ".lh#cpp#snippets#noexcept()." ".lh#cpp#snippets#override()}]) 8 | VimL: call s:Include("empty-exception-class", "cpp") 9 | -------------------------------------------------------------------------------- /after/template/cpp/file.template: -------------------------------------------------------------------------------- 1 | VimL:" file File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: i/ofstream 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::<+i+>fstream f(¡s:Surround(1, '<+filename+>')¡); 9 | -------------------------------------------------------------------------------- /after/template/cpp/for-enum.template: -------------------------------------------------------------------------------- 1 | VimL:" For loop over Enum definition Template, Luc Hermitte 2 | VimL:" hint: for (Enum::type e=Enum::type(); e!=Enum::MAX__; ++e) { ... } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: let s:enum_name = inputdialog('Name of the enum class ?', Marker_Txt('EnumType')) 9 | VimL: let s:index = inputdialog('Name of the for index ?', Marker_Txt('e')) 10 | VimL: " todo: automagically detect the type of the real enum, and the MAX__ value 11 | for(¡s:enum_name¡::type ¡s:index¡ = ¡s:enum_name¡::type() ; ¡s:index¡ != ¡s:enum_name¡::MAX__ ; ++¡s:index¡ ){ 12 | ¡s:Surround(1, '<++>')¡ 13 | }<+s:TerminalPlaceHolder()+> 14 | -------------------------------------------------------------------------------- /after/template/cpp/for-iterator.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ for-loop on iterators Template, Luc Hermitte 2 | VimL:" hint: for (T::iterator b=c.begin(), e=c.end(); b!=e; ++b) { ... } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL:" 9 | VimL: let s:cont = lh#ui#input('Container name: ') 10 | VimL: let s:begin = lh#ui#input('Iterator variable: ', 'b') 11 | VimL: let s:end = lh#ui#input('Iterator end variable: ', 'e') 12 | VimL:" 13 | VimL:" Note: The "const" can be deleted or kept thanks to MarkersMark 14 | MuT: let s:container_type = lh#dev#types#of_var(s:cont, lh#marker#txt('container_type')) 15 | MuT: let s:const = lh#dev#cpp#types#is_const(s:container_type) ? 'const_' : lh#marker#txt('const_') 16 | VimL: let s:container_type = lh#dev#cpp#types#remove_cv(lh#dev#cpp#types#remove_reference(s:container_type)) 17 | for (<+s:container_type+>::<+s:const+>iterator ¡s:begin¡ = ¡s:cont¡.begin(), ¡s:end¡ = ¡s:cont¡.end() 18 | ; ¡s:begin¡ != ¡s:end¡ 19 | ; ++¡s:begin¡ 20 | ) 21 | { 22 | ¡s:Surround(1, '<++>')¡ 23 | }<+s:TerminalPlaceHolder()+> 24 | -------------------------------------------------------------------------------- /after/template/cpp/for-range.template: -------------------------------------------------------------------------------- 1 | VimL:" range-based for loop File Template, Luc Hermitte, 07th Jul 2015 2 | VimL:" hint: for(auto&& e : range) 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: let s:reindent = 1 8 | VimL: let s:type = s:Param("type", lh#marker#txt('auto&&')) 9 | VimL: let s:elem = s:Param("elem", lh#marker#txt('e')) 10 | VimL: let s:range = s:Param("range", lh#marker#txt('range')) 11 | for(<+s:type+> <+s:elem+> : <+s:range+>){ 12 | ¡s:Surround(1, '<++>')¡ 13 | }<+s:TerminalPlaceHolder()+> 14 | VimL: unlet s:type 15 | VimL: unlet s:elem 16 | VimL: unlet s:range 17 | -------------------------------------------------------------------------------- /after/template/cpp/fori.template: -------------------------------------------------------------------------------- 1 | VimL:"{for int i=0...} Template-File, Luc Hermitte 2 | VimL:" hint: for (int i=0;i!=N;++i) { action } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | for(<+int+> <+i+>=0; <+i+>!=<+MAX+> ; ++<+i+>){ 9 | ¡s:Surround(1, '<+code+>')¡ 10 | }<+s:TerminalPlaceHolder()+> 11 | -------------------------------------------------------------------------------- /after/template/cpp/foriN.template: -------------------------------------------------------------------------------- 1 | VimL:"{for size_t i=0, N= ; i!=N...} Template-File, Luc Hermitte 2 | VimL:" hint: for (std::size_t i=0, N=...;i!=N;++i) { action } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | for(<+std::size_t+> <+i+>=0, <+N+>=<+MAX+>; <+i+>!=<+N+> ; ++<+i+>){ 9 | ¡s:Surround(1, '<+code+>')¡ 10 | }<+s:TerminalPlaceHolder()+> 11 | -------------------------------------------------------------------------------- /after/template/cpp/forward.template: -------------------------------------------------------------------------------- 1 | VimL:" forward File Template, Luc Hermitte, mar. 29 mars 2016 17:13:03 CEST 2 | VimL:" hint: std::forward(v) 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | MuT: let s:var = s:SurroundableParam('var', 1) 8 | MuT: let s:type = s:SurroundableParam('type', 2) 9 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 10 | std::forward<<+s:type+>>(<+s:var+>)<+s:TerminalPlaceHolder()+> 11 | -------------------------------------------------------------------------------- /after/template/cpp/getter.template: -------------------------------------------------------------------------------- 1 | VimL:" getter File Template, Luc Hermitte , 02nd Dec 2015 2 | VimL:" hint: T const& getFoo() const 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: "The interactive mode (w/ dynamic placeholders) won't permit to have "getFoo" and "return m_foo". 7 | MuT: let s:attribute = s:Param("attribute", {'type': lh#marker#txt(lh#naming#type('type')), 'name': lh#marker#txt('name')}) 8 | MuT: let s:attrb_name = s:attribute.name 9 | MuT: let s:ret_expr = lh#naming#member(s:attrb_name) 10 | MuT: if lh#dev#cpp#types#is_smart_ptr(s:attribute.type) 11 | MuT: let s:ret_type = lh#dev#cpp#types#remove_ptr(s:attribute.type) 12 | VimL: let s:ret_expr = '*'.s:ret_expr 13 | MuT: else 14 | MuT: let s:ret_type = s:attribute.type 15 | MuT: endif 16 | VimL: let s:ret_type = lh#dev#cpp#types#const_correct_type(s:ret_type) 17 | <+s:ret_type+> <+lh#naming#getter(s:attrb_name)+>() const{return <+s:ret_expr+>;} 18 | -------------------------------------------------------------------------------- /after/template/cpp/init-constructor.template: -------------------------------------------------------------------------------- 1 | VimL:" init-constructor File Template, Luc Hermitte, 30th Nov 2015 2 | VimL:" hint: Constructor(parameters): m_attributes(params){} 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: " in case the class name is already known, no need to extract it 7 | VimL: call s:Include('get-class-name', 'cpp/internals') 8 | MuT: let s:parameters = s:Param("parameters", lh#option#unset()) 9 | MuT: let s:fn_comments = lh#dox#new_function("Init constructor.") 10 | VimL: let s:fn_comments.throw = {"optional": 1} 11 | VimL: " let s:fn_comments.text = [] 12 | MuT: if lh#option#is_set(s:parameters) 13 | MuT: let s:parameterList = lh#cpp#snippets#build_param_list(s:parameters) 14 | MuT: let s:definition = (empty(s:parameters)? "" : (len(s:parameters)>1?"\n": "").": ").join(map(copy(s:parameters), 'lh#naming#member(v:val.name)."(".lh#naming#param(v:val.name).")"'), "\n, ").'{}' 15 | VimL: for param in s:parameters | call s:fn_comments.add_param(param) | unlet param | endfor 16 | MuT: else 17 | MuT: let s:parameterList = lh#marker#txt('ctr-parameters') 18 | MuT: let s:definition = ';' 19 | VimL: let s:fn_comments.param = [lh#marker#txt('ctr-parameters'). ' ' . lh#marker#txt()] 20 | MuT: endif 21 | VimL: call s:Include("function-comment", "cpp/internals",s:fn_comments) 22 | <+s:clsname+>(<+s:parameterList+>)<+s:definition+> 23 | -------------------------------------------------------------------------------- /after/template/cpp/interface.template: -------------------------------------------------------------------------------- 1 | VimL:" interface File Template, Luc Hermitte , lun. 19 déc. 2016 18:32:45 CET 2 | VimL:" hint: Interface class -- An abstract class actually 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: " --- Defines Doxygen comments 8 | MuT: let s:parameters = s:Param('cls_parameters', {}) 9 | VimL: call lh#dict#add_new(s:parameters, {'comments': {}}) 10 | MuT: let s:cls_comments = s:parameters.comments 11 | VimL: let s:cls_comments.semantics = get(s:cls_comments, 'semantics', [])+['Interface'] 12 | VimL: " --- Insert the skeleton built 13 | VimL: call s:Include('abstract-class', 'cpp', {'cls_parameters': s:parameters}) 14 | -------------------------------------------------------------------------------- /after/template/cpp/internals/abs-rel-shared.template: -------------------------------------------------------------------------------- 1 | VimL:" Shared definition for Absolute and relative Classes Template, Luc Hermitte 2 | VimL:" Used to define Date and Duration, Point and Distance, ... 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL:" 9 | namespace DETAILS 10 | { 11 | <+s:tmpl_decl+>class <+s:sharedclsname+> 12 | { 13 | public: 14 | typedef ¡lh#ui#if(s:istemplate, s:tmpl_type, "<+scalar_type+>")¡ scalar_type; 15 | friend class ¡s:absclsname.s:tmpl¡; 16 | friend class ¡s:relclsname.s:tmpl¡; 17 | protected: 18 | /**@name Construction/destruction 19 | */ 20 | //@{ 21 | /** Initialisation constructor. 22 | */ 23 | <+s:sharedclsname+>(<+parameters+>)¡lh#ui#if(s:istemplate,"\n<+: +>{<++>}", ";")¡ 24 | /** Protected destructor. 25 | */ 26 | ~<+s:sharedclsname+>(); 27 | ¡lh#cpp#abs_rel#canonicalortodoxform(s:absclsname, ! s:defaultisenough)¡ 28 | //@} 29 | 30 | /**@name Operations 31 | */ 32 | //@{ 33 | void add(<+s:sharedclsname+> const& <+s:rhs+>)¡lh#ui#if(s:istemplate,"\n{<++>}", ";")¡ 34 | void dec(<+s:sharedclsname+> const& <+s:rhs+>)¡lh#ui#if(s:istemplate,"\n{<++>}", ";")¡ 35 | void mult(scalar_type <+s:coeff+>)¡lh#ui#if(s:istemplate,"\n{<++>}", ";")¡ 36 | void div(scalar_type <+s:coeff+>)¡lh#ui#if(s:istemplate,"\n{<++>}", ";")¡ 37 | static bool isEqual( 38 | <+s:sharedclsname+> const& <+s:rhs+>, 39 | <+s:sharedclsname+> const& <+s:lhs+>)¡lh#ui#if(s:istemplate,"\n{<++>}", ";")¡ 40 | //@} 41 | private: 42 | <+representation+>; 43 | }; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /after/template/cpp/internals/attribute.template: -------------------------------------------------------------------------------- 1 | VimL:" attribute File Template, Luc Hermitte , 02nd Dec 2015 2 | VimL:" hint: Type m_attribute; 3 | VimL: " Parameter: "attribute" (optional) 4 | VimL: " - "name": string, mandatory 5 | VimL: " - "type": string, mandatory, 6 | VimL: " - "type_info": dict, mandatory (comes from lh#cpp#types#get_info()) 7 | VimL: " - "storage": string, optional: "constepxr ", "static ", "thread_local ", ... 8 | VimL: " - "default": string, optional, C++11+ only: " = value" 9 | VimL: " - "align": number, optional 10 | VimL: " - "include": string/list: files to #include 11 | VimL: " @pre "type" is expected to have been processed w/ lh#cpp#type#*() 12 | VimL: let s:marker_open = '<+' 13 | VimL: let s:marker_close = '+>' 14 | VimL: let s:reindent = 1 15 | VimL: " TODO: Handle Doxygen/comments as well 16 | MuT: let s:attribute = s:Param("attribute", {'type': lh#marker#txt(lh#naming#type('type')), 'name': lh#marker#txt('name')}) 17 | VimL: call s:Include('includes', 'cpp/internals', s:attribute) 18 | MuT: let s:align = repeat(' ', max([0, get(s:attribute, 'align', 0) - lh#encoding#strlen(s:attribute.type)])) 19 | MuT: if !lh#cpp#use_cpp11() 20 | MuT: let s:default_attrb_value = "" 21 | MuT: else 22 | MuT: let s:default_attrb_value = get(s:attribute, "default", "") 23 | VimL: let s:default_attrb_value = empty(s:default_attrb_value) ? "" : " = ".s:default_attrb_value 24 | MuT: endif 25 | MuT: if lh#option#is_set(s:attribute.type_info) 26 | VimL: call s:AddPostExpandCallback('lh#dev#import#add_any('.string(get(s:attribute.type_info, "includes", [])).')') 27 | MuT: endif 28 | <+get(s:attribute, 'storage', '')+><+s:attribute.type+> <+s:align+><+lh#naming#member(s:attribute.name)+><+s:default_attrb_value+>; 29 | VimL: " <+get(s:attribute, 'storage', '')+><+s:Include(s:attribute.type, 'cpp')+> <+s:align+><+lh#naming#member(s:attribute.name)+><+s:default_attrb_value+>; 30 | -------------------------------------------------------------------------------- /after/template/cpp/internals/formatted-comment.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ formatted-comment template-routine, Luc Hermitte, 23rd Mar 2012 2 | VimL:" Meant to be used as a function whose parameter is a list of things to print. 3 | VimL:" Default output format=doxygen; override this template for other formats. 4 | VimL:" hint: /** stuff from the list... */ 5 | VimL: let s:reindent = 1 6 | VimL: function! s:_LoopOverDoxItems(doc) 7 | VimL: " echomsg "-->".string(a:doc) 8 | VimL: let lead = lh#dox#comment_leading_char(). " " 9 | VimL: let lines = [] 10 | VimL: for item in a:doc 11 | VimL: let text = get(item, 'text', '') 12 | VimL: if has_key(item,"tag") 13 | VimL: " try to use the lh#dox#{tag}() function if it exists 14 | VimL: if (item.tag) == "param" 15 | VimL: let line = lh#dox#{item.tag}(item) 16 | VimL: elseif exists("*lh#dox#".(item.tag)) 17 | VimL: let line = lh#dox#{item.tag}(text) 18 | VimL: else 19 | VimL: let line = lh#dox#tag(item.tag) . " " . text 20 | VimL: endif 21 | VimL: elseif has_key(item, "license") 22 | VimL: let license = s:GetTemplateLines(item.license, "license/text") 23 | VimL: let pat_not_text = '\c\(^'.s:Command('').'\|'.s:Special('').'\)' 24 | VimL: call map(license, "v:val =~ pat_not_text ? (v:val) : lead.v:val") 25 | VimL: let lines += license 26 | VimL: continue 27 | VimL: else 28 | VimL: let line = text 29 | VimL: endif 30 | VimL: " optional entries are completly surrounded by a placeholder 31 | VimL: if has_key(item,"optional") && item.optional && match(line, lh#marker#txt(".\\{-}"))==-1 32 | VimL: let line = lh#marker#txt(line) 33 | VimL: endif 34 | VimL: " special case: @ingroup is put on the /** line 35 | VimL: if has_key(item,"tag") && item.tag == "ingroup" 36 | VimL: let s:content.lines[s:content.crt-1] .= line 37 | VimL: elseif (line!~'^\s*$') " empty lines produce nothing 38 | VimL: " Use "\n" as {text} to force an empty line 39 | VimL: let lines += [line=="\n" ? lead : lead.line] 40 | VimL: endif 41 | VimL: endfor 42 | VimL: "trim trailing whitespaces 43 | VimL: call map(lines, "substitute(v:val, ' *$', '', '')") 44 | VimL: call s:Inject(lines) 45 | VimL: endfunction 46 | MuT: if lh#ft#option#get("template_expand_doc", &ft, 1) 47 | MuT: let s:restore_options = lh#on#exit().restore(s:content, 'can_apply_style') 48 | VimL: let s:content.can_apply_style = s:Param('style', 0) 49 | /** 50 | VimL: call s:_LoopOverDoxItems(empty(s:Args()) ? [] : s:Args()[0]) 51 | */ 52 | VimL: " let g:lines = deepcopy(s:content.lines) 53 | VimL: call s:restore_options.finalize() 54 | MuT: endif 55 | -------------------------------------------------------------------------------- /after/template/cpp/internals/function-comment.template: -------------------------------------------------------------------------------- 1 | VimL:" function-comment File Template, Luc Hermitte, 22nd Aug 2011 2 | VimL:" template to generate function comments, default format=doxygen 3 | VimL: let s:fn_comments=s:Args()[0] 4 | VimL: " 5 | VimL: function! s:_AddItemToDoc(tagname, data) 6 | VimL: let text = empty(a:data) ? "\n" : a:data 7 | VimL: if empty(a:tagname) 8 | VimL: return [{'text': text}] 9 | VimL: else 10 | VimL: return [{'tag':(a:tagname), 'text': text}] 11 | VimL: endif 12 | VimL: endfunction 13 | VimL: " 14 | VimL: function! s:_AddToDoc(tagname, data) 15 | VimL: " if !has_key(a:data, a:tagname) | return [] | endif 16 | VimL: let res = [] 17 | VimL: if type(a:data[a:tagname]) == type([]) 18 | VimL: for e in a:data[a:tagname] 19 | VimL: let e2 = {(a:tagname): e} 20 | VimL: let res += s:_AddToDoc(a:tagname, e2) 21 | VimL: endfor 22 | VimL: elseif type(a:data[a:tagname]) == type({}) 23 | VimL: " special case to handle things like "optional" 24 | VimL: let data = copy(a:data[a:tagname]) 25 | VimL: let data.tag = a:tagname 26 | VimL: let res += [data] 27 | VimL: else 28 | VimL: let res += s:_AddItemToDoc(a:tagname, a:data[a:tagname]) 29 | VimL: endif 30 | VimL: return res 31 | VimL: endfunction 32 | VimL: " 33 | VimL: function! s:_GenerateDoc(data) 34 | VimL: " echomsg "\n-->".string(a:data) 35 | VimL: " tags ordered => determine the order in which they are displayed 36 | VimL: let pre_tags_default = [ 'brief', 'ingroup', 'tparam', 'param', 'return', 'throw', 'invariant', 'pre', 'post'] 37 | VimL: let post_tags_default = ['note', 'warning', 'author', 'since', 'version', 'see'] 38 | VimL: let doc = [] 39 | VimL: let tags = lh#ft#option#get('pre_desc_ordered_tags', &ft, pre_tags_default) 40 | VimL: for tag in filter(copy(tags), 'has_key(a:data, v:val)') 41 | VimL: let doc += s:_AddToDoc(tag, a:data) 42 | VimL: endfor 43 | VimL: if has_key(s:fn_comments, 'semantics') 44 | VimL: let doc += s:_AddItemToDoc('semantics', '') 45 | VimL: for t in s:fn_comments.semantics 46 | VimL: let doc += s:_AddItemToDoc('', '- '.t) 47 | VimL: endfor 48 | VimL: endif 49 | VimL: if has_key(s:fn_comments, 'text') 50 | VimL: if empty(s:fn_comments.text) 51 | VimL: let doc += s:_AddItemToDoc('', '') 52 | VimL: else 53 | VimL: for t in s:fn_comments.text 54 | VimL: let doc += s:_AddItemToDoc('', t) 55 | VimL: endfor 56 | VimL: endif 57 | VimL: endif 58 | VimL: let tags = lh#ft#option#get('post_desc_ordered_tags', &ft, post_tags_default) 59 | VimL: for tag in filter(copy(tags), 'has_key(a:data, v:val)') 60 | VimL: let doc += s:_AddToDoc(tag, a:data) 61 | VimL: endfor 62 | VimL: " echomsg string(doc) 63 | VimL: " and finally, generate! 64 | VimL: call s:Include('formatted-comment', 'cpp/internals', doc) 65 | VimL: endfunction 66 | MuT: if lh#ft#option#get('template_expand_doc', &ft, 1) 67 | VimL: call s:_GenerateDoc(s:fn_comments) 68 | MuT: endif 69 | -------------------------------------------------------------------------------- /after/template/cpp/internals/function.template: -------------------------------------------------------------------------------- 1 | VimL:" «function» File Template, Luc Hermitte , 27th Nov 2015 2 | VimL:" hint: «function-hint» 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | MuT: let s:function = s:Param('function', {}) 6 | MuT: let s:kind = get(s:function, 'kind', '') 7 | MuT: if s:kind =~ '\vconstructor|destructor|assignment-operator' 8 | VimL: call s:Include(s:kind, 'cpp', s:function) 9 | MuT: " let s:how = get(s:function, 'how', '') 10 | MuT: " let s:how = s:how =~ "\\vpure|deleted|defaulted" ? " ".lh#cpp#snippets#{s:how}() : "" 11 | MuT: " let s:clsname = s:Param("clsname", lh#cpp#AnalysisLib_Class#CurrentScope(line("."), "class")) 12 | VimL: "<+s:clsname+>(<+s:Param("parameters", lh#marker#txt("ctr-parameters"))+>)<+s:how+>; 13 | MuT: elseif s:kind =~ '\vget|set' 14 | VimL: call s:Include(s:kind.'ter', 'cpp', {'attribute': s:function.attribute}) 15 | MuT: let s:attrb_name = s:function.attribute.name 16 | MuT: else 17 | MuT: let s:signature = get(s:function, 'signature', '') 18 | MuT: let s:implementation = get(s:function, 'implementation', ';') 19 | VimL: let s:signature = substitute(s:signature, '<+__clsname__+>', s:clsname, 'g') 20 | MuT: if s:implementation != ';' 21 | VimL: let s:implementation = substitute(s:implementation, '<+__clsname__+>', s:clsname, 'g') 22 | VimL: let s:implementation = '{'.s:implementation.'}' 23 | MuT: endif 24 | MuT: let s:fn_comments = get(s:function, 'comments', {}) 25 | MuT: if !empty(s:fn_comments) 26 | VimL: call s:Include('function-comment', 'cpp/internals', s:fn_comments) 27 | MuT: endif 28 | <+s:signature+><+s:implementation+> 29 | MuT: endif 30 | VimL: " TODO: definition in separate file 31 | -------------------------------------------------------------------------------- /after/template/cpp/internals/get-b-e.template: -------------------------------------------------------------------------------- 1 | VimL:" get-b-e File Template, Luc Hermitte , jeu. 02 juin 2016 17:02:36 CEST 2 | VimL: " Parameters: 3 | VimL: " - "container" 4 | VimL: " Options: 5 | VimL: " - (bg):cpp_begin_end_style 6 | VimL: " Defines: 7 | VimL: " - s:begin 8 | VimL: " - s:end 9 | VimL: " - s:container 10 | VimL: " And: 11 | VimL: " - include the relevant files according to g:cpp_begin_end_style 12 | VimL: let s:value_start = '¡' 13 | VimL: let s:value_end = s:value_start 14 | VimL: let s:marker_open = '<+' 15 | VimL: let s:marker_close = '+>' 16 | MuT: let s:container = s:SurroundableParam('container', 1) 17 | MuT: let s:begin = lh#cpp#snippets#_select_begin_end(s:container, 'begin') 18 | MuT: let s:end = lh#cpp#snippets#_select_begin_end(s:container, 'end') 19 | MuT: let s:includes = lh#cpp#snippets#_include_begin_end() 20 | VimL: call lh#list#for_each_call(s:includes, s:getSNR('AddPostExpandCallback("lh#dev#import#add(v:val)")')) 21 | -------------------------------------------------------------------------------- /after/template/cpp/internals/get-class-name.template: -------------------------------------------------------------------------------- 1 | VimL:" get-class-name routine File Template, Luc Hermitte , jeu. 17 déc. 2015 18:40:56 CET 2 | VimL:" hint: Internal routine to fetch the class name if already known 3 | VimL: "1- in case the class name is already known, no need to extract it 4 | MuT: let s:clsname = s:Param("clsname",join(s:CmdLineParams(), '')) 5 | MuT: if empty(s:clsname) 6 | VimL: "2- otherwise: we try to extract it 7 | MuT: let s:clsname = lh#cpp#AnalysisLib_Class#CurrentScope(line("."), "class") 8 | MuT: if empty(s:clsname) 9 | VimL: "3- otherwise, we ask it to the end-user, default = filename minus extensions 10 | MuT: let s:clsname = lh#ui#input("class name ?", lh#marker#txt(lh#naming#type(expand("%:t:r")))) 11 | MuT: endif 12 | VimL: "4- reinject the new clsname into the arguments 13 | VimL: " However, as this template-file is included, arguments will be popped 14 | VimL: " => clsname will be lost in crt context 15 | VimL: " => it has to be injected in parent context! (yes, this is quite dirty!) 16 | VimL: call s:InjectInParentArgs({'clsname': (s:clsname)}) 17 | MuT: endif 18 | -------------------------------------------------------------------------------- /after/template/cpp/internals/includes.template: -------------------------------------------------------------------------------- 1 | VimL:" includes File Template, Luc Hermitte , 02nd Dec 2015 2 | VimL:" hint: include skel-routine 3 | VimL: " Parameter: list/string: files to include 4 | MuT: let s:includes = lh#list#flatten([s:Param("includes", [])]) 5 | VimL: for inc in s:includes | call s:AddPostExpandCallback('lh#dev#import#add("'.inc.'")') | endfor 6 | -------------------------------------------------------------------------------- /after/template/cpp/internals/list-constructors.template: -------------------------------------------------------------------------------- 1 | VimL:" list-constructors File Template, Luc Hermitte , 27th Nov 2015 2 | VimL:" hint: Routine template-file, returns: s:constructors 3 | VimL: "let g:args = deepcopy(s:args) 4 | MuT: let s:flat_args = lh#list#flatten(s:args) 5 | MuT: let s:constructors = filter(copy(s:flat_args), 'match(keys(v:val), "constructor") >= 0') 6 | VimL: "let g:constructors0 = deepcopy(s:constructors) 7 | VimL: " Ignore removed (none) constructors 8 | VimL: call filter(s:constructors, "empty(lh#cpp#snippets#_filter_functions(v:val, 'none'))") 9 | VimL: "let g:constructors1 = deepcopy(s:constructors) 10 | VimL: " Ignore defaulted constructors 11 | VimL: call filter(s:constructors, "empty(lh#cpp#snippets#_filter_functions(v:val, 'how', 'defaulted'))") 12 | VimL: "let g:constructors2 = deepcopy(s:constructors) 13 | MuT: let s:ctr_functions = filter(copy(s:flat_args), 'has_key(v:val,"functions")') 14 | VimL: "let g:ctr_functions = deepcopy(s:ctr_functions) 15 | MuT: if !empty(s:ctr_functions) 16 | VimL: let s:ctr_functions2 = lh#list#accumulate2(s:ctr_functions, {}, 'extend(v:1_, v:2_)') 17 | VimL: "let s:ctr_functions3 = filter(copy(s:ctr_functions2['functions']), 'get(v:val, "kind", "") == "constructor"') 18 | VimL: let s:ctr_functions3 = s:ctr_functions2.functions.filter({'kind': 'constructor'}) 19 | VimL: call extend(s:constructors, s:ctr_functions3) 20 | MuT: endif 21 | VimL: "let g:constructors3 = deepcopy(s:constructors) 22 | -------------------------------------------------------------------------------- /after/template/cpp/internals/namespace-name.template: -------------------------------------------------------------------------------- 1 | VimL:" Factorize namespace name "computation" 2 | MuT: let s:namespace = s:Param('namespace', '###') 3 | MuT: if (type(s:namespace) == type('')) && (s:namespace == '###') 4 | MuT: let s:namespace0 = lh#ft#option#get('project_namespace', &ft, lh#marker#txt('ns')) 5 | MuT: let s:namespace = type(s:namespace0) == type([]) ? join(s:namespace0, "::") : s:namespace0 6 | VimL: let s:namespace = lh#ui#input('Namespace name: ', s:namespace) 7 | MuT: endif 8 | -------------------------------------------------------------------------------- /after/template/cpp/internals/shall_explicit_defaults.template: -------------------------------------------------------------------------------- 1 | VimL:" shall_explicit_defaults File Template, Luc Hermitte , 26th Nov 2015 2 | VimL:" hint: wraps call to lh#cpp#snippets#shall_explicit_defaults() 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | MuT: if lh#cpp#snippets#shall_explicit_defaults() 8 | MuT: let default_explicit = {"visibility": "public", "how": "defaulted"} 9 | MuT: else 10 | MuT: let default_explicit = {"visibility": "none"} 11 | MuT: endif 12 | -------------------------------------------------------------------------------- /after/template/cpp/internals/stream-common.template: -------------------------------------------------------------------------------- 1 | VimL:" «stream-common» File Template, Luc Hermitte 2 | VimL: let s:reindent = 1 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:type = 'std::'.s:direction.'stream' 6 | VimL: let s:op = lh#ui#if(s:direction=='o', '<<', '>>') 7 | VimL: let s:const = lh#ui#if(s:direction=='o', 'const ', ' ') 8 | VimL: let s:clsname0 = Cpp_SearchClassDefinition(line('.')) 9 | VimL: let s:friend = lh#ui#if(strlen(s:clsname0), 'friend ', ' ') 10 | VimL: let s:clsname = lh#ui#input("Template\noperator".s:op." for the class:", s:clsname0) 11 | VimL: call s:Include('stream-signature', 'cpp/internals') 12 | VimL: call s:Include('stream-implementation', 'cpp/internals') 13 | <++> 14 | VimL: " Todo: check for context-namespaces and trim them from s:clsname 15 | VimL: " Todo: check for the previous class if s:clsname0 isempty 16 | VimL: " Todo: options for inline or not ; -> g:implPlace, ... 17 | VimL: " Todo: ask for simple or complex (Langer/Roguewave) inserter 18 | VimL: " Todo: Try to detect The attributes of the objet in order to generate the instruction. ; option: separator 19 | -------------------------------------------------------------------------------- /after/template/cpp/internals/stream-implementation.template: -------------------------------------------------------------------------------- 1 | VimL:" «stream-implementation» File Template, Luc Hermitte 2 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("<'.s:direction.'stream>")') 3 | { 4 | VimL: " The space for the second argument is madatory at the moment. 5 | return ¡s:stream_param.' '.s:op¡ <+fields+>; 6 | } 7 | -------------------------------------------------------------------------------- /after/template/cpp/internals/stream-signature.template: -------------------------------------------------------------------------------- 1 | VimL:" «stream-signature» File Template, Luc Hermitte, 04th Jun 2004 2 | VimL: let s:stream_param = lh#naming#param(s:direction."s") 3 | <+s:friend.s:type+> & operator<+s:op+>(¡s:type.' & '.s:stream_param¡, <+s:const.s:clsname+> & <+lh#naming#param("v")+>) 4 | -------------------------------------------------------------------------------- /after/template/cpp/iss.template: -------------------------------------------------------------------------------- 1 | VimL:" {istringstream iss(str); iss >>..} File Template, Luc Hermitte, 06th Dec 2010 2 | VimL:" hint: std::istringstream iss(str); if (iss >> ...) { ... } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_start = '¡' 5 | VimL: let s:value_end = s:value_start 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | std::istringstream iss(<++>); 10 | if (iss >> <++>) { 11 | <++> 12 | }<++> 13 | -------------------------------------------------------------------------------- /after/template/cpp/list.template: -------------------------------------------------------------------------------- 1 | VimL:" list File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::list<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::list<¡s:Surround(1, '<+type+>')¡> <++> 9 | -------------------------------------------------------------------------------- /after/template/cpp/map.template: -------------------------------------------------------------------------------- 1 | VimL:" map File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::map<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::map<¡s:Surround(1, '<+key+>')¡, ¡s:Surround(2, '<+value+>')¡><+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/namespace.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ namespace Template, Luc Hermitte 2 | VimL:" hint: namespace ns { ... } // ns 3 | VimL:" Options: 4 | VimL:" - snippet parameter: {'namespace' : xxx} 5 | VimL:" - (bg):[cpp_]project_namespace 6 | VimL:" - (bg):cpp_use_nested_namespace (bool) when [bg]:cpp_std_flavour=/CXXFLAGS/CMake match C++17 7 | VimL:" - lh#style options 8 | VimL: let s:value_start = '¡' 9 | VimL: let s:value_end = '¡' 10 | VimL: let s:reindent = 1 11 | VimL: let s:marker_open = '<+' 12 | VimL: let s:marker_close = '+>' 13 | VimL:" 14 | MuT: if ! exists('s:namespace') 15 | VimL: call s:Include('namespace-name', 'cpp/internals') 16 | MuT: endif 17 | MuT: let s:ns_join = lh#cpp#option#multiple_namespaces_on_same_line() 18 | MuT: if lh#cpp#use_cpp17() && lh#option#get('cpp_use_nested_namespaces', 1) 19 | MuT: let s:namespaces = type(s:namespace) == type([]) ? s:namespace : [s:namespace] 20 | MuT: else 21 | MuT: let s:namespaces = type(s:namespace) == type([]) ? s:namespace : split(s:namespace, "::") 22 | MuT: endif 23 | VimL: " let s:ns_open = s:namespace =~ '^\s*$' ? ["namespace{// Anonymous namespace"] : map(copy(s:namespaces), '"namespace ".v:val."{"') 24 | VimL: " let s:ns_close = s:namespace =~ '^\s*$' ? ["}// Anonymous namespace"] : map(copy(s:namespaces), '"}".(s:ns_join ? "" : " // ".v:val." namespace")') 25 | VimL: let s:ns_open = empty(s:namespaces) ? ["namespace{// Anonymous namespace"] : map(copy(s:namespaces), '"namespace ".v:val."{"') 26 | VimL: let s:ns_close = empty(s:namespaces) ? ["}// Anonymous namespace"] : map(copy(s:namespaces), '"}".(s:ns_join ? "" : "// ".v:val." namespace")') 27 | VimL: let s:ns_join_s = s:ns_join ? " " : "\n" 28 | <+join(s:ns_open, s:ns_join_s)+> 29 | MuT: let s:def_content = s:Param('content', lh#marker#txt()) 30 | ¡s:Surround(1, s:def_content)¡ 31 | MuT: let s:ns_comment = s:ns_join && !empty(s:namespaces) ? ("// ".join(s:namespaces, "::") . " namespace".(len(s:namespaces)>1 ? "s": "")) : "" 32 | <+join(s:ns_close, s:ns_join_s)+><+s:ns_comment+> 33 | MuT: if ! s:Param('included', 0) 34 | <+s:TerminalPlaceHolder()+> 35 | MuT: endif 36 | VimL: "<+join(s:ns_close, s:ns_join_s)+><+s:ns_join && s:namespace !~ '^\s*$'? (" // ".s:namespace . " namespace".(len(s:namespaces)>1 ? "s": "")) : ""+> 37 | -------------------------------------------------------------------------------- /after/template/cpp/noncopyable.template: -------------------------------------------------------------------------------- 1 | VimL:" noncopyable File Template, Luc Hermitte , 28th May 2014 2 | VimL:" hint: boost::noncopyable 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | boost::noncopyable 9 | -------------------------------------------------------------------------------- /after/template/cpp/operator-binary.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ binary operator snippet, Luc Hermitte, 30th Sep 2013 2 | VimL:" hint: operatorX(T lhs, T const& rhs) { return lhs X= rhs; } 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL:" 7 | VimL: "1- snippet parameters 8 | VimL: "1.1- classname 9 | VimL: "1.1.1- in case the class name is already known, no need to extract it 10 | MuT: let s:clsname = s:Param("clsname",join(s:CmdLineParams(), '')) 11 | MuT: if empty(s:clsname) 12 | VimL: "1.1.2- otherwise: we try to extract it 13 | MuT: let s:clsname = lh#cpp#AnalysisLib_Class#CurrentScope(line("."), "class") 14 | MuT: if empty(s:clsname) 15 | VimL: "1.1.3- otherwise, we try to get the name of the last class found 16 | MuT: let s:clsname = lh#cpp#AnalysisLib_Class#search_closest_class(line('.')) 17 | VimL: "1.1.4- otherwise, we ask it to the end-user, default = filename minus extensions 18 | MuT: if empty(s:clsname) 19 | MuT: let s:clsname = lh#ui#input("class name ?", lh#marker#txt(lh#naming#type(expand("%:t:r")))) 20 | MuT: endif 21 | MuT: let s:_friend = '' 22 | MuT: else 23 | MuT: let s:_friend = 'friend ' 24 | MuT: endif 25 | MuT: else 26 | MuT: let s:_friend = lh#marker#txt('friend ') 27 | MuT: endif 28 | VimL: "1.2- the operator 29 | MuT: let s:_op = s:Param('operator', lh#marker#txt('X')) 30 | VimL: "1.3- operator parameters 31 | MuT: let s:_lhs = lh#naming#param('lhs') 32 | MuT: let s:_rhs = lh#naming#param('rhs') 33 | VimL: " 34 | VimL:" 2- the code 35 | <+s:_friend+><+s:clsname+> operator<+s:_op+>(<+s:clsname+> <+s:_lhs+>, <+s:clsname+> const& <+s:_rhs+>){ return <+s:_lhs+> <+s:_op+>= <+s:_rhs+>; } 36 | -------------------------------------------------------------------------------- /after/template/cpp/oss.template: -------------------------------------------------------------------------------- 1 | VimL:"{std::ostringstream oss; oss << } Template-File, Luc Hermitte 2 | VimL:" hint: std::ostringstream oss; oss << ... 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | std::ostringstream oss; 10 | oss << <++>; 11 | <++> 12 | -------------------------------------------------------------------------------- /after/template/cpp/otb-sug-latex.template: -------------------------------------------------------------------------------- 1 | VimL:" $Id$ 2 | VimL:" otb-sug-latex File Template, Luc Hermitte, 21st May 2012 3 | VimL:" hint: Software Guide : BeginLatex 4 | VimL: let s:marker_open = '<+' 5 | VimL: let s:marker_close = '+>' 6 | // Software Guide : BeginLatex 7 | // 8 | ¡s:Surround(1, '// <+doc+>')¡ 9 | // 10 | // Software Guide : EndLatex 11 | -------------------------------------------------------------------------------- /after/template/cpp/otb-sug-snippet.template: -------------------------------------------------------------------------------- 1 | VimL:" $Id$ 2 | VimL:" otb-sug-snippet File Template, Luc Hermitte, 21st May 2012 3 | VimL:" hint: Software Guide : BeginCodeSnippet 4 | VimL: let s:marker_open = '<+' 5 | VimL: let s:marker_close = '+>' 6 | // Software Guide : BeginCodeSnippet 7 | ¡s:Surround(1, '<+code+>')¡ 8 | // Software Guide : EndCodeSnippet 9 | -------------------------------------------------------------------------------- /after/template/cpp/path.template: -------------------------------------------------------------------------------- 1 | VimL:" boost-path File Template, Luc Hermitte, 29th Apr 2014 2 | VimL:" hint: boost::filesystem::path 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | boost::filesystem::path<++> 9 | -------------------------------------------------------------------------------- /after/template/cpp/ptr_vector.template: -------------------------------------------------------------------------------- 1 | VimL:" ptr_vector File Template, Luc Hermitte , 22nd May 2014 2 | VimL:" hint: boost::ptr_vector<> 3 | VimL:" hint: std::vector<> 4 | VimL: let s:value_start = '¡' 5 | VimL: let s:value_end = s:value_start 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | boost::ptr_vector<¡s:Surround(1, '<+type+>')¡> <++> 10 | -------------------------------------------------------------------------------- /after/template/cpp/ref_setter.template: -------------------------------------------------------------------------------- 1 | VimL:" setter File Template, Luc Hermitte , 02nd Dec 2015 2 | VimL:" hint: void setFoo(T const& foo) { *m_foo = foo; } // for ptr attributes 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: "The interactive mode (w/ dynamic placeholders) won't permit to have "setFoo" and "return m_foo". 7 | MuT: let s:attribute = s:Param("attribute", {'type': lh#marker#txt(lh#naming#type('type')), 'name': lh#marker#txt('name')}) 8 | MuT: let s:attrb_name = s:attribute.name 9 | MuT: let s:attrb_param = lh#naming#param(s:attrb_name) 10 | MuT: if !lh#dev#cpp#types#IsPointer(s:attribute.type) 11 | VimL: throw "ref_setter snippet: ".s:attribute.type." is not recognized as a pointer type" 12 | MuT: else 13 | MuT: let s:in_type = lh#dev#cpp#types#remove_ptr(s:attribute.type) 14 | VimL: let s:in_type = lh#dev#cpp#types#const_correct_type(s:in_type) 15 | void <+lh#naming#setter(s:attrb_name)+>(<+s:in_type+> <+s:attrb_param+>){*<+lh#naming#member(s:attrb_name)+> = <+s:attrb_param+>;} 16 | MuT: endif 17 | -------------------------------------------------------------------------------- /after/template/cpp/scoped_ptr.template: -------------------------------------------------------------------------------- 1 | VimL:" scoped_ptr File Template, Luc Hermitte , jeu. 23 juin 2016 17:28:07 CEST 2 | VimL:" hint: boost::scoped_ptr<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | boost::scoped_ptr<¡s:Surround(1, '<+type+>')¡><+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/set.template: -------------------------------------------------------------------------------- 1 | VimL:" set File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::set<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::set<¡s:Surround(1, '<+type+>')¡><+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/setter.template: -------------------------------------------------------------------------------- 1 | VimL:" setter File Template, Luc Hermitte , 02nd Dec 2015 2 | VimL:" hint: void setFoo(T const& foo) { m_foo = foo; } 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: "The interactive mode (w/ dynamic placeholders) won't permit to have "setFoo" and "return m_foo". 7 | MuT: let s:attribute = s:Param("attribute", {'type': lh#marker#txt(lh#naming#type('type')), 'name': lh#marker#txt('name')}) 8 | MuT: let s:attrb_name = s:attribute.name 9 | MuT: let s:attrb_param = lh#naming#param(s:attrb_name) 10 | void <+lh#naming#setter(s:attrb_name)+>(<+lh#dev#cpp#types#const_correct_type(s:attribute.type)+> <+s:attrb_param+>){<+lh#naming#member(s:attrb_name)+> = <+s:attrb_param+>;} 11 | -------------------------------------------------------------------------------- /after/template/cpp/shared_ptr.template: -------------------------------------------------------------------------------- 1 | VimL:" shared_ptr File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std/boost::shared_ptr<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | MuT: if lh#cpp#use_cpp11() 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | std::shared_ptr<¡s:Surround(1, '<+type+>')¡> <++> 10 | MuT: else 11 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 12 | boost::shared_ptr<¡s:Surround(1, '<+type+>')¡> <++> 13 | MuT: endif 14 | -------------------------------------------------------------------------------- /after/template/cpp/sort.template: -------------------------------------------------------------------------------- 1 | VimL:" std::sort File Template, Luc Hermitte, 28th May 2015 2 | VimL:" hint: std::sort(range.begin(), range.end()); 3 | VimL:" todo: support for std::begin() and std::end() 4 | VimL: let s:value_start = '¡' 5 | VimL: let s:value_end = s:value_start 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: let s:reindent = 1 9 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 10 | VimL: let s:range = s:Surround(1, s:Param('range', lh#marker#txt('range'))) 11 | std::sort(<+s:range+>.begin(),<+s:range+>.end()); 12 | VimL: unlet s:range 13 | -------------------------------------------------------------------------------- /after/template/cpp/starts_with.template: -------------------------------------------------------------------------------- 1 | VimL:" starts_with File Template, Luc Hermitte , 28th May 2014 2 | VimL:" hint: boost::algorithm::starts_with 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | boost::algorithm::starts_with(<+input+>, <+prefix_searched+>) 9 | -------------------------------------------------------------------------------- /after/template/cpp/static_assert.template: -------------------------------------------------------------------------------- 1 | VimL:" static_assert File Template, Luc Hermitte, 23rd Apr 2014 2 | VimL:" hint: static_assert(cond, msg)/BOOST_STATIC_ASSERT(cond) 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: let s:_condition = s:Param('condition', lh#marker#txt("condition")) 7 | VimL: let s:_message = s:Param('message', lh#marker#txt("message")) 8 | MuT: if lh#cpp#use_cpp11() 9 | static_assert(<+s:_condition+>, <+s:_message+>); 10 | MuT: else 11 | BOOST_STATIC_ASSERT(<+s:_condition+>); 12 | VimL: call s:AddPostExpandCallback(lh#dev#import#add("")) 13 | MuT: endif 14 | -------------------------------------------------------------------------------- /after/template/cpp/stream-extractor.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ stream-extractor (operator>>) Template, Luc Hermitte, 04th Jun 2004 2 | VimL:" hint: istream& operator>>(istream &, class-type) 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:direction = 'i' 6 | VimL: call s:Include('stream-common', 'cpp/internals') 7 | -------------------------------------------------------------------------------- /after/template/cpp/stream-inserter.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ stream-inserter (operator<<) Template, Luc Hermitte, 04th Jun 2004 2 | VimL:" hint: ostream& operator<<(ostream &, class-type) 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:direction = 'o' 6 | VimL: call s:Include('stream-common', 'cpp/internals') 7 | -------------------------------------------------------------------------------- /after/template/cpp/string.template: -------------------------------------------------------------------------------- 1 | VimL:" string File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::string 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 6 | std::string<+s:TerminalPlaceHolder()+> 7 | -------------------------------------------------------------------------------- /after/template/cpp/swap-function.template: -------------------------------------------------------------------------------- 1 | VimL:" swap-function File Template, Luc Hermitte , mar. 22 déc. 2015 11:34:40 CET 2 | VimL:" hint: void swap(T & other) 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: call s:Include('get-class-name', 'cpp/internals') 6 | MuT: let s:param_name = lh#naming#param("other") 7 | VimL: let s:fn_comments = lh#dox#new_function("Swap operation.") 8 | VimL: let s:fn_comments.throw = ["None"] 9 | VimL: let s:fn_comments.param = [{'name': s:param_name, 'text': "data with which content is swapped", 'dir': 'in,out'}] 10 | VimL: call s:Include("function-comment", "cpp/internals",s:fn_comments) 11 | VimL: " If parameters are known => swap them! 12 | MuT: let s:attributes = s:Param("attributes", lh#option#unset()) 13 | MuT: if lh#option#is_set(s:attributes) && !empty(s:attributes) 14 | MuT: let s:definition = "{using std::swap;\n" 15 | VimL: let s:definition .= join(map(copy(s:attributes), '"swap(".lh#naming#member(v:val.name).", ".s:param_name.".".lh#naming#member(v:val.name).");"'), "\n") 16 | VimL: let s:definition .= '}' 17 | MuT: else 18 | MuT: let s:definition = ';' 19 | MuT: endif 20 | void swap(<+s:clsname+> & <+s:param_name+>) <+lh#cpp#snippets#noexcept()+><+s:definition+> 21 | -------------------------------------------------------------------------------- /after/template/cpp/throw.template: -------------------------------------------------------------------------------- 1 | VimL:"{throw default exceptions for project} Template-File, Luc Hermitte 2 | VimL:" hint: throw std::runtime_error/@throw (depending on context) 3 | VimL:" 4 | VimL:" This snippet supports options: 5 | VimL:" - b:exception_type in the form of a string 6 | VimL:" - b:exception_args in the form of lh#function: 7 | VimL:" e.g.: let b:exception_args = 'v:1_.lh#marker#txt(", ".b:cpp_project_namespace."::ExitCode::")' 8 | VimL:" This functor takes a parameter that will get injected in place of v:1_ 9 | VimL:" e.g. VimL: call s:Include('throw', 'cpp', '"Cannot decode'.s:enum_name.'"') 10 | VimL:" Note: If you want to dynamically adapt to the current marcher 11 | VimL:" characters, or the current b:cpp_project_namespace option, don't use `string()` 12 | VimL:" in expressions like: 13 | VimL:" :let b:exception_args = 'v:1_.'.string(lh#marker#txt(', '.b:cpp_project_namespace.'::ExitCode::')) 14 | VimL:" 15 | VimL: let s:reindent = 1 16 | VimL: let s:marker_open = '<+' 17 | VimL: let s:marker_close = '+>' 18 | MuT: let s:_exception_type = lh#ft#option#get('exception_type', &ft, 'std::runtime_error') 19 | MuT: let s:_exception_txt = empty(s:CmdLineParams()) ? lh#marker#txt('text') : (s:CmdLineParams()[0]) 20 | MuT: let s:_exception_args = lh#function#bind(lh#ft#option#get('exception_args', &ft, 'v:1_')) 21 | MuT: if synIDattr(synID(line('.'),col('.')-1,1),'name') =~ 'doxygen\|comment' 22 | <+lh#dox#throw(lh#marker#txt(s:_exception_type))+><++> 23 | MuT: else 24 | MuT: if s:_exception_type =~ 'std::.*' 25 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 26 | MuT: endif 27 | throw <+s:_exception_type+>(<+lh#function#execute(s:_exception_args, s:_exception_txt)+>);<++> 28 | MuT: endif 29 | VimL: unlet s:_exception_type 30 | VimL: unlet s:_exception_txt 31 | VimL: unlet s:_exception_args 32 | -------------------------------------------------------------------------------- /after/template/cpp/traits.template: -------------------------------------------------------------------------------- 1 | VimL:" traits-class File Template, Luc Hermitte, 20th Jan 2011 2 | VimL:" hint: traits-class 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_start = '¡' 5 | VimL: let s:value_end = s:value_start 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | /** <+name+> traits class. 9 | */ 10 | template > struct <+name+>_traits 11 | { 12 | <++> 13 | }; 14 | 15 | /** <+name+> traits class specialization for \c <+spe+>. 16 | */ 17 | VimL: " todo: auto deduce the overridable traits 18 | template <> struct <+name+>_traits<<+spe+>> 19 | { 20 | <++> 21 | }; 22 | -------------------------------------------------------------------------------- /after/template/cpp/try.template: -------------------------------------------------------------------------------- 1 | VimL:"{try{...}catch(){...}} Template-File, Luc Hermitte 2 | VimL:" hint: try { ... } catch(...) { ... } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | try{ 9 | ¡s:Surround(1, '<+code+>')¡ 10 | }catch(<+std::exception const& e+>){ 11 | ¡s:Surround(2, '<+catch-code+>')¡ 12 | } <+s:TerminalPlaceHolder()+> 13 | -------------------------------------------------------------------------------- /after/template/cpp/typeid.template: -------------------------------------------------------------------------------- 1 | VimL:" typeid File Template, Luc Hermitte , jeu. 31 mars 2016 11:38:16 CEST 2 | VimL:" hint: typeid(<++>).name() 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | typeid(<+s:SurroundableParam("type", 1)+>).name()<+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/unique_ptr.template: -------------------------------------------------------------------------------- 1 | VimL:" unique_ptr File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::unique_ptr<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::unique_ptr<¡s:Surround(1, '<+type+>')¡> <++> 9 | -------------------------------------------------------------------------------- /after/template/cpp/unordered_map.template: -------------------------------------------------------------------------------- 1 | VimL:" unordered_map File Template, Luc Hermitte, 07th Oct 2017 2 | VimL:" hint: std::unordered_map 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::unordered_map<¡s:Surround(1, '<+key+>')¡, ¡s:Surround(2, '<+value+>')¡><+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/unordered_set.template: -------------------------------------------------------------------------------- 1 | VimL:" unordered_set File Template, Luc Hermitte, 07th Oct 2017 2 | VimL:" hint: std::unordered_map 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 8 | std::unordered_set<¡s:Surround(1, '<+type+>')¡><+s:TerminalPlaceHolder()+> 9 | -------------------------------------------------------------------------------- /after/template/cpp/utf8.template: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/after/template/cpp/utf8.template -------------------------------------------------------------------------------- /after/template/cpp/value-class.template: -------------------------------------------------------------------------------- 1 | VimL:" value-class File Template, Luc Hermitte , 25th Nov 2015 2 | VimL:" hint: Value Class ((implicitly) copyable, no hierarchy) 3 | MuT: let s:destructor = s:Param("destructor", {}) 4 | VimL: if get(s:destructor, 'virtual', 0) | throw "Value classes aren't expected to belong to polymorphic hierarchies" | endif 5 | VimL: " --- in case the class name is already known, no need to extract it 6 | VimL: call s:Include('get-class-name', 'cpp/internals') 7 | VimL: " --- Defines Doxygen comments 8 | MuT: let s:parameters = s:Param('cls_parameters', {}) 9 | VimL: call lh#dict#add_new(s:parameters, {'comments': {}, 'copyable': 1}) 10 | MuT: let s:cls_comments = s:parameters.comments 11 | VimL: let s:cls_comments.semantics = get(s:cls_comments, 'semantics', []) 12 | VimL: let s:cls_comments.semantics += ['Value object',lh#marker#txt('Regular object'),lh#marker#txt('Comparable')] 13 | VimL: " --- Force special functions 14 | VimL: " TODO: detect when the class has no declared attribute. Propose to force the generation of empty shells for the special functions in case the object will contain non-copyable attributes 15 | VimL: " --- Insert the skeleton built 16 | VimL: call s:Include('class-skeleton', 'cpp/internals', s:parameters) 17 | -------------------------------------------------------------------------------- /after/template/cpp/vector.template: -------------------------------------------------------------------------------- 1 | VimL:" vector File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std::vector<> 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 6 | MuT: let s:type = s:SurroundableParam('type', 1) 7 | std::vector<<+s:type+>> <+s:TerminalPlaceHolder()+> 8 | -------------------------------------------------------------------------------- /after/template/cpp/weak_ptr.template: -------------------------------------------------------------------------------- 1 | VimL:" weak_ptr File Template, Luc Hermitte, 28th Apr 2014 2 | VimL:" hint: std/boost::weak_ptr<> 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | MuT: if lh#cpp#use_cpp11() 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | std::weak_ptr<¡s:Surround(1, '<+type+>')¡> <++> 10 | MuT: else 11 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 12 | boost::weak_ptr<¡s:Surround(1, '<+type+>')¡> <++> 13 | MuT: endif 14 | -------------------------------------------------------------------------------- /after/template/cpp/while-getline.template: -------------------------------------------------------------------------------- 1 | VimL:" while-getline File Template, Luc Hermitte, 06th Sep 2012 2 | VimL:" hint: while(std::getline(stream,line)) { action; } 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | VimL: let s:reindent = 1 8 | VimL: call s:AddPostExpandCallback('lh#dev#import#add("")') 9 | while(std::getline(<+stream+>, <+line+>)){ 10 | ¡s:Surround(1, '<+code+>')¡ 11 | }<+s:TerminalPlaceHolder()+> 12 | -------------------------------------------------------------------------------- /after/template/dox/author.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ Doxygen snippet for authors, Luc Hermitte 2 | VimL:" hint: @author 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | <+lh#dox#author()+> 7 | -------------------------------------------------------------------------------- /after/template/dox/code.template: -------------------------------------------------------------------------------- 1 | VimL:" doxygen File Template, Luc Hermitte, 11th Apr 2012 2 | VimL:" hint: | 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | VimL: let s:code = s:Param("code", lh#marker#txt()) 7 | VimL: let s:text = s:Surround(1, s:code) 8 | <+lh#dox#tag("code")+> 9 | VimL: unlet s:code 10 | VimL: unlet s:text 11 | -------------------------------------------------------------------------------- /after/template/dox/em.template: -------------------------------------------------------------------------------- 1 | VimL:" doxygen snippet, Luc Hermitte, 11th Apr 2012 2 | VimL:" hint: | 3 | VimL: let s:text = s:Surround(1, lh#marker#txt()) 4 | <+s:text+><+s:TerminalPlaceHolder()+> 5 | -------------------------------------------------------------------------------- /after/template/dox/file.template: -------------------------------------------------------------------------------- 1 | VimL:" dox/file Template, Luc Hermitte 2 | VimL:" hint: /** @file ... */ 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = '¡' 5 | VimL: let s:reindent = 1 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL:" 9 | /**<+lh#dox#tag("ingroup")+> g¡lh#option#get('dox_group', '<+Projet+>')¡ 10 | * <+lh#dox#tag("file")+> ¡expand('%:t')¡ 11 | * <+lh#dox#author()+> 12 | * <+lh#dox#tag("version")+> ¡'$'¡Revision$ 13 | * <+lh#dox#since()+> 14 | * ¡'$'¡Id$ 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /after/template/dox/function.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ Doxygen snippet for functions, Luc Hermitte 2 | VimL:" Meant to be used through the command :DOX 3 | VimL:" hint: /** @ingroup, @params, @exceptions, ... */ 4 | VimL:" TODO: rewrite to rely on function-comment.template 5 | VimL: let s:value_start = '¡' 6 | VimL: let s:value_end = '¡' 7 | VimL: let s:reindent = 1 8 | VimL: let s:marker_open = '<+' 9 | VimL: let s:marker_close = '+>' 10 | /**¡CppDox_snippet('ingroup', '')¡ 11 | ¡CppDox_snippet('brief', '* ')¡ 12 | * <+details+> 13 | ¡CppDox_snippet('Params', '* ')¡ 14 | * 15 | ¡CppDox_snippet('return', '* ')¡ 16 | ¡CppDox_snippet('exceptions', '* ')¡ 17 | ¡CppDox_snippet('preconditions', '* ')¡ 18 | */ 19 | -------------------------------------------------------------------------------- /after/template/dox/group.template: -------------------------------------------------------------------------------- 1 | VimL:" Doxygen local group File-Template, Luc Hermitte, 26th Jan 2011 2 | VimL:" hint: Doxygen local group 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | VimL: let s:reindent = 1 6 | /**<+lh#dox#tag("name ")+><+group-name+> */ 7 | MuT: let s:text = s:Surround(1, "<++>") 8 | VimL: let s:text = s:text != "<++>" ? ("\n".s:text) : lh#marker#txt() 9 | //@{<+s:text+> 10 | //@}<+s:TerminalPlaceHolder()+> 11 | -------------------------------------------------------------------------------- /after/template/dox/html.template: -------------------------------------------------------------------------------- 1 | VimL:" doxygen <+html+> snippets, Luc Hermitte, 11th Apr 2012 2 | VimL:" hint: | 3 | VimL: let s:marker_open = '<+' 4 | VimL: let s:marker_close = '+>' 5 | MuT: let s:text = s:Surround(1, lh#marker#txt()) 6 | MuT: let s:tag = s:Surround(2, lh#marker#txt("html")) 7 | <<+s:tag+>><+s:text+>><+s:TerminalPlaceHolder()+> 8 | -------------------------------------------------------------------------------- /after/template/dox/ingroup.template: -------------------------------------------------------------------------------- 1 | VimL:" $Id$ 2 | VimL:" dox/ingroup File Template, Luc Hermitte, 23rd Dec 2013 3 | VimL:" hint: /**@ingroup ... */ 4 | VimL: let s:value_start = '¡' 5 | VimL: let s:value_end = s:value_start 6 | VimL: let s:marker_open = '<+' 7 | VimL: let s:marker_close = '+>' 8 | VimL: let s:reindent = 1 9 | VimL:" 10 | /**<+lh#dox#tag("ingroup")+> g¡lh#option#get('dox_group', '<+Projet+>')¡ 11 | */<++> 12 | -------------------------------------------------------------------------------- /after/template/dox/since.template: -------------------------------------------------------------------------------- 1 | VimL:" C++ Doxygen snippet for since tag, Luc Hermitte 2 | VimL:" hint: @since Version 3 | VimL: let s:value_start = '¡' 4 | VimL: let s:value_end = s:value_start 5 | VimL: let s:marker_open = '<+' 6 | VimL: let s:marker_close = '+>' 7 | <+lh#dox#since()+> 8 | -------------------------------------------------------------------------------- /after/template/dox/tt.template: -------------------------------------------------------------------------------- 1 | VimL:" doxygen File Template, Luc Hermitte, 11th Apr 2012 2 | VimL:" hint: | 3 | MuT: let s:text = s:Surround(1, lh#marker#txt()) 4 | <+s:text+><+s:TerminalPlaceHolder()+> 5 | -------------------------------------------------------------------------------- /autoload/lh/cpp/UnmatchedFunctions.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/autoload/lh/cpp/UnmatchedFunctions.vim -------------------------------------------------------------------------------- /autoload/lh/cpp/abs_rel.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/autoload/lh/cpp/abs_rel.vim -------------------------------------------------------------------------------- /autoload/lh/cpp/ftplugin.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: autoload/lh/cpp/ftplugin.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.0.0 8 | " Created: 11th Sep 2008 9 | " Last Update: $Date$ 10 | "------------------------------------------------------------------------ 11 | " Description: 12 | " Provides lh#cpp#ftplugin#OptionalClass(...) that can be used to write 13 | " :commands in ftplugins that tries to deduce the name of the current 14 | " class if none is provided. 15 | " }}}1 16 | "============================================================================= 17 | 18 | let s:cpo_save=&cpo 19 | set cpo&vim 20 | "------------------------------------------------------------------------ 21 | " ## Functions {{{1 22 | " # Debug {{{2 23 | function! lh#cpp#ftplugin#verbose(level) 24 | let s:verbose = a:level 25 | endfunction 26 | 27 | function! s:Verbose(expr) 28 | if exists('s:verbose') && s:verbose 29 | echomsg a:expr 30 | endif 31 | endfunction 32 | 33 | function! lh#cpp#ftplugin#debug(expr) 34 | return eval(a:expr) 35 | endfunction 36 | 37 | "------------------------------------------------------------------------ 38 | " # Public {{{2 39 | function! lh#cpp#ftplugin#OptionalClass(...) 40 | if a:0 != 0 41 | if type(a:1) == type("") && strlen(a:1)>0 42 | return a:1 43 | elseif type(a:1) == type([]) 44 | if len(a:1) > 0 && strlen(a:1[0]) > 0 45 | return a:1[0] 46 | endif 47 | endif 48 | endif 49 | 50 | let classname = lh#cpp#AnalysisLib_Class#CurrentScope(line('.'),'class') 51 | return classname 52 | endfunction 53 | 54 | "------------------------------------------------------------------------ 55 | let &cpo=s:cpo_save 56 | "============================================================================= 57 | " vim600: set fdm=marker: 58 | -------------------------------------------------------------------------------- /autoload/lh/cpp/libclang.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: autoload/lh/cpp/libclang.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.2.1. 8 | let s:k_version = '221' 9 | " Created: 28th Nov 2019 10 | " Last Update: 28th Nov 2019 11 | "------------------------------------------------------------------------ 12 | " Description: 13 | " Adapt results from vim-clang 14 | " 15 | "------------------------------------------------------------------------ 16 | " History: «history» 17 | " TODO: «missing features» 18 | " }}}1 19 | "============================================================================= 20 | 21 | if ! (lh#has#plugin('autoload/clang.vim') && clang#can_plugin_be_used()) 22 | finish 23 | endif 24 | 25 | let s:cpo_save=&cpo 26 | set cpo&vim 27 | 28 | let s:k_has_compil_hints = lh#has#plugin('autoload/lh/compil_hints.vim') 29 | "------------------------------------------------------------------------ 30 | " ## Misc Functions {{{1 31 | " # Version {{{2 32 | function! lh#cpp#libclang#version() 33 | return s:k_version 34 | endfunction 35 | 36 | " # Debug {{{2 37 | let s:verbose = get(s:, 'verbose', 0) 38 | function! lh#cpp#libclang#verbose(...) 39 | if a:0 > 0 | let s:verbose = a:1 | endif 40 | return s:verbose 41 | endfunction 42 | 43 | function! s:Log(expr, ...) abort 44 | call call('lh#log#this',[a:expr]+a:000) 45 | endfunction 46 | 47 | function! s:Verbose(expr, ...) abort 48 | if s:verbose 49 | call call('s:Log',[a:expr]+a:000) 50 | endif 51 | endfunction 52 | 53 | function! lh#cpp#libclang#debug(expr) abort 54 | return eval(a:expr) 55 | endfunction 56 | 57 | 58 | "------------------------------------------------------------------------ 59 | " ## API functions {{{1 60 | " # Ancestors {{{2 61 | function! s:add_info_to_qf(qf, balloons, info, level, balloon_ctx) abort " {{{3 62 | let info = a:info.location 63 | let info.text = a:level. '+- '.a:info.access.' '.a:info.spelling 64 | call add(a:qf, info) 65 | let balloon_ctx = ' : '.a:info.access.' '.a:info.spelling . a:balloon_ctx 66 | call add(a:balloons, balloon_ctx) 67 | if has_key(a:info, 'parents') 68 | call map(copy(a:info.parents), 's:add_info_to_qf(a:qf, a:balloons, v:val, "| ".a:level, balloon_ctx)') 69 | endif 70 | endfunction 71 | 72 | " Function: lh#cpp#libclang#show_ancestors(...) {{{3 73 | " TODO: 74 | " - Support to pass an optional class name 75 | " - Add option to choose qflist or loclist 76 | function! lh#cpp#libclang#show_ancestors(...) abort 77 | let [parents, current] = clang#parents() 78 | let qf = [] 79 | let qf += [extend(current.location, {'text': current.name})] 80 | let balloons = [' : inspected leaf'] 81 | call map(copy(parents), 's:add_info_to_qf(qf, balloons, v:val, "", "")') 82 | call setqflist(qf) 83 | if lh#has#properties_in_qf() 84 | call setqflist([], 'a', {'title': current.name . ' base classes'}) 85 | if s:k_has_compil_hints 86 | call lh#compil_hints#set_balloon_format({k, v -> l:current.name . l:balloons[v.key]}) 87 | endif 88 | endif 89 | if exists(':Copen') 90 | Copen 91 | else 92 | copen 93 | endif 94 | endfunction 95 | 96 | "------------------------------------------------------------------------ 97 | " ## Internal functions {{{1 98 | 99 | "------------------------------------------------------------------------ 100 | " }}}1 101 | "------------------------------------------------------------------------ 102 | let &cpo=s:cpo_save 103 | "============================================================================= 104 | " vim600: set fdm=marker: 105 | -------------------------------------------------------------------------------- /autoload/lh/cpp/macros.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: autoload/lh/cpp/macros.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0. 6 | let s:k_version = '220' 7 | " Created: 30th Jun 2016 8 | " Last Update: 30th Jun 2016 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " API related to C and C++ macros 12 | " 13 | "------------------------------------------------------------------------ 14 | " History: «history» 15 | " TODO: «missing features» 16 | " }}}1 17 | "============================================================================= 18 | 19 | let s:cpo_save=&cpo 20 | set cpo&vim 21 | "------------------------------------------------------------------------ 22 | " ## Misc Functions {{{1 23 | " # Version {{{2 24 | function! lh#cpp#macros#version() 25 | return s:k_version 26 | endfunction 27 | 28 | " # Debug {{{2 29 | let s:verbose = get(s:, 'verbose', 0) 30 | function! lh#cpp#macros#verbose(...) 31 | if a:0 > 0 | let s:verbose = a:1 | endif 32 | return s:verbose 33 | endfunction 34 | 35 | function! s:Log(expr, ...) 36 | call call('lh#log#this',[a:expr]+a:000) 37 | endfunction 38 | 39 | function! s:Verbose(expr, ...) 40 | if s:verbose 41 | call call('s:Log',[a:expr]+a:000) 42 | endif 43 | endfunction 44 | 45 | function! lh#cpp#macros#debug(expr) abort 46 | return eval(a:expr) 47 | endfunction 48 | 49 | 50 | "------------------------------------------------------------------------ 51 | " ## Exported functions {{{1 52 | 53 | " # Clean `#if` 54 | " Function: lh#cpp#macros#keep(bool) {{{3 55 | " Remove the true/false path into a `#if ... #else ... #endif` construct 56 | " TODO: support `defined(...)`, `#elif`, ... 57 | function! lh#cpp#macros#keep(bool) abort 58 | " 0- Requirements 59 | " 0.1- Check matchit is installed 60 | if !exists('g:loaded_matchit') 61 | runtime macros/matchit.vim 62 | if !exists('g:loaded_matchit') 63 | throw 'Cannot trim `#if..#else..#endif` path without matchit' 64 | endif 65 | endif 66 | " 0.2- Be sure we're on the `#if 0/1` line 67 | let line = getline('.') 68 | if line !~ '\v^#\s*if\s+[01]' 69 | throw 'Cursor not on a `#if 0|1` line. Cannot trim paths.' 70 | endif 71 | 72 | " 1- Note line numbers 73 | normal! ^ 74 | let l_if = line('.') 75 | normal % 76 | let l = line('.') 77 | if getline(l) =~ '\v^#\s*else' 78 | let l_else = l 79 | normal % 80 | let l = line('.') 81 | endif " Not an elif here! 82 | if getline(l) !~ '\v^#\s*endif' 83 | throw '`#endif` expected (`#elif` is not supported yet)' 84 | endif 85 | let l_endif = line('.') 86 | 87 | " 2- Trim (starting from the end) 88 | let keep_start = (line =~ '\v^#\s*if\s+1') == eval(a:bool) 89 | let l_last_if = keep_start ? l_if : l_else 90 | let l_first_else = keep_start ? l_else : l_endif 91 | call s:Verbose('Keeping the `#%1` case -- :%2,%3d | %4,%5d', keep_start ? 'if' : 'else', l_first_else, l_endif, l_if, l_last_if) 92 | silent! exe l_first_else.','.l_endif.'d _' 93 | silent! exe l_if.','.l_last_if.'d _' 94 | endfunction 95 | 96 | "------------------------------------------------------------------------ 97 | " ## Internal functions {{{1 98 | 99 | "------------------------------------------------------------------------ 100 | " }}}1 101 | "------------------------------------------------------------------------ 102 | let &cpo=s:cpo_save 103 | "============================================================================= 104 | " vim600: set fdm=marker: 105 | -------------------------------------------------------------------------------- /autoload/lh/cpp/option.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: autoload/lh/cpp/option.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0 6 | " Created: 05th Apr 2012 7 | " Last Update: 08th Mar 2018 8 | "------------------------------------------------------------------------ 9 | " Description: 10 | " Options for lh-cpp 11 | " 12 | " Deprecated: 13 | " This nl_before_bracket API has been deprecated in favour of AddStyle! 14 | " 15 | "------------------------------------------------------------------------ 16 | " Installation: 17 | " Drop this file into {rtp}/autoload/lh/cpp 18 | " Requires Vim7+, lh-dev 19 | " }}}1 20 | "============================================================================= 21 | 22 | let s:cpo_save=&cpo 23 | set cpo&vim 24 | "------------------------------------------------------------------------ 25 | " ## Misc Functions {{{1 26 | " # Version {{{2 27 | let s:k_version = 2 28 | function! lh#cpp#option#version() 29 | return s:k_version 30 | endfunction 31 | 32 | " # Debug {{{2 33 | let s:verbose = 0 34 | function! lh#cpp#option#verbose(...) 35 | if a:0 > 0 | let s:verbose = a:1 | endif 36 | return s:verbose 37 | endfunction 38 | 39 | function! s:Verbose(expr) 40 | if s:verbose 41 | echomsg a:expr 42 | endif 43 | endfunction 44 | 45 | function! lh#cpp#option#debug(expr) 46 | return eval(a:expr) 47 | endfunction 48 | 49 | 50 | "------------------------------------------------------------------------ 51 | " ## Exported functions {{{1 52 | 53 | " # Preferences regarding how control statements are expanded {{{2 54 | " Possible values: 0 (default)/1 55 | " Applies to: if (){}, else{}, for (;;){}, while(){}, switch, catch, ... 56 | 57 | 58 | " Function: lh#cpp#option#nl_before_bracket() {{{3 59 | " Write each '(' on a new line; -> if \n() ... {} 60 | function! lh#cpp#option#nl_before_bracket() 61 | call s:Deprecated() 62 | return lh#ft#option#get('nl_before_bracket', &ft, 0) 63 | endfunction 64 | 65 | " Function: lh#cpp#option#nl_before_curlyB() {{{3 66 | " Write each '{' on a new line; -> if ...() \n {} 67 | function! lh#cpp#option#nl_before_curlyB() 68 | call s:Deprecated() 69 | return lh#ft#option#get('nl_before_curlyB', &ft, 0) 70 | endfunction 71 | 72 | " Function: lh#cpp#option#multiple_namespace_on_same_line() {{{3 73 | " Write each "namespace Foo {" on a same line 74 | function! lh#cpp#option#multiple_namespaces_on_same_line() 75 | return lh#ft#option#get('multiple_namespaces_on_same_line', &ft, 1) 76 | endfunction 77 | "------------------------------------------------------------------------ 78 | " ## Internal functions {{{1 79 | 80 | " # Deprecated {{{2 81 | let s:deprecated_notified = 0 82 | function! s:Deprecated() 83 | echomsg "lh#cpp#option#nl_before_bracket() API has been deprecated, please use lh#style#*() and AddStyle instead." 84 | let s:deprecated_notified = 1 85 | endfunction 86 | 87 | " }}}1 88 | "------------------------------------------------------------------------ 89 | let &cpo=s:cpo_save 90 | "============================================================================= 91 | " vim600: set fdm=marker: 92 | -------------------------------------------------------------------------------- /autoload/lh/cpp/override.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/autoload/lh/cpp/override.vim -------------------------------------------------------------------------------- /autoload/lh/cpp/scope.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: autoload/lh/cpp/scope.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.0.0b10 6 | " Created: 25th Jun 2014 7 | " Last Update: $Date$ 8 | "------------------------------------------------------------------------ 9 | " Description: 10 | " Support autoload plugin for ftplugin/cpp/cpp_AddMissingScope.vim 11 | " }}}1 12 | "============================================================================= 13 | 14 | let s:cpo_save=&cpo 15 | set cpo&vim 16 | "------------------------------------------------------------------------ 17 | " ## Misc Functions {{{1 18 | " # Version {{{2 19 | let s:k_version = 200 20 | function! lh#cpp#scope#version() 21 | return s:k_version 22 | endfunction 23 | 24 | " # Debug {{{2 25 | let s:verbose = 0 26 | function! lh#cpp#scope#verbose(...) 27 | if a:0 > 0 | let s:verbose = a:1 | endif 28 | return s:verbose 29 | endfunction 30 | 31 | function! s:Verbose(expr) 32 | if s:verbose 33 | echomsg a:expr 34 | endif 35 | endfunction 36 | 37 | function! lh#cpp#scope#debug(expr) 38 | return eval(a:expr) 39 | endfunction 40 | 41 | 42 | "------------------------------------------------------------------------ 43 | " ## API functions {{{1 44 | " Function: lh#cpp#scope#_add_missing() {{{3 45 | function! lh#cpp#scope#_add_missing() abort 46 | let [id, info] = lh#cpp#tags#fetch("add-missing-scope") 47 | try 48 | 49 | " Filter out constructors 50 | let isk_save = &isk 51 | set isk-=: 52 | call filter(info, "! (v:val.kind =~ 'f' && v:val.name=~'.*\\<\\(\\k\\+\\)::\\1')") 53 | 54 | " Build the list of names 55 | let names = {} 56 | for t in info 57 | if ! has_key(names, t.name) 58 | let names[t.name] = {} 59 | endif 60 | let names[t.name][t.kind[0]] = '' 61 | endfor 62 | 63 | " Check the number of possible choices 64 | if len(info) > 1 65 | call lh#common#error_msg("add-missing-scope: too many acceptable tags for `" 66 | \ .id."': ".string(names)) 67 | return 68 | endif 69 | 70 | let name = keys(names)[0] 71 | 72 | if name == id 73 | call lh#common#warning_msg("add-missing-scope: `".id."' is already expanded") 74 | return 75 | endif 76 | 77 | " build the new line 78 | set isk+=: 79 | let line = getline('.') 80 | let head = matchstr(line[:col('.')-1], '.*\ze\<\k\+$') 81 | let tail = line[lh#encoding#strlen(head):] 82 | let missing = matchstr(name, '.*\ze'.id) 83 | call setline(line('.'), head.missing.tail) 84 | finally 85 | let &isk = isk_save 86 | endtry 87 | endfunction 88 | "------------------------------------------------------------------------ 89 | " ## Exported functions {{{1 90 | 91 | "------------------------------------------------------------------------ 92 | " ## Internal functions {{{1 93 | 94 | "------------------------------------------------------------------------ 95 | let &cpo=s:cpo_save 96 | "============================================================================= 97 | " vim600: set fdm=marker: 98 | -------------------------------------------------------------------------------- /autoload/lh/cpp/style.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: autoload/lh/cpp/style.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.0.0 8 | " Created: 10th Feb 2009 9 | " Last Update: 08th Mar 2018 10 | "------------------------------------------------------------------------ 11 | " Description: 12 | " General coding style functions 13 | " 14 | "------------------------------------------------------------------------ 15 | " History: 16 | " v1.1.0: Creation 17 | " v2.0.0: License GPLv3 w/ extension 18 | " TODO: 19 | " - Refactor to build on top of lh#dev 20 | " - Integrate style preferences used by InsertAccessors 21 | " }}}1 22 | "============================================================================= 23 | 24 | let s:cpo_save=&cpo 25 | set cpo&vim 26 | "------------------------------------------------------------------------ 27 | 28 | " ## Functions {{{1 29 | " # Debug {{{2 30 | function! lh#cpp#style#verbose(level) 31 | let s:verbose = a:level 32 | endfunction 33 | 34 | function! s:Verbose(expr) 35 | if exists('s:verbose') && s:verbose 36 | echomsg a:expr 37 | endif 38 | endfunction 39 | 40 | function! lh#cpp#style#debug(expr) 41 | return eval(a:expr) 42 | endfunction 43 | 44 | " # Style accessors {{{2 45 | function! lh#cpp#style#get(datakind, pos) 46 | let value = lh#option#get(a:datakind.a:pos, '') 47 | return value 48 | endfunction 49 | 50 | " # Names conversion {{{2 51 | " Function: lh#cpp#style#attribute2parameter_name(attrb_name) {{{3 52 | function! lh#cpp#style#attribute2parameter_name(attrb_name) 53 | let core_name = lh#naming#variable(a:attrb_name) 54 | let param_name = lh#naming#param(core_name) 55 | if param_name == a:attrb_name 56 | let param_name = lh#marker#txt(param_name) 57 | endif 58 | return param_name 59 | endfunction 60 | 61 | "------------------------------------------------------------------------ 62 | let &cpo=s:cpo_save 63 | "============================================================================= 64 | " vim600: set fdm=marker: 65 | -------------------------------------------------------------------------------- /doc/API.md: -------------------------------------------------------------------------------- 1 | ## lh-cpp API 2 | 3 | ### C++ Flavour 4 | 5 | These functions permit to set the C++ flavour currently used. 6 | 7 | The typical use case of these functions is to adapt code snippets to best fit 8 | the idioms of the language, or to select the more standard 9 | type/function/construct available. 10 | 11 | #### Examples 12 | See for instance: 13 | - [`array_size` snippet](snippets.md#array_size) 14 | - [`namespace` snippet](snippets.md#namespace) 15 | - [`shared_ptr` snippet](snippets.md#shared_ptr) 16 | - [`static_assert` snippet](snippets.md#static_assert) 17 | - [`begin`-`end` expander](features.md#begin_end) 18 | 19 | #### Functions 20 | ##### `lh#cpp#get_flavour()` 21 | __Returns__: the current C++ flavour (03, 05, 11, 14, or 17) 22 | 23 | The flavour is obtained from [`(bg)_cpp_std_flavour`, `$CXXFLAGS`, or 24 | `$CMAKE_CXXFLAGS`](options.md#bgcpp_std_flavour-and-cxxflags). 25 | 26 | ##### `lh#cpp#use_TR1()` 27 | __Returns__: whether TR1 (or more is supported). 28 | 29 | This function checks [`lh#cpp#get_flavour()`](lh#cpp#get_flavour) result >= 30 | '05'. 31 | 32 | In order to check for TR1 and only TR1, test `lh#cpp#use_TR1() & !lh#cpp#use_cpp11()`. 33 | 34 | ##### `lh#cpp#use_cpp11()` 35 | __Returns__: whether C++11 (or more) is supported 36 | 37 | This function relies on [`lh#cpp#get_flavour()`](lh#cpp#get_flavour) 38 | 39 | ##### `lh#cpp#use_cpp14()` 40 | __Returns__: whether C++14 (or more) is supported 41 | 42 | This function relies on [`lh#cpp#get_flavour()`](lh#cpp#get_flavour) 43 | 44 | ##### `lh#cpp#use_cpp17()` 45 | __Returns__: whether C++17 (or more) is supported 46 | 47 | This function relies on [`lh#cpp#get_flavour()`](lh#cpp#get_flavour) 48 | 49 | #### Tests 50 | See [tests/lh/test-flavours.vim](tests/lh/test-flavours.vim). 51 | -------------------------------------------------------------------------------- /doc/Doxygen.md: -------------------------------------------------------------------------------- 1 | ## File-templates 2 | lh-cpp & [mu-template](http://github.com/LucHermitte/mu-template) come with 3 | tunable project headers (the default is quite bad I have to admit). You'll have 4 | to override `templates/c/internals/c-file-header.template` to something like: 5 | 6 | ```c++ 7 | /**<+File brief line+> 8 | * <+lh#dox#tag('file ').s:filename+> 9 | * <+lh#dox#ingroup()+> 10 | * <+lh#dox#author()+>, creation 11 | * <+lh#dox#tag('copyright ')+><+strftime('%Y')+> Copyright-Holder-name 12 | * <+lh#dox#since('ProjectVersion')+> 13 | * <+lh#dox#tag('date ').strftime('%Y %b %d')+> creation 14 | *

Licence:

Your Project Licence 15 | * 16 | * PROJECTNAME project. 17 | */ 18 | ``` 19 | 20 | (All the other stuff is already taken care of: include guards will be added automatically in header files, and `foo.h` will be automatically included in `foo.c(pp)`) 21 | 22 | Then, in a local vimrc, you'll have to set the 23 | [following options](options.md#doxygen-related-options): 24 | 25 | * `(bpg):({ft}_)dox_author` 26 | * `(bpg):({ft}_)dox_group` 27 | * `(bpg):ProjectVersion` 28 | 29 | ## Snippets 30 | 31 | Several C++ snippets for classes and functions automatically generate doxygen 32 | documentation. 33 | See [doxygen related options](options.md#doxygen-related-options), 34 | [class snippets](snippets.md#classes) and [Doxygen snippets](snippets.md#doxygen) 35 | for more information on the subject. 36 | 37 | ## `:DOX` 38 | 39 | lh-cpp provides the `:DOX` command that analyses the current function signature to build a doxygen skeleton. 40 | 41 | The ([configurable](#configuration)) skeleton will have: 42 | * a brief line 43 | * a list of _in_, _out_, or _inout_ `@parameters` 44 | * a `@return` tag, if something is returned 45 | * `@exception` specifications if known 46 | * other tags like `@version` 47 | * etc. 48 | 49 | 50 | ### Examples 51 | 52 | Given 53 | 54 | ```c++ 55 | std::string f( 56 | std::vector & v, 57 | std::unique_ptr foo, 58 | int i, 59 | SomeType v, 60 | std::string const& str, int *pj); 61 | ``` 62 | 63 | `:DOX` will produce: 64 | 65 | ```c++ 66 | /** 67 | * «brief explanation». 68 | * «details» 69 | * @param[«in,»out] v «v-explanations» 70 | * @param«[in]» foo «foo-explanations» 71 | * @param[in] i «i-explanations» 72 | * @param«[in]» v «v-explanations» 73 | * @param[in] str «str-explanations» 74 | * @param[«in,»out] pj «pj-explanations» 75 | * 76 | * @return «std::string» 77 | * «@throw » 78 | * @pre foo != NULL«» 79 | * @pre pj != NULL«» 80 | */ 81 | std::string f( 82 | std::vector & v, 83 | std::unique_ptr foo, 84 | int i, 85 | SomeType v, 86 | std::string const& str, int *pj); 87 | ``` 88 | 89 | You can see: 90 | 91 | * `«»` used as a [placeholder](https://github.com/LucHermitte/lh-brackets) to 92 | jump to ; 93 | * references interpreted as _out_ and possibly _in_ parameters ; 94 | * const-references interpreted as _in_ parameters ; 95 | * parameters of known types correctly recognized as _in_ parameters ; 96 | * parameters of unknown types could be proxys/pointers and thus they could act 97 | as _out_ parameters instead ; 98 | * pointer types are recognized as such, and `:DOX` suggest adding a 99 | precondition of non-nullity in their case ; 100 | * a few other tags left to the user to fill in as nothing could be deduced from 101 | the function signature. 102 | 103 | 104 | ### `:DOX` specific options 105 | All [doxygen related options](options.md#doxygen-related-options) apply. 106 | 107 | More over, `:DOX` has other dependencies: 108 | 109 | * `lh#dev#cpp#types#is_base_type()` can be tuned to influence whether parameters 110 | taken by copy are considered as _in_ parameters through: 111 | * `(bpg):({ft}_)base_type_pattern` 112 | * `lh#dev#cpp#types#is_pointer()` is used to recognize pointer types. 113 | -------------------------------------------------------------------------------- /doc/Enums.md: -------------------------------------------------------------------------------- 1 | lh-cpp provides the following features related to enums: 2 | * [generation of a scoped and iterable enumerated type](#enum-snippet) 3 | * [for-snippet for the iterable enum](#enum-iteration) 4 | * [automated generation of a switch-case statement from an enum](#switch-case-generation) 5 | 6 | 7 | ### Enum snippet 8 | 9 | lh-cpp ships a [µtemplate](http://github.com/LucHermitte/mu-template) snippet that expands `enum` into an enum definition with the following properties: 10 | * C++ scoped (no `MYENUM_VAL1`, `MYENUM_VAL2`, ... but `MYENUM::VAL1`, `MYENUM::VAL2`, ...) (which can be taken advantage of in C++ template functions) 11 | * the number of elements is automatically provided (which can be used, for instance, into static assertions in order to check that an associated array of strings has a consistant dimension) 12 | * iterable with no need to explicitly cast an `int` into the enum type. 13 | 14 | Let's say you answer "`MyEnum`" when requested with the enum name, the following will be inserted: 15 | ```C++ 16 | struct MyEnum { 17 | enum type { «values», MAX__ }; 18 | static type next(type e_) { 19 | assert(e_ < MAX__); 20 | return type(e_+1); 21 | } 22 | static char const* to_string(type e_); 23 | static type to_enum(std::string const& s_); 24 | }; 25 | inline 26 | MyEnum::type& operator++(MyEnum::type& e_) { 27 | return e_ = MyEnum::next(e_); 28 | } 29 | inline 30 | MyEnum::type operator++(MyEnum::type&e_, int) { 31 | const MyEnum::type tmp = e_; 32 | e_ = MyEnum::next(e_); 33 | return tmp; 34 | } 35 | ``` 36 | 37 | ### Enum iteration 38 | 39 | In order to take advantage of the particular format of the [iterable enum](#enum-snippet), 40 | a [µtemplate](http://github.com/LucHermitte/mu-template) snippet is provided to 41 | iterate over all enumerated values. 42 | 43 | `for-enum` will expand into: 44 | ```C++ 45 | for (MyEnum::type «e» = MyEnum::type() ; «e» != MyEnum::MAX__ ; ++«e» ) { 46 | «» 47 | }«» 48 | ``` 49 | 50 | ### switch-case generation 51 | 52 | Given an [iterable enum](#enum-snippet) variable or type name, type this name 53 | and then hit `se`. lh-cpp will fill 54 | [µtemplate](http://github.com/LucHermitte/mu-template) switch-case snippets 55 | with all possible values from the enum type. e.g. with: 56 | 57 | ```C++ 58 | struct MyEnum { 59 | enum type { V1, V2, V42, MAX__ }; 60 | ... 61 | MyEnum::type some_enum_var; 62 | ``` 63 | in INSERT-mode `some_enum_var^Xse` expands into: 64 | ```C++ 65 | switch (some_enum_var) 66 | { 67 | case MyEnum::V1: 68 | { 69 | «MyEnum::V1-code»; 70 | break; 71 | } 72 | case MyEnum::V2: 73 | { 74 | «MyEnum::V2-code»; 75 | break; 76 | } 77 | case MyEnum::V42: 78 | { 79 | «MyEnum::V42-code»; 80 | break; 81 | } 82 | default: 83 | { 84 | «default-code»; 85 | break; 86 | } 87 | }«» 88 | ``` 89 | As of today this feature requires a ctags database containing all the tags 90 | related to the enum, and an [iterable enum](#enum-snippet). (I plan to support 91 | [C++0x class-enums](http://en.wikipedia.org/wiki/C%2B%2B0x#Strongly_typed_enumerations) 92 | and to find eventually an alternative to ctags) 93 | -------------------------------------------------------------------------------- /doc/TODO.md: -------------------------------------------------------------------------------- 1 | # lh-cpp TO DO list 2 | 3 | ## Folding 4 | 5 | - [ ] if only `{`, search next line 6 | - [ ] `do` `while` 7 | - [ ] embedded `#if` 8 | 9 | ## syntax highlight 10 | 11 | - [ ] detect `case` 12 | - [X] without a `break`, or a `return`, or `continue`, or a `goto`, or `- [[fallthrough]]` 13 | - [ ] `break;} case` is incorrectly recognized 14 | - [ ] `default` is not recognized 15 | - [ ] detect raw pointers 16 | - [ ] detect calls to `malloc`/`free`/... 17 | - [ ] detect calls to `delete` (outside destructors) 18 | - [ ] detect calls to `new` (C++14) 19 | - [ ] detect C casts 20 | - [X] ignore `void foo() const` 21 | - [ ] ignore `decltype(auto) foo;` 22 | - [ ] ignore `f(12)(13)(14)` 23 | 24 | ## snippets / wizard 25 | 26 | ### class wizard 27 | 28 | - [ ] Doc!! 29 | - [X] Options 30 | - [ ] Snippets 31 | 32 | - [ ] Class kinds 33 | - [ ] CRTP 34 | - [ ] arithmetic class 35 | - [ ] clonable simpl. or interactive 36 | - [ ] value w/ manual copy (& swap) 37 | - [ ] NVI ? 38 | - [ ] template class 39 | - [ ] enum class (only tests?) 40 | - [ ] singleton (test) 41 | - [ ] Simplified way to generate new classes w/ attribs & all 42 | 43 | - [ ] class features 44 | - [ ] Check inline TODOs 45 | - [ ] attributes 46 | - [ ] use snippet if there is one with the same type name, idem for 47 | inheritance -> require patch on <+s:Include()+> in mu-template 48 | - [ ] dox functions 49 | - [ ] test w/ and w/o 50 | - [X] default constructor 51 | - [X] copy constructor 52 | - [X] init constructor 53 | - [X] destructor 54 | - [X] assignment operator 55 | - [X] copy'n'swap -> `swap` 56 | - [ ] `what` 57 | - [ ] attributes 58 | - [ ] types & classes 59 | - [ ] pointer means invariant 60 | - [ ] move contructor 61 | - [ ] move assignment-operator 62 | - [ ] Enforce «rule of all or nothing» 63 | - [ ] Special functions need atomic tests 64 | - [X] default constructor 65 | - [X] copy constructor 66 | - [X] init constructor 67 | - [X] destructor 68 | - [X] assignment operator 69 | - [X] copy'n'swap 70 | - [ ] C++11 71 | - [ ] w/ TBW `:MuT cpp/class attributes=foo:int,#bar:string parents=Bar,-Toto` 72 | - [X] `:Constructor` 73 | 74 | 75 | ### Other snippets 76 | - [ ] `` snippets should use cpp/begin-end 77 | - [ ] lambda 78 | - [ ] Check `:InsertEnum` -> tests 79 | - [X] Fix `:MuTemplate c/swith un deux` 80 | - [ ] Find a better way to pass options to `:MuTemplate` command in order to take 81 | advantage of cpp/class snippets. For instance: 82 | 83 | ``` 84 | " +==public, #==protected, -==private 85 | :MuT cpp/class attributes=foo:int,#bar:string parents=Bar,-Toto 86 | ``` 87 | 88 | ## misc 89 | 90 | - [ ] Register options for completion & co into menus, `:Set` and `:Toggle` 91 | - [ ] Have lh#dev#import rely on lh#cpp#types, or the other way around 92 | - [ ] `:MOVETOIMPL` doesn't work on constructors when there is an 93 | initialization-list 94 | -------------------------------------------------------------------------------- /doc/c.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/doc/c.html -------------------------------------------------------------------------------- /doc/screencast-select-function.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/doc/screencast-select-function.gif -------------------------------------------------------------------------------- /doc/screencast-snippet-baseNV-class.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/doc/screencast-snippet-baseNV-class.gif -------------------------------------------------------------------------------- /doc/types.md: -------------------------------------------------------------------------------- 1 | ## lh-cpp Type DataBase 2 | 3 | lh-cpp provides a database for most standard types and some semi-standard 4 | types, i.e. [Boost](http://www.boost.org) types. 5 | 6 | ### Accessing type information 7 | 8 | #### `lh#cpp#types#get_info(type[, default-value])` 9 | Function that returns the type information associated to `type`. 10 | 11 | If no information is found for `type`, the `default-value` will be returned. 12 | 13 | A type information is a dictionary object made of: 14 | * `"name"`: simplified name of the type (acts as a key to retrieve its 15 | associated information) 16 | * `"namespace"`: its namespace 17 | * `"type"`: the full type name (with template parameters) 18 | * `"includes`"`: list of headers file that may define the type. 19 | * `"typename_for_header(...)"` function. 20 | 21 | See the [related unit test](../tests/lh/test-types.vim) 22 | 23 | #### `lh#cpp#types#get_includes(type)` 24 | 25 | Returns the list of header files that are know to define the `type`. 26 | 27 | 28 | ### Current database status 29 | 30 | The best way to see which types are defined is to consult the source code of 31 | [autoload/lh/cpp/types.vim](../autoload/lh/cpp/types.vim). 32 | -------------------------------------------------------------------------------- /ftplugin/c/LoadHeaderFile.vim: -------------------------------------------------------------------------------- 1 | " LoadHeaderFile 2 | " Last Change: 29th july 2001 by Luc Hermitte 3 | " -> Split lines and change indentation in order to fit within 80 cols 4 | " -> Change the way the filename is extracted from the include line 5 | " Maintainer: Garner Halloran (garner@havoc.gtf.org) 6 | 7 | if !exists( "g:loaded_LoadHeaderFile" ) 8 | ""finish 9 | ""endif 10 | let g:loaded_LoadHeaderFile = 1 11 | 12 | fun! LoadHeaderFile( arg, loadSource ) 13 | if match( a:arg, "#include" ) >= 0 14 | " extract the file name 15 | let matchPattern = '\s*#include\s*\(<\|"\)\(.*\)\(>\|"\)\s*' 16 | let $filename = substitute( a:arg, matchPattern, '\2', 'g') 17 | 18 | if strlen($filename) != 0 19 | " if loadSource is 1, then replace .h with .cpp and load that file 20 | " instead 21 | if a:loadSource == 1 22 | let $filename = substitute( $filename, '\V.h', ".cpp", "" ) 23 | " if loadSource is 2, then replace .h with .c and load that file 24 | " instead 25 | elseif a:loadSource == 2 26 | let $filename = substitute( $filename, '\V.h', ".c", "" ) 27 | endif 28 | 29 | sfind $filename 30 | return 31 | endif 32 | endif 33 | endfun 34 | 35 | 36 | endif 37 | -------------------------------------------------------------------------------- /ftplugin/c/c_AddInclude.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_AddInclude.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.1.3 8 | let s:k_version = 213 9 | " Created: 22nd May 2012 10 | " Last Update: 28th Oct 2015 11 | "------------------------------------------------------------------------ 12 | " Description: 13 | " This ftplugin defines a mapping to insert missing includes (given we 14 | " know which symbol shall be defined...) 15 | " 16 | "------------------------------------------------------------------------ 17 | " Installation: 18 | " Drop this file into {rtp}/ftplugin/c 19 | " Requires Vim7+, lh-dev 20 | " History: 21 | " v2.0.0 GPLv3 w/ exception 22 | " TODO: 23 | " Handle the case where several files are found 24 | " Move to autoload plugin 25 | " Recognize commented includes 26 | " }}}1 27 | "============================================================================= 28 | 29 | finish " This ftplugin has been deprecated in favour of lh-dev/ImportModule feature 30 | " Buffer-local Definitions {{{1 31 | " Avoid local reinclusion {{{2 32 | if &cp || (exists("b:loaded_ftplug_c_AddInclude") 33 | \ && (b:loaded_ftplug_c_AddInclude >= s:k_version) 34 | \ && !exists('g:force_reload_ftplug_c_AddInclude')) 35 | finish 36 | endif 37 | let b:loaded_ftplug_c_AddInclude = s:k_version 38 | let s:cpo_save=&cpo 39 | set cpo&vim 40 | " Avoid local reinclusion }}}2 41 | 42 | "------------------------------------------------------------------------ 43 | " Local mappings {{{2 44 | 45 | nnoremap InsertInclude :call InsertInclude() 46 | if !hasmapto('InsertInclude', 'n') 47 | nmap i InsertInclude 48 | endif 49 | 50 | "============================================================================= 51 | " Global Definitions {{{1 52 | " Avoid global reinclusion {{{2 53 | if &cp || (exists("g:loaded_ftplug_c_AddInclude") 54 | \ && (g:loaded_ftplug_c_AddInclude >= s:k_version) 55 | \ && !exists('g:force_reload_ftplug_c_AddInclude')) 56 | let &cpo=s:cpo_save 57 | finish 58 | endif 59 | let g:loaded_ftplug_c_AddInclude = s:k_version 60 | " Avoid global reinclusion }}}2 61 | "------------------------------------------------------------------------ 62 | " Functions {{{2 63 | " Note: most filetype-global functions are best placed into 64 | " autoload/«your-initials»/c/«c_AddInclude».vim 65 | " Keep here only the functions are are required when the ftplugin is 66 | " loaded, like functions that help building a vim-menu for this 67 | " ftplugin. 68 | function! s:InsertInclude() abort 69 | " If there are several choices, ask which one to use. 70 | " But first: check the files. 71 | let [id, info] = lh#cpp#tags#fetch("insert-include") 72 | 73 | let files = {} 74 | for t in info 75 | if ! has_key(files, t.filename) 76 | let files[t.filename] = {} 77 | endif 78 | let files[t.filename][t.kind[0]] = '' 79 | endfor 80 | " NB: there shouldn't be any to prioritize between p and f kinds as the 81 | " filtering on include files shall get rid of the f kinds (that exist along 82 | " with a prototype) 83 | if len(files) > 1 84 | call lh#common#error_msg("insert-include: too many acceptable tags for `" 85 | \ .id."': ".string(files)) 86 | return 87 | endif 88 | mark ' 89 | let fullfilename = keys(files)[0] 90 | let filename = fullfilename " this is the full filename 91 | " echo filename 92 | try 93 | call lh#cpp#include#add(filename, fullfilename=~ '\\|\') 94 | catch /^insert-include:.* is already included/ 95 | call lh#common#warning_msg("insert-include: ".filename.", where `" 96 | \ .id."' is defined, is already included") 97 | endtry 98 | echo "Use CTRL-O to go back to previous cursor position" 99 | endfunction 100 | 101 | " Functions }}}2 102 | "------------------------------------------------------------------------ 103 | let &cpo=s:cpo_save 104 | "============================================================================= 105 | " vim600: set fdm=marker: 106 | -------------------------------------------------------------------------------- /ftplugin/c/c_UnmatchedFunctions.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/c/c_UnmatchedFunctions.vim -------------------------------------------------------------------------------- /ftplugin/c/c_complete_include.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_complete_include.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.1 6 | let s:k_version = 221 7 | " Created: 08th Nov 2011 8 | " Last Update: 16th Jan 2019 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " Mapping to complete #include filename not based on &path (as 12 | " |i_CTRL-X_CTRL-F| is). 13 | " The completion is based instead on {bg}:{ft_}_includes_path + &include 14 | " 15 | "------------------------------------------------------------------------ 16 | " Installation: 17 | " Drop this file into {rtp}/ftplugin/c 18 | " Requires Vim7+, lh-vim-lib 2.2.7+ 19 | " «install details» 20 | " History: «history» 21 | " TODO: «missing features» 22 | " }}}1 23 | "============================================================================= 24 | 25 | " Buffer-local Definitions {{{1 26 | " Avoid local reinclusion {{{2 27 | let s:cpo_save=&cpo 28 | set cpo&vim 29 | 30 | if &cp || (exists("b:loaded_ftplug_c_complete_include") 31 | \ && (b:loaded_ftplug_c_complete_include >= s:k_version) 32 | \ && !exists('g:force_reload_ftplug_c_complete_include')) 33 | let &cpo=s:cpo_save 34 | finish 35 | endif 36 | let b:loaded_ftplug_c_complete_include = s:k_version 37 | " Avoid local reinclusion }}}2 38 | 39 | "------------------------------------------------------------------------ 40 | " Local mappings {{{2 41 | 42 | inoremap CompleteIncludes =Complete() 43 | if !hasmapto('CompleteIncludes', 'i') 44 | imap i CompleteIncludes 45 | endif 46 | 47 | nnoremap OpenIncludes :call Open() 48 | if !hasmapto('OpenIncludes', 'n') 49 | nmap i OpenIncludes 50 | endif 51 | 52 | "============================================================================= 53 | " Global Definitions {{{1 54 | " Avoid global reinclusion {{{2 55 | if exists("g:loaded_ftplug_c_complete_include") 56 | \ && (g:loaded_ftplug_c_complete_include >= s:k_version) 57 | \ && !exists('g:force_reload_ftplug_c_complete_include') 58 | let &cpo=s:cpo_save 59 | finish 60 | endif 61 | let g:loaded_ftplug_c_complete_include = s:k_version 62 | " Avoid global reinclusion }}}2 63 | "------------------------------------------------------------------------ 64 | " Functions {{{2 65 | " Note: most filetype-global functions are best placed into 66 | " autoload/«your-initials»/c/«c_complete_include».vim 67 | " Keep here only the functions are are required when the ftplugin is 68 | " loaded, like functions that help building a vim-menu for this 69 | " ftplugin. 70 | 71 | " Function: s:Complete() {{{3 72 | function! s:Complete() abort 73 | let cleanup = lh#on#exit() 74 | \.restore('&isk') 75 | try 76 | set isk+=/ 77 | let prev = lh#ui#GetLikeCTRL_W() 78 | finally 79 | call cleanup.finalize() 80 | endtry 81 | let paths = lh#cpp#tags#get_included_paths(&path) 82 | let files = lh#path#glob_as_list(paths, [prev.'*']) 83 | " Keep headers files and directories 84 | call filter(files, 'v:val =~? "\\v\.(h|hpp|hxx|txx|h\\+\\+)$" || isdirectory(v:val)') 85 | call map(files, 'v:val . (isdirectory(v:val)?"/":"")') 86 | let files = lh#list#unique_sort(files) 87 | let entries = map(copy(files), '{"word": lh#path#strip_start(v:val, paths), "menu": v:val}') 88 | call lh#icomplete#new(col('.')-lh#encoding#strlen(prev)-1, entries, []).start_completion() 89 | return '' 90 | endfunction 91 | 92 | " Function: s:Open() {{{3 93 | " built on top of SearchInRuntime 94 | function! s:Open() abort 95 | try 96 | let path = &path 97 | let paths = lh#cpp#tags#get_included_paths() 98 | exe 'set path+='.join(paths, ',') 99 | exe "normal \f" 100 | finally 101 | let &path = path 102 | endtry 103 | endfunction 104 | 105 | " }}}1 106 | "------------------------------------------------------------------------ 107 | let &cpo=s:cpo_save 108 | "============================================================================= 109 | " vim600: set fdm=marker: 110 | -------------------------------------------------------------------------------- /ftplugin/c/c_gcov.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_gcov.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 221 6 | let s:k_version = 221 7 | " Created: 30th Oct 2012 8 | " Last Update: 16th Jan 2019 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " ftplugin to swap between a .gcov file and its source 12 | " 13 | "------------------------------------------------------------------------ 14 | " Installation: 15 | " Drop this file into {rtp}/ftplugin/c 16 | " Requires Vim7+ 17 | " «install details» 18 | " History: «history» 19 | " TODO: «missing features» 20 | " }}}1 21 | "============================================================================= 22 | 23 | " Buffer-local Definitions {{{1 24 | " Avoid local reinclusion {{{2 25 | let s:cpo_save=&cpo 26 | set cpo&vim 27 | 28 | if &cp || (exists("b:loaded_ftplug_c_gcov") 29 | \ && (b:loaded_ftplug_c_gcov >= s:k_version) 30 | \ && !exists('g:force_reload_ftplug_c_gcov')) 31 | let &cpo=s:cpo_save 32 | finish 33 | endif 34 | let b:loaded_ftplug_c_gcov = s:k_version 35 | " Avoid local reinclusion }}}2 36 | 37 | "------------------------------------------------------------------------ 38 | " Local mappings {{{2 39 | 40 | nnoremap g :call JumpOrToggleGCOVFile(expand('%:p'), 'e') 41 | 42 | "------------------------------------------------------------------------ 43 | " Local commands {{{2 44 | 45 | 46 | "============================================================================= 47 | " Global Definitions {{{1 48 | " Avoid global reinclusion {{{2 49 | if exists("g:loaded_ftplug_c_gcov") 50 | \ && (g:loaded_ftplug_c_gcov >= s:k_version) 51 | \ && !exists('g:force_reload_ftplug_c_gcov') 52 | let &cpo=s:cpo_save 53 | finish 54 | endif 55 | let g:loaded_ftplug_c_gcov = s:k_version 56 | " Avoid global reinclusion }}}2 57 | "------------------------------------------------------------------------ 58 | " Functions {{{2 59 | " Note: most filetype-global functions are best placed into 60 | " autoload/«your-initials»/c/«c_gcov».vim 61 | " Keep here only the functions are are required when the ftplugin is 62 | " loaded, like functions that help building a vim-menu for this 63 | " ftplugin. 64 | " Function: s:FindGCOVFile(source_file) {{{3 65 | let s:k_gcov_ext = '.gcov' 66 | function! s:FindGCOVFile(source_file) abort 67 | let current_file = fnamemodify(a:source_file, ':t') 68 | let current_path = fnamemodify(a:source_file,':p:h') 69 | let gcov_files_path = lh#ft#option#get('gcov_files_path', &ft, current_path) 70 | let files = lh#path#glob_as_list(gcov_files_path, current_file.s:k_gcov_ext) 71 | if empty(files) 72 | throw "Cannot find <".current_file.s:k_gcov_ext."> in ".string(files).". Please set b:[{ft}_]gcov_files_path" 73 | else 74 | let gcov_file = lh#path#select_one(files, "Which gcov file matches <".current_file."> ?") 75 | return gcov_file 76 | endif 77 | endfunction 78 | 79 | function! s:JumpOrToggleGCOVFile(source_file, cmd) abort 80 | let gcov_file = s:FindGCOVFile(a:source_file) 81 | call lh#buffer#jump(gcov_file, a:cmd) 82 | endfunction 83 | " Functions }}}2 84 | " }}}1 85 | "------------------------------------------------------------------------ 86 | let &cpo=s:cpo_save 87 | "============================================================================= 88 | " vim600: set fdm=marker: 89 | -------------------------------------------------------------------------------- /ftplugin/c/c_mu-template_api.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_mu-template_api.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0 6 | " Created: 14th Apr 2006 7 | " Last Update: 16th Jan 2019 8 | "------------------------------------------------------------------------ 9 | " Description: 10 | " Provides API functions used in mu-template's C template-files. 11 | " 12 | " - C_nl_before_bracket() that returns the text to insert before a 13 | " bracket according to the option |g:c_nl_before_bracket| 14 | " - C_nl_before_curlyB() that returns the text to insert before a 15 | " curly-bracket according to the option |g:c_nl_before_bracket| 16 | " 17 | "------------------------------------------------------------------------ 18 | " Installation: See |lh-cpp-readme.txt| 19 | " Dependancies: mu-template (=> lh-map-tools, searchInRuntime) 20 | " TODO: move to an autoload plugin 21 | " }}}1 22 | "============================================================================= 23 | 24 | "============================================================================= 25 | " Avoid global reinclusion {{{1 26 | let s:cpo_save=&cpo 27 | set cpo&vim 28 | if exists("g:loaded_c_mu_template_api") 29 | \ && !exists('g:force_reload_c_mu_template_api') 30 | let &cpo=s:cpo_save 31 | finish 32 | endif 33 | let g:loaded_c_mu_template_api = 1 34 | " Avoid global reinclusion }}}1 35 | "------------------------------------------------------------------------ 36 | " Functions {{{1 37 | 38 | " note: The space is needed after the "\n" to avoid mu-template from joining 39 | " the two next lines. 40 | function! C_nl_before_bracket() abort 41 | return lh#cpp#option#nl_before_bracket() ? "\n " : " " 42 | endfunction 43 | 44 | function! C_nl_before_curlyB() abort 45 | return lh#cpp#option#nl_before_curlyB() ? "\n " : " " 46 | endfunction 47 | 48 | " Functions }}}1 49 | "------------------------------------------------------------------------ 50 | let &cpo=s:cpo_save 51 | "============================================================================= 52 | " vim600: set fdm=marker: 53 | -------------------------------------------------------------------------------- /ftplugin/c/c_set.vim: -------------------------------------------------------------------------------- 1 | " ======================================================================== 2 | " File: ftplugin/c/c_set.vim 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.1.3 6 | let s:k_version = 213 7 | " Last Update: 28th Oct 2015 8 | " 9 | " Purpose: ftplugin for C (-like) programming 10 | " 11 | "------------------------------------------------------------------------ 12 | " Installation: See |lh-cpp-readme.txt| 13 | " Dependencies: 14 | " LoadHeaderFile.vim 15 | " flist & flistmaps.vim -- Dr Chips 16 | " VIM >= 6.00 only 17 | " ======================================================================== 18 | 19 | " 4 log: 20 | " 14th Apr 2007: &isk-=- 21 | " for changelog: 02nd Jun 2006 -> suffixesadd 22 | 23 | 24 | " ======================================================================== 25 | " Buffer local definitions {{{1 26 | " ======================================================================== 27 | if exists("b:loaded_c_set") && !exists('g:force_reload_c_set') 28 | finish 29 | endif 30 | let b:loaded_c_set = s:k_version 31 | let s:cpo_save = &cpo 32 | set cpo&vim 33 | 34 | " ------------------------------------------------------------------------ 35 | " Includes {{{ 36 | " ------------------------------------------------------------------------ 37 | source $VIMRUNTIME/ftplugin/c.vim 38 | let b:did_ftplugin = 1 39 | " }}} 40 | " ------------------------------------------------------------------------ 41 | " Options to set {{{ 42 | " ------------------------------------------------------------------------ 43 | " Note: these options can be overrided into a ftplugin placed in an after/ 44 | " directory. 45 | " 46 | setlocal formatoptions=croql 47 | setlocal cindent 48 | setlocal cinoptions=g0,t0 49 | setlocal define=^\(#\s*define\|[a-z]*\s*const\(expr\)\=\s*[a-z]*\) 50 | setlocal comments=sr:/*,mb:*,exl:*/,:///,:// 51 | " setlocal isk+=# " so #if is considered as a keyword, etc 52 | " setlocal isk-=- " so ptr- (in ptr->member) is not 53 | " setlocal isk-=< 54 | " setlocal isk-=> 55 | " setlocal isk-=: 56 | setlocal isk=#,a-z,A-Z,48-57,_ 57 | setlocal suffixesadd+=.h,.c 58 | 59 | setlocal cmdheight=3 60 | setlocal nosmd 61 | 62 | " Dictionary from Dr.-Ing. Fritz Mehner 63 | let s:dictionary=expand(":p:h").'/word.list' 64 | if filereadable(s:dictionary) 65 | let &l:dictionary=s:dictionary 66 | setlocal complete+=k 67 | endif 68 | setlocal complete-=i 69 | " }}} 70 | " ------------------------------------------------------------------------ 71 | " File loading {{{ 72 | " ------------------------------------------------------------------------ 73 | " 74 | " Things on :A and :AS 75 | ""so $VIM/macros/a.vim 76 | " 77 | ""so :p:h/LoadHeaderFile.vim 78 | if exists("*LoadHeaderFile") 79 | nnoremap 80 | \ :call LoadHeaderFile(getline('.'),0) 81 | inoremap 82 | \ :call LoadHeaderFile(getline('.'),0) 83 | endif 84 | 85 | " flist (Dr Chips) 86 | ""so :p:h/flistmaps.vim 87 | if filereadable(expand("hints")) 88 | au BufNewFile,BufReadPost *.h,*.ti,*.inl,*.c,*.C,*.cpp,*.CPP,*.cxx 89 | \ so hints 90 | endif 91 | 92 | " }}} 93 | " ------------------------------------------------------------------------ 94 | "}}}1 95 | " ======================================================================== 96 | let &cpo = s:cpo_save 97 | "============================================================================= 98 | " vim600: set fdm=marker: 99 | -------------------------------------------------------------------------------- /ftplugin/c/c_show_scope.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_show_scope.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.1. 6 | let s:k_version = '221' 7 | " Created: 29th May 2017 8 | " Last Update: 16th Jan 2019 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " Display the context on the current function/namespace/class/... 12 | " 13 | "------------------------------------------------------------------------ 14 | " History: «history» 15 | " TODO: «missing features» 16 | " }}}1 17 | "============================================================================= 18 | 19 | " Buffer-local Definitions {{{1 20 | " Avoid local reinclusion {{{2 21 | let s:cpo_save=&cpo 22 | set cpo&vim 23 | if &cp || (exists("b:loaded_ftplug_c_show_scope") 24 | \ && (b:loaded_ftplug_c_show_scope >= s:k_version) 25 | \ && !exists('g:force_reload_ftplug_c_show_scope')) 26 | let &cpo=s:cpo_save 27 | finish 28 | endif 29 | let b:loaded_ftplug_c_show_scope = s:k_version 30 | " Avoid local reinclusion }}}2 31 | 32 | "------------------------------------------------------------------------ 33 | " Local mappings {{{2 34 | 35 | nnoremap sc :echo lh#cpp#analyse#context() 36 | 37 | " }}}1 38 | "------------------------------------------------------------------------ 39 | let &cpo=s:cpo_save 40 | "============================================================================= 41 | " vim600: set fdm=marker: 42 | -------------------------------------------------------------------------------- /ftplugin/c/c_snippets.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/c/c_snippets.vim -------------------------------------------------------------------------------- /ftplugin/c/c_stl.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_stl.vim 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 1.1.0 6 | " Created: 24th oct 2002 7 | " Last Update: $Date$ 8 | "------------------------------------------------------------------------ 9 | " Description: Show current the name of the current function, we are within, 10 | " on status line. 11 | " 12 | "------------------------------------------------------------------------ 13 | " Installation: See |lh-cpp-readme.txt| 14 | "============================================================================= 15 | " Local Definitions: {{{ 16 | " Avoid reinclusion 17 | finish 18 | " deactivated because it could be very, very slow in some cases 19 | if exists('b:loaded_ftplug_c_stl') | finish | endif 20 | let b:loaded_ftplug_c_stl = 1 21 | " 22 | let s:cpo_save=&cpo 23 | set cpo&vim 24 | " 25 | "------------------------------------------------------------------------ 26 | " setlocal stl=%{C_ShowFuncName()} 27 | " setlocal statusline=%<%f%h%{1==&modified?'[+]':''}%r%=\ %-16(%l,%c%V\ %)\ %P 28 | " setlocal statusline=%-30(%<%f\ %h%{1==&modified?'[+]':''}%r%)%{C_ShowFuncName()}%=\ %-16(%l,%c%V\ %)\ %P 29 | setlocal statusline=%<%f\ %h%{1==&modified?'[+]':''}%r%{C_ShowFuncName()}%=\ %-16(%l,%c%V\ %)\ %P 30 | " }}} 31 | "============================================================================= 32 | " Global Definitions: {{{ 33 | if exists("g:loaded_c_stl") 34 | let &cpo=s:cpo_save 35 | finish 36 | endif 37 | let g:loaded_c_stl = 1 38 | "------------------------------------------------------------------------ 39 | " Function: C_ShowFuncName() {{{ 40 | function! C_ShowFuncName() 41 | let s:type = '\<\I\i*\>' 42 | let s:name = '\%(::\)\=\<\I\i*\>\%(::\<\I\i*\>\)*' 43 | let s:param= '[^)]\+' 44 | 45 | " spaces, line-breaks, C comments or C++ comments 46 | let s:blan0='\%(//.*$\|\_s\|/\*.\{-}\*/\)*' 47 | let s:blank_ne0='\%(\_s\|/\*.\{-}\*/\|//.*$\)\+' 48 | 49 | " let s:blank0='\%(//.*$\|\_s\|/\*.\{-}\*/\)*' 50 | " let s:blank_ne0='\%(\_s\|/\*.\{-}\*/\|//.*$\)\+' 51 | " let s:blank = '\%('.s:blank0.'\)\@>' 52 | " let s:blank_ne = '\%('.s:blank_ne0.'\)\@>' 53 | 54 | let s:begin= '\%(\%^\|[;}]\)'.s:blank.'\zs' 55 | 56 | let s:function= s:type. s:blank_ne .s:name.s:blank 57 | \ .'(\%('.s:blank_ne.'\|'.s:param.'\)*)' 58 | \ .s:blank.'\%(\\)\='.s:blank 59 | " \ .'(\%('.s:param.'\)*)' 60 | let g:fn = s:function 61 | 62 | let l1 = 0 63 | let l2 = line('.')+1 64 | while 1 65 | let l2 = searchpair( '{\_[^{]*\%<'.l2.'l', '', '}', 'bnW' ) 66 | if l2 <= 0 67 | return '' | endif 68 | " let l1 = searchpair( s:function.'\%'.l2.'l{', '', '\%$', 'bnW' ) 69 | let l1 = searchpair( s:function.'\%'.l2.'l{', '', '}', 'bnW' ) 70 | if l1 > 0 | break | endif 71 | endwhile 72 | call confirm('l1='.l1, '&ok', 1) 73 | 74 | 75 | " \ what_is_good_to_skip_comments) 76 | 77 | " ... then getlines from line l (if > 0) to '{'. 78 | if l1 <= 0 | return '' | endif 79 | let l = exists('r') ? r : '' 80 | let ln=line('$') 81 | while l1 < ln 82 | let l = l. substitute(getline(l1), s:blank_ne, ' ', 'g') 83 | if -1 != match(l, '{') 84 | let l = substitute(l, '\s\+\|{.*$', ' ', 'g') 85 | return ' -> '.l 86 | endif 87 | let l1 = l1 + 1 88 | endwhile 89 | endfunction 90 | " }}} 91 | "------------------------------------------------------------------------ 92 | let &cpo=s:cpo_save 93 | " }}} 94 | "============================================================================= 95 | " vim600: set fdm=marker: 96 | -------------------------------------------------------------------------------- /ftplugin/c/c_switch-enum.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/c_switch-enum.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.0.0 8 | " Created: 24th Jun 2006 9 | " Last Update: $Date$ 10 | "------------------------------------------------------------------------ 11 | " Description: 12 | " Builds a switch statement from all the possible values that define an 13 | " enum. 14 | " 15 | "------------------------------------------------------------------------ 16 | " Requirements: 17 | " Vim 7.0+ 18 | " lh-dev, mu-template, an up-to-date ctags database 19 | " word_tools.vim 20 | " 21 | " TODO: 22 | " - indirections with C typedef definitions 23 | " -> typedef enum { ... } ; 24 | " - Work with embedded C++ scopes 25 | " - Use libclang when available 26 | " Cannot manage: 27 | " - the order of enumerated values, try to see with libclang 28 | " 29 | " }}}1 30 | "============================================================================= 31 | 32 | " Avoid buffer reinclusion {{{1 33 | let s:cpo_save=&cpo 34 | set cpo&vim 35 | if exists('b:loaded_ftplug_switch_enum') 36 | \ && !exists('g:force_reload_c_switch_enum') 37 | let &cpo=s:cpo_save 38 | finish 39 | endif 40 | let b:loaded_ftplug_switch_enum = 200 41 | 42 | " }}}1 43 | "------------------------------------------------------------------------ 44 | " Commands and mappings {{{1 45 | command! -b -nargs=0 SwitchEnum call lh#cpp#enum#expand_enum_to_switch() 46 | inoremap SwitchEnum :SwitchEnum 47 | if !hasmapto('SwitchEnum', 'i') 48 | imap se SwitchEnum 49 | endif 50 | 51 | " Commands and mappings }}}1 52 | "============================================================================= 53 | "------------------------------------------------------------------------ 54 | let &cpo=s:cpo_save 55 | "============================================================================= 56 | " vim600: set fdm=marker: 57 | -------------------------------------------------------------------------------- /ftplugin/c/flistmaps.vim: -------------------------------------------------------------------------------- 1 | " flist.vim maps for Vim 2 | " Author : Charles E. Campbell, Jr. 3 | " Copyright: Charles E. Campbell, Jr. 4 | " License : refer to the file for flist 5 | " 6 | if !exists("g:loaded_flistmaps_vim") 7 | let g:loaded_flistmaps_vim = 1 8 | 9 | " Make various lists of C/C++ functions 10 | " \p? prototypes : \[px]g: globals \pc: comment \pp: all prototypes 11 | " \x? externs : \[px]s: statics \xx: all externs 12 | nnoremap \pc :w:!${CECCMD}/flist -c % >tmp.vim:r tmp.vim:!rm tmp.vim 13 | nnoremap \pg :w:!${CECCMD}/flist -pg % >tmp.vim:r tmp.vim:!rm tmp.vim 14 | nnoremap \pp :w:!${CECCMD}/flist -p % >tmp.vim:r tmp.vim:!rm tmp.vim 15 | nnoremap \ps :w:!${CECCMD}/flist -ps % >tmp.vim:r tmp.vim:!rm tmp.vim 16 | nnoremap \xg :w:!${CECCMD}/flist -xg % >tmp.vim:r tmp.vim:!rm tmp.vim 17 | nnoremap \xs :w:!${CECCMD}/flist -xs % >tmp.vim:r tmp.vim:!rm tmp.vim 18 | nnoremap \xx :w:!${CECCMD}/flist -x % >tmp.vim:r tmp.vim:!rm tmp.vim 19 | endif 20 | -------------------------------------------------------------------------------- /ftplugin/c/keep_pound_if_path.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/c/keep_pound_if_path.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.1. 6 | let s:k_version = '221' 7 | " Created: 30th Jun 2016 8 | " Last Update: 16th Jan 2019 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " Remove the true/false path into a `#if ... #else ... #endif` construct 12 | " 13 | "------------------------------------------------------------------------ 14 | " History: «history» 15 | " TODO: «missing features» 16 | " }}}1 17 | "============================================================================= 18 | 19 | " Buffer-local Definitions {{{1 20 | " Avoid local reinclusion {{{2 21 | let s:cpo_save=&cpo 22 | set cpo&vim 23 | if &cp || (exists("b:loaded_ftplug_keep_pound_if_path") 24 | \ && (b:loaded_ftplug_keep_pound_if_path >= s:k_version) 25 | \ && !exists('g:force_reload_ftplug_keep_pound_if_path')) 26 | let &cpo=s:cpo_save 27 | finish 28 | endif 29 | let b:loaded_ftplug_keep_pound_if_path = s:k_version 30 | " Avoid local reinclusion }}}2 31 | 32 | "------------------------------------------------------------------------ 33 | " Local commands {{{2 34 | 35 | command! -b -nargs=1 KeepPoundIfPath call lh#cpp#macros#keep() 36 | 37 | "============================================================================= 38 | "------------------------------------------------------------------------ 39 | " }}}1 40 | "------------------------------------------------------------------------ 41 | let &cpo=s:cpo_save 42 | "============================================================================= 43 | " vim600: set fdm=marker: 44 | -------------------------------------------------------------------------------- /ftplugin/cpp/changelog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/changelog -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_AddMissingScope.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/cpp/cpp_AddMissingScope.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.1 6 | let s:k_version = 221 7 | " Created: 25th Jun 2014 8 | " Last Update: 16th Jan 2019 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " Given an identifier under the cursor, search for its scope (namespace, 12 | " ...) and insert it. 13 | " 14 | "------------------------------------------------------------------------ 15 | " }}}1 16 | "============================================================================= 17 | 18 | " Buffer-local Definitions {{{1 19 | " Avoid local reinclusion {{{2 20 | let s:cpo_save=&cpo 21 | set cpo&vim 22 | if &cp || (exists("b:loaded_ftplug_cpp_AddMissingScope") 23 | \ && (b:loaded_ftplug_cpp_AddMissingScope >= s:k_version) 24 | \ && !exists('g:force_reload_ftplug_cpp_AddMissingScope')) 25 | let &cpo=s:cpo_save 26 | finish 27 | endif 28 | let b:loaded_ftplug_cpp_AddMissingScope = s:k_version 29 | " Avoid local reinclusion }}}2 30 | 31 | "------------------------------------------------------------------------ 32 | " Local mappings {{{2 33 | 34 | nnoremap AddMissingScope :call lh#cpp#scope#_add_missing() 35 | if !hasmapto('AddMissingScope', 'n') 36 | nmap AddMissingScope 37 | endif 38 | 39 | " }}}1 40 | "------------------------------------------------------------------------ 41 | let &cpo=s:cpo_save 42 | "============================================================================= 43 | " vim600: set fdm=marker: 44 | -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_BuildTemplates.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/cpp_BuildTemplates.vim -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_Constructor.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/cpp_Constructor.vim -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_Enum.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/cpp/cpp_Enum.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.2.1 8 | let s:k_version = 221 9 | " Created: 30th Apr 2014 10 | " Last Update: 16th Jan 2019 11 | "------------------------------------------------------------------------ 12 | " Description: 13 | " Defines the command 14 | " :InsertEnum [] [Enum Values...] 15 | " which insert a smart enum (the one defined in cpp/enum2) 16 | " }}}1 17 | "============================================================================= 18 | 19 | " Buffer-local Definitions {{{1 20 | " Avoid local reinclusion {{{2 21 | let s:cpo_save=&cpo 22 | set cpo&vim 23 | if &cp || (exists("b:loaded_ftplug_cpp_Enum") 24 | \ && (b:loaded_ftplug_cpp_Enum >= s:k_version) 25 | \ && !exists('g:force_reload_ftplug_cpp_Enum')) 26 | let &cpo=s:cpo_save 27 | finish 28 | endif 29 | let b:loaded_ftplug_cpp_Enum = s:k_version 30 | " Avoid local reinclusion }}}2 31 | 32 | "------------------------------------------------------------------------ 33 | " Local commands {{{2 34 | 35 | command! -b -nargs=* InsertEnum call lh#cpp#enum#_new() 36 | 37 | " }}}1 38 | "------------------------------------------------------------------------ 39 | let &cpo=s:cpo_save 40 | "============================================================================= 41 | " vim600: set fdm=marker: 42 | -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_InsertAccessors.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/cpp_InsertAccessors.vim -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_Inspect.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/cpp_Inspect.vim -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_Override.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/cpp_Override.vim -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_options-commands.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/cpp/cpp_options-commands.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 1.1.0 6 | " Created: 10th oct 2002 7 | " Last Update: $Date$ (10th oct 2002) 8 | "------------------------------------------------------------------------ 9 | " Description: 10 | " Some commands used to handle the local files cpp_options.vim 11 | " 12 | " To define options for a project in a hierarchy tree, use |local_vimrc| 13 | " instead. 14 | " 15 | "------------------------------------------------------------------------ 16 | " Installation: Drop this files into $$/ftplugin/cpp/ 17 | " History: {{{ 18 | " Version 1.0.0 19 | " (*) Commands come from cpp_GotoFunctionImpl.vim 20 | " }}} 21 | " TODO: Find a way to define options for a project or a hierarchy 22 | " tree. 23 | "============================================================================= 24 | " Avoid reinclusion {{{ 25 | if exists('b:loaded_ftplug_cpp_options_commands_vim') | finish | endif 26 | let b:loaded_ftplug_cpp_options_commands_vim = 1 27 | " 28 | let s:cpo_save=&cpo 29 | set cpo&vim 30 | " }}} 31 | "------------------------------------------------------------------------ 32 | command! -buffer -nargs=0 CheckOptions :call CheckOptions() 33 | 34 | "============================================================================= 35 | " No reinclusion {{{ 36 | if exists("g:loaded_cpp_options_commands_vim") 37 | let &cpo=s:cpo_save 38 | finish 39 | endif 40 | let g:loaded_cpp_options_commands_vim = 1 41 | " }}} 42 | "------------------------------------------------------------------------ 43 | let s:esc_pwd = '' 44 | " Function: s:CheckOptions() {{{ 45 | " Role: Checks whether we must reload the options file to match the current 46 | " project. 47 | function! s:CheckOptions() 48 | if s:esc_pwd != escape(getcwd(), '\') 49 | let s:pwd = getcwd() 50 | let s:esc_pwd = escape(s:pwd, '\') 51 | let g:do_load_cpp_options = 1 52 | if filereadable("./cpp_options.vim") 53 | so ./cpp_options.vim 54 | " elseif filereadable("$VIM/ftplugin/cpp/cpp_options.vim") 55 | " so $VIM/ftplugin/cpp/cpp_options.vim 56 | else 57 | " so :p:h/cpp_options.vim 58 | runtime ftplugin/cpp/cpp_options.vim 59 | endif 60 | endif 61 | endfunction 62 | " }}} 63 | "------------------------------------------------------------------------ 64 | let &cpo=s:cpo_save 65 | "============================================================================= 66 | " vim600: set fdm=marker: 67 | -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_options.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/ftplugin/cpp/cpp_options.vim -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_refactor.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/cpp/cpp_refactor.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " License: GPLv3 with exceptions 6 | " 7 | " Version: 2.2.1 8 | " Created: 10th Feb 2005 9 | " Last Update: 21st Feb 2019 10 | "------------------------------------------------------------------------ 11 | " Description: Some refactoring oriented mappings and commands 12 | " 13 | " Definitions: 14 | " - :ToInitList 15 | " - :AddBrief 16 | " 17 | "------------------------------------------------------------------------ 18 | " Installation: See |lh-cpp-readme.txt| 19 | " 20 | " History: 21 | " v0.1: 10th Feb 2005 22 | " Initial version 23 | " }}}1 24 | "============================================================================= 25 | 26 | 27 | "============================================================================= 28 | " Avoid buffer reinclusion {{{1 29 | let s:cpo_save=&cpo 30 | set cpo&vim 31 | if &cp || (exists('b:loaded_ftplug_cpp_refactor') 32 | \ && !exists('g:force_reload_cpp_refactor')) 33 | let &cpo=s:cpo_save 34 | finish 35 | endif 36 | let b:loaded_ftplug_cpp_refactor = 1 37 | 38 | " }}}1 39 | "------------------------------------------------------------------------ 40 | " Commands and mappings {{{1 41 | 42 | " Adds Doxygen's keyword @brief into headers where it is missing. 43 | command! -buffer -range=% AddBrief 44 | \ ,s#\(/\*\*\%(\s*\n\s*\*\)*\)\s*\([^@ ]\)#\1 @brief \u\2 45 | 46 | " Changes a list of affectations (instruction) into an initialisation list. 47 | " This is meant to be used into poorly-written constructors. 48 | " How To use it: 49 | " - Move first the '{' after the instructions you want to transform 50 | " - Select (visual mode) the lines where the instructions are 51 | " - Type ``:ToInitList'' 52 | " - Enjoy 53 | " - You may have to change the leading ':' inserted into a ','. 54 | " NB: 55 | " - The initialisation list is reindented at the end of the operation. 56 | command! -buffer -range ToInitList 57 | \ ,s#^\s*\(.\{-}\)\s*=\s*\(.\{-}\);#, \1( \2 )# 58 | \ |s#^,#:# 59 | \ |,normal! == 60 | 61 | 62 | command! -buffer -nargs=* Parents :call ShowParents() 63 | 64 | command! -buffer -range -nargs=0 Modernize :call lh#cpp#refactor#_modernize() 65 | 66 | " Commands and mappings }}}1 67 | "============================================================================= 68 | " Avoid global reinclusion {{{1 69 | if exists("g:loaded_cpp_refactor") 70 | \ && !exists('g:force_reload_cpp_refactor') 71 | let &cpo=s:cpo_save 72 | finish 73 | endif 74 | let g:loaded_cpp_refactor = 1 75 | " Avoid global reinclusion }}}1 76 | "------------------------------------------------------------------------ 77 | " Functions {{{1 78 | 79 | function! s:ShowParents(...) abort 80 | let classname = (a:0 == 0) 81 | \ ? lh#cpp#AnalysisLib_Class#CurrentScope(line('.'),'any') 82 | \ : a:1 83 | let ancestors = lh#cpp#AnalysisLib_Class#Ancestors(classname) 84 | echo string(ancestors) 85 | endfunction 86 | 87 | 88 | " Functions }}}1 89 | "------------------------------------------------------------------------ 90 | let &cpo=s:cpo_save 91 | "============================================================================= 92 | " vim600: set fdm=marker: 93 | -------------------------------------------------------------------------------- /ftplugin/cpp/cpp_set.vim: -------------------------------------------------------------------------------- 1 | " ======================================================================== 2 | " File: ftplugin/cpp/cpp_set.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0 6 | " Last Update: 07th Mar 2017 7 | " 8 | "------------------------------------------------------------------------ 9 | " Description: 10 | " Defines vim options for C++ programming. 11 | " }}}1 12 | " ======================================================================== 13 | 14 | " for changelog: 02nd Jun 2006 -> suffixesadd 15 | 16 | " ======================================================================== 17 | " Buffer local definitions {{{1 18 | " ======================================================================== 19 | if exists("b:loaded_local_cpp_settings") && !exists('g:force_reload_cpp_set') 20 | finish 21 | endif 22 | let b:loaded_local_cpp_settings = 1 23 | 24 | "" line continuation used here ?? 25 | let s:cpo_save = &cpo 26 | set cpo&vim 27 | 28 | " ------------------------------------------------------------------------ 29 | " Commands {{{2 30 | " ------------------------------------------------------------------------ 31 | " Cf. cpp_BuildTemplates.vim 32 | " 33 | " ------------------------------------------------------------------------ 34 | " VIM Includes {{{2 35 | " ------------------------------------------------------------------------ 36 | if exists("b:did_ftplugin") 37 | unlet b:did_ftplugin 38 | endif 39 | source $VIMRUNTIME/ftplugin/cpp.vim 40 | let b:did_ftplugin = 1 41 | 42 | " 43 | " ------------------------------------------------------------------------ 44 | " Options to set {{{2 45 | " ------------------------------------------------------------------------ 46 | " setlocal formatoptions=croql 47 | " setlocal cindent 48 | " 49 | setlocal cinoptions=g0,t0,h1s,i0 50 | if has('patch-7.3-202') 51 | setlocal cinoptions+=N-s 52 | endif 53 | setlocal suffixesadd+=.hpp,.cpp,.C,.h++,.c++,.hh 54 | 55 | " Emulate [[ and ]] in C++ 56 | nnoremap [[ :call lh#dev#_goto_function_begin() 57 | onoremap [[ :call lh#dev#_goto_function_begin() 58 | nnoremap ][ :call lh#dev#_goto_function_end() 59 | onoremap ][ :call lh#dev#_goto_function_end() 60 | 61 | " browse filter 62 | if has("gui_win32") 63 | let b:browsefilter = 64 | \ "C++ Header Files (*.hpp *.h++ *hh)\t*.hpp;*.h++;*.hh\n" . 65 | \ "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" . 66 | \ "C Header Files (*.h)\t*.h\n" . 67 | \ "C Source Files (*.c)\t*.c\n" . 68 | \ "All Files (*.*)\t*.*\n" 69 | endif 70 | " }}}2 71 | 72 | " ======================================================================== 73 | " General definitions {{{1 74 | " ======================================================================== 75 | if exists("g:loaded_cpp_set") && !exists('g:force_reload_cpp_ftp') 76 | let &cpo = s:cpo_save 77 | finish 78 | endif 79 | let g:loaded_cpp_set = 1 80 | 81 | let &cpo = s:cpo_save 82 | "============================================================================= 83 | " vim600: set fdm=marker: 84 | -------------------------------------------------------------------------------- /ftplugin/idl_set.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: ftplugin/cpp/idl_set.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 1.1.0 6 | " Created: 09th Mar 2005 7 | " Last Update: 30th Apr 2019 8 | "------------------------------------------------------------------------ 9 | " Description: Few definitions for IDL editing. 10 | " 11 | "------------------------------------------------------------------------ 12 | " Installation: Drop the file into {rtp}/ftplugin/ 13 | " History: 14 | " v1.0: first version 15 | " inspired from ftplugin/c/c_set.vim and ftplugin/cpp/cpp_set.vim 16 | " TODO: 17 | " * Ensure Def_MapC from c_set.vim is loaded 18 | " }}}1 19 | "============================================================================= 20 | 21 | 22 | "============================================================================= 23 | " Avoid buffer reinclusion {{{1 24 | let s:cpo_save=&cpo 25 | set cpo&vim 26 | if exists('b:loaded_ftplug_idl_set_vim') 27 | \ && !exists('g:force_reload_idl_set_vim') 28 | let &cpo=s:cpo_save 29 | finish 30 | endif 31 | let b:loaded_ftplug_idl_set_vim = 1 32 | 33 | 34 | " ------------------------------------------------------------------------ 35 | " VIM Includes {{{2 36 | " ------------------------------------------------------------------------ 37 | if exists("b:did_ftplugin") 38 | unlet b:did_ftplugin 39 | endif 40 | 41 | " }}}1 42 | "------------------------------------------------------------------------ 43 | " Commands and mappings {{{1 44 | 45 | " ------------------------------------------------------------------------ 46 | " Options to set {{{2 47 | " ------------------------------------------------------------------------ 48 | setlocal formatoptions=croql 49 | setlocal cindent 50 | setlocal comments=sr:/*,mb:*,exl:*/,:// 51 | setlocal isk+=# " so #if is considered as a keyword, etc 52 | 53 | setlocal ch=2 54 | setlocal nosmd 55 | setlocal cinoptions=g0,t0,h1s 56 | 57 | runtime syntax/doxygen.vim 58 | 59 | runtime ftplugin/c/c_brackets.vim 60 | 61 | " ------------------------------------------------------------------------ 62 | " Comments ; Javadoc/DOC++/Doxygen style {{{2 63 | " ------------------------------------------------------------------------ 64 | " /** inserts /** 65 | " */ 66 | " but only outside the scope of C++ comments and strings 67 | inoremap /** =Def_MapC('/**', 68 | \ '/**\\/\\ ', 69 | \ '/**\\/!mark!\\ ') 70 | " /* inserts /** */ 71 | inoremap /* =Def_MapC('/* ', 72 | \ '/** */\\', 73 | \ '/** */!mark!\F*i') 74 | 75 | " Commands and mappings }}}1 76 | "============================================================================= 77 | " Avoid global reinclusion {{{1 78 | if exists("g:loaded_idl_set_vim") 79 | \ && !exists('g:force_reload_idl_set_vim') 80 | let &cpo=s:cpo_save 81 | finish 82 | endif 83 | let g:loaded_idl_set_vim = 1 84 | " Avoid global reinclusion }}}1 85 | "------------------------------------------------------------------------ 86 | " Functions {{{1 87 | 88 | " Functions }}}1 89 | "------------------------------------------------------------------------ 90 | let &cpo=s:cpo_save 91 | "============================================================================= 92 | " vim600: set fdm=marker: 93 | -------------------------------------------------------------------------------- /plugin/homeLikeVC++.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: plugin/homeLikeVC++.vim 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.0.1 6 | " Created: 23rd mar 2002 7 | " Last Update: $Date$ 8 | "------------------------------------------------------------------------ 9 | " Description: Makes behaves like it does with Ms-VC++. 10 | " -> Hitting once moves the cursor to the first non blank character of 11 | " the line, twice: to the first column of the line. 12 | " -> once moves the cursor at the last non blank character, then at the 13 | " last character (if different), ... 14 | " 15 | "------------------------------------------------------------------------ 16 | " Installation: Drop it into one of your plugin directories 17 | " 18 | " This plugin does not propose, on purpose, windows-like keybindings 19 | " combining with , nor . 20 | " These keybinding are more generic, and may need to be implemented 21 | " differently according to one's taste. If you come from a MsWindows 22 | " background you may be interrested in 23 | " :imap gh 24 | " :nmap gh 25 | " :vmap 26 | " 27 | " :imap gh 28 | " :nmap gh 29 | " :vmap 30 | " 31 | " Personnally, I'd rather never end-up in SELECT-mode unless I 32 | " explicitly say so, or unless I jumped to a |marker| (aka 33 | " |placeholder|). For instance, I often need to (visually) select text 34 | " and then surround it with a pair of brackets, while I expect '(' to 35 | " expand into '()' when I am in INSERT- or SELECT-mode. 36 | " 37 | " Thus, In my .vimrc, I define the following mappings: 38 | " :imap vo 39 | " :nmap v 40 | " :vmap 41 | " :imap v 42 | " :nmap v 43 | " :vmap 44 | " 45 | " Note: I use here :*map and not :*noremap. 46 | " 47 | " History: 48 | " v1.0: initial version 49 | " v1.1: VISUAL-mode mapping added. 50 | " v2.0.0: is supported as well 51 | " v2.0.1: silent mappings 52 | "============================================================================= 53 | " 54 | " Avoid reinclusion 55 | if exists("g:loaded_homeLikeVC") && !exists('g:force_reload_homelikeVC') 56 | finish 57 | endif 58 | let g:loaded_homeLikeVC = '2.0.1' 59 | 60 | "------------------------------------------------------------------------ 61 | inoremap @=HomeLikeVCpp() 62 | nnoremap @=HomeLikeVCpp() 63 | vnoremap @=HomeLikeVCpp() 64 | 65 | inoremap @=EndLikeVCpp()a 66 | nnoremap @=EndLikeVCpp() 67 | vnoremap @=EndLikeVCpp() 68 | 69 | function! s:HomeLikeVCpp() 70 | let ll = strpart(getline('.'), -1, col('.')) 71 | if ll =~ '^\s\+$' | return '0' 72 | else | return '^' 73 | endif 74 | endfunction 75 | 76 | 77 | function! s:EndLikeVCpp() 78 | let l = strpart(getline('.'), col('.')-1) 79 | let ll = match(l, '^\S\s*$') 80 | 81 | if getline('.') =~ '^\s*$' 82 | if col('.') + (mode()!='v') == col('$') | return 'g_' 83 | else | return '$' 84 | endif 85 | else 86 | if ll >= 0 | return '$' 87 | else | return 'g_' 88 | endif 89 | endif 90 | endfunction 91 | -------------------------------------------------------------------------------- /plugin/omap-param.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: plugin/omap-param.vim {{{1 3 | " Maintainer: Luc Hermitte 4 | " 5 | " Other Contributors: A.Politz 6 | " Version: 1.1.0 7 | " Created: 03rd Sep 2007 8 | " Last Update: $Date$ (05th Sep 2007) 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " Mappings for selecting functions parameters in various programming 12 | " langages where parameters are passed within braces, separated by 13 | " commas. 14 | " 15 | " See: 16 | " :h objet-select 17 | " 18 | "------------------------------------------------------------------------ 19 | " Installation: 20 | " Drop this file into {rtp}/plugin/ 21 | " Requires 22 | " - Vim 7+, 23 | " - {rtp}/autoload/lh/position.vim 24 | " - {rtp}/autoload/lh/syntax.vim 25 | " History: 26 | " v0.9.0 first version 27 | " Credits: 28 | " 29 | " A.Politz 30 | " TODO: 31 | " Move this into lh-vim-lib or a plugin. 32 | " Notes: 33 | " * "i," can't be used to select several parameters with several uses of 34 | " "i," ; use "a," instead (-> "va,a,a,"). This is because of simple 35 | " letter parameters. 36 | " However, "v2i," works perfectly. 37 | " * The following should be resistant to &magic, and other mappings 38 | " * select-mode is not parasited by this plugin 39 | " }}}1 40 | "============================================================================= 41 | 42 | "============================================================================= 43 | " Avoid global reinclusion {{{1 44 | let s:cpo_save=&cpo 45 | set cpo&vim 46 | if exists("g:loaded_omap_param_vim") 47 | \ && !exists('g:force_reload_omap_param_vim') 48 | let &cpo=s:cpo_save 49 | finish 50 | endif 51 | let g:loaded_omap_param_vim = 1 52 | " Avoid global reinclusion }}}1 53 | "------------------------------------------------------------------------ 54 | " Public Mappings {{{1 55 | onoremap i, :call SelectParam(1,0) 56 | xnoremap i, :call SelectParam(1,1)gv 57 | onoremap a, :call SelectParam(0,0) 58 | xnoremap a, :call SelectParam(0,1)gv 59 | 60 | " Private Functions {{{1 61 | function! s:SelectParam(inner, visual) abort 62 | let saved_pos = getpos('.') 63 | if a:visual ==1 && lh#position#char_at_mark("'>") =~ '[(,]' 64 | \ && !lh#syntax#skip_at_mark("'>") 65 | normal! gv 66 | elseif searchpair('(',',',')','bcW','lh#syntax#skip()') > 0 || 67 | \ searchpair('(',',',')','bW','lh#syntax#skip()') > 0 68 | " Test necessary because 'c' flag and Skip() don't always work well together 69 | call search('.') 70 | normal! v 71 | else 72 | throw "Not on a parameter" 73 | endif 74 | 75 | let cnt = v:count <= 0 ? 1 : v:count 76 | 77 | while cnt > 0 78 | let cnt -= 1 79 | if 0 == searchpair('(', ',',')', 'W','lh#syntax#skip()') 80 | if lh#position#is_before(getpos('.'), saved_pos) 81 | " no "vi," when starting from the last parameter 82 | exe "normal! \" 83 | call setpos('.', saved_pos) 84 | throw (a:visual?'v':'').(a:inner?'i':'a').",: Cursor not on a parameter" 85 | else 86 | echomsg (a:visual?'v':'').(a:inner?'i':'a').",: No more parameters" 87 | " 999di, silently deletes everything till the end 88 | break 89 | endif 90 | endif 91 | endwhile 92 | " Don't include the last closing paren 93 | if a:inner == 1 || searchpair('(',',',')','n','lh#syntax#skip()') <= 0 94 | call search('.','b') 95 | endif 96 | endfunction 97 | 98 | 99 | " Private Functions }}}1 100 | 101 | if 0 102 | finish 103 | call Un(Null,fun2(fun3(a,b,g(NULL))),t, titi, r , zzz 104 | call Un(Null,fun2(fun3(a,b,g(NULL))),t, titi, , zzz) 105 | endif 106 | 107 | "------------------------------------------------------------------------ 108 | let &cpo=s:cpo_save 109 | "============================================================================= 110 | " vim600: set fdm=marker: 111 | -------------------------------------------------------------------------------- /script/PVS2qf.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | '" 9 | 10 | 11 | 12 | 21 | 22 | [ 23 | 24 | 27 | { 'filename': '', 28 | 'lnum': , 29 | 'nr' : '', 30 | 'text': 31 | ' 32 | 33 | ', 34 | 'type': } 35 | 36 | , 37 | ] 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spec/deps_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | require 'spec_helper' 3 | require 'pp' 4 | 5 | 6 | RSpec.describe "C++ check dependencies are loaded", :cpp, :deps do 7 | let (:filename) { "test.cpp" } 8 | 9 | before :each do 10 | # expect(vim.echo('&enc')).to eq 'utf-8' 11 | # vim.command('let b:marker_open = "\u00AB"') 12 | # vim.command('let b:marker_close = "\u00BB"') 13 | # expect(vim.echo('b:marker_open')).to eq '«' 14 | # expect(vim.echo('lh#marker#open()')).to eq '«' 15 | vim.command('filetype plugin on') 16 | vim.command("file #{filename}") 17 | vim.set('ft=cpp') 18 | vim.set('expandtab') 19 | vim.set('sw=4') 20 | vim.command('silent! unlet g:cpp_explicit_default') 21 | vim.command('silent! unlet g:cpp_std_flavour') 22 | clear_buffer 23 | end 24 | 25 | it "has loaded C++ ftplugin" do 26 | # pp vim.echo('&rtp') 27 | # pp vim.command(':scriptnames') 28 | expect(/plugin.mu-template\.vim/).to be_sourced 29 | # expect(/ftplugin.cpp.cpp_snippets\.vim/).to be_sourced 30 | vim.command('call lh#mut#dirs#update()') 31 | expect(vim.echo('g:lh#mut#dirs#cache')).to match(/cpp/) 32 | # pp vim.echo('g:lh#mut#dirs#cache') 33 | 34 | expect(vim.echo('lh#naming#type("toto")')).to eq "Toto" 35 | end 36 | 37 | end 38 | -------------------------------------------------------------------------------- /spec/empty-exception-class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | require 'spec_helper' 3 | require 'pp' 4 | 5 | 6 | RSpec.describe "C++ empty-exception class wizard", :empty_exception, :cpp, :class do 7 | let (:filename) { "test.cpp" } 8 | 9 | # ====[ Executed once before all test {{{2 10 | before :all do 11 | if !defined? vim.runtime 12 | vim.define_singleton_method(:runtime) do |path| 13 | self.command("runtime #{path}") 14 | end 15 | end 16 | vim.runtime('spec/support/input-mock.vim') 17 | expect(vim.command('verbose function lh#ui#input')).to match(/input-mock.vim/) 18 | expect(vim.echo('lh#mut#dirs#get_templates_for("cpp/empty-exception-class")')).to match(/empty-exception-class.template/) 19 | end 20 | 21 | # ====[ Always executed before each test {{{2 22 | before :each do 23 | vim.command('filetype plugin on') 24 | vim.command("file #{filename}") 25 | vim.set('ft=cpp') 26 | vim.set('expandtab') 27 | vim.set('sw=4') 28 | vim.command('silent! unlet g:cpp_explicit_default') 29 | vim.command('silent! unlet g:cpp_std_flavour') 30 | clear_buffer 31 | set_buffer_contents <<-EOF 32 | /** File Header line to trick auto-inclusion */ 33 | EOF 34 | vim.command(%Q{call append(1, ['', ''])}) 35 | expect(vim.echo('line("$")')).to eq '3' 36 | expect(vim.echo('setpos(".", [1,3,1,0])')).to eq '0' 37 | expect(vim.echo('line(".")')).to eq '3' 38 | end 39 | 40 | 41 | specify "empty_exception_class noncopyable, with implicit definitions, C++98", :cpp98 do 42 | expect(vim.command('MuTemplate cpp/empty-exception-class')).to match(/^$|#include added/) 43 | assert_buffer_contents <<-EOF 44 | /** File Header line to trick auto-inclusion */ 45 | #include 46 | 47 | /** 48 | * «Test». 49 | * @invariant «» 50 | *

Semantics
51 | * - Exception class 52 | * - Copyable 53 | * @author «author-name», creation 54 | * @since Version «1.0» 55 | */ 56 | class «Test» : public std::runtime_error 57 | { 58 | public: 59 | 60 | /** 61 | * Init constructor. 62 | * @param «ctr-parameters» «» 63 | * «@throw » 64 | */ 65 | «Test»(«ctr-parameters»); 66 | }; 67 | EOF 68 | end 69 | 70 | specify "empty_exception_class noncopyable, with implicit definitions, C++11", :cpp11 do 71 | vim.command('let g:cpp_std_flavour = 11') 72 | expect(vim.command('MuTemplate cpp/empty-exception-class')).to match(/^$|#include added/) 73 | assert_buffer_contents <<-EOF 74 | /** File Header line to trick auto-inclusion */ 75 | #include 76 | 77 | /** 78 | * «Test». 79 | * @invariant «» 80 | *

Semantics
81 | * - Exception class 82 | * - Copyable 83 | * @author «author-name», creation 84 | * @since Version «1.0» 85 | */ 86 | class «Test» : public std::runtime_error 87 | { 88 | public: 89 | 90 | using std::runtime_error::runtime_error; 91 | }; 92 | EOF 93 | end 94 | 95 | specify "empty_exception_class noncopyable, no implicit definitions, C++11", :cpp11, :defaulted do 96 | vim.command('let g:cpp_std_flavour = 11') 97 | vim.command("let g:cpp_explicit_default = 1") 98 | expect(vim.command('MuTemplate cpp/empty-exception-class')).to match(/^$|#include added/) 99 | assert_buffer_contents <<-EOF 100 | /** File Header line to trick auto-inclusion */ 101 | #include 102 | 103 | /** 104 | * «Test». 105 | * @invariant «» 106 | *

Semantics
107 | * - Exception class 108 | * - Copyable 109 | * @author «author-name», creation 110 | * @since Version «1.0» 111 | */ 112 | class «Test» : public std::runtime_error 113 | { 114 | public: 115 | 116 | «Test»(«Test» const&) = default; 117 | «Test»& operator=(«Test» const&) = default; 118 | /** 119 | * Virtual destructor. 120 | * @throw Nothing 121 | */ 122 | virtual ~«Test»() = default; 123 | using std::runtime_error::runtime_error; 124 | }; 125 | EOF 126 | end 127 | 128 | end 129 | 130 | # vim:set sw=2: 131 | 132 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'tmpdir' 2 | require 'vimrunner' 3 | require 'vimrunner/rspec' 4 | require 'support/vim' 5 | require 'rspec/expectations' 6 | require 'support/vim_matchers' 7 | # require 'simplecov' 8 | 9 | # SimpleCov.start 10 | 11 | module Vimrunner 12 | class Client 13 | def runtime(script) 14 | script_path = Path.new(script) 15 | command("runtime #{script_path}") 16 | end 17 | end 18 | end 19 | 20 | 21 | Vimrunner::RSpec.configure do |config| 22 | config.reuse_server = true 23 | 24 | vim_plugin_path = File.expand_path('.') 25 | vim_flavor_path = ENV['HOME']+'/.vim/flavors' 26 | 27 | config.start_vim do 28 | vim = Vimrunner.start_gvim 29 | # vim = Vimrunner.start 30 | 31 | vim.add_plugin(vim_flavor_path, 'bootstrap.vim') 32 | vim.prepend_runtimepath(vim_plugin_path+'/after') 33 | vim.prepend_runtimepath(vim_plugin_path) 34 | 35 | # lh-UT 36 | vim_UT_path = File.expand_path('../../../vim-UT', __FILE__) 37 | vim.prepend_runtimepath(vim_UT_path) 38 | vim.runtime('plugin/UT.vim') 39 | 40 | # pp vim_flavor_path 41 | # lh-vim-lib 42 | vim_lib_path = File.expand_path('../../../lh-vim-lib', __FILE__) 43 | vim.prepend_runtimepath(vim_lib_path) 44 | vim.runtime('plugin/let.vim') # LetIfUndef 45 | # vim.runtime('plugin/ui-functions.vim') # lh#ui#confirm 46 | # vim.command(':messages') 47 | 48 | # lh-tags 49 | vim_tags_path = File.expand_path('../../../lh-tags', __FILE__) 50 | vim.prepend_runtimepath(vim_tags_path) 51 | vim.runtime('plugin/lh-tags.vim') # AddStyle 52 | 53 | # lh-style 54 | vim_style_path = File.expand_path('../../../lh-style', __FILE__) 55 | vim.prepend_runtimepath(vim_style_path) 56 | vim.runtime('plugin/lh-style.vim') # AddStyle 57 | 58 | # lh-dev 59 | vim_dev_path = File.expand_path('../../../lh-dev', __FILE__) 60 | vim.prepend_runtimepath(vim_dev_path) 61 | 62 | # lh-brackets 63 | vim_brackets_path = File.expand_path('../../../lh-brackets', __FILE__) 64 | vim.prepend_runtimepath(vim_brackets_path) 65 | vim.runtime('plugin/misc_map.vim') # Inoreab 66 | vim.runtime('plugin/common_brackets.vim') # Brackets 67 | vim.runtime('plugin/bracketing.base.vim') # !mark! 68 | vim.command('set enc=utf-8') 69 | #vim.command('SetMarker <+ +>') 70 | 71 | # mu-template 72 | mu_template_path = File.expand_path('../../../mu-template@lh', __FILE__) 73 | vim.prepend_runtimepath(mu_template_path+'/after') 74 | vim.prepend_runtimepath(mu_template_path) 75 | vim.runtime('plugin/mu-template.vim') # !mark! 76 | 77 | # pp vim.echo('&rtp') 78 | vim.command('set shm=') 79 | 80 | has_redo = vim.echo('has("patch-7.4.849")') 81 | if has_redo != "1" 82 | puts "WARNING: this flavor of vim won't permit to support redo" 83 | end 84 | vim 85 | end 86 | end 87 | 88 | RSpec.configure do |config| 89 | config.include Support::Vim 90 | 91 | def write_file(filename, contents) 92 | dirname = File.dirname(filename) 93 | FileUtils.mkdir_p dirname if not File.directory?(dirname) 94 | 95 | File.open(filename, 'w') { |f| f.write(contents) } 96 | end 97 | end 98 | 99 | # vim:set sw=2: 100 | -------------------------------------------------------------------------------- /spec/value-class_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | require 'spec_helper' 3 | require 'pp' 4 | 5 | 6 | RSpec.describe "C++ Value class wizard", :cpp, :class, :value do 7 | let (:filename) { "test.cpp" } 8 | 9 | # ====[ Executed once before all test {{{2 10 | before :all do 11 | if !defined? vim.runtime 12 | vim.define_singleton_method(:runtime) do |path| 13 | self.command("runtime #{path}") 14 | end 15 | end 16 | vim.runtime('spec/support/input-mock.vim') 17 | expect(vim.command('verbose function lh#ui#input')).to match(/input-mock.vim/) 18 | expect(vim.echo('lh#mut#dirs#get_templates_for("cpp/value-class")')).to match(/value-class.template/) 19 | end 20 | 21 | # ====[ Always executed before each test {{{2 22 | before :each do 23 | vim.command('filetype plugin on') 24 | vim.command("file #{filename}") 25 | vim.set('ft=cpp') 26 | vim.set('expandtab') 27 | vim.set('sw=4') 28 | vim.command('silent! unlet g:cpp_explicit_default') 29 | vim.command('silent! unlet g:cpp_std_flavour') 30 | clear_buffer 31 | set_buffer_contents <<-EOF 32 | /** File Header line to trick auto-inclusion */ 33 | EOF 34 | vim.command(%Q{call append(1, ['', ''])}) 35 | expect(vim.echo('line("$")')).to eq '3' 36 | expect(vim.echo('setpos(".", [1,3,1,0])')).to eq '0' 37 | expect(vim.echo('line(".")')).to eq '3' 38 | end 39 | 40 | specify "value-class copyable", :cpp98, :cpp11, :copyable do 41 | expect(vim.command('MuTemplate cpp/value-class')).to eq "" 42 | assert_buffer_contents <<-EOF 43 | /** File Header line to trick auto-inclusion */ 44 | 45 | /** 46 | * «Test». 47 | * @invariant «» 48 | *

Semantics
49 | * - Value object 50 | * - «Regular object» 51 | * - «Comparable» 52 | * @author «author-name», creation 53 | * @since Version «1.0» 54 | */ 55 | class «Test» 56 | { 57 | public: 58 | 59 | }; 60 | EOF 61 | end 62 | 63 | specify "value-class copyable, no implicit definition", :cpp11, :copyable, :defaulted do 64 | vim.command("let g:cpp_std_flavour = 11") 65 | vim.command("let g:cpp_explicit_default = 1") 66 | expect(vim.command('MuTemplate cpp/value-class')).to eq "" 67 | assert_buffer_contents <<-EOF 68 | /** File Header line to trick auto-inclusion */ 69 | 70 | /** 71 | * «Test». 72 | * @invariant «» 73 | *

Semantics
74 | * - Value object 75 | * - «Regular object» 76 | * - «Comparable» 77 | * @author «author-name», creation 78 | * @since Version «1.0» 79 | */ 80 | class «Test» 81 | { 82 | public: 83 | 84 | «Test»() = default; 85 | «Test»(«Test» const&) = default; 86 | «Test»& operator=(«Test» const&) = default; 87 | /** 88 | * Destructor. 89 | * @throw Nothing 90 | * @warning this class is not meant to be publicly inherited 91 | */ 92 | ~«Test»() = default; 93 | }; 94 | EOF 95 | end 96 | 97 | 98 | end 99 | 100 | # vim:set sw=2: 101 | -------------------------------------------------------------------------------- /syntax/c-assign-in-condition.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: syntax/c-assign-in-condition.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0 6 | " Created: 08th Oct 2007 7 | " Last Update: 16th Dec 2015 8 | "------------------------------------------------------------------------ 9 | " Purpose: C syntax enhancements 10 | " (*) Hightlights assignements in if(), while(), ..., conditions 11 | " 12 | "------------------------------------------------------------------------ 13 | " Requirements: 14 | " None 15 | " 16 | " Option: 17 | " - |c_no_assign_in_condition| to disable the check that assignments are 18 | " done in conditions. 19 | " }}}1 20 | " ======================================================================== 21 | " {{{1 Syntax definitions 22 | " 23 | " {{{2 Don't assign in conditions 24 | if !get(g:, "c_no_assign_in_condition", 0) 25 | 26 | syn match cAssignInConditionBad '\(\]*\)\@<==[^=][^,)]*' 27 | syn match cAssignInConditionRare '\(\]*\)\@<==[^=][^,)]*' 28 | 29 | hi def link cAssignInConditionBad SpellBad 30 | hi def link cAssignInConditionRare SpellRare 31 | endif 32 | 33 | 34 | " ======================================================================== 35 | " {{{1 Some mappings 36 | 37 | " }}}1 38 | " ======================================================================== 39 | " vim: set foldmethod=marker: 40 | -------------------------------------------------------------------------------- /syntax/c-fallthrough-case.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: syntax/c-fallthrough-case.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0. 6 | let s:k_version = '217' 7 | " Created: 16th Dec 2015 8 | " Last Update: 16th Dec 2015 9 | "------------------------------------------------------------------------ 10 | " Description: C syntax enhancements 11 | " (*) Hightlights cases that fall through other cases 12 | " 13 | " Option: 14 | " - |c_no_hl_fallthrough_case| to disable the check 15 | " Disabled by default 16 | " }}}1 17 | "============================================================================= 18 | 19 | let s:cpo_save=&cpo 20 | set cpo&vim 21 | "------------------------------------------------------------------------ 22 | if !get(g:, 'c_no_hl_fallthrough_case', 1) 23 | silent! syn clear cFallthroughCase 24 | 25 | " These are usually defined as keywords, but we don't want their 26 | " |:syn-priority| to be higher => we redefine them as |:syn-match| 27 | syn clear cLabel 28 | silent! syn clear cBadLabel 29 | syn match cBadLabel /\v/ containedin=cFallthroughCase 30 | syn match cBadLabel /\v/ containedin=cFallthroughCase 31 | syn match cLabel /\v/ 32 | syn match cLabel /\v/ 33 | 34 | " FIXME: "break;} case" is incorrectly recognized 35 | " FIXME: "default:" is not recognized 36 | syn match cFallthroughCase /\v(((||\_s+\w+|return.*)\_s*;(\_s*})*|\{|\[\[fallthrough]])\_s*)@\_s+\w+|)\s*:/ contains=cBadLabel 37 | 38 | hi def link cFallthroughCase spellBad 39 | hi def link cBadLabel badLabel 40 | hi badLabel term=reverse,bold ctermfg=3 ctermbg=9 gui=undercurl,bold guisp=Red guifg=Brown 41 | endif 42 | "------------------------------------------------------------------------ 43 | let &cpo=s:cpo_save 44 | "============================================================================= 45 | " vim600: set fdm=marker: 46 | -------------------------------------------------------------------------------- /syntax/c.vim: -------------------------------------------------------------------------------- 1 | " ======================================================================== 2 | " File: syntax/c.vim 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 1.1.0 6 | " Last Update: $Date$ 7 | " 8 | " Purpose: C syntax enhancements 9 | " Option: 10 | " ======================================================================== 11 | 12 | " This is the only valid way to load the C++ and C default syntax file. 13 | so $VIMRUNTIME/syntax/c.vim 14 | 15 | " Source syntax hooks for C 16 | runtime! syntax/c-*.vim syntax/c_*.vim 17 | 18 | -------------------------------------------------------------------------------- /syntax/cpp-c-cast.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: syntax/cpp-c-cast.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.2.0 6 | let s:k_version = '220' 7 | " Created: 16th Dec 2015 8 | " Last Update: 20th Apr 2016 9 | "------------------------------------------------------------------------ 10 | " Description: C++ syntax enhancements 11 | " (*) detect C casts in C++ 12 | " 13 | " Options: 14 | " - |cpp_no_hl_c_cast| to disable the check 15 | " 16 | " Known bugs: 17 | " - `decltype(auto) foo;` 18 | " - `f(12)(13)(14)` 19 | " }}}1 20 | "============================================================================= 21 | " {{{1 Syntax definitions 22 | if get(g:, 'cpp_no_hl_c_cast', 0) 23 | finish 24 | endif 25 | 26 | silent! syn clear cCast 27 | 28 | " (int*)v 29 | " but exclude some operators like "and", "or", "xor", "not" with "@!" 30 | " and function specifiers: "const", "volatile", "final", "override", "throw", "noexcept" 31 | syn match cCast '\v\(.{-}\)\s*(|||||||||)@!\w+' 32 | " (int*)(expr) 33 | " "\w@!" is used to ignore double chained calls to operator() 34 | " -> f(12)(13) and f (12)(13) are ignored 35 | " -> (int*)(expr) is matched 36 | syn match cCast '\v(\w\s*)@ 4 | " 5 | " Version: 2.2.0. 6 | " Created: 23rd Apr 2009 7 | " Last Update: 16th Dec 2015 8 | "------------------------------------------------------------------------ 9 | " Description: C++ syntax enhancements for CxxTest 10 | " assertions. 11 | " 12 | "------------------------------------------------------------------------ 13 | " Option: 14 | " History: «history» 15 | " TODO: «missing features» 16 | " }}}1 17 | "============================================================================= 18 | 19 | let s:cpo_save=&cpo 20 | set cpo&vim 21 | "------------------------------------------------------------------------ 22 | 23 | syn keyword cppCxxTest TS_FAIL 24 | syn keyword cppCxxTest TS_ASSERT 25 | syn keyword cppCxxTest TS_ASSERT_EQUALS 26 | syn keyword cppCxxTest TS_ASSERT_SAME_DELTA 27 | syn keyword cppCxxTest TS_ASSERT_DIFFERS 28 | syn keyword cppCxxTest TS_ASSERT_LESS_THAN 29 | syn keyword cppCxxTest TS_ASSERT_LESS_THAN_EQUALS 30 | syn keyword cppCxxTest TS_ASSERT_PREDICATE 31 | syn keyword cppCxxTest TS_ASSERT_RELATION 32 | syn keyword cppCxxTest TS_ASSERT_THROWS 33 | syn keyword cppCxxTest TS_ASSERT_THROWS_EQUALS 34 | syn keyword cppCxxTest TS_ASSERT_THROWS_ASSERT 35 | syn keyword cppCxxTest TS_ASSERT_THROWS_ANYTHING 36 | syn keyword cppCxxTest TS_ASSERT_THROWS_NOTHING 37 | syn keyword cppCxxTest TS_WARN 38 | syn keyword cppCxxTest TS_TRACE 39 | 40 | syn keyword cppCxxTest TSM_FAIL 41 | syn keyword cppCxxTest TSM_ASSERT 42 | syn keyword cppCxxTest TSM_ASSERT_EQUALS 43 | syn keyword cppCxxTest TSM_ASSERT_SAME_DELTA 44 | syn keyword cppCxxTest TSM_ASSERT_DIFFERS 45 | syn keyword cppCxxTest TSM_ASSERT_LESS_THAN 46 | syn keyword cppCxxTest TSM_ASSERT_LESS_THAN_EQUALS 47 | syn keyword cppCxxTest TSM_ASSERT_PREDICATE 48 | syn keyword cppCxxTest TSM_ASSERT_RELATION 49 | syn keyword cppCxxTest TSM_ASSERT_THROWS 50 | syn keyword cppCxxTest TSM_ASSERT_THROWS_EQUALS 51 | syn keyword cppCxxTest TSM_ASSERT_THROWS_ASSERT 52 | syn keyword cppCxxTest TSM_ASSERT_THROWS_ANYTHING 53 | syn keyword cppCxxTest TSM_ASSERT_THROWS_NOTHING 54 | syn keyword cppCxxTest TSM_WARN 55 | syn keyword cppCxxTest TSM_TRACE 56 | 57 | hi def link cppCxxTest Special 58 | 59 | "------------------------------------------------------------------------ 60 | let &cpo=s:cpo_save 61 | "============================================================================= 62 | " vim600: set fdm=marker: 63 | -------------------------------------------------------------------------------- /syntax/cpp-funcdef.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: syntax/cpp-funcdef.vim {{{1 3 | " Author: Olivier Teuliere 4 | " 5 | " Maintainer: Luc Hermitte 6 | " 7 | " Version: 2.2.0. 8 | " Created: 23rd Jul 2007 9 | " Last Update: 16th Dec 2015 10 | "------------------------------------------------------------------------ 11 | " Purpose: C++ syntax enhancements 12 | " (*) Hightlights member-function definitions 13 | " 14 | "------------------------------------------------------------------------ 15 | " Option: 16 | " - |cpp_no_hl_funcdef| to disable the highlight 17 | " }}}1 18 | " ======================================================================== 19 | " {{{1 Syntax definitions 20 | " 21 | " {{{2 Enforce catch by reference 22 | if !get(g:, "cpp_no_hl_funcdef", 0) 23 | syn match cppFuncDef "::\~\?\zs\h\w*\ze([^)]*\()\s*\(const\)\?\)\?$" 24 | 25 | hi def link cppFuncDef Special 26 | endif 27 | 28 | " ======================================================================== 29 | 30 | " ======================================================================== 31 | " vim: set foldmethod=marker: 32 | -------------------------------------------------------------------------------- /syntax/cpp.vim: -------------------------------------------------------------------------------- 1 | " ======================================================================== 2 | " File: syntax/cpp.vim 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 1.1.0 6 | " Last Update: $Date$ 7 | " 8 | " Purpose: C++ syntax enhancements 9 | " 10 | " Option: 11 | " ======================================================================== 12 | 13 | " This is the only valid way to load the C++ and C default syntax file. 14 | so $VIMRUNTIME/syntax/cpp.vim 15 | 16 | 17 | " Source syntax hooks for C++ 18 | runtime! syntax/cpp-*.vim syntax/cpp_*.vim 19 | 20 | " Load syntax enhancements for Doxygen, if installed 21 | " runtime syntax/doxygen.vim 22 | " see :h doxygen 23 | " .vimrc => :let g:load_doxygen_syntax=1 24 | 25 | " Load syntax enhancements for wxWindows, if installed 26 | runtime syntax/wxwin.vim 27 | -------------------------------------------------------------------------------- /tests/VimFlavor: -------------------------------------------------------------------------------- 1 | flavor 'LucHermitte/vim-UT', '>= 0.6.0' 2 | -------------------------------------------------------------------------------- /tests/lh/analysis.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: tests/lh/analysis.vim {{{1 3 | " Author: Luc Hermitte 4 | " 5 | " Version: 2.0.0.b15 6 | let s:k_version = '2.0.0b15' 7 | " Created: 17th Feb 2015 8 | " Last Update: $Date$ 9 | "------------------------------------------------------------------------ 10 | " Description: 11 | " Unit Tests for AnalysisLic 12 | " }}}1 13 | "============================================================================= 14 | 15 | UTSuite [lh-cpp] Testing lh/cpp/AnalysisLib_Class 16 | 17 | runtime autoload/lh/cpp/AnalysisLib_Class.vim 18 | 19 | let s:cpo_save=&cpo 20 | set cpo&vim 21 | 22 | "------------------------------------------------------------------------ 23 | function! s:Test_simplify_id() 24 | " Partial Match up to last ns 25 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['', 'a', 'a::b'] ) == 'C' 26 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['::', 'a::', 'a::b::']) == 'C' 27 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a', 'a::b'] ) == 'C' 28 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a::', 'a::b::'] ) == 'C' 29 | 30 | " Partial Match (of first ns) 31 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a', 'a::z'] ) == 'b::C' 32 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a::', 'a::z::'] ) == 'b::C' 33 | 34 | " No Match 35 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['z', 'a::z'] ) == 'a::b::C' 36 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['z::', 'a::z::'] ) == 'a::b::C' 37 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['', 'z', 'a::z'] ) == 'a::b::C' 38 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['::', 'z::', 'a::z::']) == 'a::b::C' 39 | 40 | " Full Match 41 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a', 'a::b::C'] ) == '' 42 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a::', 'a::b::C::'] ) == '' 43 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['', 'b', 'a::b::C'] ) == '' 44 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['::', 'b::', 'a::b::C::']) == '' 45 | endfunction 46 | 47 | function! s:Test_simplify_id_and_show_ns() 48 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['', 'a', 'a::b'] , 1) == ['a::b::', 'C'] 49 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['::', 'a::', 'a::b::'], 1) == ['a::b::', 'C'] 50 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a', 'a::b'] , 1) == ['a::b::', 'C'] 51 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a::', 'a::b::'] , 1) == ['a::b::', 'C'] 52 | 53 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a', 'a::z'] , 1) == ['a::', 'b::C'] 54 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['a::', 'a::z::'] , 1) == ['a::', 'b::C'] 55 | 56 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['z', 'a::z'] , 1) == ['', 'a::b::C'] 57 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['z::', 'a::z::'] , 1) == ['', 'a::b::C'] 58 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['', 'z', 'a::z'] , 1) == ['', 'a::b::C'] 59 | Assert lh#cpp#AnalysisLib_Class#simplify_id('a::b::C', ['::', 'z::', 'a::z::'], 1) == ['', 'a::b::C'] 60 | endfunction 61 | 62 | "------------------------------------------------------------------------ 63 | let &cpo=s:cpo_save 64 | "============================================================================= 65 | " vim600: set fdm=marker: 66 | -------------------------------------------------------------------------------- /tests/lh/cpp-TU-override.cpp: -------------------------------------------------------------------------------- 1 | // Vim: let b:tags_dirname = '.' 2 | // 3 | namespace nZ { 4 | class B {}; 5 | } // nZ namespace 6 | 7 | 8 | namespace foo { 9 | class A0 10 | { 11 | virtual ~A0() = 0; 12 | virtual void a0(); 13 | }; 14 | 15 | class A1 16 | { 17 | virtual ~A1(); 18 | virtual void f1(std::string const& s) = 0; 19 | virtual void f2() { f1("foo"); } 20 | void f2(int); 21 | 22 | [] 23 | }; 24 | 25 | class A2 : virtual A0 26 | { 27 | virtual ~A2() {} 28 | virtual void g(); 29 | virtual void a0(); 30 | 31 | ['A0'] 32 | } 33 | 34 | class A3 : virtual A0 35 | { 36 | void a0(); 37 | 38 | ['A0'] 39 | } 40 | 41 | class C1 : A1, A2 42 | { 43 | virtual ~C1(); 44 | void f2(); 45 | 46 | ['A0', 'A1', 'A2'] 47 | }; 48 | 49 | class D : C1, virtual A0 50 | { 51 | virtual void g(); 52 | 53 | ['A0', 'A1', 'A2', 'C1'] 54 | }; 55 | class B : A0{}; 56 | } // foo namespace 57 | 58 | namespace bar { 59 | using namespace nZ; 60 | struct V {}; 61 | struct Z {}; 62 | struct C1 : virtual V {}; 63 | struct C2 : virtual V, Z {}; 64 | struct C3 : C2{}; 65 | struct D : C1, C3, B {}; 66 | // echo lh#cpp#AnalysisLib_Class#Ancestors('bar::D') 67 | } // bar namespace 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /tests/lh/cpp-TU.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/tests/lh/cpp-TU.cpp -------------------------------------------------------------------------------- /tests/lh/omap-param.vim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LucHermitte/lh-cpp/c0a65da5e8b78a81300d318d88bda368fe1922cb/tests/lh/omap-param.vim --------------------------------------------------------------------------------