Skip to content

Commit

Permalink
feat: add sourcemap.sourcemap_file option
Browse files Browse the repository at this point in the history
  • Loading branch information
lopi-py committed Nov 10, 2024
1 parent 5780255 commit c08de64
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased]

### Added

- Option `sourcemap.sourcemap_file` to specify a different name to use for the sourcemap

### Changed

- Upgraded the required version of `luau-lsp` to `1.35.0`

### Removed

- Deprecated option `types.roblox`
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ require("luau-lsp").setup {
enabled = true,
autogenerate = true, -- automatic generation when the server is attached
rojo_project_file = "default.project.json",
sourcemap_file = "sourcemap.json",
},
}
```
Expand Down Expand Up @@ -164,7 +165,6 @@ require("luau-lsp").setup {
settings = {
["luau-lsp"] = {
require = {
mode = "relativeToFile",
directoryAliases = require("luau-lsp").aliases(),
},
},
Expand Down Expand Up @@ -226,6 +226,7 @@ local defaults = {
rojo_path = "rojo",
rojo_project_file = "default.project.json",
include_non_scripts = true,
sourcemap_file = "sourcemap.json",
},
types = {
---@type string[]
Expand Down
8 changes: 4 additions & 4 deletions lua/luau-lsp/bytecode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end
local function create_view()
vim.cmd "belowright vsplit +enew"

local augroup = vim.api.nvim_create_augroup("luau-lsp/bytecode", {})
local group = vim.api.nvim_create_augroup("luau-lsp/bytecode", {})

bytecode_bufnr = vim.api.nvim_get_current_buf()
bytecode_winnr = vim.api.nvim_get_current_win()
Expand All @@ -59,17 +59,17 @@ local function create_view()
})

vim.api.nvim_create_autocmd(UPDATE_EVENTS, {
group = augroup,
group = group,
callback = function(event)
M.update_buffer(event.buf)
end,
})

vim.api.nvim_create_autocmd("BufUnload", {
group = augroup,
group = group,
buffer = bytecode_bufnr,
callback = function()
vim.api.nvim_del_augroup_by_id(augroup)
vim.api.nvim_del_augroup_by_id(group)
end,
})

Expand Down
1 change: 1 addition & 0 deletions lua/luau-lsp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local defaults = {
rojo_path = "rojo",
rojo_project_file = "default.project.json",
include_non_scripts = true,
sourcemap_file = "sourcemap.json",
},
types = {
---@type string[]
Expand Down
2 changes: 1 addition & 1 deletion lua/luau-lsp/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function M.check()
check_executable {
name = "luau-lsp",
cmd = { vim.fn.exepath(config.get().server.cmd[1]), "--version" },
version = "1.34.0",
version = "1.35.0",
}

local ok, autocmds = pcall(vim.api.nvim_get_autocmds, {
Expand Down
6 changes: 3 additions & 3 deletions lua/luau-lsp/roblox/sourcemap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ local function start_sourcemap_generation(project_file)
"--watch",
project_file,
"--output",
"sourcemap.json",
config.get().sourcemap.sourcemap_file,
}

if config.get().sourcemap.include_non_scripts then
table.insert(cmd, "--include-non-scripts")
end

local augroup = vim.api.nvim_create_augroup("luau-lsp/sourcemap", {})
local group = vim.api.nvim_create_augroup("luau-lsp/sourcemap", {})
local ok, job = pcall(vim.system, cmd, {
text = true,
}, function(result)
Expand All @@ -80,7 +80,7 @@ local function start_sourcemap_generation(project_file)
pid = job.pid

vim.api.nvim_create_autocmd("VimLeavePre", {
group = augroup,
group = group,
callback = stop_sourcemap_generation,
})
end
Expand Down
1 change: 1 addition & 0 deletions lua/luau-lsp/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ local function get_settings()
},
sourcemap = {
enabled = config.get().sourcemap.enabled,
sourcemapFile = config.get().sourcemap.sourcemap_file,
},
},
}
Expand Down
14 changes: 1 addition & 13 deletions spec/server_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,6 @@ describe("luau-lsp server", function()
create_luau_buffer()
local client = wait_for_client()

assert.same({
["luau-lsp"] = {
platform = {
type = "roblox",
},
sourcemap = {
enabled = true,
},
testSetting = {
testField = "testing",
},
},
}, client.settings)
assert.same("testing", vim.tbl_get(client.settings, "luau-lsp", "testSetting", "testField"))
end)
end)

0 comments on commit c08de64

Please sign in to comment.