https://github.com/romus204/referencer.nvim
Lightweight, asynchronous Neovim plugin that uses the LSP to show references to functions, methods, types and other
https://github.com/romus204/referencer.nvim
neovim neovim-plugin
Last synced: 2 months ago
JSON representation
Lightweight, asynchronous Neovim plugin that uses the LSP to show references to functions, methods, types and other
- Host: GitHub
- URL: https://github.com/romus204/referencer.nvim
- Owner: romus204
- License: mit
- Created: 2025-06-09T18:20:42.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-11-19T06:25:28.000Z (5 months ago)
- Last Synced: 2025-11-19T08:20:35.651Z (5 months ago)
- Topics: neovim, neovim-plugin
- Language: Lua
- Homepage:
- Size: 22.5 KB
- Stars: 22
- Watchers: 0
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim-sorted - romus204/referencer.nvim
- awesome-neovim - romus204/referencer.nvim - Lightweight, asynchronous that uses the LSP to show references to functions, methods, types and other. (LSP)
README
# referencer.nvim
`referencer.nvim` is a lightweight, asynchronous Neovim plugin written in Lua that uses the built-in LSP to show the number of references to functions, methods, types, or other symbols directly in the buffer using virtual text.
This is especially useful for quickly understanding code usage without manually invoking LSP commands.
---
## Preview
https://github.com/user-attachments/assets/1b6351c8-407b-4ed4-846e-dc6cef817219
---
## Features
- ✨ **Asynchronous**: non-blocking usage count queries using built-in LSP.
- 👁️ Displays number of references next to functions, methods, structs, etc.
- ⚖️ Fully configurable highlight groups and colors.
- 💪 Works with any LSP that supports `textDocument/references` and `textDocument/documentSymbol`.
- ⚖️ On-demand or auto-triggered via `LspAttach` event.
---
## Installation
With [lazy.nvim](https://github.com/folke/lazy.nvim):
```lua
{
"romus204/referencer.nvim",
config = function()
require("referencer").setup()
end
}
```
With [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua
use {
"romus204/referencer.nvim",
config = function()
require("referencer").setup()
end
}
```
---
## Default configuration
```lua
require("referencer").setup({
enable = false, -- enable after LSP attach
format = " %d reference(s)", -- format string for reference count
show_no_reference = true, -- show if refs count = 0
kinds = { 5, 6, 8, 12, 13, 14, 23, } -- LSP SymbolKinds to show references for
hl_group = "Comment", -- default highlight group
color = nil, -- optional custom color (overrides hl_group)
virt_text_pos = "eol", -- virtual text position (eol | overlay | right_align)
pattern = nil, -- pattern for LspAttach autocmd to auto-enable
lsp_servers = {} -- list of servers for which this plugin will be active. nil or {} is ALL LSP clients
})
```
## Configuration example
```lua
require("referencer").setup({
enable = true,
format = " %d ref",
show_no_reference = true,
kinds = { 12, 6, 5, 23, 8 },
hl_group = "Comment",
color = "#FFA500",
virt_text_pos = "eol",
pattern = {"*.go", "*.py"},
lsp_servers = {'gopls', 'pyright'}
})
```
### `kinds`
A list of LSP `SymbolKind` numeric values. Some common kinds:
File = 1;
Module = 2;
Namespace = 3;
Package = 4;
Class = 5;
Method = 6;
Property = 7;
Field = 8;
Constructor = 9;
Enum = 10;
Interface = 11;
Function = 12;
Variable = 13;
Constant = 14;
String = 15;
Number = 16;
Boolean = 17;
Array = 18;
Object = 19;
Key = 20;
Null = 21;
EnumMember = 22;
Struct = 23;
Event = 24;
Operator = 25;
TypeParameter = 26;
Full list: [LSP Specification - SymbolKind](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#symbolkind)
---
## Commands
| Command | Description |
| ------------------- | ----------------------------------- |
| `:ReferencerToggle` | Toggle reference display on/off |
| `:ReferencerUpdate` | Force refresh reference information in current buffer |