Skip to content

Status line component showing the number of LSP definition and reference of the token under the cursor.

License

Notifications You must be signed in to change notification settings

chrisgrieser/nvim-dr-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

badge

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

Installation

The plugin requires at least nvim 0.10.

-- lazy.nvim
{ "chrisgrieser/nvim-dr-lsp" },

-- packer
use { "chrisgrieser/nvim-dr-lsp" }

There is no .setup call for this plugin. Just add the components to your statusline.

Highlights of definitions and references

  • Definitions are under-dashed, references are under-dotted.
  • These are set up automatically for you as soon as the buffer is attached to an LSP client.
  • To disable the highlights feature, set vim.g.dr_lsp_no_highlight = true before loading the plugin.

Definition and reference count in the statusbar

Definitions and references inside current buffer:

LSP: 2D 6R

Definitions or references outside current buffer

LSP: 1(2)D 4(10)R
  • 1 definition in the current buffer
  • 2 definitions in the workspace
  • 4 references in the current buffer
  • 10 definitions in the workspace
-- 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

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.

Buy Me a Coffee at ko-fi.com

About

Status line component showing the number of LSP definition and reference of the token under the cursor.

Topics

Resources

License

Stars

Watchers

Forks

Languages