nvim: set up nvim-navic

This commit is contained in:
Daniel Lundin 2022-12-27 18:49:51 +01:00
parent bab0d9cb20
commit cae9db14d4
3 changed files with 164 additions and 142 deletions

View file

@ -7,6 +7,14 @@ return {
"jjo/vim-cue", "jjo/vim-cue",
"ckipp01/stylua-nvim", "ckipp01/stylua-nvim",
{
"SmiteshP/nvim-navic",
config = function()
vim.g.navic_silence = true
require("nvim-navic").setup({ separator = " ", highlight = true, depth_limit = 5 })
end,
},
{ {
"numToStr/Comment.nvim", "numToStr/Comment.nvim",
keys = { keys = {

View file

@ -45,8 +45,8 @@ function M.config()
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end end
local on_attach = function() local function on_attach(client, bufnr)
-- require("folding").on_attach() require("nvim-navic").attach(client, bufnr)
end end
-- simple setups -- -- simple setups --
@ -86,8 +86,8 @@ function M.config()
}) })
lspconfig.sumneko_lua.setup({ lspconfig.sumneko_lua.setup({
on_attach = function() on_attach = function(client, bufnr)
on_attach() on_attach(client, bufnr)
vim.cmd([[autocmd BufWritePre <buffer> lua require'stylua-nvim'.format_file()]]) vim.cmd([[autocmd BufWritePre <buffer> lua require'stylua-nvim'.format_file()]])
end, end,
settings = { settings = {

View file

@ -25,6 +25,20 @@ function M.config()
path = 1, path = 1,
file_status = true, file_status = true,
}, },
{
function()
local navic = require("nvim-navic")
local ret = navic.get_location()
return ret:len() > 2000 and "navic error" or ret
end,
cond = function()
if package.loaded["nvim-navic"] then
local navic = require("nvim-navic")
return navic.is_available()
end
end,
color = { fg = "#d66622" },
},
}, },
lualine_x = { "filetype" }, lualine_x = { "filetype" },
lualine_y = { "location", "progress" }, lualine_y = { "location", "progress" },