diff --git a/doc/telescope.txt b/doc/telescope.txt index c41f01403a..23bbb271bb 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -49,9 +49,9 @@ telescope.setup({opts}) *telescope.setup()* *telescope.defaults.history* history: ~ - This field handles the configuration for prompt history. It can either - be a table or false. - If its false then history is disabled. + 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 either false or nil. Currently mappings still need to be added, Example: mappings = { @@ -62,23 +62,19 @@ telescope.setup({opts}) *telescope.setup()* }, Fields: - - path: the path to the telescope history as string + - 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 - if limit is set to nil it will grown unbound + - limit: The amount of entries that will be written in the history. + Warning: If limit is set to nil it will grown unbound. default: 100 - - handler: is a developer setting that is meant for extensions. - You can replace the actual implementation of the history - and provide your own. One example of this is - nvim-telescope/telescope-smart-history.nvim which allows - context sensitive (cwd + picker) history. + - 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 - Is a simple history implementation that is not context - sensitive, it writes all history in one text file. - *telescope.defaults.layout_config* layout_config: ~ diff --git a/lua/telescope/actions/history.lua b/lua/telescope/actions/history.lua index 48a24cac6b..8ec58e27ab 100644 --- a/lua/telescope/actions/history.lua +++ b/lua/telescope/actions/history.lua @@ -59,7 +59,7 @@ histories.History.__index = histories.History ---@field pre_get function: Will be called before a next or previous item will be returned (optional) function histories.History:new(opts) local obj = {} - if conf.history == false or type(conf.history) ~= "table" then + if not conf.history or type(conf.history) ~= "table" then obj.enabled = false return setmetatable(obj, self) end diff --git a/lua/telescope/actions/state.lua b/lua/telescope/actions/state.lua index 192c44d56f..8470f2d443 100644 --- a/lua/telescope/actions/state.lua +++ b/lua/telescope/actions/state.lua @@ -40,7 +40,7 @@ end function action_state.get_current_history() local history = global_state.get_global_key("history") if not history then - if conf.history == false or type(conf.history) ~= "table" then + if not conf.history or type(conf.history) ~= "table" then history = require('telescope.actions.history').get_simple_history() global_state.set_global_key("history", history) else diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua index d2d09df435..dac518060e 100644 --- a/lua/telescope/config.lua +++ b/lua/telescope/config.lua @@ -220,9 +220,9 @@ local telescope_defaults = { limit = 100, handler = function(...) return require('telescope.actions.history').get_simple_history(...) end, }, [[ - This field handles the configuration for prompt history. It can either - be a table or false. - If its false then history is disabled. + 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 either false or nil. Currently mappings still need to be added, Example: mappings = { @@ -233,22 +233,18 @@ local telescope_defaults = { }, Fields: - - path: the path to the telescope history as string + - 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 - if limit is set to nil it will grown unbound + - limit: The amount of entries that will be written in the history. + Warning: If limit is set to nil it will grown unbound. default: 100 - - handler: is a developer setting that is meant for extensions. - You can replace the actual implementation of the history - and provide your own. One example of this is - nvim-telescope/telescope-smart-history.nvim which allows - context sensitive (cwd + picker) history. + - 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 - - Is a simple history implementation that is not context - sensitive, it writes all history in one text file. ]], }, @@ -383,7 +379,7 @@ function config.set_defaults(user_defaults, tele_defaults) ) end if name == "history" then - if user_defaults[name] == false or config.values[name] == false then + if not user_defaults[name] or not config.values[name] then return false end