1- local conf = require (" telescope.config" ).values
1+ local uv = vim .uv
2+
23local Path = require " neoplen.path"
3- local utils = require " telescope.utils"
44
5- local uv = vim .uv
5+ local conf = require (" telescope.config" ).values
6+ local utils = require " telescope.utils"
67
78--- @brief
89--- A base implementation of a prompt history that provides a simple history
@@ -40,7 +41,7 @@ local append_async = function(path, txt)
4041 write_async (path , txt , " a" )
4142end
4243
43- local histories = {}
44+ local M = {}
4445
4546--- Manages prompt history
4647--- @class History @Manages prompt history
@@ -50,8 +51,8 @@ local histories = {}
5051--- @field content table : History table. Needs to be filled by your own History implementation
5152--- @field index number : Used to keep track of the next or previous index. Default is #content + 1
5253--- @field cycle_wrap boolean : Controls if history will wrap on reaching beginning or end
53- histories .History = {}
54- histories .History .__index = histories .History
54+ M .History = {}
55+ M .History .__index = M .History
5556
5657--- @inlinedoc
5758--- @class telescope.actions.history.opts
@@ -62,7 +63,7 @@ histories.History.__index = histories.History
6263
6364--- Create a new History
6465--- @param opts table : Defines the behavior of History
65- function histories .History :new (opts )
66+ function M .History :new (opts )
6667 local obj = {}
6768 if conf .history == false or type (conf .history ) ~= " table" then
6869 obj .enabled = false
@@ -86,12 +87,12 @@ function histories.History:new(opts)
8687end
8788
8889--- Shorthand to create a new history
89- function histories .new (...)
90- return histories .History :new (... )
90+ function M .new (...)
91+ return M .History :new (... )
9192end
9293
9394--- Will reset the history index to the default initial state. Will happen after the picker closed
94- function histories .History :reset ()
95+ function M .History :reset ()
9596 if not self .enabled then
9697 return
9798 end
102103--- @param line string : current line that will be appended
103104--- @param picker table : the current picker object
104105--- @param no_reset boolean : On default it will reset the state at the end. If you don ' t want to do this set to true
105- function histories .History :append (line , picker , no_reset )
106+ function M .History :append (line , picker , no_reset )
106107 if not self .enabled then
107108 return
108109 end
113114--- @param line string : the current line
114115--- @param picker table : the current picker object
115116--- @return string : the next history item
116- function histories .History :get_next (line , picker )
117+ function M .History :get_next (line , picker )
117118 if not self .enabled then
118119 utils .notify (" History:get_next" , {
119120 msg = " You are cycling to next the history item but history is disabled. Read ':help telescope.defaults.history'" ,
142143--- @param line string : the current line
143144--- @param picker table : the current picker object
144145--- @return string : the previous history item
145- function histories .History :get_prev (line , picker )
146+ function M .History :get_prev (line , picker )
146147 if not self .enabled then
147148 utils .notify (" History:get_prev" , {
148149 msg = " You are cycling to next the history item but history is disabled. Read ':help telescope.defaults.history'" ,
174175--- A simple implementation of history.
175176---
176177--- It will keep one unified history across all pickers.
177- histories .get_simple_history = function ()
178- return histories .new {
178+ M .get_simple_history = function ()
179+ return M .new {
179180 init = function (obj )
180181 local p = Path :new (obj .path )
181182 if not p :exists () then
@@ -213,4 +214,4 @@ histories.get_simple_history = function()
213214 }
214215end
215216
216- return histories
217+ return M
0 commit comments