doing 2.0.18 → 2.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile.lock +15 -5
  4. data/README.md +1 -1
  5. data/bin/doing +2 -18
  6. data/doing.gemspec +5 -4
  7. data/doing.rdoc +2 -2
  8. data/generate_completions.sh +3 -3
  9. data/lib/doing/cli_status.rb +6 -2
  10. data/lib/doing/completion/bash_completion.rb +185 -0
  11. data/lib/doing/completion/fish_completion.rb +175 -0
  12. data/lib/doing/completion/string.rb +17 -0
  13. data/lib/doing/completion/zsh_completion.rb +140 -0
  14. data/lib/doing/completion.rb +39 -0
  15. data/lib/doing/version.rb +1 -1
  16. data/lib/doing/wwid.rb +18 -6
  17. data/lib/doing.rb +1 -1
  18. data/lib/helpers/fzf/.goreleaser.yml +119 -0
  19. data/lib/helpers/fzf/.rubocop.yml +28 -0
  20. data/lib/helpers/fzf/ADVANCED.md +565 -0
  21. data/lib/helpers/fzf/BUILD.md +49 -0
  22. data/lib/helpers/fzf/CHANGELOG.md +1193 -0
  23. data/lib/helpers/fzf/Dockerfile +11 -0
  24. data/lib/helpers/fzf/LICENSE +21 -0
  25. data/lib/helpers/fzf/Makefile +166 -0
  26. data/lib/helpers/fzf/README-VIM.md +486 -0
  27. data/lib/helpers/fzf/README.md +712 -0
  28. data/lib/helpers/fzf/bin/fzf-tmux +233 -0
  29. data/lib/helpers/fzf/doc/fzf.txt +512 -0
  30. data/lib/helpers/fzf/go.mod +17 -0
  31. data/lib/helpers/fzf/go.sum +31 -0
  32. data/lib/helpers/fzf/install +382 -0
  33. data/lib/helpers/fzf/install.ps1 +65 -0
  34. data/lib/helpers/fzf/main.go +14 -0
  35. data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
  36. data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
  37. data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
  38. data/lib/helpers/fzf/shell/completion.bash +381 -0
  39. data/lib/helpers/fzf/shell/completion.zsh +329 -0
  40. data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
  41. data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
  42. data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
  43. data/lib/helpers/fzf/src/LICENSE +21 -0
  44. data/lib/helpers/fzf/src/algo/algo.go +884 -0
  45. data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
  46. data/lib/helpers/fzf/src/algo/normalize.go +492 -0
  47. data/lib/helpers/fzf/src/ansi.go +409 -0
  48. data/lib/helpers/fzf/src/ansi_test.go +427 -0
  49. data/lib/helpers/fzf/src/cache.go +81 -0
  50. data/lib/helpers/fzf/src/cache_test.go +39 -0
  51. data/lib/helpers/fzf/src/chunklist.go +89 -0
  52. data/lib/helpers/fzf/src/chunklist_test.go +80 -0
  53. data/lib/helpers/fzf/src/constants.go +85 -0
  54. data/lib/helpers/fzf/src/core.go +351 -0
  55. data/lib/helpers/fzf/src/history.go +96 -0
  56. data/lib/helpers/fzf/src/history_test.go +68 -0
  57. data/lib/helpers/fzf/src/item.go +44 -0
  58. data/lib/helpers/fzf/src/item_test.go +23 -0
  59. data/lib/helpers/fzf/src/matcher.go +235 -0
  60. data/lib/helpers/fzf/src/merger.go +120 -0
  61. data/lib/helpers/fzf/src/merger_test.go +88 -0
  62. data/lib/helpers/fzf/src/options.go +1691 -0
  63. data/lib/helpers/fzf/src/options_test.go +457 -0
  64. data/lib/helpers/fzf/src/pattern.go +425 -0
  65. data/lib/helpers/fzf/src/pattern_test.go +209 -0
  66. data/lib/helpers/fzf/src/protector/protector.go +8 -0
  67. data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
  68. data/lib/helpers/fzf/src/reader.go +201 -0
  69. data/lib/helpers/fzf/src/reader_test.go +63 -0
  70. data/lib/helpers/fzf/src/result.go +243 -0
  71. data/lib/helpers/fzf/src/result_others.go +16 -0
  72. data/lib/helpers/fzf/src/result_test.go +159 -0
  73. data/lib/helpers/fzf/src/result_x86.go +16 -0
  74. data/lib/helpers/fzf/src/terminal.go +2832 -0
  75. data/lib/helpers/fzf/src/terminal_test.go +638 -0
  76. data/lib/helpers/fzf/src/terminal_unix.go +26 -0
  77. data/lib/helpers/fzf/src/terminal_windows.go +45 -0
  78. data/lib/helpers/fzf/src/tokenizer.go +253 -0
  79. data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
  80. data/lib/helpers/fzf/src/tui/dummy.go +46 -0
  81. data/lib/helpers/fzf/src/tui/light.go +987 -0
  82. data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
  83. data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
  84. data/lib/helpers/fzf/src/tui/tcell.go +721 -0
  85. data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
  86. data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
  87. data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
  88. data/lib/helpers/fzf/src/tui/tui.go +625 -0
  89. data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
  90. data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
  91. data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
  92. data/lib/helpers/fzf/src/util/chars.go +198 -0
  93. data/lib/helpers/fzf/src/util/chars_test.go +46 -0
  94. data/lib/helpers/fzf/src/util/eventbox.go +96 -0
  95. data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
  96. data/lib/helpers/fzf/src/util/slab.go +12 -0
  97. data/lib/helpers/fzf/src/util/util.go +138 -0
  98. data/lib/helpers/fzf/src/util/util_test.go +40 -0
  99. data/lib/helpers/fzf/src/util/util_unix.go +47 -0
  100. data/lib/helpers/fzf/src/util/util_windows.go +83 -0
  101. data/lib/helpers/fzf/test/fzf.vader +175 -0
  102. data/lib/helpers/fzf/test/test_go.rb +2626 -0
  103. data/lib/helpers/fzf/uninstall +117 -0
  104. data/scripts/generate_bash_completions.rb +6 -12
  105. data/scripts/generate_fish_completions.rb +7 -16
  106. data/scripts/generate_zsh_completions.rb +6 -15
  107. metadata +144 -9
@@ -0,0 +1,11 @@
1
+ FROM archlinux/base:latest
2
+ RUN pacman -Sy && pacman --noconfirm -S awk git tmux zsh fish ruby procps go make gcc
3
+ RUN gem install --no-document -v 5.14.2 minitest
4
+ RUN echo '. /usr/share/bash-completion/completions/git' >> ~/.bashrc
5
+ RUN echo '. ~/.bashrc' >> ~/.bash_profile
6
+
7
+ # Do not set default PS1
8
+ RUN rm -f /etc/bash.bashrc
9
+ COPY . /fzf
10
+ RUN cd /fzf && make install && ./install --all
11
+ CMD tmux new 'set -o pipefail; ruby /fzf/test/test_go.rb | tee out && touch ok' && cat out && [ -e ok ]
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2021 Junegunn Choi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,166 @@
1
+ SHELL := bash
2
+ GO ?= go
3
+ GOOS ?= $(word 1, $(subst /, " ", $(word 4, $(shell go version))))
4
+
5
+ MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
6
+ ROOT_DIR := $(shell dirname $(MAKEFILE))
7
+ SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE)
8
+
9
+ ifdef FZF_VERSION
10
+ VERSION := $(FZF_VERSION)
11
+ else
12
+ VERSION := $(shell git describe --abbrev=0 2> /dev/null)
13
+ endif
14
+ ifeq ($(VERSION),)
15
+ $(error Not on git repository; cannot determine $$FZF_VERSION)
16
+ endif
17
+ VERSION_TRIM := $(shell sed "s/-.*//" <<< $(VERSION))
18
+ VERSION_REGEX := $(subst .,\.,$(VERSION_TRIM))
19
+
20
+ ifdef FZF_REVISION
21
+ REVISION := $(FZF_REVISION)
22
+ else
23
+ REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES) 2> /dev/null)
24
+ endif
25
+ ifeq ($(REVISION),)
26
+ $(error Not on git repository; cannot determine $$FZF_REVISION)
27
+ endif
28
+ BUILD_FLAGS := -a -ldflags "-s -w -X main.version=$(VERSION) -X main.revision=$(REVISION)" -tags "$(TAGS)"
29
+
30
+ BINARY32 := fzf-$(GOOS)_386
31
+ BINARY64 := fzf-$(GOOS)_amd64
32
+ BINARYARM5 := fzf-$(GOOS)_arm5
33
+ BINARYARM6 := fzf-$(GOOS)_arm6
34
+ BINARYARM7 := fzf-$(GOOS)_arm7
35
+ BINARYARM8 := fzf-$(GOOS)_arm8
36
+ BINARYPPC64LE := fzf-$(GOOS)_ppc64le
37
+ BINARYRISCV64 := fzf-$(GOOS)_riscv64
38
+
39
+ # https://en.wikipedia.org/wiki/Uname
40
+ UNAME_M := $(shell uname -m)
41
+ ifeq ($(UNAME_M),x86_64)
42
+ BINARY := $(BINARY64)
43
+ else ifeq ($(UNAME_M),amd64)
44
+ BINARY := $(BINARY64)
45
+ else ifeq ($(UNAME_M),i686)
46
+ BINARY := $(BINARY32)
47
+ else ifeq ($(UNAME_M),i386)
48
+ BINARY := $(BINARY32)
49
+ else ifeq ($(UNAME_M),armv5l)
50
+ BINARY := $(BINARYARM5)
51
+ else ifeq ($(UNAME_M),armv6l)
52
+ BINARY := $(BINARYARM6)
53
+ else ifeq ($(UNAME_M),armv7l)
54
+ BINARY := $(BINARYARM7)
55
+ else ifeq ($(UNAME_M),armv8l)
56
+ BINARY := $(BINARYARM8)
57
+ else ifeq ($(UNAME_M),arm64)
58
+ BINARY := $(BINARYARM8)
59
+ else ifeq ($(UNAME_M),aarch64)
60
+ BINARY := $(BINARYARM8)
61
+ else ifeq ($(UNAME_M),ppc64le)
62
+ BINARY := $(BINARYPPC64LE)
63
+ else ifeq ($(UNAME_M),riscv64)
64
+ BINARY := $(BINARYRISCV64)
65
+ else
66
+ $(error Build on $(UNAME_M) is not supported, yet.)
67
+ endif
68
+
69
+ all: target/$(BINARY)
70
+
71
+ test: $(SOURCES)
72
+ [ -z "$$(gofmt -s -d src)" ] || (gofmt -s -d src; exit 1)
73
+ SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" \
74
+ github.com/junegunn/fzf/src \
75
+ github.com/junegunn/fzf/src/algo \
76
+ github.com/junegunn/fzf/src/tui \
77
+ github.com/junegunn/fzf/src/util
78
+
79
+ bench:
80
+ cd src && SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" -run=Bench -bench=. -benchmem
81
+
82
+ install: bin/fzf
83
+
84
+ build:
85
+ goreleaser --rm-dist --snapshot
86
+
87
+ release:
88
+ ifndef GITHUB_TOKEN
89
+ $(error GITHUB_TOKEN is not defined)
90
+ endif
91
+
92
+ # Check if we are on master branch
93
+ ifneq ($(shell git symbolic-ref --short HEAD),master)
94
+ $(error Not on master branch)
95
+ endif
96
+
97
+ # Check if version numbers are properly updated
98
+ grep -q ^$(VERSION_REGEX)$$ CHANGELOG.md
99
+ grep -qF '"fzf $(VERSION_TRIM)"' man/man1/fzf.1
100
+ grep -qF '"fzf $(VERSION_TRIM)"' man/man1/fzf-tmux.1
101
+ grep -qF $(VERSION) install
102
+ grep -qF $(VERSION) install.ps1
103
+
104
+ # Make release note out of CHANGELOG.md
105
+ mkdir -p tmp
106
+ sed -n '/^$(VERSION_REGEX)$$/,/^[0-9]/p' CHANGELOG.md | tail -r | \
107
+ sed '1,/^ *$$/d' | tail -r | sed 1,2d | tee tmp/release-note
108
+
109
+ # Push to temp branch first so that install scripts always works on master branch
110
+ git checkout -B temp master
111
+ git push origin temp --follow-tags --force
112
+
113
+ # Make a GitHub release
114
+ goreleaser --rm-dist --release-notes tmp/release-note
115
+
116
+ # Push to master
117
+ git checkout master
118
+ git push origin master
119
+
120
+ # Delete temp branch
121
+ git push origin --delete temp
122
+
123
+ clean:
124
+ $(RM) -r dist target
125
+
126
+ target/$(BINARY32): $(SOURCES)
127
+ GOARCH=386 $(GO) build $(BUILD_FLAGS) -o $@
128
+
129
+ target/$(BINARY64): $(SOURCES)
130
+ GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@
131
+
132
+ # https://github.com/golang/go/wiki/GoArm
133
+ target/$(BINARYARM5): $(SOURCES)
134
+ GOARCH=arm GOARM=5 $(GO) build $(BUILD_FLAGS) -o $@
135
+
136
+ target/$(BINARYARM6): $(SOURCES)
137
+ GOARCH=arm GOARM=6 $(GO) build $(BUILD_FLAGS) -o $@
138
+
139
+ target/$(BINARYARM7): $(SOURCES)
140
+ GOARCH=arm GOARM=7 $(GO) build $(BUILD_FLAGS) -o $@
141
+
142
+ target/$(BINARYARM8): $(SOURCES)
143
+ GOARCH=arm64 $(GO) build $(BUILD_FLAGS) -o $@
144
+
145
+ target/$(BINARYPPC64LE): $(SOURCES)
146
+ GOARCH=ppc64le $(GO) build $(BUILD_FLAGS) -o $@
147
+
148
+ target/$(BINARYRISCV64): $(SOURCES)
149
+ GOARCH=riscv64 $(GO) build $(BUILD_FLAGS) -o $@
150
+
151
+ bin/fzf: target/$(BINARY) | bin
152
+ cp -f target/$(BINARY) bin/fzf
153
+
154
+ docker:
155
+ docker build -t fzf-arch .
156
+ docker run -it fzf-arch tmux
157
+
158
+ docker-test:
159
+ docker build -t fzf-arch .
160
+ docker run -it fzf-arch
161
+
162
+ update:
163
+ $(GO) get -u
164
+ $(GO) mod tidy
165
+
166
+ .PHONY: all build release test bench install clean docker docker-test update
@@ -0,0 +1,486 @@
1
+ FZF Vim integration
2
+ ===================
3
+
4
+ Installation
5
+ ------------
6
+
7
+ Once you have fzf installed, you can enable it inside Vim simply by adding the
8
+ directory to `&runtimepath` in your Vim configuration file. The path may
9
+ differ depending on the package manager.
10
+
11
+ ```vim
12
+ " If installed using Homebrew
13
+ set rtp+=/usr/local/opt/fzf
14
+
15
+ " If installed using git
16
+ set rtp+=~/.fzf
17
+ ```
18
+
19
+ If you use [vim-plug](https://github.com/junegunn/vim-plug), the same can be
20
+ written as:
21
+
22
+ ```vim
23
+ " If installed using Homebrew
24
+ Plug '/usr/local/opt/fzf'
25
+
26
+ " If installed using git
27
+ Plug '~/.fzf'
28
+ ```
29
+
30
+ But if you want the latest Vim plugin file from GitHub rather than the one
31
+ included in the package, write:
32
+
33
+ ```vim
34
+ Plug 'junegunn/fzf'
35
+ ```
36
+
37
+ The Vim plugin will pick up fzf binary available on the system. If fzf is not
38
+ found on `$PATH`, it will ask you if it should download the latest binary for
39
+ you.
40
+
41
+ To make sure that you have the latest version of the binary, set up
42
+ post-update hook like so:
43
+
44
+ ```vim
45
+ Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
46
+ ```
47
+
48
+ Summary
49
+ -------
50
+
51
+ The Vim plugin of fzf provides two core functions, and `:FZF` command which is
52
+ the basic file selector command built on top of them.
53
+
54
+ 1. **`fzf#run([spec dict])`**
55
+ - Starts fzf inside Vim with the given spec
56
+ - `:call fzf#run({'source': 'ls'})`
57
+ 2. **`fzf#wrap([spec dict]) -> (dict)`**
58
+ - Takes a spec for `fzf#run` and returns an extended version of it with
59
+ additional options for addressing global preferences (`g:fzf_xxx`)
60
+ - `:echo fzf#wrap({'source': 'ls'})`
61
+ - We usually *wrap* a spec with `fzf#wrap` before passing it to `fzf#run`
62
+ - `:call fzf#run(fzf#wrap({'source': 'ls'}))`
63
+ 3. **`:FZF [fzf_options string] [path string]`**
64
+ - Basic fuzzy file selector
65
+ - A reference implementation for those who don't want to write VimScript
66
+ to implement custom commands
67
+ - If you're looking for more such commands, check out [fzf.vim](https://github.com/junegunn/fzf.vim) project.
68
+
69
+ The most important of all is `fzf#run`, but it would be easier to understand
70
+ the whole if we start off with `:FZF` command.
71
+
72
+ `:FZF[!]`
73
+ ---------
74
+
75
+ ```vim
76
+ " Look for files under current directory
77
+ :FZF
78
+
79
+ " Look for files under your home directory
80
+ :FZF ~
81
+
82
+ " With fzf command-line options
83
+ :FZF --reverse --info=inline /tmp
84
+
85
+ " Bang version starts fzf in fullscreen mode
86
+ :FZF!
87
+ ```
88
+
89
+ Similarly to [ctrlp.vim](https://github.com/kien/ctrlp.vim), use enter key,
90
+ `CTRL-T`, `CTRL-X` or `CTRL-V` to open selected files in the current window,
91
+ in new tabs, in horizontal splits, or in vertical splits respectively.
92
+
93
+ Note that the environment variables `FZF_DEFAULT_COMMAND` and
94
+ `FZF_DEFAULT_OPTS` also apply here.
95
+
96
+ ### Configuration
97
+
98
+ - `g:fzf_action`
99
+ - Customizable extra key bindings for opening selected files in different ways
100
+ - `g:fzf_layout`
101
+ - Determines the size and position of fzf window
102
+ - `g:fzf_colors`
103
+ - Customizes fzf colors to match the current color scheme
104
+ - `g:fzf_history_dir`
105
+ - Enables history feature
106
+
107
+ #### Examples
108
+
109
+ ```vim
110
+ " This is the default extra key bindings
111
+ let g:fzf_action = {
112
+ \ 'ctrl-t': 'tab split',
113
+ \ 'ctrl-x': 'split',
114
+ \ 'ctrl-v': 'vsplit' }
115
+
116
+ " An action can be a reference to a function that processes selected lines
117
+ function! s:build_quickfix_list(lines)
118
+ call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
119
+ copen
120
+ cc
121
+ endfunction
122
+
123
+ let g:fzf_action = {
124
+ \ 'ctrl-q': function('s:build_quickfix_list'),
125
+ \ 'ctrl-t': 'tab split',
126
+ \ 'ctrl-x': 'split',
127
+ \ 'ctrl-v': 'vsplit' }
128
+
129
+ " Default fzf layout
130
+ " - Popup window (center of the screen)
131
+ let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
132
+
133
+ " - Popup window (center of the current window)
134
+ let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'relative': v:true } }
135
+
136
+ " - Popup window (anchored to the bottom of the current window)
137
+ let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'relative': v:true, 'yoffset': 1.0 } }
138
+
139
+ " - down / up / left / right
140
+ let g:fzf_layout = { 'down': '40%' }
141
+
142
+ " - Window using a Vim command
143
+ let g:fzf_layout = { 'window': 'enew' }
144
+ let g:fzf_layout = { 'window': '-tabnew' }
145
+ let g:fzf_layout = { 'window': '10new' }
146
+
147
+ " Customize fzf colors to match your color scheme
148
+ " - fzf#wrap translates this to a set of `--color` options
149
+ let g:fzf_colors =
150
+ \ { 'fg': ['fg', 'Normal'],
151
+ \ 'bg': ['bg', 'Normal'],
152
+ \ 'hl': ['fg', 'Comment'],
153
+ \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
154
+ \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
155
+ \ 'hl+': ['fg', 'Statement'],
156
+ \ 'info': ['fg', 'PreProc'],
157
+ \ 'border': ['fg', 'Ignore'],
158
+ \ 'prompt': ['fg', 'Conditional'],
159
+ \ 'pointer': ['fg', 'Exception'],
160
+ \ 'marker': ['fg', 'Keyword'],
161
+ \ 'spinner': ['fg', 'Label'],
162
+ \ 'header': ['fg', 'Comment'] }
163
+
164
+ " Enable per-command history
165
+ " - History files will be stored in the specified directory
166
+ " - When set, CTRL-N and CTRL-P will be bound to 'next-history' and
167
+ " 'previous-history' instead of 'down' and 'up'.
168
+ let g:fzf_history_dir = '~/.local/share/fzf-history'
169
+ ```
170
+
171
+ ##### Explanation of `g:fzf_colors`
172
+
173
+ `g:fzf_colors` is a dictionary mapping fzf elements to a color specification
174
+ list:
175
+
176
+ element: [ component, group1 [, group2, ...] ]
177
+
178
+ - `element` is an fzf element to apply a color to:
179
+
180
+ | Element | Description |
181
+ | --- | --- |
182
+ | `fg` / `bg` / `hl` | Item (foreground / background / highlight) |
183
+ | `fg+` / `bg+` / `hl+` | Current item (foreground / background / highlight) |
184
+ | `preview-fg` / `preview-bg` | Preview window text and background |
185
+ | `hl` / `hl+` | Highlighted substrings (normal / current) |
186
+ | `gutter` | Background of the gutter on the left |
187
+ | `pointer` | Pointer to the current line (`>`) |
188
+ | `marker` | Multi-select marker (`>`) |
189
+ | `border` | Border around the window (`--border` and `--preview`) |
190
+ | `header` | Header (`--header` or `--header-lines`) |
191
+ | `info` | Info line (match counters) |
192
+ | `spinner` | Streaming input indicator |
193
+ | `query` | Query string |
194
+ | `disabled` | Query string when search is disabled |
195
+ | `prompt` | Prompt before query (`> `) |
196
+ | `pointer` | Pointer to the current line (`>`) |
197
+
198
+ - `component` specifies the component (`fg` / `bg`) from which to extract the
199
+ color when considering each of the following highlight groups
200
+
201
+ - `group1 [, group2, ...]` is a list of highlight groups that are searched (in
202
+ order) for a matching color definition
203
+
204
+ For example, consider the following specification:
205
+
206
+ ```vim
207
+ 'prompt': ['fg', 'Conditional', 'Comment'],
208
+ ```
209
+
210
+ This means we color the **prompt**
211
+ - using the `fg` attribute of the `Conditional` if it exists,
212
+ - otherwise use the `fg` attribute of the `Comment` highlight group if it exists,
213
+ - otherwise fall back to the default color settings for the **prompt**.
214
+
215
+ You can examine the color option generated according the setting by printing
216
+ the result of `fzf#wrap()` function like so:
217
+
218
+ ```vim
219
+ :echo fzf#wrap()
220
+ ```
221
+
222
+ `fzf#run`
223
+ ---------
224
+
225
+ `fzf#run()` function is the core of Vim integration. It takes a single
226
+ dictionary argument, *a spec*, and starts fzf process accordingly. At the very
227
+ least, specify `sink` option to tell what it should do with the selected
228
+ entry.
229
+
230
+ ```vim
231
+ call fzf#run({'sink': 'e'})
232
+ ```
233
+
234
+ We haven't specified the `source`, so this is equivalent to starting fzf on
235
+ command line without standard input pipe; fzf will use find command (or
236
+ `$FZF_DEFAULT_COMMAND` if defined) to list the files under the current
237
+ directory. When you select one, it will open it with the sink, `:e` command.
238
+ If you want to open it in a new tab, you can pass `:tabedit` command instead
239
+ as the sink.
240
+
241
+ ```vim
242
+ call fzf#run({'sink': 'tabedit'})
243
+ ```
244
+
245
+ Instead of using the default find command, you can use any shell command as
246
+ the source. The following example will list the files managed by git. It's
247
+ equivalent to running `git ls-files | fzf` on shell.
248
+
249
+ ```vim
250
+ call fzf#run({'source': 'git ls-files', 'sink': 'e'})
251
+ ```
252
+
253
+ fzf options can be specified as `options` entry in spec dictionary.
254
+
255
+ ```vim
256
+ call fzf#run({'sink': 'tabedit', 'options': '--multi --reverse'})
257
+ ```
258
+
259
+ You can also pass a layout option if you don't want fzf window to take up the
260
+ entire screen.
261
+
262
+ ```vim
263
+ " up / down / left / right / window are allowed
264
+ call fzf#run({'source': 'git ls-files', 'sink': 'e', 'left': '40%'})
265
+ call fzf#run({'source': 'git ls-files', 'sink': 'e', 'window': '30vnew'})
266
+ ```
267
+
268
+ `source` doesn't have to be an external shell command, you can pass a Vim
269
+ array as the source. In the next example, we pass the names of color
270
+ schemes as the source to implement a color scheme selector.
271
+
272
+ ```vim
273
+ call fzf#run({'source': map(split(globpath(&rtp, 'colors/*.vim')),
274
+ \ 'fnamemodify(v:val, ":t:r")'),
275
+ \ 'sink': 'colo', 'left': '25%'})
276
+ ```
277
+
278
+ The following table summarizes the available options.
279
+
280
+ | Option name | Type | Description |
281
+ | -------------------------- | ------------- | ---------------------------------------------------------------- |
282
+ | `source` | string | External command to generate input to fzf (e.g. `find .`) |
283
+ | `source` | list | Vim list as input to fzf |
284
+ | `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |
285
+ | `sink` | funcref | Reference to function to process each selected item |
286
+ | `sinklist` (or `sink*`) | funcref | Similar to `sink`, but takes the list of output lines at once |
287
+ | `options` | string/list | Options to fzf |
288
+ | `dir` | string | Working directory |
289
+ | `up`/`down`/`left`/`right` | number/string | (Layout) Window position and size (e.g. `20`, `50%`) |
290
+ | `tmux` | string | (Layout) fzf-tmux options (e.g. `-p90%,60%`) |
291
+ | `window` (Vim 8 / Neovim) | string | (Layout) Command to open fzf window (e.g. `vertical aboveleft 30new`) |
292
+ | `window` (Vim 8 / Neovim) | dict | (Layout) Popup window settings (e.g. `{'width': 0.9, 'height': 0.6}`) |
293
+
294
+ `options` entry can be either a string or a list. For simple cases, string
295
+ should suffice, but prefer to use list type to avoid escaping issues.
296
+
297
+ ```vim
298
+ call fzf#run({'options': '--reverse --prompt "C:\\Program Files\\"'})
299
+ call fzf#run({'options': ['--reverse', '--prompt', 'C:\Program Files\']})
300
+ ```
301
+
302
+ When `window` entry is a dictionary, fzf will start in a popup window. The
303
+ following options are allowed:
304
+
305
+ - Required:
306
+ - `width` [float range [0 ~ 1]] or [integer range [8 ~ ]]
307
+ - `height` [float range [0 ~ 1]] or [integer range [4 ~ ]]
308
+ - Optional:
309
+ - `yoffset` [float default 0.5 range [0 ~ 1]]
310
+ - `xoffset` [float default 0.5 range [0 ~ 1]]
311
+ - `relative` [boolean default v:false]
312
+ - `border` [string default `rounded`]: Border style
313
+ - `rounded` / `sharp` / `horizontal` / `vertical` / `top` / `bottom` / `left` / `right` / `no[ne]`
314
+
315
+ `fzf#wrap`
316
+ ----------
317
+
318
+ We have seen that several aspects of `:FZF` command can be configured with
319
+ a set of global option variables; different ways to open files
320
+ (`g:fzf_action`), window position and size (`g:fzf_layout`), color palette
321
+ (`g:fzf_colors`), etc.
322
+
323
+ So how can we make our custom `fzf#run` calls also respect those variables?
324
+ Simply by *"wrapping"* the spec dictionary with `fzf#wrap` before passing it
325
+ to `fzf#run`.
326
+
327
+ - **`fzf#wrap([name string], [spec dict], [fullscreen bool]) -> (dict)`**
328
+ - All arguments are optional. Usually we only need to pass a spec dictionary.
329
+ - `name` is for managing history files. It is ignored if
330
+ `g:fzf_history_dir` is not defined.
331
+ - `fullscreen` can be either `0` or `1` (default: 0).
332
+
333
+ `fzf#wrap` takes a spec and returns an extended version of it (also
334
+ a dictionary) with additional options for addressing global preferences. You
335
+ can examine the return value of it like so:
336
+
337
+ ```vim
338
+ echo fzf#wrap({'source': 'ls'})
339
+ ```
340
+
341
+ After we *"wrap"* our spec, we pass it to `fzf#run`.
342
+
343
+ ```vim
344
+ call fzf#run(fzf#wrap({'source': 'ls'}))
345
+ ```
346
+
347
+ Now it supports `CTRL-T`, `CTRL-V`, and `CTRL-X` key bindings (configurable
348
+ via `g:fzf_action`) and it opens fzf window according to `g:fzf_layout`
349
+ setting.
350
+
351
+ To make it easier to use, let's define `LS` command.
352
+
353
+ ```vim
354
+ command! LS call fzf#run(fzf#wrap({'source': 'ls'}))
355
+ ```
356
+
357
+ Type `:LS` and see how it works.
358
+
359
+ We would like to make `:LS!` (bang version) open fzf in fullscreen, just like
360
+ `:FZF!`. Add `-bang` to command definition, and use `<bang>` value to set
361
+ the last `fullscreen` argument of `fzf#wrap` (see `:help <bang>`).
362
+
363
+ ```vim
364
+ " On :LS!, <bang> evaluates to '!', and '!0' becomes 1
365
+ command! -bang LS call fzf#run(fzf#wrap({'source': 'ls'}, <bang>0))
366
+ ```
367
+
368
+ Our `:LS` command will be much more useful if we can pass a directory argument
369
+ to it, so that something like `:LS /tmp` is possible.
370
+
371
+ ```vim
372
+ command! -bang -complete=dir -nargs=? LS
373
+ \ call fzf#run(fzf#wrap({'source': 'ls', 'dir': <q-args>}, <bang>0))
374
+ ```
375
+
376
+ Lastly, if you have enabled `g:fzf_history_dir`, you might want to assign
377
+ a unique name to our command and pass it as the first argument to `fzf#wrap`.
378
+
379
+ ```vim
380
+ " The query history for this command will be stored as 'ls' inside g:fzf_history_dir.
381
+ " The name is ignored if g:fzf_history_dir is not defined.
382
+ command! -bang -complete=dir -nargs=? LS
383
+ \ call fzf#run(fzf#wrap('ls', {'source': 'ls', 'dir': <q-args>}, <bang>0))
384
+ ```
385
+
386
+ ### Global options supported by `fzf#wrap`
387
+
388
+ - `g:fzf_layout`
389
+ - `g:fzf_action`
390
+ - **Works only when no custom `sink` (or `sinklist`) is provided**
391
+ - Having custom sink usually means that each entry is not an ordinary
392
+ file path (e.g. name of color scheme), so we can't blindly apply the
393
+ same strategy (i.e. `tabedit some-color-scheme` doesn't make sense)
394
+ - `g:fzf_colors`
395
+ - `g:fzf_history_dir`
396
+
397
+ Tips
398
+ ----
399
+
400
+ ### fzf inside terminal buffer
401
+
402
+ On the latest versions of Vim and Neovim, fzf will start in a terminal buffer.
403
+ If you find the default ANSI colors to be different, consider configuring the
404
+ colors using `g:terminal_ansi_colors` in regular Vim or `g:terminal_color_x`
405
+ in Neovim.
406
+
407
+ ```vim
408
+ " Terminal colors for seoul256 color scheme
409
+ if has('nvim')
410
+ let g:terminal_color_0 = '#4e4e4e'
411
+ let g:terminal_color_1 = '#d68787'
412
+ let g:terminal_color_2 = '#5f865f'
413
+ let g:terminal_color_3 = '#d8af5f'
414
+ let g:terminal_color_4 = '#85add4'
415
+ let g:terminal_color_5 = '#d7afaf'
416
+ let g:terminal_color_6 = '#87afaf'
417
+ let g:terminal_color_7 = '#d0d0d0'
418
+ let g:terminal_color_8 = '#626262'
419
+ let g:terminal_color_9 = '#d75f87'
420
+ let g:terminal_color_10 = '#87af87'
421
+ let g:terminal_color_11 = '#ffd787'
422
+ let g:terminal_color_12 = '#add4fb'
423
+ let g:terminal_color_13 = '#ffafaf'
424
+ let g:terminal_color_14 = '#87d7d7'
425
+ let g:terminal_color_15 = '#e4e4e4'
426
+ else
427
+ let g:terminal_ansi_colors = [
428
+ \ '#4e4e4e', '#d68787', '#5f865f', '#d8af5f',
429
+ \ '#85add4', '#d7afaf', '#87afaf', '#d0d0d0',
430
+ \ '#626262', '#d75f87', '#87af87', '#ffd787',
431
+ \ '#add4fb', '#ffafaf', '#87d7d7', '#e4e4e4'
432
+ \ ]
433
+ endif
434
+ ```
435
+
436
+ ### Starting fzf in a popup window
437
+
438
+ ```vim
439
+ " Required:
440
+ " - width [float range [0 ~ 1]] or [integer range [8 ~ ]]
441
+ " - height [float range [0 ~ 1]] or [integer range [4 ~ ]]
442
+ "
443
+ " Optional:
444
+ " - xoffset [float default 0.5 range [0 ~ 1]]
445
+ " - yoffset [float default 0.5 range [0 ~ 1]]
446
+ " - relative [boolean default v:false]
447
+ " - border [string default 'rounded']: Border style
448
+ " - 'rounded' / 'sharp' / 'horizontal' / 'vertical' / 'top' / 'bottom' / 'left' / 'right'
449
+ let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
450
+ ```
451
+
452
+ Alternatively, you can make fzf open in a tmux popup window (requires tmux 3.2
453
+ or above) by putting fzf-tmux options in `tmux` key.
454
+
455
+ ```vim
456
+ " See `man fzf-tmux` for available options
457
+ if exists('$TMUX')
458
+ let g:fzf_layout = { 'tmux': '-p90%,60%' }
459
+ else
460
+ let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
461
+ endif
462
+ ```
463
+
464
+ ### Hide statusline
465
+
466
+ When fzf starts in a terminal buffer, the file type of the buffer is set to
467
+ `fzf`. So you can set up `FileType fzf` autocmd to customize the settings of
468
+ the window.
469
+
470
+ For example, if you open fzf on the bottom on the screen (e.g. `{'down':
471
+ '40%'}`), you might want to temporarily disable the statusline for a cleaner
472
+ look.
473
+
474
+ ```vim
475
+ let g:fzf_layout = { 'down': '30%' }
476
+ autocmd! FileType fzf
477
+ autocmd FileType fzf set laststatus=0 noshowmode noruler
478
+ \| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
479
+ ```
480
+
481
+ [License](LICENSE)
482
+ ------------------
483
+
484
+ The MIT License (MIT)
485
+
486
+ Copyright (c) 2013-2021 Junegunn Choi