Skip to content

Commit c9227ea

Browse files
committed
docs(README): use FzfLua global object
1 parent 1a8b424 commit c9227ea

1 file changed

Lines changed: 28 additions & 27 deletions

File tree

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ Fzf-lua aims to be as plug and play as possible with sane defaults, you can
115115
run any fzf-lua command like this:
116116

117117
```lua
118-
:lua require('fzf-lua').files()
119-
-- or using the `FzfLua` vim command:
118+
:lua require("fzf-lua").files()
119+
-- once loaded we can use the global object
120+
:lua FzfLua.files()
121+
-- or the vim command:
120122
:FzfLua files
121123
```
122124

@@ -412,7 +414,7 @@ Fzf-Lua conveniently comes with a VS-Code like picker by default
412414
> to see detailed usage notes and a comprehensive list of yet more(!) available options.
413415
414416
```lua
415-
require("fzf-lua").setup{
417+
require("fzf-lua").setup {
416418
-- MISC GLOBAL SETUP OPTIONS, SEE BELOW
417419
-- fzf_bin = ...,
418420
-- each of these options can also be passed as function that return options table
@@ -586,7 +588,6 @@ keymap = {
586588
<summary>actions</summary>
587589

588590
```lua
589-
local actions = require("fzf-lua").actions
590591
actions = {
591592
-- Below are the default actions, setting any value in these tables will override
592593
-- the defaults, to inherit from the defaults change [1] from `false` to `true`
@@ -598,15 +599,15 @@ actions = {
598599
-- `file_edit_or_qf` opens a single selection or sends multiple selection to quickfix
599600
-- replace `enter` with `file_edit` to open all files/bufs whether single or multiple
600601
-- replace `enter` with `file_switch_or_edit` to attempt a switch in current tab first
601-
["enter"] = actions.file_edit_or_qf,
602-
["ctrl-s"] = actions.file_split,
603-
["ctrl-v"] = actions.file_vsplit,
604-
["ctrl-t"] = actions.file_tabedit,
605-
["alt-q"] = actions.file_sel_to_qf,
606-
["alt-Q"] = actions.file_sel_to_ll,
607-
["alt-i"] = actions.toggle_ignore,
608-
["alt-h"] = actions.toggle_hidden,
609-
["alt-f"] = actions.toggle_follow,
602+
["enter"] = FzfLua.actions.file_edit_or_qf,
603+
["ctrl-s"] = FzfLua.actions.file_split,
604+
["ctrl-v"] = FzfLua.actions.file_vsplit,
605+
["ctrl-t"] = FzfLua.actions.file_tabedit,
606+
["alt-q"] = FzfLua.actions.file_sel_to_qf,
607+
["alt-Q"] = FzfLua.actions.file_sel_to_ll,
608+
["alt-i"] = FzfLua.actions.toggle_ignore,
609+
["alt-h"] = FzfLua.actions.toggle_hidden,
610+
["alt-f"] = FzfLua.actions.toggle_follow,
610611
},
611612
}
612613
```
@@ -1070,7 +1071,7 @@ previewers = {
10701071
cwd_only = false,
10711072
stat_file = true, -- verify files exist on disk
10721073
-- can also be a lua function, for example:
1073-
-- stat_file = require("fzf-lua").utils.file_is_readable,
1074+
-- stat_file = FzfLua.utils.file_is_readable,
10741075
-- stat_file = function() return true end,
10751076
include_current_session = false, -- include bufs from current session
10761077
},
@@ -1300,13 +1301,13 @@ previewers = {
13001301
-- by default display all LSP locations
13011302
-- to customize, duplicate table and delete unwanted providers
13021303
providers = {
1303-
{ "references", prefix = require("fzf-lua").utils.ansi_codes.blue("ref ") },
1304-
{ "definitions", prefix = require("fzf-lua").utils.ansi_codes.green("def ") },
1305-
{ "declarations", prefix = require("fzf-lua").utils.ansi_codes.magenta("decl") },
1306-
{ "typedefs", prefix = require("fzf-lua").utils.ansi_codes.red("tdef") },
1307-
{ "implementations", prefix = require("fzf-lua").utils.ansi_codes.green("impl") },
1308-
{ "incoming_calls", prefix = require("fzf-lua").utils.ansi_codes.cyan("in ") },
1309-
{ "outgoing_calls", prefix = require("fzf-lua").utils.ansi_codes.yellow("out ") },
1304+
{ "references", prefix = FzfLua.utils.ansi_codes.blue("ref ") },
1305+
{ "definitions", prefix = FzfLua.utils.ansi_codes.green("def ") },
1306+
{ "declarations", prefix = FzfLua.utils.ansi_codes.magenta("decl") },
1307+
{ "typedefs", prefix = FzfLua.utils.ansi_codes.red("tdef") },
1308+
{ "implementations", prefix = FzfLua.utils.ansi_codes.green("impl") },
1309+
{ "incoming_calls", prefix = FzfLua.utils.ansi_codes.cyan("in ") },
1310+
{ "outgoing_calls", prefix = FzfLua.utils.ansi_codes.yellow("out ") },
13101311
},
13111312
}
13121313
},
@@ -1399,13 +1400,13 @@ Using `files` with a different command and working directory:
13991400
Using `live_grep` with `git grep`:
14001401

14011402
```lua
1402-
:lua require'fzf-lua'.live_grep({ cmd = "git grep --line-number --column --color=always" })
1403+
:lua FzfLua.live_grep({ cmd = "git grep --line-number --column --color=always" })
14031404
```
14041405

14051406
`spell_suggest` with non-default window size relative to cursor:
14061407

14071408
```lua
1408-
:lua require'fzf-lua'.spell_suggest({ winopts = { height=0.33, width=0.33, relative="cursor" } })
1409+
:lua FzfLua.spell_suggest({ winopts = { height=0.33, width=0.33, relative="cursor" } })
14091410
-- Or via the vimL command
14101411
:FzfLua spell_suggest winopts={height=0.33,width=0.33,relative=cursor}
14111412
:FzfLua spell_suggest winopts={height=0.33,width=0.33} winopts.relative=cursor
@@ -1495,7 +1496,7 @@ well as custom completion, for example, set path/completion using `<C-x><C-f>`:
14951496

14961497
```lua
14971498
vim.keymap.set({ "n", "v", "i" }, "<C-x><C-f>",
1498-
function() require("fzf-lua").complete_path() end,
1499+
function() FzfLua.complete_path() end,
14991500
{ silent = true, desc = "Fuzzy complete path" })
15001501
```
15011502

@@ -1507,7 +1508,7 @@ Or with a custom command and preview:
15071508
```lua
15081509
vim.keymap.set({ "i" }, "<C-x><C-f>",
15091510
function()
1510-
require("fzf-lua").complete_file({
1511+
FzfLua.complete_file({
15111512
cmd = "rg --files",
15121513
winopts = { preview = { hidden = true } }
15131514
})
@@ -1526,14 +1527,14 @@ Every fzf-lua function can be easily converted to a completion function by sendi
15261527
> `p` to paste the selected entry.
15271528
15281529
```lua
1529-
require("fzf-lua").fzf_exec({"foo", "bar"}, {complete = true})
1530+
FzfLua.fzf_exec({"foo", "bar"}, {complete = true})
15301531
```
15311532

15321533
Custom completion is possible using a custom completion callback, the example below
15331534
will replace the text from the current cursor column with the selected entry:
15341535

15351536
```lua
1536-
require("fzf-lua").fzf_exec({"foo", "bar"}, {
1537+
FzfLua.fzf_exec({"foo", "bar"}, {
15371538
-- @param selected: the selected entry or entries
15381539
-- @param opts: fzf-lua caller/provider options
15391540
-- @param line: originating buffer completed line

0 commit comments

Comments
 (0)