diff --git a/lua/trouble/item.lua b/lua/trouble/item.lua index 5719993f..0bf3a6ca 100644 --- a/lua/trouble/item.lua +++ b/lua/trouble/item.lua @@ -17,6 +17,7 @@ local Util = require("trouble.util") ---@field source string ---@field cache table ---@field range? trouble.Range +---@field cwd? string local M = {} ---@param opts trouble.Item | {filename?:string} @@ -36,7 +37,8 @@ function M.new(opts) end assert(self.filename, "filename is required") if self.filename then - self.filename = vim.fs.normalize(self.filename) + local normalized = vim.fs.normalize(self.filename) + self.filename = self.cwd and vim.fs.joinpath(vim.fs.normalize(self.cwd), normalized) or normalized local parts = vim.split(self.filename, "/", { plain = true }) self.basename = table.remove(parts) self.dirname = table.concat(parts, "/") diff --git a/lua/trouble/sources/snacks.lua b/lua/trouble/sources/snacks.lua index 3e178a02..2ffe914c 100644 --- a/lua/trouble/sources/snacks.lua +++ b/lua/trouble/sources/snacks.lua @@ -38,6 +38,7 @@ function M.item(item) return Item.new({ source = "snacks", buf = item.buf, + cwd = item.cwd, filename = item.file, pos = item.pos, end_pos = item.end_pos,