From f7a1a5dc928be00407d584c0d636b491b8688c61 Mon Sep 17 00:00:00 2001 From: marvelman3284 Date: Tue, 1 Jun 2021 09:22:24 -0400 Subject: [PATCH] Add lspinstall functionality --- lua/mappings.lua | 4 ++-- lua/nvim-lspconfig.lua | 37 ++++++++++++++++++++++++++++++------- lua/pluginList.lua | 6 +++--- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/lua/mappings.lua b/lua/mappings.lua index 70fde6a..1c91eee 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -18,8 +18,8 @@ map("v", "x", [=[ "_x ]=], opt) this line too ]] -- OPEN TERMINALS -- -map("n", "", [[vnew term://bash ]], opt) -- over right -map("n", "", [[ split term://bash | resize 10 ]], opt) -- bottom +map("n", "", [[vnew term://zsh ]], opt) -- over right +map("n", "", [[ split term://zsh | resize 10 ]], opt) -- bottom map("n", "t", [[ tabnew | term ]], opt) -- newtab -- COPY EVERYTHING in the file-- diff --git a/lua/nvim-lspconfig.lua b/lua/nvim-lspconfig.lua index 01655ab..b013672 100644 --- a/lua/nvim-lspconfig.lua +++ b/lua/nvim-lspconfig.lua @@ -38,14 +38,14 @@ end local lspconf = require("lspconfig") -- these langs require same lspconfig so put em all in a table and loop through! -local servers = {"html", "cssls", "tsserver", "pyright", "bashls", "clangd", "ccls"} +local lspservers = {"html", "cssls", "tsserver", "pyright", "bashls", "clangd", "ccls", "gopls"} -for _, lang in ipairs(servers) do - lspconf[lang].setup { - on_attach = on_attach, - root_dir = vim.loop.cwd - } -end +for _, lang in ipairs(lspservers) do + lspconf[lang].setup { + on_attach = on_attach, + root_dir = vim.loop.cwd + } + end -- vls conf example local vls_binary = "/usr/local/bin/vls" @@ -59,6 +59,29 @@ USER = "/home/" .. vim.fn.expand("$USER") local sumneko_root_path = USER .. "/.config/lua-language-server" local sumneko_binary = USER .. "/.config/lua-language-server/bin/Linux/lua-language-server" + +local lsp_installer = require'nvim-lsp-installer' + +function common_on_attach(client, bufnr) + -- setup buffer keymaps etc. +end + +local installed_servers = lsp_installer.get_installed_servers() + +for _, server in pairs(installed_servers) do + opts = { + on_attach = common_on_attach, + } + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + server:setup(opts) +end + + lspconf.sumneko_lua.setup { cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, root_dir = function() diff --git a/lua/pluginList.lua b/lua/pluginList.lua index 4b60d9b..8afbfe0 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -4,13 +4,13 @@ local use = packer.use -- using { } for using different branch , loading plugin with certain commands etc return require("packer").startup( function() + use 'neovim/nvim-lsp-config' + use 'williamboman/nvim-lsp-installer' use "wbthomason/packer.nvim" - -- color related stuff use "siduck76/nvim-base16.lua" use "norcalli/nvim-colorizer.lua" -- use "ollykel/v-vim" -- v syntax highlighter - -- lsp stuff use "nvim-treesitter/nvim-treesitter" use "neovim/nvim-lspconfig" @@ -46,7 +46,7 @@ return require("packer").startup( -- discord rich presence --use "andweeb/presence.nvim" - + use "wakatime/vim-wakatime" use {"lukas-reineke/indent-blankline.nvim", branch = "lua"} end, {