commit 6294936a504e83a99bb8d85690557ed2433169dd
parent 0c069a8bc2c361b971a1b4b09b07fe3846f2d091
Author: Thomas Vigouroux <tomvig38@gmail.com>
Date: Wed, 14 Apr 2021 17:00:33 +0200
feat(lua): use lsp completion
Diffstat:
2 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/after/plugin/config/completion.vim b/after/plugin/config/completion.vim
@@ -1,4 +1,4 @@
-" Last Change: 2021 Apr 13
+" Last Change: 2021 Apr 14
if !exists('g:loaded_completion')
finish
@@ -19,7 +19,7 @@ let g:completion_chain_complete_list = {
\ {'complete_items': ['lsp', 'snippet']},
\ ],
\'lua' : [
- \ {'complete_items': ['snippet']}
+ \ {'complete_items': ['lsp', 'snippet']}
\ ],
\'mem' : [
\ {'complete_items': ['ts', 'snippet']}
diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua
@@ -1,25 +1,6 @@
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
--- To re-enable when https://github.com/neovim/neovim/issues/13476 is fixed
--- function handle_publish_diags(err, method, result, client_id, bufnr, config)
--- vim.lsp.diagnostic.on_publish_diagnostics(err, method, result, client_id, bufnr, {
--- underline = true,
--- virtual_text = true,
--- signs = true,
--- update_in_insert = true,
--- })
-
--- vim.lsp.diagnostic.set_loclist {
--- open_loclist = false,
--- client_id = client_id,
--- severity_limit = "Warning",
--- }
-
--- local loclist = vim.fn.getloclist(vim.fn.bufwinid(bufnr or 0))
--- end
-
--- vim.lsp.handlers["textDocument/publishDiagnostics"] = handle_publish_diags
vim.cmd[[packadd nvim-lsp]]
local nvim_lsp = require'lspconfig'
@@ -38,6 +19,38 @@ nvim_lsp.rust_analyzer.setup{ capabilities = capabilities }
nvim_lsp.ghcide.setup{ capabilities = capabilities }
nvim_lsp.tsserver.setup{ capabilities = capabilities }
+local sumneko_root_path = vim.fn.expand('$HOME')..'/src/lua-language-server'
+local sumneko_binary = sumneko_root_path.."/bin/Linux/lua-language-server"
+
+require'lspconfig'.sumneko_lua.setup {
+ cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.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',
+ -- Setup your lua path
+ path = vim.split(package.path, ';'),
+ },
+ diagnostics = {
+ -- Get the language server to recognize the `vim` global
+ globals = {'vim'},
+ },
+ workspace = {
+ -- Make the server aware of Neovim runtime files
+ library = {
+ [vim.fn.expand('$VIMRUNTIME/lua')] = true,
+ [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
+ },
+ },
+ -- Do not send telemetry data containing a randomized but unique identifier
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+}
+
-- texlab
local function texlab_attach()
protocol.SymbolKind = {