Helps navigating pytest fixtures by providing jump to declaration, rename, and find usages commands, using treesitter.
- Jump to fixture definition — jump to the declaration of the fixture under the cursor.
Done by calling
PytrizeJumpFixture. Alternativelylua require('pytrize.api').jump_fixture(). See Jump to fixture below. - Rename fixture — rename the fixture under the cursor across the project.
Done by calling
PytrizeRenameFixture. Alternativelylua require('pytrize.api').rename_fixture(). See Rename fixture below. - Find fixture usages — find all usages of the fixture under the cursor across the project.
Done by calling
PytrizeFixtureUsages. Alternativelylua require('pytrize.api').fixture_usages(). See Fixture usages below.
For example using lazy.nvim:
{
'sigfriedcub1990/nvim-pytrize.lua',
version = '*',
ft = 'python', -- Load only for python files
opts = {
-- metrics = true, -- uncomment to log timing info for jump and rename
-- preferred_input = 'fzf-lua', -- uncomment to use fzf-lua for fixture usages
},
-- uncomment if you want to lazy load
-- cmd = {'PytrizeJumpFixture', 'PytrizeRenameFixture', 'PytrizeFixtureUsages'},
}require("pytrize").setup takes an optional table of settings which currently have the default values:
{
no_commands = false,
highlight = 'LineNr',
metrics = false,
preferred_input = nil,
}where:
no_commandscan be set totrueand the user commands won't be declared.highlightdefines the highlighting used for virtual text.metricswhen set totrue, logs timing information viavim.notifyafter each jump-to-fixture and rename operation. Useful for understanding performance in large projects. The jump reports total time and index-build time; the rename reports total, grep, scoping (fixture resolution), and apply time.preferred_inputwhich method to use for displaying results (if installed). Currently'fzf-lua'is supported — when set, fixture usages are displayed in anfzf-luapicker instead of the quickfix list. Whennil(the default), results go to the quickfix list.
To jump to the declaration of a fixture under the cursor, do PytrizeJumpFixture:

To rename the fixture under the cursor, do PytrizeRenameFixture.
To find all usages of the fixture under the cursor, do PytrizeFixtureUsages.
Results are loaded into Neovim's quickfix list and the quickfix window is opened automatically.
Each entry shows the file, line, and the line content where the fixture is used — as a parameter, a body reference, or inside @pytest.mark.usefixtures(...). The fixture definition itself is excluded from the results.
When preferred_input = 'fzf-lua' is set and fzf-lua is installed, fixture usages (PytrizeFixtureUsages) are displayed in an fzf picker with a built-in previewer. Supported actions:
Enter— open filectrl-s— open in horizontal splitctrl-v— open in vertical splitctrl-t— open in new tab
If fzf-lua is not installed, results fall back to the quickfix list.

