An open API service indexing awesome lists of open source software.

https://github.com/krshrimali/nvim-utils.nvim

All my utilities of neovim in a single plugin
https://github.com/krshrimali/nvim-utils.nvim

Last synced: about 1 month ago
JSON representation

All my utilities of neovim in a single plugin

Awesome Lists containing this project

README

          

# ๐ŸŒณ Universal Treesitter Utils (`nvim-utils.nvim`)

FYI: README generated by ChatGPT.

A Neovim plugin to explore, inspect, and extract structure from code using [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).

### โœจ Features

- ๐Ÿง  Extract current function or class under cursor.
- ๐Ÿ“‹ Copy parent function/class to clipboard.
- ๐Ÿช„ Show multi-line function **signatures**.
- ๐Ÿงช Run `pytest` for Python functions (optional, customizable).
- ๐Ÿ“‹ Copy the test command for the current parent function to clipboard.
- ๐Ÿ”‘ Keymap-ready with LazyVim/which-key support.

---

## ๐Ÿ“ฆ Installation (with LazyVim / `lazy.nvim`)

In your Lazy config (`~/.config/nvim/lua/plugins/tgkrsutil.lua`):

```lua
return {
"krshrimali/nvim-utils.nvim",
config = function()
require("tgkrsutil").setup({
enable_test_runner = true,
test_runner = function(file, func)
return string.format("pytest %s -k %s", file, func)
end,
})
end,
event = "VeryLazy",
}
```

---

## ๐Ÿ”‘ Key Mappings

| Mapping | Description |
|----------------|----------------------------------------------|
| `rt` | Run test for function (Python only) |
| `rT` | Run test in a new terminal (_will be deleted soon_) |
| `rc` | Copy test command to the clipboard |
| `rif` | Copy parent function to clipboard |
| `ric` | Copy parent class to clipboard |
| `rsf` | Show full parent function **signature** |
| `rsc` | Show parent class signature (first line) |

> These are registered automatically in `setup()` but can be overridden manually.

---

## ๐Ÿงช Test Runner

Test support is **Python-only by default**, via `pytest`.

You can override it:

```lua
require("tgkrsutil").setup({
test_runner = function(file, func)
return "go test -v -run ^" .. func .. "$ " .. file
end
})
```

---

## โœ… Requirements

- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- Supported Treesitter parser for your language (e.g. `:TSInstall python`)
- Optional: `pytest` if using the default test runner

---

## ๐Ÿชช License

MIT ยฉ Kushashwa Ravi Shrimali