nixprime / cpsm

A CtrlP matcher, specialized for paths.
Apache License 2.0
202 stars 19 forks source link

cpsm

Build Status

cpsm is a matcher for CtrlP. Although it supports all kinds of queries, it is highly optimized for file paths (and, to a lesser extent, similar strings like identifiers in source code).

Motivation

There are a lot of different way to manage multiple files in Vim. The goal of cpsm is to enable a particular one based on CtrlP:

  1. Completely forget about the current set of open buffers.

  2. When you want to open a file, invoke CtrlP and type - at most - a handful of immediately obvious letters in the file's name or path, like the beginning of its filename.

  3. Get immediate visual feedback from CtrlP as to whether or not it has correctly determined what file you want.

  4. Hit Enter to open the file you wanted in the current window.

To achieve this, cpsm needs to deliver:

See the "Performance" section below for both search quality and time comparisons to other matchers.

Requirements

Pyenv users on Mac OS X: cpsm requires dynamic Python libraries, which pyenv does not build by default. If CMake indicates that it's using static libraries, e.g.:

-- Found PythonLibs: /Users/<username>/.pyenv/versions/3.5.2/lib/python3.5/config-3.5m/libpython3.5m.a

Rebuild with dynamic library support by running env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install <version>.

Python 3 Support

If your Vim is compiled against Python 3 instead (+python3 flag) the install script should detect this in most cases and everything should just work. You may need different python headers installed (e.g. python3-dev on Ubuntu).

If the detection does not work for any reason you can set PY3=ON or PY3=OFF as appropriate when running ./install.sh to override it.

Installation

  1. Install cpsm using your favorite Vim package manager. For example, with Vundle, this consists of adding:

    Vundle 'nixprime/cpsm'

    to your vimrc and then running :PluginInstall from Vim.

  2. Build the Python module. On Linux, cd into ~/.vim/bundle/cpsm and run ./install.sh. Otherwise, peek inside install.sh and see what it does.

  3. Add:

    let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'}

    to your vimrc.

Options

All of the following options are set by adding

let (option name) = (option value)

to your .vimrc.

In addition, cpsm respects the value set for g:ctrlp_match_current_file.

Performance

License

This software is licensed under the Apache License, Version 2.0.