From 6b84433e4eb2195c11d8c7beff3b76d30cd49dce Mon Sep 17 00:00:00 2001 From: Saeed Afzal Date: Sat, 14 May 2022 23:08:26 +0100 Subject: [PATCH] Update lsp config --- lua/plugins/config/cmp.lua | 24 ++++++++++++ lua/plugins/config/lspconfig.lua | 7 ++++ lua/plugins/config/nvimtree.lua | 14 ++++--- lua/plugins/config/whichkey.lua | 15 ++++++-- lua/plugins/setup.lua | 66 ++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 lua/plugins/config/cmp.lua create mode 100644 lua/plugins/config/lspconfig.lua diff --git a/lua/plugins/config/cmp.lua b/lua/plugins/config/cmp.lua new file mode 100644 index 0000000..55174c4 --- /dev/null +++ b/lua/plugins/config/cmp.lua @@ -0,0 +1,24 @@ +local cmp = require("cmp") + +cmp.setup { + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }) + }), + + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" } + }, { + { name = "buffer" } + }) +} diff --git a/lua/plugins/config/lspconfig.lua b/lua/plugins/config/lspconfig.lua new file mode 100644 index 0000000..e2f5d04 --- /dev/null +++ b/lua/plugins/config/lspconfig.lua @@ -0,0 +1,7 @@ +local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) + +local lspconfig = require("lspconfig") + +lspconfig.sumneko_lua.setup { + capabilities = capabilities +} diff --git a/lua/plugins/config/nvimtree.lua b/lua/plugins/config/nvimtree.lua index 8748a60..b1b8f7a 100644 --- a/lua/plugins/config/nvimtree.lua +++ b/lua/plugins/config/nvimtree.lua @@ -10,11 +10,6 @@ require("nvim-tree").setup { hijack_cursor = true, update_cwd = true, - update_focused_file = { - enable = true, - update_cwd = true - }, - view = { hide_root_folder = true }, @@ -23,5 +18,14 @@ require("nvim-tree").setup { indent_markers = { enable = true } + }, + + update_focused_file = { + enable = true, + update_cwd = true + }, + + diagnostics = { + enable = true } } diff --git a/lua/plugins/config/whichkey.lua b/lua/plugins/config/whichkey.lua index 0d91948..3a9b713 100644 --- a/lua/plugins/config/whichkey.lua +++ b/lua/plugins/config/whichkey.lua @@ -12,11 +12,11 @@ wk.register({ x = { "BufferClose", "Close Buffer" }, n = { "BufferMoveNext", "Move Next" }, m = { "BufferMovePrevious", "Move Previous" }, - + p = { name = "Pinned Buffers", p = { "BufferPin", "Pin Buffer" }, - x = { "BufferCloseAllButPinned", "Close All But Pinned" } + x = { "BufferCloseAllButPinned", "Close All But Pinned" } } }, @@ -27,7 +27,8 @@ wk.register({ f = { "Telescope fd", "Find Files" }, c = { "Telescope current_buffer_fuzzy_find", "Find In Current Buffer" }, b = { "Telescope buffers", "Buffers" }, - k = { "Telescope keymaps", "Keymaps" } + k = { "Telescope keymaps", "Keymaps" }, + t = { "TodoTelescope", "Todos" } }, g = { @@ -42,5 +43,11 @@ wk.register({ -- Barbar (switching buffers) [""] = { "BufferNext", "Next Buffer" }, - [""] = { "BufferPrevious", "Previous Buffer" } + [""] = { "BufferPrevious", "Previous Buffer" }, + + ["t"] = { + name = "Trouble", + t = { "TroubleToggle", "Trouble Toggle" }, + d = { "TodoTrouble", "Todos" } + } }) diff --git a/lua/plugins/setup.lua b/lua/plugins/setup.lua index 81376f7..c4bf856 100644 --- a/lua/plugins/setup.lua +++ b/lua/plugins/setup.lua @@ -118,6 +118,72 @@ require("packer").startup(function(use) end } + -- NOTE: LSP + use { + "williamboman/nvim-lsp-installer", + { + "neovim/nvim-lspconfig", + config = function() + require("nvim-lsp-installer").setup() + end + } + } + + use { + "ray-x/lsp_signature.nvim", + after = "nvim-lspconfig", + config = function() + require("lsp_signature").setup() + end + } + + use { + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip" + } + + use { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + { + "hrsh7th/nvim-cmp", + config = function() + require("plugins.config.cmp") + require("plugins.config.lspconfig") + end + } + } + + use { + "rafamadriz/friendly-snippets", + event = "InsertCharPre" + } + + use { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup() + end + } + + use { + "folke/trouble.nvim", + requires = "kyazdani42/nvim-web-devicons", + config = function() + require("trouble").setup() + end + } + + use { + "folke/todo-comments.nvim", + requires = "nvim-lua/plenary.nvim", + config = function() + require("todo-comments").setup() + end + } + if packer_bootstrap then require("packer").sync() end