From 735b2ed90b9fb2d18c41d78d7aec21e0eae92b57 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 28 Oct 2024 17:50:01 +0100 Subject: [PATCH 1/5] add nvim-navic for code context instead of nvim-treesitter-context --- lua/kickstart/plugins/lspconfig.lua | 17 +++++++++++++++++ lua/kickstart/plugins/treesitter.lua | 1 - lua/options.lua | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index c8c0a31..c02ff82 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -28,6 +28,9 @@ return { -- Allows extra capabilities provided by nvim-cmp 'hrsh7th/cmp-nvim-lsp', + + -- Code context using LSP info + 'SmiteshP/nvim-navic', }, config = function() -- Brief aside: **What is LSP?** @@ -206,6 +209,20 @@ return { }, } + -- Setup code context via nvim-navic + require('nvim-navic').setup { + lsp = { + auto_attach = true, + preference = { + 'svelte', + 'intelephense', + 'ts_ls', + 'tailwindcss', + }, + }, + highlight = true, + } + -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install -- other tools, you can run diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index 73e88c0..9db60f6 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -2,7 +2,6 @@ return { { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', dependencies = { - 'nvim-treesitter/nvim-treesitter-context', 'nvim-treesitter/nvim-treesitter-textobjects', }, build = ':TSUpdate', diff --git a/lua/options.lua b/lua/options.lua index a43fa62..2dd38a9 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -96,6 +96,9 @@ vim.opt.guicursor = 'n-v-i-c:block-Cursor' vim.o.laststatus = 3 vim.api.nvim_set_hl(0, 'WinSeparator', { bg = nil }) +-- Set winbar to nvim-navic for code context +vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}" + vim.api.nvim_create_autocmd('UIEnter', { group = vim.api.nvim_create_augroup('SetGUISettings', { clear = true }), callback = function() From 3841ef2309310ff899e6ab14d327e26e9f03145f Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 20 Nov 2024 11:10:39 +0100 Subject: [PATCH 2/5] remove unused navic defaults in preparation for plugin --- lazy-lock.json | 2 +- lua/kickstart/plugins/lspconfig.lua | 14 -------------- lua/options.lua | 3 --- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 518f25e..7362c1d 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -22,8 +22,8 @@ "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, "nvim-lint": { "branch": "master", "commit": "b3ab4ba88845893663d0b7122ee82921adf28358" }, "nvim-lspconfig": { "branch": "master", "commit": "541f3a2781de481bb84883889e4d9f0904250a56" }, + "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-treesitter": { "branch": "master", "commit": "03452942dfbd998701d4123ccad2090e1bc7e9f1" }, - "nvim-treesitter-context": { "branch": "master", "commit": "78a81c7494e7d1a08dd1200b556933e513fd9f29" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "oil.nvim": { "branch": "master", "commit": "39dbf875861449cf09e936fa80073f3413e9439c" }, diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index c02ff82..f6a5946 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -209,20 +209,6 @@ return { }, } - -- Setup code context via nvim-navic - require('nvim-navic').setup { - lsp = { - auto_attach = true, - preference = { - 'svelte', - 'intelephense', - 'ts_ls', - 'tailwindcss', - }, - }, - highlight = true, - } - -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install -- other tools, you can run diff --git a/lua/options.lua b/lua/options.lua index 2dd38a9..a43fa62 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -96,9 +96,6 @@ vim.opt.guicursor = 'n-v-i-c:block-Cursor' vim.o.laststatus = 3 vim.api.nvim_set_hl(0, 'WinSeparator', { bg = nil }) --- Set winbar to nvim-navic for code context -vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}" - vim.api.nvim_create_autocmd('UIEnter', { group = vim.api.nvim_create_augroup('SetGUISettings', { clear = true }), callback = function() From 56e41799765a789a89644d347b568c1c3512884d Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 20 Nov 2024 11:17:44 +0100 Subject: [PATCH 3/5] install barbecue.nvim to configure nvim-navic --- lazy-lock.json | 1 + lua/custom/plugins/barbecue.lua | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 lua/custom/plugins/barbecue.lua diff --git a/lazy-lock.json b/lazy-lock.json index 7362c1d..aca6496 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,6 @@ { "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, + "barbecue": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, diff --git a/lua/custom/plugins/barbecue.lua b/lua/custom/plugins/barbecue.lua new file mode 100644 index 0000000..6074b86 --- /dev/null +++ b/lua/custom/plugins/barbecue.lua @@ -0,0 +1,10 @@ +return { + 'utilyre/barbecue.nvim', + name = 'barbecue', + version = '*', + dependencies = { + 'SmiteshP/nvim-navic', + 'nvim-tree/nvim-web-devicons', + }, + opts = {}, +} From 884a60ca6a6d0f7bf4798b75118f3d4ff4ecaa2c Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 20 Nov 2024 11:19:34 +0100 Subject: [PATCH 4/5] show only file extension instead of duplicate filename display --- lua/custom/plugins/barbecue.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/custom/plugins/barbecue.lua b/lua/custom/plugins/barbecue.lua index 6074b86..c00031d 100644 --- a/lua/custom/plugins/barbecue.lua +++ b/lua/custom/plugins/barbecue.lua @@ -6,5 +6,9 @@ return { 'SmiteshP/nvim-navic', 'nvim-tree/nvim-web-devicons', }, - opts = {}, + opts = { + modifiers = { + basename = ':e', + }, + }, } From d393c44b373615f05330dd14c08b7a069faa168c Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 20 Nov 2024 11:21:51 +0100 Subject: [PATCH 5/5] ignore gitcommit filetype for context display --- lua/custom/plugins/barbecue.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/custom/plugins/barbecue.lua b/lua/custom/plugins/barbecue.lua index c00031d..d3687c1 100644 --- a/lua/custom/plugins/barbecue.lua +++ b/lua/custom/plugins/barbecue.lua @@ -7,6 +7,9 @@ return { 'nvim-tree/nvim-web-devicons', }, opts = { + exclude_filetypes = { + 'gitcommit', + }, modifiers = { basename = ':e', },