Skip to content

Commit

Permalink
Move ftplugin plug-ins
Browse files Browse the repository at this point in the history
- Fix file skeletons.
- Move filetype plug-ins.
- Update the toolbox.
- Documentation.

Note: The filetype plug-ins have been moved, and are thus not loaded
automatically anymore. Copy them from 'c-support/rc' to 'ftplugin',
or add the commands there to your own filetype plug-ins.

taken from WolfgangMehner/vim-plugins, revision
WolfgangMehner/vim-plugins@006ed31
  • Loading branch information
WolfgangMehner committed Nov 5, 2017
1 parent 3c35bc8 commit 1ef8728
Show file tree
Hide file tree
Showing 23 changed files with 422 additions and 283 deletions.
24 changes: 14 additions & 10 deletions README.md
Expand Up @@ -3,8 +3,9 @@ Preface

This repository is mainly for the use with plug-in managers.

The development happens here:
[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins)
Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/csupport.html).

The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins).


--------------------------------------------------------------------------------
Expand Down Expand Up @@ -222,6 +223,10 @@ RELEASE NOTES FOR VERSION 6.2.1
- Fix a problem with the path when setting 'Run->executable to run'.
- New and reworked templates. Change statement templates.

Note: The filetype plug-ins have been moved, and are thus not loaded
automatically anymore. Copy them from 'c-support/rc' to 'ftplugin',
or add the commands there to your own filetype plug-ins.

Note: This reworks most of the statement templates. The loop and if templates
which do not introduce a block have been remove entirely, since the templates
without blocks save barely any typing. They do not make much sense in visual
Expand Down Expand Up @@ -280,12 +285,6 @@ ___The following files and extensions are for convenience only.___
___c.vim will work without them.___
___The settings are explained in the files themselves.___

ftplugin/c.vim
Example filetype plug-in for C/C++:
defines additional maps
ftplugin/make.vim
Access hotkeys for make(1) in makefiles.

ftdetect/template.vim
ftplugin/template.vim
syntax/template.vim
Expand All @@ -296,8 +295,6 @@ ___The settings are explained in the files themselves.___
c-support/doc/ChangeLog
Complete change log.

c-support/rc/customization.cpp.vim
Additional mappings for C++.
c-support/rc/customization.ctags
Additional settings for use in .ctags to enable
navigation through makefiles and qmake files with the
Expand All @@ -317,6 +314,13 @@ ___The settings are explained in the files themselves.___
The file is commented. Append it to your .vimrc if you
like.

c-support/rc/c.vim
c-support/rc/cpp.vim
Example filetype plug-in for C/C++:
defines additional maps
c-support/rc/make.vim
Access hotkeys for make(1) in makefiles.

c-support/rc/*.templates
Sample template files for customization. Used by the
template setup wizard.
Expand Down
161 changes: 133 additions & 28 deletions autoload/mmtoolbox/cmake.vim
Expand Up @@ -43,7 +43,7 @@ endif
if &cp || ( exists('g:CMake_Version') && ! exists('g:CMake_DevelopmentOverwrite') )
finish
endif
let g:CMake_Version= '0.9.2' " version number of this script; do not change
let g:CMake_Version= '0.9.3' " version number of this script; do not change
"
"-------------------------------------------------------------------------------
" Auxiliary functions {{{1
Expand Down Expand Up @@ -291,7 +291,7 @@ let s:ErrorFormat_MakeAdditions =
"
" policy list {{{2
"
let s:Policies_Version = '2.8.12'
let s:Policies_Version = '3.10'
let s:Policies_List = [
\ [ 'CMP0000', 'A minimum required CMake version must be specified.', '2.6.0' ],
\ [ 'CMP0001', 'CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.', '2.6.0' ],
Expand All @@ -309,14 +309,62 @@ let s:Policies_List = [
\ [ 'CMP0013', 'Duplicate binary directories are not allowed.', '2.8.0' ],
\ [ 'CMP0014', 'Input directories must have CMakeLists.txt.', '2.8.0' ],
\ [ 'CMP0015', 'link_directories() treats paths relative to the source dir.', '2.8.1' ],
\ [ 'CMP0016', 'target_link_libraries() reports error if only argument is not a target.', '2.8.3' ],
\ [ 'CMP0016', 'target_link_libraries() reports error if its only argument is not a target.', '2.8.3' ],
\ [ 'CMP0017', 'Prefer files from the CMake module directory when including from there.', '2.8.4' ],
\ [ 'CMP0018', 'Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.', '2.8.9' ],
\ [ 'CMP0019', 'Do not re-expand variables in include and link information.', '2.8.11' ],
\ [ 'CMP0020', 'Automatically link Qt executables to qtmain target on Windows.', '2.8.11' ],
\ [ 'CMP0021', 'Fatal error on relative paths in INCLUDE_DIRECTORIES target property.', '2.8.12' ],
\ [ 'CMP0022', 'INTERFACE_LINK_LIBRARIES defines the link interface.', '2.8.12' ],
\ [ 'CMP0023', 'Plain and keyword target_link_libraries signatures cannot be mixed.', '2.8.12' ],
\ [ 'CMP0024', 'Disallow include export result.', '3.0' ],
\ [ 'CMP0025', 'Compiler id for Apple Clang is now AppleClang.', '3.0' ],
\ [ 'CMP0026', 'Disallow use of the LOCATION property for build targets.', '3.0' ],
\ [ 'CMP0027', 'Conditionally linked imported targets with missing include directories.', '3.0' ],
\ [ 'CMP0028', 'Double colon in target name means ALIAS or IMPORTED target.', '3.0' ],
\ [ 'CMP0029', 'The subdir_depends() command should not be called.', '3.0.' ],
\ [ 'CMP0030', 'The use_mangled_mesa() command should not be called.', '3.0' ],
\ [ 'CMP0031', 'The load_command() command should not be called.', '3.0' ],
\ [ 'CMP0032', 'The output_required_files() command should not be called.', '3.0' ],
\ [ 'CMP0033', 'The export_library_dependencies()command should not be called.', '3.0' ],
\ [ 'CMP0034', 'The utility_source() command should not be called.', '3.0' ],
\ [ 'CMP0035', 'The variable_requires() command should not be called.', '3.0' ],
\ [ 'CMP0036', 'The build_name() command should not be called.', '3.0' ],
\ [ 'CMP0037', 'Target names should not be reserved and should match a validity pattern.', '3.0' ],
\ [ 'CMP0038', 'Targets may not link directly to themselves.', '3.0' ],
\ [ 'CMP0039', 'Utility targets may not have link dependencies.', '3.0' ],
\ [ 'CMP0040', 'The target in the TARGET signature of add_custom_command() must exist and must be defined in current directory.', '3.0' ],
\ [ 'CMP0041', 'Error on relative include with generator expression.', '3.0' ],
\ [ 'CMP0042', 'MACOSX_RPATH is enabled by default.', '3.0' ],
\ [ 'CMP0043', 'Ignore COMPILE_DEFINITIONS_<Config> properties', '3.0' ],
\ [ 'CMP0044', 'Case sensitive <LANG>_COMPILER_ID generator expressions', '3.0' ],
\ [ 'CMP0045', 'Error on non-existent target in get_target_property.', '3.0' ],
\ [ 'CMP0046', 'Error on non-existent dependency in add_dependencies.', '3.0' ],
\ [ 'CMP0047', 'Use QCC compiler id for the qcc drivers on QNX.', '3.0' ],
\ [ 'CMP0048', 'The project() command manages VERSION variables.', '3.0' ],
\ [ 'CMP0049', 'Do not expand variables in target source entries.', '3.0' ],
\ [ 'CMP0050', 'Disallow add_custom_command SOURCE signatures.', '3.0' ],
\ [ 'CMP0051', 'List TARGET_OBJECTS in SOURCES target property.', '3.1' ],
\ [ 'CMP0052', 'Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES.', '3.1' ],
\ [ 'CMP0053', 'Simplify variable reference and escape sequence evaluation.', '3.1' ],
\ [ 'CMP0054', 'Only interpret if() arguments as variables or keywords when unquoted.', '3.1' ],
\ [ 'CMP0055', 'Strict checking for the break() command.', '3.2' ],
\ [ 'CMP0056', 'Honor link flags in try_compile() source-file signature.', '3.2' ],
\ [ 'CMP0057', 'Support new if() IN_LIST operator.', '3.3' ],
\ [ 'CMP0058', 'Ninja requires custom command byproducts to be explicit.', '3.3' ],
\ [ 'CMP0059', 'Do not treat DEFINITIONS as a built-in directory property.', '3.3' ],
\ [ 'CMP0060', 'Link libraries by full path even in implicit directories.', '3.3' ],
\ [ 'CMP0061', 'CTest does not by default tell make to ignore errors (-i).', '3.3' ],
\ [ 'CMP0062', 'Disallow install() of export() result.', '3.3' ],
\ [ 'CMP0063', 'Honor visibility properties for all target types.', '3.3' ],
\ [ 'CMP0064', 'Recognize TEST as a operator for the if() command.', '3.4' ],
\ [ 'CMP0065', 'Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property.', '3.4' ],
\ [ 'CMP0066', 'Honor per-config flags in try_compile() source-file signature.', '3.7' ],
\ [ 'CMP0067', 'Honor language standard in try_compile() source-file signature.', '3.8' ],
\ [ 'CMP0068', 'RPATH settings on macOS do not affect install_name.', '3.9' ],
\ [ 'CMP0069', 'INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.', '3.9' ],
\ [ 'CMP0070', 'Define file(GENERATE) behavior for relative paths.', '3.10' ],
\ [ 'CMP0071', 'Let AUTOMOC and AUTOUIC process GENERATED files.', '3.10' ],
\ [ 'CMP????', 'There might be more policies not mentioned here, since this list is not maintained automatically.', '?.?.?' ],
\ ]
"
Expand Down Expand Up @@ -605,9 +653,9 @@ function! s:Run ( args, cmake_only )
"
silent exe 'update' | " write source file if necessary
cclose
"
exe 'lchdir '.fnameescape( s:BuildLocation )
"

exe 'cd '.fnameescape( s:BuildLocation )

if a:cmake_only == 1
"
let g:CMakeDebugStr .= 'CMake only, ' " debug
Expand Down Expand Up @@ -636,15 +684,16 @@ function! s:Run ( args, cmake_only )
let &g:errorformat = errorf_saved
"
let g:CMakeDebugStr .= 'success: '.( v:shell_error == 0 ).', ' " debug
"

cd -

" errors occurred?
if v:shell_error != 0
botright cwindow
else
redraw " redraw after cclose, before echoing
call s:ImportantMsg ( 'CMake : CMake finished successfully.' )
endif
"
else
"
let g:CMakeDebugStr .= 'CMake & make, ' " debug
Expand Down Expand Up @@ -705,7 +754,9 @@ function! s:Run ( args, cmake_only )
endif
"
let g:CMakeDebugStr .= 'success: '.( v:shell_error == 0 ).', ' " debug
"

cd -

" errors occurred?
if v:shell_error != 0
botright cwindow
Expand All @@ -727,13 +778,10 @@ function! s:Run ( args, cmake_only )
call s:ImportantMsg ( 'CMake : make finished successfully.' )
endif
endif
"
endif
"
lchdir -
"

let g:CMakeDebugStr .= 'done' " debug
"

endfunction " ---------- end of function s:Run ----------
"
"-------------------------------------------------------------------------------
Expand Down Expand Up @@ -766,11 +814,41 @@ endfunction " ---------- end of function s:PolicyListText ----------

"-------------------------------------------------------------------------------
" s:OpenBuffer : Open a scratch buffer. {{{1
"
" If a buffer called 'buf_name' already exists, jump to that buffer. Otherwise,
" open a buffer of the given name an set it up as a scratch buffer. It is
" deleted after the window is closed.
"
" Options:
" - showdir: the directory will be shown in the buffer list (set buf=nowrite)
"
" Settings:
" - buftype=nofile/nowrite (depending on the option 'showdir')
" - bufhidden=wipe
" - swapfile=0
" - tabstop=8
"
" Parameters:
" buf_name - name of the buffer (string)
" ... - options (string)
" Returns:
" opened - true, if a new buffer was opened (integer)
"-------------------------------------------------------------------------------
function! s:OpenBuffer ( buf_name )
function! s:OpenBuffer ( buf_name, ... )

" a buffer like this already existing?
if bufnr ( a:buf_name ) != -1
" options
let btype = 'nofile'

for val in a:000
if val == 'showdir'
let btype = 'nowrite' " like 'nofile', but the directory is shown in the buffer list
else
call s:ErrorMsg ( 'CMake : Unknown buffer option: '.val )
endif
endfor

" a buffer like this already opened on the current tab page?
if bufwinnr ( a:buf_name ) != -1
" yes -> go to the window containing the buffer
exe bufwinnr( a:buf_name ).'wincmd w'
return 0
Expand All @@ -781,22 +859,44 @@ function! s:OpenBuffer ( buf_name )

" buffer exists elsewhere?
if bufnr ( a:buf_name ) != -1
" yes -> settings of the new buffer
" yes -> reuse it
silent exe 'edit #'.bufnr( a:buf_name )
return 0
else
" no -> settings of the new buffer
silent exe 'file '.escape( a:buf_name, ' ' )
setlocal noswapfile
setlocal bufhidden=wipe
setlocal tabstop=8
let &l:buftype = btype
let &l:bufhidden = 'wipe'
let &l:swapfile = 0
let &l:tabstop = 8
call s:RenameBuffer( a:buf_name )
endif

return 1
endfunction " ---------- end of function s:OpenBuffer ----------

"-------------------------------------------------------------------------------
" s:RenameBuffer : Rename a scratch buffer. {{{1
"
" Parameters:
" name - the new name (string)
" Returns:
" -
"-------------------------------------------------------------------------------
function! s:RenameBuffer ( name )

silent exe 'keepalt file '.fnameescape( a:name )

endfunction " ---------- end of function s:RenameBuffer ----------

"-------------------------------------------------------------------------------
" s:UpdateBuffer : Update a scratch buffer. {{{1
"
" Replace the text in the buffer with 'text'.
"
" Parameters:
" text - the text to place in the buffer (string)
" Returns:
" -
"-------------------------------------------------------------------------------
function! s:UpdateBuffer ( text )

Expand Down Expand Up @@ -956,23 +1056,28 @@ function! s:ShowCache ( args )
return
endif

if s:OpenBuffer ( 'CMake - cache', 'showdir' )
silent exe 'nmap <silent> <buffer> q :close<CR>'
endif

" get the cache
exe 'lchdir '.fnameescape( s:BuildLocation )
exe 'cd '.fnameescape( s:BuildLocation )

let [ success, text ] = s:TextFromSystem ( shellescape( s:CMake_Executable ).' -N '.args )
let location = fnamemodify ( s:BuildLocation, ':p' )

lchdir -
cd -

if success == 0
close
redraw " redraw after cclose, before echoing
call s:WarningMsg ( 'CMake : Could not obtain the cache.' )
return
endif

if s:OpenBuffer ( 'CMake - cache' )
silent exe 'nmap <silent> <buffer> q :close<CR>'
endif

call s:RenameBuffer ( location.'/CMake - cache' )
call s:UpdateBuffer ( text )

endfunction " ---------- end of function s:ShowCache ----------

"-------------------------------------------------------------------------------
Expand Down

0 comments on commit 1ef8728

Please sign in to comment.