local bin_name = "lua-language-server" local cmd = { bin_name, "--stdio", } local root_files = { '.luarc.json', '.luarc.jsonc', '.luacheckrc', '.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml', 'lua/', '.git', } vim.api.nvim_create_autocmd("FileType", { pattern = "lua", callback = function() vim.lsp.start({ name = "lua_ls", cmd = cmd, root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), settings = { Lua = { runtime = { version = 'LuaJIT', }, workspace = { checkThirdParty = false, library = { vim.env.VIMRUNTIME, }, }, } }, }) end, })