-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnvim-navic.lua
More file actions
88 lines (78 loc) · 1.91 KB
/
Copy pathnvim-navic.lua
File metadata and controls
88 lines (78 loc) · 1.91 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
local cache = {}
local function get_name(filename) --{{{
local ret = cache[filename]
if ret ~= nil then
return ret
end
ret = filename
local extension = vim.fn.expand("%:e")
local icon, name = require("nvim-web-devicons").get_icon(filename, extension)
if icon ~= nil then
ret = " %#" .. name .. "#" .. icon .. " " .. filename
end
cache[filename] = ret
return ret
end --}}}
local function config(_, opts)
local navic = require("nvim-navic")
navic.setup({
icons = opts.icons,
separator = opts.separator,
highlight = true,
})
local bar = { --{{{
provider = function()
local filename = vim.fn.expand("%:t")
local ret = get_name(filename)
local extra = ""
if navic.is_available() then
extra = " " .. navic.get_location()
end
return ret .. extra
end,
} --}}}
local components = {
active = { { bar } },
inactive = { { bar } },
}
vim.schedule(function()
require("feline").winbar.setup({
components = components,
disable = opts.disable,
})
end)
vim.api.nvim_create_autocmd("LspAttach", { -- {{{
callback = function(args)
if args.data == nil then
return
end
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client.supports_method("textDocument/documentSymbol") then
return
end
navic.attach(client, args.buf)
end, -- }}}
})
end
return {
"SmiteshP/nvim-navic",
dependencies = {
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
},
opts = {
icons = require("config.icons").navic,
silence = true,
separator = " %#CmpItemKindDefault#▶ %*",
disable = {
filetypes = { "neo-tree" },
},
},
init = function()
vim.g.navic_silence = true
end,
config = config,
event = { "LspAttach" },
enabled = require("config.util").is_enabled("SmitechP/nvim-navic"),
}
-- vim: fdm=marker fdl=0