diff --git a/init.lua b/init.lua index 23f2c52..ece8189 100644 --- a/init.lua +++ b/init.lua @@ -8,8 +8,7 @@ require('settings') require('lsp') require('lsp.typescript-ls') require('lsp.python-ls') --- require('lsp.lua-ls') --- require('lsp.elixir-ls') +require('lsp.lua-ls') require('lsp.go-ls') require('lsp.ocaml-ls') require('lsp.sml-ls') diff --git a/lua/lsp/lua-ls.lua b/lua/lsp/lua-ls.lua index 7287c1b..e7fd924 100644 --- a/lua/lsp/lua-ls.lua +++ b/lua/lsp/lua-ls.lua @@ -1,39 +1,33 @@ --- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) -USER = vim.fn.expand('$USER') +require'lspconfig'.lua_ls.setup { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then + return + end + end -local sumneko_root_path = "" -local sumneko_binary = "" - -if vim.fn.has("mac") == 1 then - sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/lang-srvrs/lua-language-server" - sumneko_binary = "/Users/" .. USER .. "/.config/nvim/lang-srvrs/lua-language-server/bin/macOS/lua-language-server" -elseif vim.fn.has("unix") == 1 then - sumneko_root_path = "/home/" .. USER .. "/.config/nvim/lang-srvrs/lua-language-server" - sumneko_binary = "/home/" .. USER .. "/.config/nvim/lang-srvrs/lua-language-server/bin/Linux/lua-language-server" -else - print("Unsupported system for sumneko") -end - -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) - 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.api.nvim_get_runtime_file("", true), - }, - telemetry = { - enable = false, - }, + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", } - } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189) + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = {} + } } diff --git a/lua/lsp/typescript-ls.lua b/lua/lsp/typescript-ls.lua index fca66b7..0506d00 100644 --- a/lua/lsp/typescript-ls.lua +++ b/lua/lsp/typescript-ls.lua @@ -1,17 +1,4 @@ -require'lspconfig'.tsserver.setup{ - on_attach = function(client, bufnr) - require "lsp_signature".on_attach({ - bind = false, - -- floating_window = true, - --hint_enable = true, - fix_pos = true, - use_lspsaga = true, - --handler_opts = { - -- border = "single" -- double, single, shadow, none - --}, - }) - end, - cmd = {DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", "--stdio"}, +require'lspconfig'.ts_ls.setup{ filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, root_dir = require('lspconfig/util').root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git") }