From a94b64a416f193ce0bcb5447779c71c7a4e2dcf6 Mon Sep 17 00:00:00 2001 From: lopy <70210066+lopi-py@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:40:51 -0500 Subject: [PATCH] fix: roblox types order in the command line --- CHANGELOG.md | 1 + lua/luau-lsp/config.lua | 6 +++--- lua/luau-lsp/roblox/init.lua | 12 ++++++------ lua/luau-lsp/server.lua | 7 ++++--- stylua.toml | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 449f830..d369eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- Definition files that depend on Roblox types will now load properly - Merge internal modified capabilities with the default client capabilities if not specified in the server config - Sourcemap generation and studio server will only start if the configured platform is `roblox` diff --git a/lua/luau-lsp/config.lua b/lua/luau-lsp/config.lua index d17caa3..0185951 100644 --- a/lua/luau-lsp/config.lua +++ b/lua/luau-lsp/config.lua @@ -82,9 +82,9 @@ local function validate(opts) log.warn "`types.roblox` is deprecated, use `platform.type` instead" end - local function check_server_setting(path) - if vim.tbl_get(opts, "server", "settings", "luau-lsp", path) ~= nil then - log.error("`%s` should not be passed as server setting", path) + local function check_server_setting(name) + if vim.tbl_get(opts, "server", "settings", "luau-lsp", name) ~= nil then + log.error("`%s` should not be passed as server setting", name) end end diff --git a/lua/luau-lsp/roblox/init.lua b/lua/luau-lsp/roblox/init.lua index f8e788e..2159af0 100644 --- a/lua/luau-lsp/roblox/init.lua +++ b/lua/luau-lsp/roblox/init.lua @@ -51,8 +51,8 @@ end, 1) local M = {} ---@async ----@param opts luau-lsp.ClientConfig -function M.prepare(opts) +---@param cmd string[] +function M.prepare(cmd) if config.get().platform.type ~= "roblox" then return end @@ -66,11 +66,11 @@ function M.prepare(opts) end end - table.insert(opts.cmd, "--definitions=" .. global_types_file()) - table.insert(opts.cmd, "--docs=" .. api_docs_file()) + table.insert(cmd, "--definitions=" .. global_types_file()) + table.insert(cmd, "--docs=" .. api_docs_file()) end -M.start = vim.schedule_wrap(function() +function M.start() if config.get().platform.type ~= "roblox" then return end @@ -82,6 +82,6 @@ M.start = vim.schedule_wrap(function() if config.get().plugin.enabled then require("luau-lsp.roblox.studio").start() end -end) +end return M diff --git a/lua/luau-lsp/server.lua b/lua/luau-lsp/server.lua index f12c8d7..0e6bc65 100644 --- a/lua/luau-lsp/server.lua +++ b/lua/luau-lsp/server.lua @@ -48,10 +48,13 @@ local function get_fflags() return vim.tbl_deep_extend("force", fflags, config.get().fflags.override) end +---@async ---@return string[] local function get_cmd() local cmd = vim.deepcopy(config.get().server.cmd) + require("luau-lsp.roblox").prepare(cmd) + for _, definition_file in ipairs(config.get().types.definition_files) do definition_file = vim.fs.normalize(definition_file) if util.is_file(definition_file) then @@ -126,14 +129,13 @@ end local function start_language_server() local opts = vim.tbl_deep_extend("force", config.get().server, { name = "luau-lsp", - cmd = get_cmd(), root_dir = get_root_dir(), + cmd = get_cmd(), settings = get_settings(), init_options = { fflags = get_fflags() }, }) force_push_diagnostics(opts) - require("luau-lsp.roblox").prepare(opts) local client_id = vim.lsp.start_client(opts) if not client_id then @@ -168,7 +170,6 @@ local M = {} ---@param bufnr? number function M.start(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() - if not is_luau_file(bufnr) then return end diff --git a/stylua.toml b/stylua.toml index b57aa80..026ecfe 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,7 +1,7 @@ column_width = 99 indent_type = "Spaces" indent_width = 2 -no_call_parentheses = true +call_parentheses = "None" [sort_requires] enabled = true