From 0cfe37639ad83db14afe23c5cd9dc3afe6dc9709 Mon Sep 17 00:00:00 2001 From: timoteo dinelli Date: Thu, 24 Sep 2026 11:39:12 -0700 Subject: [PATCH 1/2] Shell-escape g:ckgrep_executable in the Vim plugin The auto-appended current-buffer file was already shellescape()'d, but the configured executable path was spliced into the shell command string as-is, breaking on paths with spaces (e.g. Windows' Program Files). --- editor/vim/autoload/ckgrep.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/vim/autoload/ckgrep.vim b/editor/vim/autoload/ckgrep.vim index efbe7e4..499a99a 100644 --- a/editor/vim/autoload/ckgrep.vim +++ b/editor/vim/autoload/ckgrep.vim @@ -37,7 +37,7 @@ function! ckgrep#search(bang, args) abort " -H forces the file name on every hit so quickfix entries can jump; the " pipe makes ckgrep emit plain (uncolored) output on its own. - let l:out = systemlist(l:exe . ' -H ' . l:args) + let l:out = systemlist(shellescape(l:exe) . ' -H ' . l:args) if v:shell_error == 2 " Malformed query: ckgrep printed the reason on one line. From 57a3bde7ad955096edaaebb23dc28ae518f1a707 Mon Sep 17 00:00:00 2001 From: timoteo dinelli Date: Thu, 24 Sep 2026 11:39:12 -0700 Subject: [PATCH 2/2] Add INSTALL_VIM_PLUGIN option to install the Vim/Neovim plugin via CMake Lets a cmake --install'd prefix (not just a git checkout) serve as the Vim/Neovim plugin root, so a plugin manager can point at the installed tree instead of keeping a separate clone around. Installs editor/vim/{plugin,autoload,doc} into /share/ckgrep/vim, opt-in and off by default like BUILD_DOC. Bump version to 1.1.2. --- CMakeLists.txt | 19 +++++++++++++++---- README.md | 3 ++- cmake/VimPlugin.cmake | 23 +++++++++++++++++++++++ editor/vim/README.md | 28 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 cmake/VimPlugin.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f98c14..3db0f24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,10 @@ # ckgrep - a grep-like tool for searching CHEMKIN reaction mechanisms # # Build options: -# BUILD_TESTING Build the test suite (default ON, target: ckgrep_tests) -# BUILD_DOC Enable the Doxygen PDF manual (default OFF, target: docs) -# ENABLE_COVERAGE Clang source-based coverage (default OFF, target: coverage) +# BUILD_TESTING Build the test suite (default ON, target: ckgrep_tests) +# BUILD_DOC Enable the Doxygen PDF manual (default OFF, target: docs) +# ENABLE_COVERAGE Clang source-based coverage (default OFF, target: coverage) +# INSTALL_VIM_PLUGIN Install the Vim/Neovim plugin (default OFF) # # Layout: # source/ core library + ckgrep executable @@ -15,7 +16,7 @@ cmake_minimum_required(VERSION 3.20) project( ckgrep - VERSION 1.1.1 + VERSION 1.1.2 LANGUAGES CXX DESCRIPTION "A grep-like tool for searching CHEMKIN reaction mechanisms" ) @@ -46,6 +47,16 @@ if(BUILD_DOC) include(cmake/Documentation.cmake) endif() +# Opt-in install of the Vim/Neovim plugin alongside the binary (see editor/vim) +option( + INSTALL_VIM_PLUGIN + "Install the Vim/Neovim plugin into /share/ckgrep/vim" + OFF +) +if(INSTALL_VIM_PLUGIN) + include(cmake/VimPlugin.cmake) +endif() + # Tests are on by default; -DBUILD_TESTING=OFF also skips fetching googletest option(BUILD_TESTING "Build the ckgrep test suite" ON) if(BUILD_TESTING) diff --git a/README.md b/README.md index 31f71f9..88c1d50 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ The `ckgrep` binary is produced at `build/source/ckgrep`. | `BUILD_TESTING` | `ON` | Build the test suite (`ckgrep_tests`), run with `ctest`. | | `BUILD_DOC` | `OFF` | Enable the `docs` target building the PDF manual. | | `ENABLE_COVERAGE` | `OFF` | Instrument for coverage and enable the `coverage` target (Clang/AppleClang only). | +| `INSTALL_VIM_PLUGIN` | `OFF` | Install the [Vim/Neovim plugin](editor/vim) into `/share/ckgrep/vim`. | ### Tests @@ -74,7 +75,7 @@ cmake --install build # system prefix, e.g. /usr/local cmake --install build --prefix "$HOME/.local" # custom prefix ``` -Installs the `ckgrep` binary into `/bin`, and the LICENSE — plus the PDF manual when it has been built — into `/share/doc/ckgrep/`. +Installs the `ckgrep` binary into `/bin`, and the LICENSE — plus the PDF manual when it has been built — into `/share/doc/ckgrep/`. With `-DINSTALL_VIM_PLUGIN=ON`, the [Vim/Neovim plugin](editor/vim) is installed too, into `/share/ckgrep/vim/` — see [its README](editor/vim/README.md#from-a-cmake-install) for pointing a plugin manager at it. ## Usage diff --git a/cmake/VimPlugin.cmake b/cmake/VimPlugin.cmake new file mode 100644 index 0000000..a6c4ef1 --- /dev/null +++ b/cmake/VimPlugin.cmake @@ -0,0 +1,23 @@ +# ----------------------------------------------------------------------------- +# Installs the Vim/Neovim plugin (editor/vim) into +# /share/ckgrep/vim/{plugin,autoload,doc}, so a plugin manager can +# point straight at an installed prefix instead of a git checkout, e.g. with +# lazy.nvim: +# +# { +# dir = "/share/ckgrep/vim", +# name = "vim-ckgrep", +# cmd = "Ckgrep", +# init = function() +# vim.g.ckgrep_executable = "/bin/ckgrep" +# end, +# } +# ----------------------------------------------------------------------------- +include(GNUInstallDirs) +install( + DIRECTORY + ${PROJECT_SOURCE_DIR}/editor/vim/plugin + ${PROJECT_SOURCE_DIR}/editor/vim/autoload + ${PROJECT_SOURCE_DIR}/editor/vim/doc + DESTINATION ${CMAKE_INSTALL_DATADIR}/ckgrep/vim +) diff --git a/editor/vim/README.md b/editor/vim/README.md index 914b2dd..4905d9e 100644 --- a/editor/vim/README.md +++ b/editor/vim/README.md @@ -24,6 +24,34 @@ let g:ckgrep_executable = '/opt/ckgrep/bin/ckgrep' The plugin lives in the `editor/vim` subdirectory of the ckgrep repository. +### From a CMake install + +Building `ckgrep` from source with `-DINSTALL_VIM_PLUGIN=ON` installs this +plugin into `/share/ckgrep/vim/` alongside the binary in +`/bin/`, so a plugin manager can point straight at the installed +prefix instead of a separate git checkout: + +```bash +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DINSTALL_VIM_PLUGIN=ON +cmake --build build +cmake --install build --prefix "$HOME/.tools/ckgrep" +``` + +With [lazy.nvim](https://github.com/folke/lazy.nvim): + +```lua +{ + dir = vim.fn.expand("~/.tools/ckgrep/share/ckgrep/vim"), + name = "vim-ckgrep", + cmd = "Ckgrep", + init = function() + vim.g.ckgrep_executable = vim.fn.expand("~/.tools/ckgrep/bin/ckgrep") + end, +} +``` + +### From a git checkout + With [vim-plug](https://github.com/junegunn/vim-plug): ```vim