This Neovim configuration allows you to run Go tests from anywhere within test scope, focusing on the test function under the cursor. It provides a simple set of functions and a keybinding to streamline your Go testing workflow.
- Run Go tests under the cursor: Automatically detects the test function name and executes it.
- Simple integration: Easily add the provided functions to your Neovim configuration.
- Cache cleanup: Cleans the Go test cache before running tests to ensure fresh results.
To integrate this functionality into your Neovim setup, follow these steps:
-
Copy the code.
-
Add the code to your Neovim configuration:
- You can directly paste the code into your configuration file.
-
Reload Neovim or restart it to apply the changes.
With the configuration added, you can now run Go tests under the cursor by pressing the <leader>rt
keybinding in normal mode. This keybinding will:
- Determine the package name of the current file.
- Verify that the file type is Go.
- Identify the nearest test function under the cursor.
- Open a split terminal and run the Go test for the identified function.
<leader>rt
: Run the Go test function under the cursor.
Contributions are welcome! If you have suggestions or improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.