Skip to content

Commit

Permalink
Merge pull request #17 from sfrieds3/readme-update
Browse files Browse the repository at this point in the history
chore: update readme
  • Loading branch information
sfrieds3 authored Dec 2, 2024
2 parents 46848e6 + 73dd0f2 commit 3d10e9d
Showing 1 changed file with 48 additions and 8 deletions.
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>

0 comments on commit 3d10e9d

Please sign in to comment.