diff options
| author | fdschmidt93 <39233597+fdschmidt93@users.noreply.github.com> | 2021-09-16 23:01:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-16 23:01:40 +0200 |
| commit | 7c5b846f6f8caa8acf4b63dc4c33a801e2ea78a0 (patch) | |
| tree | 128ca47803814e4ba35c629ac0e194325dbfc830 /lua/telescope/config.lua | |
| parent | ac03f495c6ec1f832488556969f72677b69ef33d (diff) | |
feat: skip/timeout preview if file cannot be easily previewed (#1231)
* For full configuration, see `:h telescope.defaults.preview`
* Unblocks previewer on binaries, too large files, and files that take too long to read
* Allows toggling treesitter highlighting for buffer_previewer
* Allows to globally opt out of previewer
Diffstat (limited to 'lua/telescope/config.lua')
| -rw-r--r-- | lua/telescope/config.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua index 406d3c6..5fa0cf1 100644 --- a/lua/telescope/config.lua +++ b/lua/telescope/config.lua @@ -383,6 +383,56 @@ append( ) append( + "preview", + { + check_mime_type = true, + filesize_limit = 25, + timeout = 250, + treesitter = true, + }, + [[ + 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 + - 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)` + to be run if the buffer previewer was not shown due to + the respective test. + Available hooks are: {mime, filesize, timeout}_hook, e.g. + preview = { + mime_hook = function(filepath, bufnr, opts) ... end + } + See `telescope/previewers/*.lua` for relevant examples. + 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`: table of filetypes for which to attach treesitter + highlighting + Default: true + ]] +) + +append( "vimgrep_arguments", { "rg", "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" }, [[ |
