Skip to content

Commit

Permalink
feat: added basename/dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 30, 2024
1 parent a29c293 commit bb3740a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/trouble/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ M.formatters = {
text = vim.fn.fnamemodify(ctx.item.filename, ":p:~:."),
}
end,
dirname = function(ctx)
return {
text = vim.fn.fnamemodify(ctx.item.dirname, ":p:~:."),
}
end,
}
M.formatters.severity_icon = M.cached_formatter(M.formatters.severity_icon, "severity")
M.formatters.severity = M.cached_formatter(M.formatters.severity, "severity")
Expand Down
2 changes: 2 additions & 0 deletions lua/trouble/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function M.new(opts)
local self = setmetatable(opts, M)
self.filename = self.filename or vim.fn.bufname(self.buf)
self.filename = vim.fn.fnamemodify(self.filename, ":p")
self.basename = vim.fn.fnamemodify(self.filename, ":t")
self.dirname = vim.fn.fnamemodify(self.filename, ":h")
self.cache = Cache.new("item")
return self
end
Expand Down

0 comments on commit bb3740a

Please sign in to comment.