mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
* draft implementation of tags/filters * . * add filtering: - extended substring sorter to have modes: - when current string is prefixed by `:foo`, results are tag_names that come from tags/workspaces table. (if `:foo ` token is incomplete it is ignored) - when a complete workspace tag is matched ':foobar:', results are indexed_files filtered by if their parent_dir is a descendant of the workspace_dir - a recursive scan_dir() result is added to the :foobar: filter results; any non-indexed_files are given a score of zero, and are alphabetically sorted below the indexed_results - tab completion for tab_names in insert mode`:foo|` state: cycles through available options * add completion file * use attach_mappings for <CR> map * stop completion being enabled multiple times * improve keys * improve completion cancellation * add dynamic `lsp` tag * add dynamic `lsp` tag * fix empty lsp workspaces * remove hardcoded workspaces and allow config from ext_config * add filter highlight and some fixes * . * add workspace filters to readme * wip LSP workspace filter * merge ignore_patterns fix * change LSP_ROOT tagname to LSP * fix setting default values * . * update readme with filter instructions * remove debug message * improve relative paths * improve relative paths * WIP dynamic column sizes * WIP filter_column_width * fix keymaps * . * feat: persistent filters * refactor config creation * fix: filter directory column autosize * improve LSP workspace paths * . * remove workspace filter output * cache persistent filter results * fix cached results * . * remove results cache; sorting is the expensive part * respect ignore patterns for non-indexed files. * return table on on_input_filter_cb
45 lines
936 B
Lua
45 lines
936 B
Lua
local uv = vim.loop
|
|
|
|
local util = {}
|
|
|
|
-- stolen from penlight
|
|
|
|
-- escape any Lua 'magic' characters in a string
|
|
util.escape = function(str)
|
|
return (str:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1'))
|
|
end
|
|
|
|
util.filemask = function(mask)
|
|
mask = util.escape(mask)
|
|
return '^'..mask:gsub('%%%*','.*'):gsub('%%%?','.')..'$'
|
|
end
|
|
|
|
util.filename_match = function(filename, pattern)
|
|
return filename:find(util.filemask(pattern)) ~= nil
|
|
end
|
|
|
|
--
|
|
|
|
util.string_isempty = function(str)
|
|
return str == nil or str == ''
|
|
end
|
|
|
|
util.split = function(str, delimiter)
|
|
local result = {}
|
|
for match in str:gmatch("[^" .. delimiter .. "]+") do
|
|
table.insert(result, match)
|
|
end
|
|
return result
|
|
end
|
|
|
|
util.fs_stat = function(path)
|
|
local stat = uv.fs_stat(path)
|
|
local res = {}
|
|
res.exists = stat and true or false -- TODO: this is silly
|
|
res.isdirectory = (stat and stat.type == "directory") and true or false
|
|
|
|
return res
|
|
end
|
|
|
|
return util
|