From 27eccf2b515d65dcdb7f7cab1b833dd54d6227d3 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Sun, 2 Jan 2022 22:44:02 -0800 Subject: [PATCH] Add luadev for nvim lsp support --- .luarc.json | 4 ++++ neovim/lua/plugins.lua | 5 ++++- neovim/lua/plugins/lsp.lua | 39 +++++++++++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .luarc.json diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..bc34f3a --- /dev/null +++ b/.luarc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.workspace.checkThirdParty": false +} diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index 5c4c5b9..f6c60e2 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -197,7 +197,10 @@ return require("packer").startup({ requires = "neovim/nvim-lspconfig", }) - -- Better display of diagnostics + -- Lua dev for vim + use("folke/lua-dev.nvim") + + -- Better display of lsp diagnostics use("folke/trouble.nvim") -- Generic linter/formatters in diagnostics API diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index dcd8692..f848fd3 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -220,12 +220,45 @@ function M.config_null_ls() end) end +local function get_luadev_config() + local luadev = utils.try_require("lua-dev") + if luadev ~= nil then + return luadev.setup({ + -- add any options here, or leave empty to use the default settings + lspconfig = { + on_attach = default_attach, + settings = { + Lua = { + completion = { + callSnippet = "Disable", + keywordSnippet = "Disable", + }, + }, + }, + }, + }) + end + + return nil +end + function M.config_lsp_intaller() utils.try_require("nvim-lsp-installer", function(lsp_installer) + -- Default options + local opts = { + on_attach = default_attach, + } + lsp_installer.on_server_ready(function(server) - server:setup({ - on_attach = default_attach, - }) + -- Config luadev opts + if server.name == "sumneko_lua" then + local luadev = get_luadev_config() + if luadev ~= nil then + opts.settings = luadev.settings + print(vim.inspect(opts.settings.Lua)) + end + end + server:setup(opts) end) end) end