From 2008cff2651bc012bf30773df8d88a0b6b280cec Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 22 Aug 2014 15:59:22 -0700 Subject: [PATCH] [vim] Syntax highlighting for C++11 specifiers Also a GetNamespace() function that's never used, doesn't really work, but that I wrote a while back to help with doc comments. Fun! --- vim/after/ftplugin/cpp.vim | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 vim/after/ftplugin/cpp.vim diff --git a/vim/after/ftplugin/cpp.vim b/vim/after/ftplugin/cpp.vim new file mode 100644 index 0000000..0ae8648 --- /dev/null +++ b/vim/after/ftplugin/cpp.vim @@ -0,0 +1,61 @@ +" cpp.vim +" Eryn Wells = 508 || !exists("did_erw_cpp_syntax_inits") + if version < 508 + let did_erw_cpp_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink cppSpecifier Type + delcommand HiLink +endif + + +function! GetNamespaces() + " Save the cursor + let l = line('.') + let c = col('.') + + let pattern = '\v^namespace\s+(\w+)\s*\{' + + let namespaces = [] + let lastLine = search(pattern, 'bW') + while lastLine > 0 + echo 'Found namespace header on line ' . lastLine + + " Find matching brace + normal % + echo 'Found closing brace on line ' . line('.') + + if line('.') < lastLine + " We've skipped into a new namespace block. We're done. + echo 'New namespace block; breaking' + break + endif + + " Jump back to the starting brace + normal % + echo 'Back to line ' . line('.') + + let ns = substitute(getline('.'), pattern, '\1', '') + echo 'Found namespace: ' . ns + if ns !=# '' + call insert(namespaces, ns, 0) + echo 'Namespaces so far: ' . string(namespaces) + endif + + " Search for the next namespace + echo 'Searching again...' + let searchLine = search(pattern, 'bW') + endwhile + + " Restore the cursor position + call cursor(l, c) + + return namespace +endfunction