Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy load adapters #428

Open
rokbot opened this issue Jun 27, 2024 · 3 comments
Open

Lazy load adapters #428

rokbot opened this issue Jun 27, 2024 · 3 comments
Assignees

Comments

@rokbot
Copy link

rokbot commented Jun 27, 2024

Question / Proposal:

Is there a way to lazy load the adapters based on the file type?

The problem is that all the adapters are loaded even when they are no required for the current neotest session.

The current implementation is:

require("neotest").setup({
    adapters = {
        require "neotest-python",
        require "neotest-go"
    }
}) 

I tried:

local neotest = require "neotest"

if vim.bo.ft == "python" then
  neotest.setup { adapters = require "neotest-python" }
elseif vim.bo.ft == "go" then
  neotest.setup { adapters = require "neotest-go" }
end

but does not work plus it has their own problems like there should be only one setup, thinking about the after/ftplugin directory but i feel it won't work either so i suppose, maybe can be implemented internally in neotest , probably create some table that can be passed to setup as an alternative to the adapters table to be able to lazy load by ft, something like adapters_by_ft that should look like this:

require("neotest").setup({
   adapters_by_ft = {
       python = require "neotest-python",
       go = require "neotest-go"
   }
}) 

I think it would be nice, maybe i will try to implement this by myself, and if it works submit a PR.

@codymikol
Copy link
Contributor

I think it would be cool to have a mason like installer for them in addition to lazy loading them on demand

@rsareth
Copy link

rsareth commented Sep 13, 2024

It would be great to load the adapters according to the filetype. I am trying to get rid of my IDEs and to switch to Neovim for almost everything. But without neotest, it isn't interesting to get rid of my IDEs right now.

@brablc
Copy link

brablc commented Nov 1, 2024

I reported #466. It may be related - I too see both adapters to get loaded in random order and causing problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants