-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Comments
I think it would be cool to have a mason like installer for them in addition to lazy loading them on demand |
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. |
I reported #466. It may be related - I too see both adapters to get loaded in random order and causing problems. |
I've hand-rolled my own lazy-loading for Neotest adapters. On startup I create a simple mapping of Lazy.nvim plugins (shortened example, full config for ref) {
'nvim-neotest/neotest',
keys = {
{
'<leader>tf',
function()
_ = require('conf.neotest.adapters')[vim.bo.filetype] -- load adapter based on filetype
require('neotest').run.run {
suite = false,
}
end,
desc = 'nearest function',
},
},
dependencies = { { 'nvim-neotest/nvim-nio', lazy = true } },
opts = { adapters = {} } -- no adapters registered on initial setup
},
{
'nvim-neotest/neotest-python',
lazy = true,
dependencies = { 'nvim-neotest/neotest' },
init = function()
require('conf.neotest.adapters').python = 'neotest-python' -- register filetype
end,
opts = {
dap = { justMyCode = true },
runner = 'pytest',
args = {
'-s', -- don't capture console output
'--log-level',
'DEBUG',
'-vv',
},
},
config = function(_, opts)
local adapter = require 'neotest-python'(opts)
local adapters = require('neotest.config').adapters
table.insert(adapters, adapter)
end,
},
{
'haydenmeade/neotest-jest',
lazy = true,
dependencies = { 'nvim-neotest/neotest' },
init = function()
for _, filetype in ipairs {
'javascript',
'typescript',
'javascriptreact',
'typescriptreact',
} do
require('conf.neotest.adapters')[filetype] = 'neotest-jest' -- register filetypes
end
end,
opts = {},
config = function(_, opts)
local adapter = require 'neotest-jest'(opts)
local adapters = require('neotest.config').adapters
table.insert(adapters, adapter)
end,
} |
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:
I tried:
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 inneotest
, probably create some table that can be passed to setup as an alternative to theadapters
table to be able to lazy load by ft, something likeadapters_by_ft
that should look like this:I think it would be nice, maybe i will try to implement this by myself, and if it works submit a PR.
The text was updated successfully, but these errors were encountered: