diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e0891c0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,18 @@ + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + diff --git a/Makefile b/Makefile deleted file mode 100644 index 593f989..0000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -DESTDIR=~/.vim - -install: - mkdir -p ${DESTDIR}/plugin - mkdir -p ${DESTDIR}/doc - cp -r plugin/cmake-project.vim ${DESTDIR}/plugin/ - cp -r doc/* ${DESTDIR}/doc - -uninstall: - rm ${DESTDIR}/plugin/cmake-project.vim - rm ${DESTDIR}/doc/cmake-project.txt diff --git a/README b/README deleted file mode 100644 index 33fd3a3..0000000 --- a/README +++ /dev/null @@ -1,6 +0,0 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=4279 - -CMake-Project is a plugin for cmake projects effective management. It provides -a sidebar that displays project files in the tree view. - -Get latest changes from Github https://github.com/Ignotus/vim-cmake-project diff --git a/README.md b/README.md index 0852ec0..d698b06 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,91 @@ -VIM-CMake-Project v2.0.1 +VIM-CMake-Project v0.3.0 =============== About ===== -CMake project management plugin for VIM editor. -[![VCP](http://i.imgur.com/wGeVbl.png)](http://i.imgur.com/wGeVbl.png) +CMake-Project is a plugin for cmake projects effective management. + +This is a fork of https://github.com/Ignotus/vim-cmake-project +The intention was to provide minor changes, but I ended up with complete rewrite of the project. It +depends on others (optional) plugins, like NERDTree and Vimux. + +vim-cmake-project has following features: + +1. Project is activated only by opening cmake project file: "CMakeLists.txt". Project file "CMakeLists.txt" do not have + to be in the current working directory. I.e "vim ~/prg/cplus/test/CMakeLists.txt". All above described commands will + be available for the use. +2. Project provides two additional windows: + a) project files on the sidebar (using NEDRTree plugin). Project files are filtered, so it only C++/C files and txt + files will be shown. + b) output window - bottom window pane (using Vimux plugin). It will display output by executing commands. +3. Commands for building makefiles, compiling project, cleaning generated binaries and toggling project windows/panes. +4. Customizable mapping keys/shorcuts + +Screenshot +![VCP](https://raw.githubusercontent.com/sigidagi/vim-cmake-project/master/doc/vim-cmake-project-screenshot.png) + + Installing ========== - - $ make install -Specify the DESTDIR variable to install it to the other directory. +Install NERDTree and Vimux plugins (optional): + +https://github.com/scrooloose/nerdtree + +https://github.com/benmills/vimux + +Install vim-cmake-project. +If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste: + + cd ~/.vim/bundle + git clone git://github.com/sigidagi/vim-cmake-project.git + +Or for Vundle users: + +Add Plugin 'sigidagi/vim-cmake-project' to your ~/.vimrc and then: + + either within Vim: :PluginInstall + or in your shell: vim +PluginInstall +qall + +Usage +===== +Open "cmake" project file "CMakeLists.txt" with vim. CMake project file not necessary have to be +in current working directory. + +You can generate native makefiles and workspaces by this command: + + :CMakeBuild + +Compile project + + :CMakeCompile + +Clean project - remove binary files generated by cmake + + :CMakeClean + +If project is running on "tmux" all outputs are provided in separate +window/pane. Output window will open as soon as above commands are executed. +To close output window use following command: + + :CMakeOutput + +To toggle sidebar window with project files issue following command: + + :CMakeBar + +For navigation and usage of tree list in sidebar window refer to "NERDTree" plugin help + + +Default key maping: + + map pb CMakeBuild + map pc CMakeCompile + map pl CMakeClean + map po CMakeOutput + License ======= diff --git a/doc/cmake-project.txt b/doc/cmake-project.txt index 3d13b88..87a8ed8 100644 --- a/doc/cmake-project.txt +++ b/doc/cmake-project.txt @@ -1,9 +1,9 @@ *cmake-project.txt* CMake project management plugin -Author: Minh Ngo +Author: Sigitas Dagilis Licence: BSD -Homepage: http://github.com/Ignotus/vim-cmake-project -Version: 2.0.0 +Homepage: http://github.com/sigidagi/vim-cmake-project +Version: 0.3.0 ============================================================================== Contents *cmake-project* *cmake-project-contents* @@ -16,142 +16,130 @@ Contents *cmake-project* *cmake-project-content 5. Configuration ................... |cmake-project-configuration| 6. History ......................... |cmake-project-history| 7. Todo ............................ |cmake-project-todo| - 8. Credits ......................... |cmake-project-credits| ============================================================================== 1. Intro *cmake-project-intro* -CMake-Project is a plugin for cmake projects effective management. It provides -a sidebar that shows files in the tree view. +Fork of http://github.com/Ignotus/vim-cmake-project +Source code completely rewritten. It uses NERDTree plugin to provide +navigation and tree view list of project files on a sidebar and terminal +multiplexer (tmux) to output results on separate windows pane. ============================================================================== 2. Requirements *cmake-project-requirements* -You need to have the VIM editor that supports python scripting. You can check -it by this command in a console: - - $ vim --version |grep +python - +cryptv +linebreak +python/dyn +viminfo - +You need to have the NERDTree plugin installed and tmux (recommended). Plugin working +with vim 7 version. +> + $ vim --version +< ============================================================================== 3. Installation *cmake-project-installation* -Change your current directory to the plugin root archive directory and use -install methods: +If you don't have a preferred installation method, I recommend installing +pathogen.vim, and then simply copy and paste: > - make install + cd ~/.vim/bundle + git clone git://github.com/sigidagi/vim-cmake-project.git < -You can specify a destination install directory by following methods: +Or for Vundle users: Add Plugin 'sigidagi/vim-cmake-project' to your ~/.vimrc +and then: > - make install DESTDIR=/opt/vim + either within Vim: :PluginInstall + or in your shell: vim +PluginInstall +qall < - -By default, DESTDIR is equal to ~/.vim/ - ============================================================================== 4. Usage *cmake-project-usage* -First of all, you should go to the cmake project directory. + +Open "cmake" project file "CMakeLists.txt" with vim. CMake project file not necessary have to be +in current working directory. + +You can generate native makefiles and workspaces by this command: > - $ cd + :CMakeBuild < -Secondly, create a folder for cmake project build files. +Compile project > - $ mkdir + :CMakeCompile < -Thirdly, start your VIM editor in the project directory. +Clean project - remove binary files generated by cmake > - $ vim + :CMakeClean < -Fourthly, You can generate a cmake content for VIM by this command: +If project is running on "tmux" all outputs is provided on separate +window/pane. Output window will open as soon as above commands are executed. +To close output window use following command: > - :CMakeGen + :CMakeOutput < -Show the project bar by the command: +To toggle bar window with project files issue following command: > :CMakeBar < -Press over a directory to hide/show its contents. Press over a -file to open it. +For navigation and usage of tree list in bar window refer to "NERDTree" plugin +help ------------------------------------------------------------------------------ COMMANDS *cmake-project-commands* -:CMakeGen {build-directory} *:CMakeGen* - Generate a cmake project content for VIM. +:CMakeBuild *:CMakeBuild* + Generate project's makefiles + +:CMakeCompile *:CMakeCompile* + Compile project + +:CMakeClean *:CMakeClean* + Remove project binaries + +:CMakeOutput *:CMakeOutput* + Close output window :CMakeBar *:CMakeBar* - Show a project bar. + Show/toggle a project bar. ============================================================================== 5. Configuration *cmake-project-configuration* - *g:cmake_project_show_bar* -g:cmake_project_show_bar~ -Default: 0 + *g:cmake_project_build_directory* +g:cmake_project_build_directory~ +Default: "build" -Enable this parameter to show the cmake project bar after starting. +Change this parameter to provide build directory name. Example: > - let g:cmake_project_show_bar = 1 + let g:cmake_project_build_directory = "build-custom" < +Default mapping: - *g:cmake_project_bar_width* -g:cmake_project_bar_width~ -Default: 40 - -You can change CMake Project panel width by this variable. +map pb CMakeBuild~ +map pc CMakeCompile~ +map pl CMakeClean~ +map po CMakeOutput~ -Example: -> - let g:cmake_project_bar_width = 40 -< +You can change mapping by providing different keys in vimrc file. ============================================================================== 6. History *cmake-project-history* -2.0.0 (2014-02-21) - - Second major release. All code had been rewritten in Python. Interface - and configuration paramters was simplified. +0.3.0 (2014-03-07) + - Added output window, Added all commands and mapping keys for building + makefiles, compiling, cleaning and toggling windows. -1.0.0 (2012-10-21) - - First major release. +0.2.0 (2014-02-29) + - All code had been rewritten to minimize source code (less than 100 lines) + to utilize NERDTree plugin flexibility and functionality. -============================================================================== -7. Todo *cmake-project-todo* +0.1.0 (2014-06-26) + - fork from http://github.com/Ignotus/vim-cmake-project - - Other cmake project files support. // Completed in 2.0.0! - - Please send your feature requests to my github project - https://github.com/Ignotus/vim-cmake-project ============================================================================== -8. Credits *cmake-project-credits* - -CMake-project was written by Minh Ngo and is released under the BSD License. - - Copyright (C) 2012-2014 Minh Ngo - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. +7. Todo *cmake-project-todo* -Thanks to the following people for code contributions, feature suggestions etc: -Nikolay Pavlov (http://habrahabr.ru/users/ZyXI/) + - Please send your feature requests to my github project + https://github.com/sigidagi/vim-cmake-project ============================================================================== vim: tw=78 ts=8 sw=4 sts=4 et ft=help diff --git a/doc/vim-cmake-project-screenshot.png b/doc/vim-cmake-project-screenshot.png new file mode 100644 index 0000000..02221b2 Binary files /dev/null and b/doc/vim-cmake-project-screenshot.png differ diff --git a/plugin/cmake-project.vim b/plugin/cmake-project.vim index 0b15afa..07c73e1 100644 --- a/plugin/cmake-project.vim +++ b/plugin/cmake-project.vim @@ -1,230 +1,231 @@ -" vim-cmake-project -" Copyright (C) 2012-2014 Minh Ngo +"" vim-cmake-project +" Plugin provides list and navigation of project files on side bar with a help of NERDTree plugin +" and command(s) for building cmake projects. +" Side bar shows only project related files: C/C++. ( NERDTree is filtered out ) +" CMake command is deactivated and NERDTree structure is restored when CMakeLists.txt is removed from buffer. " -" Permission is hereby granted, free of charge, to any person obtaining a -" copy of this software and associated documentation files (the "Software"), -" to deal in the Software without restriction, including without limitation -" the rights to use, copy, modify, merge, publish, distribute, sublicense, -" and/or sell copies of the Software, and to permit persons to whom the -" Software is furnished to do so, subject to the following conditions: - -" The above copyright notice and this permission notice shall be included in -" all copies or substantial portions of the Software. - -" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -" SOFTWARE. - -if !has('python') - echo 'Error: Required vim compiled with +python' +" Last change: 2014 July 5 +" Maintainer: Sigitas Dagilis sigidagi@gmail.com +" License: BSD +" +" allow users to disable loading plugin by providing global variable. +" another reason - to avoid loading plugin twice. +if exists("g:loaded_cmake_project") finish endif -if !exists('g:cmake_project_show_bar') - let g:cmake_project_show_bar = 0 -else - call s:cmake_show_bar() -endif - -if !exists('g:cmake_project_bar_width') - let g:cmake_project_bar_width = 40 -endif - -if !exists('g:cmake_project_folder_open_symbol') - let g:cmake_project_folder_open_symbol = '-' -endif - -if !exists('g:cmake_project_folder_close_symbol') - let g:cmake_project_folder_close_symbol = '+' -endif - -python << EOF -import vim -from sets import Set - -s_cmake_project_show_bar = vim.eval('g:cmake_project_show_bar') -s_cmake_project_bar_width = vim.eval('g:cmake_project_bar_width') - -class Prop: - visible = True - def __init__(self, visible): - self.visible = visible - -create_tree_node = lambda: ({}, Set(), Prop(True)) - -s_cmake_project_node_dict = {} -s_cmake_project_file_dict = {} -s_cmake_project_file_tree = create_tree_node() -EOF - - -" Interface -command -nargs=1 -complete=file CMakeGen call s:cmake_gen_project() -command -nargs=0 -bar CMakeBar call s:cmake_show_bar() -map :call g:cmake_on_space_clicked() - -" Implementation -function! s:run_cmake(i_directory) abort - exec 'cd' a:i_directory - exec '!cmake' "-G\"CodeBlocks - Unix Makefiles\" " . s:cmake_project_directory - exec 'cd' s:cmake_project_directory +" function first check for existence of specified option in .vimrc +" keeping global option in dictionary for compactness, i.e later if options will grow +" it will be more convinient to keep in one place. +function! s:set_options() + let s:options = { + \ 'g:cmake_project_show_bar': 1, + \ 'g:loaded_cmake_project': 1, + \ 'g:cmake_project_build_directory': 'build' + \ } + + for aOption in keys(s:options) + if !exists(aOption) + let {aOption} = s:options[aOption] + endif + endfor endfunction +function! s:init() + augroup vim-cmake-project.vim + au! + au BufNewFile,BufRead CMakeLists.txt :call s:cmake_project_activate() + au BufDelete CMakeLists.txt :call s:cmake_project_deactivate() + au BufDelete * :call s:cmake_project_opennext() + au VimLeavePre * :call s:cmake_project_close_output() + augroup END +endfunction -function! s:gen_file_tree(i_directory) abort - exec 'cd' a:i_directory - -python << EOF -import vim -import glob -import xml.etree.ElementTree as ET - -current_dir = vim.eval('s:cmake_project_directory') -current_dir_len = len(current_dir) + 1 - -project_file = glob.glob('*.cbp')[0] -tree = ET.parse(project_file) -root = tree.getroot() - -files = [file_name.get('filename') for file_name in root.findall("./Project/Unit")] - -s_cmake_project_file_tree = create_tree_node() - -for file in files: - paths = file[current_dir_len:].split('/') - file_name = paths[-1] - paths.pop() - - current_tree_ref = s_cmake_project_file_tree - for path in paths: - directories, _, _ = current_tree_ref - if not directories.has_key(path): - directories[path] = create_tree_node() - current_tree_ref = directories[path] +" Start --------------------- +let s:cmake_project_tmux_running = 0 +call s:set_options() +call s:init() - _, files, _ = current_tree_ref - files.add((file_name, file)) +function! s:cmake_project_remap() + + if !hasmapto('CMakeCompile') + map pc CMakeCompile + endif + if !hasmapto('CMakeClean') + map pl CMakeClean + endif + if !hasmapto('CMakeBuild') + map pb CMakeBuild + endif -EOF + noremap