From 25d7bd9684da7785290ecdb8760fb9e16a950adb Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Sat, 28 May 2022 16:24:17 +0200 Subject: added cmp-capabilities to lspconfig --- .config/nvim/lua/user/plugins/cmp.lua | 2 +- .config/nvim/lua/user/plugins/lspconfig.lua | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) (limited to '.config/nvim/lua/user/plugins') diff --git a/.config/nvim/lua/user/plugins/cmp.lua b/.config/nvim/lua/user/plugins/cmp.lua index fdd7b56..4bfe38e 100644 --- a/.config/nvim/lua/user/plugins/cmp.lua +++ b/.config/nvim/lua/user/plugins/cmp.lua @@ -49,7 +49,7 @@ cmp.setup { else fallback() end - + end, { 'i', 's' }), }, sources = { diff --git a/.config/nvim/lua/user/plugins/lspconfig.lua b/.config/nvim/lua/user/plugins/lspconfig.lua index 3d4c9e3..1467d66 100644 --- a/.config/nvim/lua/user/plugins/lspconfig.lua +++ b/.config/nvim/lua/user/plugins/lspconfig.lua @@ -36,6 +36,9 @@ local on_attach = function(_, bufnr) buf_keymap(bufnr, 'n', ']d', 'lua vim.diagnostic.goto_next()') buf_keymap(bufnr, 'n', 'F', 'lua vim.lsp.buf.format { async = true }') + -- Autoformat on save doesn't work with server_capabilities, even + -- though it's the replacement for the deprecated resolved_capabilities. + -- if _.server_capabilities.document_formatting then -- vim.api.nvim_command [[augroup Format]] -- vim.api.nvim_command [[autocmd! * ]] @@ -44,10 +47,12 @@ local on_attach = function(_, bufnr) -- end end - +-- provide additional completion capabilities +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) require 'lspconfig'.eslint.setup { on_attach = on_attach, + capabilities = capabilities, flags = { debounce_text_changes = 150, }, @@ -58,6 +63,7 @@ require 'lspconfig'.eslint.setup { require 'lspconfig'.tsserver.setup { on_attach = on_attach, + capabilities = capabilities, flags = { debounce_text_changes = 150, } @@ -68,6 +74,7 @@ table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") require 'lspconfig'.sumneko_lua.setup { on_attach = on_attach, + capabilities = capabilities, flags = { debounce_text_changes = 150, }, @@ -75,20 +82,20 @@ require 'lspconfig'.sumneko_lua.setup { settings = { Lua = { runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + -- Tell language server which version of lua is used. version = 'LuaJIT', - -- Setup your lua path + -- Setup lua path path = runtime_path, }, diagnostics = { - -- Get the language server to recognize the `vim` global + -- Recognize the `vim` und `use` global globals = { 'vim', 'use' }, }, workspace = { - -- Make the server aware of Neovim runtime files + -- Make 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 + -- Do not send telemetry data telemetry = { enable = false, }, @@ -98,6 +105,7 @@ require 'lspconfig'.sumneko_lua.setup { require 'lspconfig'.solargraph.setup { on_attach = on_attach, + capabilities = capabilities, flags = { debounce_text_changes = 150, }, -- cgit v1.2.3