From b99c2fb31b9b5ea64a1ac5e61a6dbd65c08baaa3 Mon Sep 17 00:00:00 2001 From: newbie Date: Wed, 22 Nov 2023 12:59:44 +0800 Subject: [PATCH] update --- lua/lsp/lua.lua | 27 ++++++++++++++++++ lua/plugs.lua | 1 + lua/plugs/nvim-lspconfig.lua | 54 ++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 lua/lsp/lua.lua create mode 100644 lua/plugs/nvim-lspconfig.lua diff --git a/lua/lsp/lua.lua b/lua/lsp/lua.lua new file mode 100644 index 0000000..c7ebcf2 --- /dev/null +++ b/lua/lsp/lua.lua @@ -0,0 +1,27 @@ +local runtime_path = vim.split(package.path, ';') +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") +return { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path, + }, + 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 + }, + }, + }, +} diff --git a/lua/plugs.lua b/lua/plugs.lua index 8b923e7..242babd 100644 --- a/lua/plugs.lua +++ b/lua/plugs.lua @@ -6,6 +6,7 @@ return { require('plugs.coc'), -- coc + -- require('plugs.nvim-lspconfig'), -- compe require('plugs.lualine'), -- lualine require('plugs.nvimtree'), -- nvimtree require('plugs.treesitter'), -- treesitter diff --git a/lua/plugs/nvim-lspconfig.lua b/lua/plugs/nvim-lspconfig.lua new file mode 100644 index 0000000..f321180 --- /dev/null +++ b/lua/plugs/nvim-lspconfig.lua @@ -0,0 +1,54 @@ +return { + { + "neovim/nvim-lspconfig", + config = function () + end + }, + { + 'williamboman/nvim-lsp-installer', + config = function () + local lsp_installer = require "nvim-lsp-installer" + + -- 安装列表 + -- https://github.com/williamboman/nvim-lsp-installer#available-lsps + -- { key: 语言 value: 配置文件 } + local servers = { + sumneko_lua = require "lsp.lua", -- /lua/lsp/lua.lua + } + + -- 自动安装 LanguageServers + for name, _ in pairs(servers) do + local server_is_found, server = lsp_installer.get_server(name) + if server_is_found then + if not server:is_installed() then + print("Installing " .. name) + server:install() + end + end + end + end + }, + { + 'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' } + 'hrsh7th/cmp-buffer', -- { name = 'buffer' }, + 'hrsh7th/cmp-path', -- { name = 'path' } + 'hrsh7th/cmp-cmdline', -- { name = 'cmdline' } + 'onsails/lspkind-nvim', + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require('cmp') + -- local lspkind = require('lspkind') + cmp.setup { + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'cmdline' }, + }), + + } + end, + } + } +}