aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 6b836af0c40afcef97169b61451f9fcad2fc080a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Fuzzy find and open files in vis

Use [fzf](https://github.com/junegunn/fzf) to open files in [vis](https://github.com/martanne/vis).

## Usage

In `vis`:
- `:fzf`: search all files in the current sub-tree.
- You can pass arguments to fzf, e.g. : `:fzf -p !.class`

While in `fzf`:

- `<Enter>` to open the selected file in current window
- `<C-s>` to open the selected file in a horizontal split
- `<C-v>` to open the selected file in a vertical split

## Configuration

In `visrc.lua`:

```lua
plugin_vis_open = require('plugins/vis-fzf-open/fzf-open')

-- Path to the fzf executable (default: "fzf")
plugin_vis_open.fzf_path = (
    "FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g \"\"' fzf"
)
-- Arguments passed to fzf (default: "")
plugin_vis_open.fzf_args = "-q '!.class ' --height=40%"
```

Complex example for `plugin_vis_open.fzf_args`:

```lua
my_fzf_args = string.gsub([[
    --bind=$my_fzf_key_bindings \
    --color fg:242,bg:236,hl:65,fg+:15,bg+:239,hl+:108 \
    --color info:108,prompt:109,spinner:108,pointer:168,marker:168 \
    --delimiter / --nth -1 \
    --height=70% \
    --inline-info \
    --no-mouse \
    --preview-window=up:70% \
    --preview="(
        bat --style=changes,grid,numbers --color=always {} ||
        highlight -O ansi -l {} ||
        coderay {} ||
        rougify {} ||
        cat {}
    ) 2> /dev/null | head -1000"
]],
'%$([%w_]+)', {
    my_fzf_key_bindings=table.concat({
        "alt-j:preview-down",
        "alt-k:preview-up",
        "ctrl-f:preview-page-down",
        "ctrl-b:preview-page-up",
        "?:toggle-preview",
        "alt-w:toggle-preview-wrap",
        "ctrl-z:clear-screen"
    }, ",")
})

-- Arguments passed to fzf (default: "")
plugin_vis_open.fzf_args = my_fzf_args
```