From 8d7de190f99790855baae6ddcb26d2dc2167fc56 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 24 Feb 2024 18:37:43 +0900 Subject: [PATCH] nvim: new: add nvim-navic --- dotfiles/neovim/init.lua | 30 ++++++++++++++++++++++++++- dotfiles/neovim/lua/lualine_setup.lua | 12 ++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 1ad05be..ba16d89 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -15,7 +15,18 @@ vim.opt.rtp:prepend(lazypath) -- Installing plugins require('lazy').setup({ - { "catppuccin/nvim", name = "catppuccin" }, -- Color scheme + { + "catppuccin/nvim", + name = "catppuccin", + config = function() + require("catppuccin").setup({ + flavour = "macchiato", + integrations = { + navic = true, + }, + }) + end + }, -- Color scheme { dir = "./lua/term_powershell.lua", event = "CmdlineEnter", @@ -140,6 +151,18 @@ require('lazy').setup({ 'folke/trouble.nvim', -- config = function }, + { + 'SmiteshP/nvim-navic', + -- event = 'BufReadPre', + dependencies = { + 'neovim/nvim-lspconfig', + }, + config = function() + require 'nvim-navic'.setup { + highlight = true, + } + end + }, { 'Julian/lean.nvim', event = { 'BufReadPre *.lean', 'BufNewFile *.lean' }, @@ -479,6 +502,7 @@ require 'nvim-treesitter.configs'.setup { -- LSP config local lspconfig = require 'lspconfig' +local navic = require 'nvim-navic' -- Mapping for language server -- See `:help vim.diagnostic.* for documentation on any of the below functions @@ -512,6 +536,10 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', 'grf', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end end -- cmp_nvim_lsp supports additional LSP completion capabilities diff --git a/dotfiles/neovim/lua/lualine_setup.lua b/dotfiles/neovim/lua/lualine_setup.lua index 7f412d4..c88bb4a 100644 --- a/dotfiles/neovim/lua/lualine_setup.lua +++ b/dotfiles/neovim/lua/lualine_setup.lua @@ -7,6 +7,8 @@ local lsp_names = function () return ' ' .. table.concat(clients, ', ') end +local navic = require('nvim-navic') + require('lualine').setup { options = { icons_enabled = true, @@ -43,7 +45,15 @@ require('lualine').setup { lualine_z = {} }, tabline = {}, - winbar = {}, + winbar = { + lualine_c = { + { + "navic", + color_correction = nil, + navic_opts = nil, + }, + }, + }, inactive_winbar = {}, extensions = {} }