Commit Graph

7 Commits

Author SHA1 Message Date
JINNOUCHI Yasushi
38f2a2207e
fix: detect async context more robustly (#254) 2024-08-28 21:58:36 +09:00
JINNOUCHI Yasushi
db32047232
feat: use lazy.nvim to measure times if usable (#249) 2024-08-25 20:31:15 +09:00
JINNOUCHI Yasushi
c140e6ff9c
feat: make query() faster and more lazier (#241)
* refactor: simplify logic to load web_devicons

* refactor: make register() asynchronous

* fix: load lazily modules outside this plugin

* refactor: simplify logic to wait initialization

* refactor: use uv.hrtime() instead of os.clock()

* fix: avoid errors in calling plenary.log in async

* test: store elapsed time to check in tests

* test: fix module names

This becomes a problem only in Ubuntu because macOS and Windows does not
care cases in filenames.

* test: fix types and unused modules

* style: fix by stylua

* refactor: make recency / entry_maker loaded lazily
2024-08-25 19:28:52 +09:00
JINNOUCHI Yasushi
673585ee99
fix: delay calling vim.ui.select to avoid errors (#246)
Fix #243

It occurs an error E5560 when UI to select `y/n` by the user in
validating DB. This delays it until the next tick to avoid errors.
2024-08-20 15:46:15 +09:00
JINNOUCHI Yasushi
a7ebbb485d
fix: avoid errors caused by echoing messages (#242)
This error below occurs when it takes long time to init the plugin.

E5560: nvim_echo must not be called in a lua loop callback
2024-08-16 13:12:28 +09:00
JINNOUCHI Yasushi
58c0089414
fix!: register realpath for consistency (#240)
Now it uses realpath for registering and validating DB. This means, if you have entries that has filenames differing only for case, it can deal with them as they exist.

Before this, it has miscalculated scores for such cases. For example, in case you have `/path/to/foo.lua` and `/path/to/Foo.lua`, it registers entries for each file. Now it detects accurate filename for the specified one, and removes it in validation.

* test: separate logic for utils

* fix!: register realpath for consistency

* refactor: convert fs module from class

* refactor: move db initialization phase to start()

* fix: run database:start() truly asynchronously

* fix: call each functions with async wrapping

* refactor: add types for args in command

* fix: run register() synchronously

Because vim.api.nvim_* cannot be used in asynchronous functions.

* docs: add note for calling setup() twice

* fix: run non-fast logic on next tick
2024-08-15 17:40:03 +09:00
JINNOUCHI Yasushi
87ccbae5d2
feat: call init process before telescope loading (#234)
* feat: call init process before telescope loading

Fix #231

This changes enable to load frecency without telescope's loading itself.
This is needed when you want to load telescope lazily, but want to start
registering process as soon as Neovim has started.

```lua
{
  "nvim-telescope/telescope-frecency.nvim",
  main = "frecency",
  ---@type FrecencyOpts
  opts = {
    db_safe_mode = false,
  },
},

{
  "nvim-telescope/telescope.nvim",
  -- `cmd` opts makes lazy.nvim load telescope.nvim lazily.
  cmd = { "Telescope" },
  config = function()
    local telescope = require "telescope"
    telescope.setup {
      extensions = {
        other_extension = {
          foo_bar = true,
        },
        -- Here you need no configuration opts for frecency because
        -- you've already done.
      }
    }
    -- This is still needed.
    telescope.load_extension "frecency"
  end,
},
```

* docs: add note for loading telescope.nvim lazily
2024-08-01 17:12:43 +09:00