Home

Awesome

<!-- LTeX: enabled=false -->

nvim-dr-lsp 👨‍⚕️👩‍⚕️

<!-- LTeX: enabled=true --> <a href="https://dotfyle.com/plugins/chrisgrieser/nvim-dr-lsp"> <img alt="badge" src="https://dotfyle.com/plugins/chrisgrieser/nvim-dr-lsp/shield"/></a>

Definitions and References utility for the LSP.

Lightweight plugin that highlights definitions and references of the word under the cursor and displays their count in the statusline.

Showcase

<!-- toc --> <!-- tocstop -->

Installation

The plugin requires at least nvim 0.10.

-- lazy.nvim
{ 
	"chrisgrieser/nvim-dr-lsp",
	event = "LspAttach",
	opts = {},
},

-- packer
use { 
	"chrisgrieser/nvim-dr-lsp",
	config = function() require("dr-lsp").setup({}) end,
}

Configuration

-- default config
require("dr-lsp").setup {
	highlightCursorWordReferences = {
		enable = true,
	},
}

Highlight references for the word under the cursor

[!NOTE] In a previous version of this plugin, the highlights were enabled automatically. Now, the highlights are only enabled when the .setup() call is made.

Statusline: definition and reference count

Definitions and references inside current buffer:

LSP: 2D 6R

Definitions or references outside current buffer

LSP: 1(2)D 4(10)R
-- adding the component to lualine.nvim
{
	sections = {
		lualine_c = {
			{ require("dr-lsp").lspCount },
		},
	}
}

There are no built-in options to format the components, since formatting can already be done with most statusline plugins. With Lualine, for example, you can use the fmt option:

lualine_c = {
	{ 
		require("dr-lsp").lspCount, 
		-- remove the letters from the component
		fmt = function(str) return str:gsub("[RD]", "") end,
	},
},

Alternatively, require("dr-lsp").lspCountTable() returns the lspCount information as lua table for custom formatting:

{
	file = {
		definitions = 1,
		references = 4,
	},
	workspace = {
		definitions = 2,
		references = 10,
	},
}

Similar Plugins

<!-- vale Google.FirstPerson = NO -->

Credits

In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.

<a href='https://ko-fi.com/Y8Y86SQ91' target='_blank'> <img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>