From: Tobias Sachs Date: Sat, 3 Dec 2022 13:05:58 +0000 (+0100) Subject: switch to lsp-zero, it seems quite convenient.. X-Git-Url: https://src.twobees.de/?p=dotfiles.git;a=commitdiff_plain;h=52e35a2fb986a9edf07a6be343eec845218d22c5 switch to lsp-zero, it seems quite convenient.. --- diff --git a/stow/nvim/.config/nvim/init.lua b/stow/nvim/.config/nvim/init.lua index d0876a8..c7360a9 100644 --- a/stow/nvim/.config/nvim/init.lua +++ b/stow/nvim/.config/nvim/init.lua @@ -1,11 +1,12 @@ local data_path = vim.fn.stdpath('data') vim.o.backupdir = data_path .. "/backup//" -require 'plugin_mgr' -require 'set' -require 'lspsetup' -require 'mappings' -require 'treesitter' +pcall (require 'plugin_mgr') + +pcall (require 'set') +pcall (require 'lspsetup') +pcall (require 'mappings') +pcall (require 'treesitter') pcall (require 'perl') pcall (require 'theme') pcall (require 'cmp-settings') diff --git a/stow/nvim/.config/nvim/lua/lspsetup.lua b/stow/nvim/.config/nvim/lua/lspsetup.lua index 08f1a19..0668998 100644 --- a/stow/nvim/.config/nvim/lua/lspsetup.lua +++ b/stow/nvim/.config/nvim/lua/lspsetup.lua @@ -1,53 +1,4 @@ -vim.api.nvim_create_autocmd('LspAttach', { - callback = function() - vim.keymap.set ("n", "K", vim.lsp.buf.hover, { buffer=0}) -- buffer=0 -> only in current buffer - vim.keymap.set ("n", "gd", vim.lsp.buf.definition, { buffer=0}) -- goto definition - vim.keymap.set ("n", "gT", vim.lsp.buf.type_definition, { buffer=0}) -- goto typedefinition - vim.keymap.set ("n", "gi", vim.lsp.buf.implementation, { buffer=0}) -- goto implementation - vim.keymap.set ("n", "dj", vim.diagnostic.goto_next, { buffer=0}) -- goto dignostic next - vim.keymap.set ("n", "dk", vim.diagnostic.goto_prev, { buffer=0}) -- goto diognostic prev - vim.keymap.set ("n", "dl", "Telescope diagnostic", { buffer=0}) -- goto list failure - vim.keymap.set ("n", "r", vim.lsp.buf.rename, { buffer=0}) - end, -}) -require("mason").setup() +local lsp = require('lsp-zero') -require'lspconfig'.csharp_ls.setup({}) -require'lspconfig'.bashls.setup({}) - -require'lspconfig'.perlls.setup{ - settings = { - perl = { - fileFilter = { ".pm", ".pl" }, - ignoreDirs = ".git", - perlCmd = "perl", - perlInc = " " - } - }, - single_file_support = true -} - - -require'lspconfig'.sumneko_lua.setup { - filetypes = { "lua"}, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {'vim'}, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, -} +lsp.preset('recommended') +lsp.setup() diff --git a/stow/nvim/.config/nvim/lua/plugin_mgr.lua b/stow/nvim/.config/nvim/lua/plugin_mgr.lua index 319fda1..be148ee 100644 --- a/stow/nvim/.config/nvim/lua/plugin_mgr.lua +++ b/stow/nvim/.config/nvim/lua/plugin_mgr.lua @@ -16,21 +16,32 @@ return require('packer').startup(function(use) use { 'catppuccin/nvim', as = 'catppuccin' } use { 'folke/tokyonight.nvim' } use { 'unblevable/quick-scope'} - use { 'neovim/nvim-lspconfig' } use { 'onsails/lspkind.nvim' } - use { "williamboman/mason.nvim" } -- lsp installer use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + 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'}, + } + } -- complition stuff - use { 'hrsh7th/cmp-nvim-lsp' } - use { 'hrsh7th/cmp-buffer' } - use { 'hrsh7th/cmp-path' } use { 'hrsh7th/cmp-cmdline' } - use { 'hrsh7th/nvim-cmp' } -- Automatically set up configuration after cloning packer.nvim if packer_bootstrap then