There doesn't seem to be an option to make the directory relative to either cwd or the lsp root, but I'm able to override the directory formatter with my own implementation
require("trouble.format").formatters.directory = function(ctx)
if ctx.node:source() == "fs" then
local directory = ctx.item.directory or ""
local parent = ctx.node:parent_item()
if parent and parent.directory then
directory = directory:sub(#parent.directory + 1)
return { text = directory, hl = "TroubleDirectory" }
end
-- Truncate cwd
local cwd = (vim.uv or vim.loop).cwd()
if cwd and string.find(directory, cwd .. "/", 0, true) == 1 then
directory = directory:sub(#cwd + 2)
end
return { text = vim.fn.fnamemodify(directory, ":~"), hl = "TroubleDirectory" }
end
end
Describe the solution you'd like
An option to display paths relative to the cwd or lsp root. Or an option to customize the formatters from format.lua, as the way I'm doing it seems hacky.
Did you check the docs?
Is your feature request related to a problem? Please describe.
My previous issue https://github.com/folke/trouble.nvim/issues/330 got closed when Trouble v3 came out. But I still see absolute paths.
There doesn't seem to be an option to make the directory relative to either cwd or the lsp root, but I'm able to override the
directory
formatter with my own implementationDescribe the solution you'd like
An option to display paths relative to the cwd or lsp root. Or an option to customize the formatters from
format.lua
, as the way I'm doing it seems hacky.Describe alternatives you've considered
n/a
Additional context
No response