Home

Awesome

cols

A faster colcon list replacement for fuzzy-finders.

Installation

cargo install --path .

The executable will be installed to ~/.cargo/bin/cols. To run the executable without specifying the full path, ~/.cargo/bin must be added to the $PATH.

Usage

$ cols list
test_cmake_pkg  ./test_tree/subrepo/another_package     (ament_cmake)
test_python_pkg ./test_tree/subrepo/python_package      (ament_python)
zzz_package     ./test_tree/a_package   (ament_cmake)

$ cols list --base-paths test_tree/subrepo --names-only
test_cmake_pkg
test_python_pkg

For more options, see cols list --help.

Limitations

Fuzzy-finder examples

Change directory to a package picked by fzf:

function rcd {
  local pkgpath
  pkgpath=$(cols list | fzf -q "${1}" | cut -f 2)
  [ -n "${pkgpath}" ] && cd "${pkgpath}"
}

rosed replacement:

function re {
  local pkg
  pkg=$(cols list | fzf -q "${1}" | cut -f 2)
  [ -n "${pkg}" ] || return
  local filename
  filename=$(fd -0 --type f . "${pkg}" | fzf --read0 --prompt="file: ")
  [ -n "${filename}" ] || return
  ${EDITOR} "${filename}"
}

Usage with telescope-ros.nvim

cols can act as a drop-in replacement for colcon in telescope-ros.nvim:

require('telescope').setup{
    extensions = {
        ros = {
            colcon = "cols" -- Must be in $PATH
            -- colcon = vim.loop.os_homedir() .. "/.cargo/bin/cols" -- works too
        }
    }
}

compile_commands.json symlinker

The non-standard symlink command can (re-)create symlinks for compile_commands.json files from the build space for each package to its source directory. This usually helps clangd and related tooling discover the build options.

Usage:

cols symlink --help
cols symlink --build-base build --base-paths src

Note: Packages that do not contain a CMakeLists.txt file will be skipped. Existing symlinks will only be recreated if --force is used.