summaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua
blob: c5ff7945c780d4b3c2f2ed062d8ac5d90c77d6ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local M = {
	"SmiteshP/nvim-navic",
	dependencies = { "onsails/lspkind-nvim" },
}

function M.config()
	local nvim_navic = require("nvim-navic")

	local icons = require("lspkind").symbol_map
	for i, _ in pairs(icons) do
		icons[i] = icons[i] .. " "
	end

	nvim_navic.setup({
		icons = icons,
	})

	vim.api.nvim_create_autocmd("LspAttach", {
		group = vim.api.nvim_create_augroup("tobyvin_nvim-navic", { clear = true }),
		desc = "setup nvim-navic",
		callback = function(args)
			local bufnr = args.buf
			local client = vim.lsp.get_client_by_id(args.data.client_id)

			if client.name ~= "cssls" and client.server_capabilities.documentSymbolProvider then
				require("nvim-navic").attach(client, bufnr)
			end
		end,
	})
end

return M