telescope-frecency.nvim:telescope.nvim扩展,在从编辑历史记录中选择文件时提供智能优先级

  • v1_329904
    了解作者
  • 13.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 08:39
    上传日期
望远镜频率 扩展,在从编辑历史记录中选择文件时提供智能优先级。 使用Mozilla的的实现(在使用),frecently编辑的文件列表中的索引被赋予更高的优先级。 随着扩展程序逐渐了解您的编辑习惯,列表的排序会动态更改,以优先考虑您可能需要的文件。 取景器中显示的分数仅用于演示目的-默认情况下处于禁用状态 频率:按“频率”和“频率”排序 “频率”是对文件历史数据库中索引的每个唯一文件的得分。 首次将文件加载到缓冲区时,每个会话记录一次时间戳。 得分是根据最近10个时间戳记的使用期限以及文件已加载的总次数计算得出的: 新近度值(每个时间戳) 时间戳年龄 价值 4个小时 100 1天 80 3天 60 1周 40 1个月 20 90天 10 分数计算 score = frequency * recency_score / max_number_of_timestamps
telescope-frecency_nvim-master.zip
内容介绍
# telescope-frecency.nvim A [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) extension that offers intelligent prioritization when selecting files from your editing history. Using an implementation of Mozilla's [Frecency algorithm](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Places/Frecency_algorithm) (used in [Firefox's address bar](https://support.mozilla.org/en-US/kb/address-bar-autocomplete-firefox)), files edited _frecently_ are given higher precedence in the list index. As the extension learns your editing habits over time, the sorting of the list is dynamically altered to prioritize the files you're likely to need. <img src="https://raw.githubusercontent.com/sunjon/images/master/gh_readme_telescope_frecency.png" alt="screenshot" width="800"/> * _Scores shown in finder for demonstration purposes - disabled by default_ ## Frecency: Sorting by 'frequency' _and_ 'recency' 'Frecency' is a score given to each unique file indexed in a file history database. A timestamp is recorded once per session when a file is first loaded into a buffer. The score is calculated using the age of the 10 most recent timestamps and the total amount of times that the file has been loaded: ### Recency values (per timestamp) | Timestamp age | Value | | -------- | ---------- | | 4 hours | 100 | | 1 day | 80 | | 3 days | 60 | | 1 week | 40 | | 1 month | 20 | | 90 days | 10 | ### Score calculation ``` score = frequency * recency_score / max_number_of_timestamps ``` ## What about files that are neither 'frequent' _or_ 'recent' ? Frecency naturally works best for indexed files that have been given a reasonably high score. New projects or rarely used files with generic names either don't get listed at all or can be buried under results with a higher score. Frecency tackles this with *Workspace Filters*: <img src="https://raw.githubusercontent.com/sunjon/images/master/frecency_workspace_folders.gif" alt="screenshot" width="800"/> The workspace filter feature enables you to select from user defined _filter tags_ that map to a directory or collection of directories. Filters are applied by entering `:workspace_tag:` anywhere in the query. Filter name completion is available by pressing `<Tab>` after the first `:` character. When a filter is applied, results are reduced to entries whose path is a descendant of the workspace directory. The indexed results are optionally augmented with a listing of _all_ files found in a recurssive search of the workspace directory. Non-indexed files are given a score of zero and appear below the 'frecent' entries. When a non-indexed file is opened, it gains a score value and is available in future 'frecent' search results. If the active buffer (prior to the finder being launched) is attached to an LSP server, an automatic `LSP` tag is available, which maps to the workspace directories provided by the language server. ## Requirements - [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) (required) - [sql.nvim](https://github.com/tami5/sql.nvim) (required) Timestamps and file records are stored in an [SQLite3](https://www.sqlite.org/index.html) database for persistence and speed. This plugin uses `sql.nvim` to perform the database transactions. ## Installation ### [Packer.nvim](https://github.com/wbthomason/packer.nvim) ```lua use { "nvim-telescope/telescope-frecency.nvim", config = function() require"telescope".load_extension("frecency") end } ``` _TODO: add installation instructions for other package managers_ If no database is found when running Neovim with the plugin installed, a new one is created and entries from `shada` `v:oldfiles` are automatically imported. ## Usage ``` :Telescope frecency ``` ..or to map to a key: ```lua vim.api.nvim_set_keymap("n", "<leader><leader>", "<Cmd>lua require('telescope').extensions.frecency.frecency()<CR>", {noremap = true, silent = true}) ``` Filter tags are applied by typing the `:tag:` name (adding surrounding colons) in the finder query. Entering `:<Tab>` will trigger omnicompletion for available tags. ## Configuration See [default configuration](https://github.com/nvim-telescope/telescope.nvim#telescope-defaults) for full details on configuring Telescope. - `ignore_patterns` (default: `{"*.git/*", "*/tmp/*"}`) Patterns in this table control which files are indexed (and subsequently which you'll see in the finder results). - `show_scores` (default : `false`) To see the scores generated by the algorithm in the results, set this to `true`. - workspaces (default: {}) This table contains mappings of `workspace_tag` -> `workspace_directory` The key corresponds to the `:tag_name` used to select the filter in queries. The value corresponds to the top level directory by which results will be filtered. - `show_unindexed` (default: `true`) Determines if non-indexed files are included in workspace filter results. ### Example Configuration: ``` telescope.setup { extensions = { frecency = { show_scores = false, show_unindexed = true, ignore_patterns = {"*.git/*", "*/tmp/*"}, workspaces = { ["conf"] = "/home/my_username/.config", ["data"] = "/home/my_username/.local/share", ["project"] = "/home/my_username/projects", ["wiki"] = "/home/my_username/wiki" } } }, } ``` ### Highlight Groups ```vim TelescopeBufferLoaded TelescopePathSeparator TelescopeFrecencyScores TelescopeQueryFilter ``` TODO: describe highlight groups ## References - [Mozilla: Frecency algorithm](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Places/Frecency_algorithm)
评论
    相关推荐