diff --git a/lua/lsp_settings.lua b/lua/lsp_settings.lua index ca75aef..747fdb6 100644 --- a/lua/lsp_settings.lua +++ b/lua/lsp_settings.lua @@ -4,6 +4,7 @@ require("mason").setup { -- Setup lspconfig. local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) +local navic = require("nvim-navic") -- LSP hotkey config local opts = { noremap = true, silent = true } @@ -14,7 +15,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer -local on_attach = function(_, bufnr) +local on_attach = function(client, bufnr) + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') diff --git a/lua/mappings.lua b/lua/mappings.lua index ed643e3..d7fe768 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -43,3 +43,4 @@ vimp.noremap({ 'silent' }, 'n', [[:NvimTreeToggle]]) vimp.noremap({ 'silent' }, 'ff', [[:Telescope find_files]]) vimp.noremap({ 'silent' }, 'fg', [[:Telescope live_grep]]) vimp.noremap({ 'silent' }, 'fb', [[:Telescope buffers]]) +vimp.noremap({ 'silent' }, 'fp', function() require 'telescope'.extensions.projects.projects {} end) diff --git a/lua/plugins.lua b/lua/plugins.lua index dd999d9..52b4947 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -96,6 +96,13 @@ return { end }, + { + "ahmedkhalf/project.nvim", + config = function() + require("project_nvim").setup {} + end + }, + -- https://github.com/ellisonleao/glow.nvim { @@ -145,6 +152,52 @@ return { lazy = true }, }, + config = function() + require('telescope').load_extension('projects') + end + }, + + -- https://github.com/SmiteshP/nvim-navic + { + "SmiteshP/nvim-navic", + dependencies = "neovim/nvim-lspconfig", + config = function() + require('nvim-navic').setup({ + icons = { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = "練", + Interface = "練", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = "◩ ", + Array = " ", + Object = " ", + Key = " ", + Null = "ﳠ ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + highlight = false, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true + }) + end }, -- https://github.com/nvim-tree/nvim-tree.lua @@ -155,6 +208,12 @@ return { }, config = function() require('nvim-tree').setup { + sync_root_with_cwd = true, + respect_buf_cwd = true, + update_focused_file = { + enable = true, + update_root = true + }, sort_by = "case_sensitive", view = { adaptive_size = true, @@ -346,7 +405,13 @@ return { 'hoob3rt/lualine.nvim', dependencies = { { 'nvim-tree/nvim-web-devicons' } }, config = function() + local navic = require("nvim-navic") require('lualine').setup({ + sections = { + lualine_c = { + { navic.get_location, cond = navic.is_available }, + } + }, options = { theme = 'pywal-nvim' }