1
0
Fork 0
fzf.kak/README.md

124 lines
5.3 KiB
Markdown
Raw Normal View History

2018-09-22 10:59:28 +00:00
# fzf.kak
2018-09-22 11:15:53 +00:00
2018-09-24 14:45:51 +00:00
[![GitHub release](https://img.shields.io/github/release/andreyorst/fzf.kak.svg)](https://github.com/andreyorst/fzf.kak/releases)
[![GitHub Release Date](https://img.shields.io/github/release-date/andreyorst/fzf.kak.svg)](https://github.com/andreyorst/fzf.kak/releases)
2018-09-24 14:42:50 +00:00
![Github commits (since latest release)](https://img.shields.io/github/commits-since/andreyorst/fzf.kak/latest.svg)
![license](https://img.shields.io/github/license/andreyorst/fzf.kak.svg)
2018-10-11 13:39:21 +00:00
> **fzf.kak** is a plugin for [Kakoune](https://github.com/mawww/kakoune) editor, that brings integration with [fzf](https://github.com/junegunn/fzf)
2018-09-24 14:42:50 +00:00
> tool. This plugin is being tested against Kakoune 2018.09.04.
2018-09-22 11:15:53 +00:00
2018-09-24 08:54:05 +00:00
### Dependencies
2018-09-24 14:42:50 +00:00
|Tool |Information |
|:--------:|:--------------------------------------------------------------------------------------------------|
|tmux |This plugin depends on [fzf-tmux](https://github.com/junegunn/fzf/blob/master/bin/fzf-tmux) script.|
|X11 |Script works with X11 via `termcmd` option. |
|GNU Screen|GNU Screen is not yet supported. |
2018-09-24 08:54:05 +00:00
2018-09-22 11:15:53 +00:00
## Installation
2018-09-24 08:54:05 +00:00
Recommended way to install is to use [plug.kak](https://github.com/andreyorst/plug.kak) plugin
manager. You can install **fzf.kak** by adding this to your `kakrc`:
2018-09-22 11:15:53 +00:00
```kak
plug andreyorst/fzf.kak
```
2018-09-24 08:54:05 +00:00
Then reload Kakoune config or restart Kakoune and run `:plug-install`.
Or install this plugin any other preferred way.
2018-09-22 11:15:53 +00:00
## Usage
2018-09-22 17:25:20 +00:00
**fzf.kak** doesn't provide any mapping by default. Instead there's now a `fzf-mode` command
which intentionally was made to simplify user mappings.
Each fzf command has mnemonic mapping, like `f` for opening files, `t` for tags and so on.
2018-09-22 11:15:53 +00:00
In this mode new mappings are available:
- <kbd>b</kbd> - Select buffer
2018-09-27 11:52:29 +00:00
- <kbd>c</kbd> - Switch servers working directory
- <kbd>f</kbd> - Search for file and open it
2018-10-11 12:01:55 +00:00
- <kbd>v</kbd> - Edit file in version control system tree
- <kbd>V</kbd> - Explicitly select which vcs command to run
2018-09-27 11:52:29 +00:00
- <kbd>s</kbd> - Search over buffer contents and jump to result line
- <kbd>t</kbd> - Browse ctags tags
2018-09-22 11:15:53 +00:00
2018-09-22 17:25:20 +00:00
You can set your own mapping to invoke `fzf-mode`:
```
map global normal <c-p> ': fzf-mode<ret>'
# note that the space after colon is intentional to suppess fzf-mode to show in command history
```
2018-09-22 11:15:53 +00:00
So for example pressing <kbd>Ctrl+p</kbd><kbd>f</kbd> will open fzf at the
bottom of the Kakoune buffer, showing you all possible files.
2018-09-22 17:25:20 +00:00
### Settings
#### Files
2018-09-22 17:25:20 +00:00
You can configure what command to use to search for files, and it's arguments.
2018-10-11 12:01:55 +00:00
Supported tools are [GNU Find](https://www.gnu.org/software/findutils/), [The Silver Searcher](https://github.com/ggreer/the_silver_searcher), [ripgrep](https://github.com/BurntSushi/ripgrep), [fd](https://github.com/sharkdp/fd). GNU find is used by default, but you can switch to another one. There are some default values for those, so you can go:
2018-09-22 17:25:20 +00:00
```kak
2018-10-11 12:01:55 +00:00
set-option global fzf_file_command 'rg' # 'ag', 'fd' or 'find'
2018-09-22 17:25:20 +00:00
```
Or if you don't like default file arguments, which are `find -type f`, and would like to disable searching in, say `.git` directories you can set it like so:
```kak
set-option global fzf_file_command "find . \( -path '*/.svn*' -o -path '*/.git*' \) -prune -o -type f -print"
```
The same pattern applies for other commands, except `buffer`, and `cd`.
2018-10-11 12:01:55 +00:00
#### VCS
This script supports these version control systems: Git, Subversion, GNU Bazaar, Mercurial.
By default <kbd>v</kbd> mapping from `fzf mode` will detect your version control system and open fzf for you.
If you wish to explicitly use some particular vcs command, you can use `V` mapping, which includes
all supported vcs shortcuts.
2018-10-11 12:01:55 +00:00
You also able to set parameters to vcs command to use to provide project files. Supported options:
* `fzf_git_command`
* `fzf_svn_command`
* `fzf_bzr_command`
* `fzf_hg_command`
2018-10-11 12:01:55 +00:00
Other VCS are not supported officially. Open a feature request if you want some unsupported VCS to be included.
You also can change one of options to contain your vcs command, and use this command explicitly from vcs submode.
#### ctags
2018-09-30 16:56:30 +00:00
It is also possible to add parameters to ctags search executable:
```kak
set-option global fzf_tag_command 'readtags -l | cut -f1 | sort -u | ... '
```
2018-10-11 05:18:06 +00:00
#### Preview
You can turn on the preview window in fzf window by setting `fzf_preview` option to `true`:
```kak
set-option global fzf_preview true
```
You also can specify which highlighter to use within the preview window with `fzf_highlighter` option.
Supported tools are:
* Rouge
* Highlight
* Coderay
2018-09-22 13:36:29 +00:00
## Some demonstration gifs:
### Opening files:
![files](https://user-images.githubusercontent.com/19470159/45917778-3988e200-be85-11e8-890d-b180d013b99e.gif)
### Searching tags with universal-ctags
![ctags](https://user-images.githubusercontent.com/19470159/45917775-3988e200-be85-11e8-8959-d7ddf17961b7.gif)
### Browsing Git tree files
![git](https://user-images.githubusercontent.com/19470159/45917779-3988e200-be85-11e8-9136-c0c830e838bc.gif)
### Switching buffers
![buffers](https://user-images.githubusercontent.com/19470159/45917774-38f04b80-be85-11e8-963b-5721bd6364b3.gif)
### Changing directories
![dirs](https://user-images.githubusercontent.com/19470159/45917776-3988e200-be85-11e8-89bf-7c1453806c83.gif)
2018-09-22 17:25:20 +00:00