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

chore: update readme #17

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pytest_fixtures.nvim

Easily jump to pytest fixtures.
Easily jump to pytest fixtures. Supports jumping to a fixture used by the test under cursor, jumping to any test defined in the current project, or reverse lookup -- i.e. jump to a test which uses a fixture.

## Installation

Expand All @@ -11,19 +11,59 @@ lazy.nvim:
"sfrieds3/pytest_fixtures.nvim",
opts = {
-- configuration goes here
-- see the [configuration](#configuration) section below for options
},
dependencies = {
"nvim-lua/plenary.nvim"
}
},
```

## Usage

When in a python file, simply run `:PytestFixturesRefresh` to refresh the current projects pytest fixtures cache. Then, when your cursor is on a test, hit `<localleader>]` to bring up a floating window with a list of fixtures used by the current test. Selecting any one will bring you to the soruce for that test. Simple as that.
First, ensure you are in an environment with `pytest` installed. Then, when your cursor is on a test, hit `<localleader>]` (default mapping, see [configuration](#configuration) section below to override the default mapping) to bring up a floating window with a list of fixtures used by the current test. Selecting any one will bring you to the soruce for that test. Simple as that.

Currently, there is minimal to no configuration options available. But that will change soon.
Additionally, the plugin allows you to list all project fixtures, and either go to the fixture or list and go to a test using that fixture. See the [user commands](#user-commands) secion for more details.

## Planned Features
### User Commands

- [x] More configuration options
- [x] Better autocmd configuration to keep the cache updated real-time
- [x] Go-to any fixture in the project, not just those under cursor
- [x] Reverse search; i.e. see which tests use the fixture under cursor
- `PytestFixturesTestFixtures`: List fixtures used by the test under cursor and go to fixture on selection

- `PytestFixturesProjectFixtures`: List all project fixtures, and go to fixture on selection

- `PytestFixturesReverseLookup`: List all tests using a selected fixture, and go to test on selection

- `PytestFixturesProjectCachePath`: Echo the project cache path

- `PytestFixturesRefresh`: Refresh fixture cache, you should not need to run this if you have configured autocmd setup

## Default configuration

## Configuration

<details>
<summary><strong>Default configuration</strong></summary>

<!-- config:start -->

```lua
{
-- set keymaps
keymaps = { -- set keymaps for user commands generated by the plugin
["<localleader>]"] = "PytestFixturesTestFixtures",
["<localleader>}"] = "PytestFixturesProjectFixtures",
},
-- controls whether or not to create user commands
create_user_commands = true,
-- configure autocmd events for which to execute a refresh of the fixture cache
refresh_events = { "BufEnter", "BufWinEnter", "BufWritePost" },
-- configure files/directories to use for determining the project root
project_markers = { ".git", "pyproject.toml", "setup.py", "setup.cfg" },
-- configure the path to store the fixture cache
data_path = string.format("%s/pytest_fixtures", vim.fn.stdpath("data")),
}
```

<!-- config:end -->

</details>
Loading