-
-
Notifications
You must be signed in to change notification settings - Fork 842
/
telescope.txt
3668 lines (2636 loc) · 141 KB
/
telescope.txt
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
================================================================================
INTRODUCTION *telescope.nvim*
Telescope.nvim is a plugin for fuzzy finding and neovim. It helps you search,
filter, find and pick things in Lua.
Getting started with telescope:
1. Run `:checkhealth telescope` to make sure everything is installed.
2. Evaluate it working with `:Telescope find_files` or `:lua
require("telescope.builtin").find_files()`
3. Put a `require("telescope").setup() call somewhere in your neovim config.
4. Read |telescope.setup| to check what config keys are available and what
you can put inside the setup call
5. Read |telescope.builtin| to check which builtin pickers are offered and
what options these implement
6. Profit
The below flow chart illustrates a simplified telescope architecture:
┌───────────────────────────────────────────────────────────┐
│ ┌────────┐ │
│ │ Multi │ ┌───────+ │
│ │ Select │ ┌───────┐ │ Entry │ │
│ └─────┬──* │ Entry │ ┌────────+ │ Maker │ │
│ │ ┌───│Manager│────│ Sorter │┐ └───┬───* │
│ ▼ ▼ └───────* └────────┘│ │ │
│ 1────────┐ 2───┴──┐ │ │
│ ┌─────│ Picker │ │Finder│◄────┘ │
│ ▼ └───┬────┘ └──────* │
│ ┌────────┐ │ 3────────+ ▲ │
│ │Selected│ └───────│ Prompt │─────────┘ │
│ │ Entry │ └───┬────┘ │
│ └────────* ┌───┴────┐ ┌────────┐ ┌────────┐ │
│ │ ▲ 4─────────┐│ Prompt │ │(Attach)│ │Actions │ │
│ ▼ └──► │ Results ││ Buffer │◄─┤Mappings│◄─┤User Fn │ │
│5─────────┐ └─────────┘└────────┘ └────────┘ └────────┘ │
││Previewer│ │
│└─────────┘ telescope.nvim architecture │
└───────────────────────────────────────────────────────────┘
+ The `Entry Maker` at least defines
- value: "raw" result of the finder
- ordinal: string to be sorted derived from value
- display: line representation of entry in results buffer
* The finder, entry manager, selected entry, and multi selections
comprises `entries` constructed by the `Entry Maker` from
raw results of the finder (`value`s)
Primary components:
1 Picker: central UI dedicated to varying use cases
(finding files, grepping, diagnostics, etc.)
see :h telescope.builtin
2 Finder: pipe or interactively generates results to pick over
3 Prompt: user input that triggers the finder which sorts results
in order into the entry manager
4 Results: listed entries scored by sorter from finder results
5 Previewer: preview of context of selected entry
see :h telescope.previewers
A practical introduction into telescope customization is our `developers.md`
(top-level of repo) and `:h telescope.actions` that showcase how to access
information about the state of the picker (current selection, etc.).
To find out more:
https://github.com/nvim-telescope/telescope.nvim
:h telescope.setup
:h telescope.command
:h telescope.builtin
:h telescope.themes
:h telescope.layout
:h telescope.resolve
:h telescope.actions
:h telescope.actions.state
:h telescope.actions.set
:h telescope.actions.utils
:h telescope.actions.generate
:h telescope.actions.history
:h telescope.previewers
telescope.setup({opts}) *telescope.setup()*
Setup function to be run by user. Configures the defaults, pickers and
extensions of telescope.
Usage:
>
require('telescope').setup{
defaults = {
-- Default configuration for telescope goes here:
-- config_key = value,
-- ..
},
pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
},
extensions = {
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
}
}
<
Valid keys for {opts.defaults}
*telescope.defaults.sorting_strategy*
sorting_strategy: ~
Determines the direction "better" results are sorted towards.
Available options are:
- "descending" (default)
- "ascending"
*telescope.defaults.selection_strategy*
selection_strategy: ~
Determines how the cursor acts after each sort iteration.
Available options are:
- "reset" (default)
- "follow"
- "row"
- "closest"
- "none"
*telescope.defaults.scroll_strategy*
scroll_strategy: ~
Determines what happens if you try to scroll past the view of the
picker.
Available options are:
- "cycle" (default)
- "limit"
*telescope.defaults.layout_strategy*
layout_strategy: ~
Determines the default layout of Telescope pickers.
See |telescope.layout| for details of the available strategies.
Default: 'horizontal'
*telescope.defaults.layout_config*
layout_config: ~
Determines the default configuration values for layout strategies.
See |telescope.layout| for details of the configurations options for
each strategy.
Allows setting defaults for all strategies as top level options and
for overriding for specific options.
For example, the default values below set the default width to 80% of
the screen width for all strategies except 'center', which has width
of 50% of the screen width.
Default: {
bottom_pane = {
height = 25,
preview_cutoff = 120,
prompt_position = "top"
},
center = {
height = 0.4,
preview_cutoff = 40,
prompt_position = "top",
width = 0.5
},
cursor = {
height = 0.9,
preview_cutoff = 40,
width = 0.8
},
horizontal = {
height = 0.9,
preview_cutoff = 120,
prompt_position = "bottom",
width = 0.8
},
vertical = {
height = 0.9,
preview_cutoff = 40,
prompt_position = "bottom",
width = 0.8
}
}
*telescope.defaults.cycle_layout_list*
cycle_layout_list: ~
Determines the layouts to cycle through when using `actions.cycle_layout_next`
and `actions.cycle_layout_prev`.
Should be a list of "layout setups".
Each "layout setup" can take one of two forms:
1. string <br>
This is interpreted as the name of a `layout_strategy`
2. table <br>
A table with possible keys `layout_strategy`, `layout_config` and `previewer`
Default: { "horizontal", "vertical" }
*telescope.defaults.winblend*
winblend: ~
Configure winblend for telescope floating windows. See |winblend| for
more information.
Default: 0
*telescope.defaults.wrap_results*
wrap_results: ~
Word wrap the search results
Default: false
*telescope.defaults.prompt_prefix*
prompt_prefix: ~
The character(s) that will be shown in front of Telescope's prompt.
Default: '> '
*telescope.defaults.selection_caret*
selection_caret: ~
The character(s) that will be shown in front of the current selection.
Default: '> '
*telescope.defaults.entry_prefix*
entry_prefix: ~
Prefix in front of each result entry. Current selection not included.
Default: ' '
*telescope.defaults.multi_icon*
multi_icon: ~
Symbol to add in front of a multi-selected result entry.
Replaces final character of |telescope.defaults.selection_caret| and
|telescope.defaults.entry_prefix| as appropriate.
To have no icon, set to the empty string.
Default: '+'
*telescope.defaults.initial_mode*
initial_mode: ~
Determines in which mode telescope starts. Valid Keys:
`insert` and `normal`.
Default: "insert"
*telescope.defaults.border*
border: ~
Boolean defining if borders are added to Telescope windows.
Default: true
*telescope.defaults.path_display*
path_display: ~
Determines how file paths are displayed
path_display can be set to an array with a combination of:
- "hidden" hide file names
- "tail" only display the file name, and not the path
- "absolute" display absolute paths
- "smart" remove as much from the path as possible to only show
the difference between the displayed paths.
Warning: The nature of the algorithm might have a negative
performance impact!
- "shorten" only display the first character of each directory in
the path
- "truncate" truncates the start of the path when the whole path will
not fit. To increase the the gap between the path and the edge.
set truncate to number `truncate = 3`
You can also specify the number of characters of each directory name
to keep by setting `path_display.shorten = num`.
e.g. for a path like
`alpha/beta/gamma/delta.txt`
setting `path_display.shorten = 1` will give a path like:
`a/b/g/delta.txt`
Similarly, `path_display.shorten = 2` will give a path like:
`al/be/ga/delta.txt`
You can also further customise the shortening behaviour by
setting `path_display.shorten = { len = num, exclude = list }`,
where `len` acts as above, and `exclude` is a list of positions
that are not shortened. Negative numbers in the list are considered
relative to the end of the path.
e.g. for a path like
`alpha/beta/gamma/delta.txt`
setting `path_display.shorten = { len = 1, exclude = {1, -1} }`
will give a path like:
`alpha/b/g/delta.txt`
setting `path_display.shorten = { len = 2, exclude = {2, -2} }`
will give a path like:
`al/beta/gamma/de`
path_display can also be set to 'hidden' string to hide file names
path_display can also be set to a function for custom formatting of
the path display. Example:
-- Format path as "file.txt (path\to\file\)"
path_display = function(opts, path)
local tail = require("telescope.utils").path_tail(path)
return string.format("%s (%s)", tail, path)
end,
Default: {}
*telescope.defaults.borderchars*
borderchars: ~
Set the borderchars of telescope floating windows. It has to be a
table of 8 string values.
Default: { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }
*telescope.defaults.get_status_text*
get_status_text: ~
A function that determines what the virtual text looks like.
Signature: function(picker) -> str
Default: function that shows current count / all
*telescope.defaults.hl_result_eol*
hl_result_eol: ~
Changes if the highlight for the selected item in the results
window is always the full width of the window
Default: true
*telescope.defaults.dynamic_preview_title*
dynamic_preview_title: ~
Will change the title of the preview window dynamically, where it
is supported. For example, the preview window's title could show up as
the full filename.
Default: false
*telescope.defaults.results_title*
results_title: ~
Defines the default title of the results window. A false value
can be used to hide the title altogether.
Default: "Results"
*telescope.defaults.prompt_title*
prompt_title: ~
Defines the default title of the prompt window. A false value
can be used to hide the title altogether. Most of the times builtins
define a prompt_title which will be prefered over this default.
Default: "Prompt"
*telescope.defaults.mappings*
mappings: ~
Your mappings to override telescope's default mappings.
See: ~
|telescope.mappings|
*telescope.defaults.default_mappings*
default_mappings: ~
Not recommended to use except for advanced users.
Will allow you to completely remove all of telescope's default maps
and use your own.
*telescope.defaults.history*
history: ~
This field handles the configuration for prompt history.
By default it is a table, with default values (more below).
To disable history, set it to false.
Currently mappings still need to be added, Example:
mappings = {
i = {
["<C-Down>"] = require('telescope.actions').cycle_history_next,
["<C-Up>"] = require('telescope.actions').cycle_history_prev,
},
},
Fields:
- path: The path to the telescope history as string.
default: stdpath("data")/telescope_history
- limit: The amount of entries that will be written in the
history.
Warning: If limit is set to nil it will grow unbound.
default: 100
- handler: A lua function that implements the history.
This is meant as a developer setting for extensions to
override the history handling, e.g.,
https://github.com/nvim-telescope/telescope-smart-history.nvim,
which allows context sensitive (cwd + picker) history.
Default:
require('telescope.actions.history').get_simple_history
*telescope.defaults.cache_picker*
cache_picker: ~
This field handles the configuration for picker caching.
By default it is a table, with default values (more below).
To disable caching, set it to false.
Caching preserves all previous multi selections and results and
therefore may result in slowdown or increased RAM occupation
if too many pickers (`cache_picker.num_pickers`) or entries
('cache_picker.limit_entries`) are cached.
Fields:
- num_pickers: The number of pickers to be cached.
Set to -1 to preserve all pickers of your session.
If passed to a picker, the cached pickers with
indices larger than `cache_picker.num_pickers` will
be cleared.
Default: 1
- limit_entries: The amount of entries that will be written in the
Default: 1000
*telescope.defaults.preview*
preview: ~
This field handles the global configuration for previewers.
By default it is a table, with default values (more below).
To disable previewing, set it to false. If you have disabled previewers
globally, but want to opt in to previewing for single pickers, you will have to
pass `preview = true` or `preview = {...}` (your config) to the `opts` of
your picker.
Fields:
- check_mime_type: Use `file` if available to try to infer whether the
file to preview is a binary if plenary's
filetype detection fails.
Windows users get `file` from:
https://github.com/julian-r/file-windows
Set to false to attempt to preview any mime type.
Default: true for all OS excl. Windows
- filesize_limit: The maximum file size in MB attempted to be previewed.
Set to false to attempt to preview any file size.
Default: 25
- timeout: Timeout the previewer if the preview did not
complete within `timeout` milliseconds.
Set to false to not timeout preview.
Default: 250
- hook(s): Function(s) that takes `(filepath, bufnr, opts)`, where opts
exposes winid and ft (filetype).
Available hooks (in order of priority):
{filetype, mime, filesize, timeout}_hook
Important: the filetype_hook must return true or false
to indicate whether to continue (true) previewing or not (false),
respectively.
Two examples:
local putils = require("telescope.previewers.utils")
... -- preview is called in telescope.setup { ... }
preview = {
-- 1) Do not show previewer for certain files
filetype_hook = function(filepath, bufnr, opts)
-- you could analogously check opts.ft for filetypes
local excluded = vim.tbl_filter(function(ending)
return filepath:match(ending)
end, {
".*%.csv",
".*%.toml",
})
if not vim.tbl_isempty(excluded) then
putils.set_preview_message(
bufnr,
opts.winid,
string.format("I don't like %s files!",
excluded[1]:sub(5, -1))
)
return false
end
return true
end,
-- 2) Truncate lines to preview window for too large files
filesize_hook = function(filepath, bufnr, opts)
local path = require("plenary.path"):new(filepath)
-- opts exposes winid
local height = vim.api.nvim_win_get_height(opts.winid)
local lines = vim.split(path:head(height), "[\r]?\n")
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
end,
}
The configuration recipes for relevant examples.
Note: if plenary does not recognize your filetype yet --
1) Please consider contributing to:
$PLENARY_REPO/data/plenary/filetypes/builtin.lua
2) Register your filetype locally as per link
https://github.com/nvim-lua/plenary.nvim#plenaryfiletype
Default: nil
- treesitter: Determines whether the previewer performs treesitter
highlighting, which falls back to regex-based highlighting.
`true`: treesitter highlighting for all available filetypes
`false`: regex-based highlighting for all filetypes
`table`: following nvim-treesitters highlighting options:
It contains two keys:
- enable boolean|table: if boolean, enable all ts
highlighing with that flag,
disable still considered.
Containing a list of filetypes,
that are enabled, disabled
ignored because it doesnt make
any sense in this case.
- disable table: containing a list of filetypes
that are disabled
Default: true
- msg_bg_fillchar: Character to fill background of unpreviewable buffers with
Default: "╱"
- hide_on_startup: Hide previewer when picker starts. Previewer can be toggled
with actions.toggle_preview.
Default: false
*telescope.defaults.vimgrep_arguments*
vimgrep_arguments: ~
Defines the command that will be used for `live_grep` and `grep_string`
pickers.
Hint: Make sure that color is currently set to `never` because we do
not yet interpret color codes
Hint 2: Make sure that these options are in your changes arguments:
"--no-heading", "--with-filename", "--line-number", "--column"
because we need them so the ripgrep output is in the correct format.
Default: {
"rg",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case"
}
*telescope.defaults.use_less*
use_less: ~
Boolean if less should be enabled in term_previewer (deprecated and
currently no longer used in the builtin pickers).
Default: true
*telescope.defaults.set_env*
set_env: ~
Set an environment for term_previewer. A table of key values:
Example: { COLORTERM = "truecolor", ... }
Hint: Empty table is not allowed.
Default: nil
*telescope.defaults.color_devicons*
color_devicons: ~
Boolean if devicons should be enabled or not. If set to false, the
"TelescopeResultsFileIcon" highlight group is used.
Hint: Coloring only works if |termguicolors| is enabled.
Default: true
*telescope.defaults.file_sorter*
file_sorter: ~
A function pointer that specifies the file_sorter. This sorter will
be used for find_files, git_files and similar.
Hint: If you load a native sorter, you dont need to change this value,
the native sorter will override it anyway.
Default: require("telescope.sorters").get_fzy_sorter
*telescope.defaults.generic_sorter*
generic_sorter: ~
A function pointer to the generic sorter. The sorter that should be
used for everything that is not a file.
Hint: If you load a native sorter, you dont need to change this value,
the native sorter will override it anyway.
Default: require("telescope.sorters").get_fzy_sorter
*telescope.defaults.prefilter_sorter*
prefilter_sorter: ~
This points to a wrapper sorter around the generic_sorter that is able
to do prefiltering.
Its usually used for lsp_*_symbols and lsp_*_diagnostics
Default: require("telescope.sorters").prefilter
*telescope.defaults.tiebreak*
tiebreak: ~
A function that determines how to break a tie when two entries have
the same score.
Having a function that always returns false would keep the entries in
the order they are found, so existing_entry before current_entry.
Vice versa always returning true would place the current_entry
before the existing_entry.
Signature: function(current_entry, existing_entry, prompt) -> boolean
Default: function that breaks the tie based on the length of the
entry's ordinal
*telescope.defaults.file_ignore_patterns*
file_ignore_patterns: ~
A table of lua regex that define the files that should be ignored.
Example: { "^scratch/" } -- ignore all files in scratch directory
Example: { "%.npz" } -- ignore all npz files
See: https://www.lua.org/manual/5.1/manual.html#5.4.1 for more
information about lua regex
Note: `file_ignore_patterns` will be used in all pickers that have a
file associated. This might lead to the problem that lsp_ pickers
aren't displaying results because they might be ignored by
`file_ignore_patterns`. For example, setting up node_modules as ignored
will never show node_modules in any results, even if you are
interested in lsp_ results.
If you only want `file_ignore_patterns` for `find_files` and
`grep_string`/`live_grep` it is suggested that you setup `gitignore`
and have fd and or ripgrep installed because both tools will not show
`gitignore`d files on default.
Default: nil
*telescope.defaults.get_selection_window*
get_selection_window: ~
Function that takes function(picker, entry) and returns a window id.
The window ID will be used to decide what window the chosen file will
be opened in and the cursor placed in upon leaving the picker.
Default: `function() return 0 end`
*telescope.defaults.file_previewer*
file_previewer: ~
Function pointer to the default file_previewer. It is mostly used
for find_files, git_files and similar.
You can change this function pointer to either use your own
previewer or use the command-line program bat as the previewer:
require("telescope.previewers").cat.new
Default: require("telescope.previewers").vim_buffer_cat.new
*telescope.defaults.grep_previewer*
grep_previewer: ~
Function pointer to the default vim_grep previewer. It is mostly
used for live_grep, grep_string and similar.
You can change this function pointer to either use your own
previewer or use the command-line program bat as the previewer:
require("telescope.previewers").vimgrep.new
Default: require("telescope.previewers").vim_buffer_vimgrep.new
*telescope.defaults.qflist_previewer*
qflist_previewer: ~
Function pointer to the default qflist previewer. It is mostly
used for qflist, loclist and lsp.
You can change this function pointer to either use your own
previewer or use the command-line program bat as the previewer:
require("telescope.previewers").qflist.new
Default: require("telescope.previewers").vim_buffer_qflist.new
*telescope.defaults.buffer_previewer_maker*
buffer_previewer_maker: ~
Developer option that defines the underlining functionality
of the buffer previewer.
For interesting configuration examples take a look at
https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes
Default: require("telescope.previewers").buffer_previewer_maker
Parameters: ~
{opts} (table) Configuration opts. Keys: defaults, pickers,
extensions
telescope.load_extension({name}) *telescope.load_extension()*
Load an extension.
- Notes:
- Loading triggers ext setup via the config passed in |telescope.setup|
Parameters: ~
{name} (string) Name of the extension
telescope.register_extension({mod}) *telescope.register_extension()*
Register an extension. To be used by plugin authors.
Parameters: ~
{mod} (table) Module
telescope.extensions() *telescope.extensions()*
Use telescope.extensions to reference any extensions within your
configuration.
While the docs currently generate this as a function, it's actually a
table. Sorry.
================================================================================
COMMAND *telescope.command*
Telescope commands can be called through two apis, the lua api and the viml
api.
The lua api is the more direct way to interact with Telescope, as you directly
call the lua functions that Telescope defines. It can be called in a lua file
using commands like:
`require("telescope.builtin").find_files({hidden=true, layout_config={prompt_position="top"}})`
If you want to use this api from a vim file you should prepend `lua` to the
command, as below:
`lua require("telescope.builtin").find_files({hidden=true, layout_config={prompt_position="top"}})`
If you want to use this api from a neovim command line you should prepend
`:lua` to the command, as below:
`:lua require("telescope.builtin").find_files({hidden=true, layout_config={prompt_position="top"}})`
The viml api is more indirect, as first the command must be parsed to the
relevant lua equivalent, which brings some limitations. The viml api can be
called using commands like:
`:Telescope find_files hidden=true layout_config={"prompt_position":"top"}`
This involves setting options using an `=` and using viml syntax for lists and
dictionaries when the corresponding lua function requires a table.
One limitation of the viml api is that there can be no spaces in any of the
options. For example, if you want to use the `cwd` option for `find_files` to
specify that you only want to search within the folder `/foo bar/subfolder/`
you could not do that using the viml api, as the path name contains a space.
Similarly, you could NOT set the `prompt_position` to `"top"` using the
following command:
`:Telescope find_files layout_config={ "prompt_position" : "top" }`
as there are spaces in the option.
================================================================================
BUILTIN *telescope.builtin*
Telescope Builtins is a collection of community maintained pickers to support
common workflows. It can be used as reference when writing PRs, Telescope
extensions, your own custom pickers, or just as a discovery tool for all of the
amazing pickers already shipped with Telescope!
Any of these functions can just be called directly by doing:
:lua require('telescope.builtin').$NAME_OF_PICKER()
To use any of Telescope's default options or any picker-specific options, call
your desired picker by passing a lua table to the picker with all of the
options you want to use. Here's an example with the live_grep picker:
>
:lua require('telescope.builtin').live_grep({
prompt_title = 'find string in open buffers...',
grep_open_files = true
})
-- or with dropdown theme
:lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{
previewer = false
})
<
builtin.live_grep({opts}) *telescope.builtin.live_grep()*
Search for a string and get results live as you type, respects .gitignore
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) root dir to search from
(default: cwd, use
utils.buffer_dir() to search
relative to open buffer)
{grep_open_files} (boolean) if true, restrict search to open
files only, mutually exclusive
with `search_dirs`
{search_dirs} (table) directory/directories/files to
search, mutually exclusive with
`grep_open_files`
{glob_pattern} (string|table) argument to be used with
`--glob`, e.g. "*.toml", can use
the opposite "!*.toml"
{type_filter} (string) argument to be used with
`--type`, e.g. "rust", see `rg
--type-list`
{additional_args} (function) function(opts) which returns a
table of additional arguments to
be passed on
{max_results} (number) define a upper result value
{disable_coordinates} (boolean) don't show the line & row
numbers (default: false)
builtin.grep_string({opts}) *telescope.builtin.grep_string()*
Searches for the string under your cursor in your current working directory
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) root dir to search from (default:
cwd, use utils.buffer_dir() to
search relative to open buffer)
{search} (string) the query to search
{grep_open_files} (boolean) if true, restrict search to open
files only, mutually exclusive with
`search_dirs`
{search_dirs} (table) directory/directories/files to
search, mutually exclusive with
`grep_open_files`
{use_regex} (boolean) if true, special characters won't be
escaped, allows for using regex
(default: false)
{word_match} (string) can be set to `-w` to enable exact
word matches
{additional_args} (function) function(opts) which returns a table
of additional arguments to be passed
on
{disable_coordinates} (boolean) don't show the line and row numbers
(default: false)
{only_sort_text} (boolean) only sort the text, not the file,
line or row (default: false)
builtin.find_files({opts}) *telescope.builtin.find_files()*
Search for files (respecting .gitignore)
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) root dir to search from (default:
cwd, use utils.buffer_dir() to
search relative to open buffer)
{find_command} (function|table) cmd to use for the search. Can be
a fn(opts) -> tbl (default:
autodetect)
{follow} (boolean) if true, follows symlinks (i.e.
uses `-L` flag for the `find`
command)
{hidden} (boolean) determines whether to show hidden
files or not (default: false)
{no_ignore} (boolean) show files ignored by .gitignore,
.ignore, etc. (default: false)
{no_ignore_parent} (boolean) show files ignored by .gitignore,
.ignore, etc. in parent dirs.
(default: false)
{search_dirs} (table) directory/directories/files to
search
{search_file} (string) specify a filename to search for
builtin.fd() *telescope.builtin.fd()*
This is an alias for the `find_files` picker
builtin.treesitter() *telescope.builtin.treesitter()*
Lists function names, variables, and other symbols from treesitter queries
- Default keymaps:
- `<C-l>`: show autocompletion menu to prefilter your query by kind of ts
node you want to see (i.e. `:var:`)
Options: ~
{show_line} (boolean) if true, shows the row:column that the
result is found at (default: true)
{bufnr} (number) specify the buffer number where
treesitter should run. (default:
current buffer)
{symbol_highlights} (table) string -> string. Matches symbol with
hl_group
builtin.current_buffer_fuzzy_find({opts}) *telescope.builtin.current_buffer_fuzzy_find()*
Live fuzzy search inside of the currently open buffer
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{skip_empty_lines} (boolean) if true we dont display empty lines
(default: false)
builtin.tags({opts}) *telescope.builtin.tags()*
Lists tags in current directory with tag location file preview (users are
required to run ctags -R to generate tags or update when introducing new
changes)
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) root dir to search from (default: cwd, use
utils.buffer_dir() to search relative to
open buffer)
{ctags_file} (string) specify a particular ctags file to use
{show_line} (boolean) if true, shows the content of the line the
tag is found on in the picker (default:
true)
{only_sort_tags} (boolean) if true we will only sort tags (default:
false)
{fname_width} (number) defines the width of the filename section
(default: 30)
builtin.current_buffer_tags({opts}) *telescope.builtin.current_buffer_tags()*
Lists all of the tags for the currently open buffer, with a preview
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) root dir to search from (default: cwd, use
utils.buffer_dir() to search relative to
open buffer)
{ctags_file} (string) specify a particular ctags file to use
{show_line} (boolean) if true, shows the content of the line the
tag is found on in the picker (default:
true)
{only_sort_tags} (boolean) if true we will only sort tags (default:
false)
{fname_width} (number) defines the width of the filename section
(default: 30)
builtin.git_files({opts}) *telescope.builtin.git_files()*
Fuzzy search for files tracked by Git. This command lists the output of the
`git ls-files` command, respects .gitignore
- Default keymaps:
- `<cr>`: opens the currently selected file
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) specify the path of the repo
{use_git_root} (boolean) if we should use git root as cwd or
the cwd (important for submodule)
(default: true)
{show_untracked} (boolean) if true, adds `--others` flag to
command and shows untracked files
(default: false)
{recurse_submodules} (boolean) if true, adds the
`--recurse-submodules` flag to command
(default: false)
{git_command} (table) command that will be exectued.
{"git","ls-files","--exclude-standard","--cached"}
builtin.git_commits({opts}) *telescope.builtin.git_commits()*
Lists commits for current directory with diff preview
- Default keymaps:
- `<cr>`: checks out the currently selected commit
- `<C-r>m`: resets current branch to selected commit using mixed mode
- `<C-r>s`: resets current branch to selected commit using soft mode
- `<C-r>h`: resets current branch to selected commit using hard mode
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) specify the path of the repo
{use_git_root} (boolean) if we should use git root as cwd or the cwd
(important for submodule) (default: true)
{git_command} (table) command that will be exectued.
{"git","log","--pretty=oneline","--abbrev-commit","--","."}
builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()*
Lists commits for current buffer with diff preview
- Default keymaps or your overriden `select_` keys:
- `<cr>`: checks out the currently selected commit
- `<c-v>`: opens a diff in a vertical split
- `<c-x>`: opens a diff in a horizontal split
- `<c-t>`: opens a diff in a new tab
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) specify the path of the repo
{use_git_root} (boolean) if we should use git root as cwd or the cwd
(important for submodule) (default: true)
{current_file} (string) specify the current file that should be used
for bcommits (default: current buffer)