From 9e03a9d7086ead17ab36cf08138a5b20d697f2dd Mon Sep 17 00:00:00 2001 From: CompeyDev Date: Sun, 18 Dec 2022 18:52:12 +0530 Subject: [PATCH] feat: improve LSP using lsp-zero for rust and python --- init.lua | 1 - lua/user/lsp/init.lua | 21 +++++++++++++++++++++ lua/user/plugins.lua | 25 +++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index f4e922a..52d779d 100644 --- a/init.lua +++ b/init.lua @@ -19,4 +19,3 @@ require "user.indentline" require "user.alpha" require "user.whichkey" require "user.autocommands" -require'lspconfig'.rust_analyzer.setup{} diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua index c8eef0f..9b6617b 100644 --- a/lua/user/lsp/init.lua +++ b/lua/user/lsp/init.lua @@ -6,3 +6,24 @@ end require "user.lsp.mason" require("user.lsp.handlers").setup() require "user.lsp.null-ls" +require "user.lsp.rust" +require "user.lsp.go" +require('go').setup() +require'lspconfig'.rust_analyzer.setup{} + +local lsp = require('lsp-zero') + +lsp.preset('recommended') + + +lsp.ensure_installed({ + 'tsserver', + 'eslint', + 'sumneko_lua', + 'rust_analyzer', + 'anakin_language_server' +}) + +lsp.nvim_workspace() + +lsp.setup() diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index 658c89a..e6c5837 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -85,8 +85,8 @@ return packer.startup(function(use) use { "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" } -- buffer completions use { "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" } -- path completions use { "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" } -- snippet completions - use("fatih/vim-go") - use("govim/govim") + -- use("fatih/vim-go") + -- use("govim/govim") use("simrat39/rust-tools.nvim") use { "hrsh7th/cmp-nvim-lsp", commit = "3cf38d9c957e95c397b66f91967758b31be4abe6" } use { "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" } @@ -96,12 +96,33 @@ return packer.startup(function(use) use { "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" } -- a bunch of snippets to use -- LSP + use 'ray-x/go.nvim' use { "neovim/nvim-lspconfig", commit = "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda" } -- enable LSP use { "williamboman/mason.nvim", commit = "c2002d7a6b5a72ba02388548cfaf420b864fbc12"} -- simple to use language server installer use { "williamboman/mason-lspconfig.nvim", commit = "0051870dd728f4988110a1b2d47f4a4510213e31" } use { "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" } -- for formatters and linters use { "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" } + use { + 'VonHeikemen/lsp-zero.nvim', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + {'rafamadriz/friendly-snippets'}, + } +} -- Telescope use { "nvim-telescope/telescope.nvim", commit = "76ea9a898d3307244dce3573392dcf2cc38f340f" }