Skip to content

Commit

Permalink
fix: roblox types order in the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
lopi-py committed Aug 17, 2024
1 parent 186fcea commit a94b64a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
6 changes: 3 additions & 3 deletions lua/luau-lsp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions lua/luau-lsp/roblox/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
7 changes: 4 additions & 3 deletions lua/luau-lsp/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stylua.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
column_width = 99
indent_type = "Spaces"
indent_width = 2
no_call_parentheses = true
call_parentheses = "None"

[sort_requires]
enabled = true

0 comments on commit a94b64a

Please sign in to comment.