AlxHnr / build.vim

Vim plugin for building projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This plugin provides commands for using the build system to which the current file belongs. It searches from each files directory upwards for Makefiles and the like.

Note: If the current file does not belong to any known build systems, it will be build using associated compilers. E.g. C files will be build using gcc.

Usage Examples

CMake

Your project may look like this:

├── CMakeLists.txt
└── src/
    └── main.cpp

Open any file in the project and use the following command to initialize CMake. Optional arguments can be provided and will be passed directly to cmake:

:Build init -DCMAKE_BUILD_TYPE=Release

Here are some examples for invoking cmake. Additional arguments will be passed directly to cmake:

:Build build
:Build build --target some_cmake_target
:Build test
:Build clean

Note: Running :Build without any arguments is equivalent to :Build build.

CMake with subdirectories

Your project may look like this:

├── CMakeLists.txt
├── src/
│   └── main.cpp
└── util/
    ├── CMakeLists.txt
    ├── util.cpp
    └── misc/
        ├── CMakeLists.txt
        └── misc.cpp

Set the current working directory to the directory containing the main CMakeLists.txt and proceed as in the previous example:

:lchdir ~/path/to/project
:Build init -DCMAKE_BUILD_TYPE=Release
:Build
:Build build --target my_target

Note: You can use this plugin to set the working directory automatically.

Autotools

Your project may look like this:

├── configure
├── Makefile.in
├── LICENSE
├── README
└── src/
    └── main.c
    └── foo.h
    └── foo.c

Open any file in the project and configure the build using the following command. Optional configure flags can be provided:

:Build init --enable-gtk --without-foo --prefix="$HOME/.local"

Then run make using the :Build command:

:Build
:Build clean
:Build build -j8 --keep-going --dry-run

Plain C files

If the current file does not belong to a build system, it can be compiled using the :Build command. This plugin defines three subcommands for C files:

:Build build
:Build run
:Build clean

Pass custom arguments to the compiler:

:Build build -Wall -Wextra -Werror -pedantic

Note: If :Build is called without arguments it will be equivalent to :Build build.

Python, Bash and other scripting languages

For some files which don't belong to a build system, the run target will be defined:

:Build run

About

Vim plugin for building projects

License:MIT License


Languages

Language:Vim Script 100.0%