mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
fix(completion/marginalia): improve issues with project-buffer annotations
Show project relative file paths even when project root and file paths start with a mixure of "~/" and absolute path. Also handle buffers not backed by a file on disk by falling back onto marginalia--buffer-file.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
(require 'siren-cape)
|
||||
(require 'siren-company)
|
||||
(require 'siren-copilot)
|
||||
(require 'siren-marginalia)
|
||||
|
||||
;; Documentation
|
||||
(require 'siren-dash-at-point)
|
||||
@@ -38,7 +39,6 @@
|
||||
(require 'siren-display-indentation)
|
||||
(require 'siren-display-line-numbers)
|
||||
(require 'siren-embark)
|
||||
(require 'siren-marginalia)
|
||||
(require 'siren-minions)
|
||||
(require 'siren-mwim)
|
||||
(require 'siren-origami)
|
||||
|
||||
@@ -63,11 +63,15 @@ mode."
|
||||
:face 'marginalia-file-name))))
|
||||
|
||||
(defun marginalia--project-buffer-file (buffer)
|
||||
"Return the file or process name of BUFFER relative to project root, if it
|
||||
is within project root."
|
||||
(let ((root (marginalia--project-root))
|
||||
(file (marginalia--buffer-file buffer)))
|
||||
(if (string-equal root file) file
|
||||
"Return the file or process name of BUFFER relative to project root."
|
||||
(let* ((root (expand-file-name (marginalia--project-root)))
|
||||
(raw-file (marginalia--buffer-file buffer))
|
||||
(file (if (string-prefix-p "~/" raw-file)
|
||||
(expand-file-name raw-file)
|
||||
raw-file)))
|
||||
(if (or (string-empty-p root)
|
||||
(string-equal root file))
|
||||
raw-file
|
||||
(string-remove-prefix root file))))
|
||||
|
||||
:config
|
||||
Reference in New Issue
Block a user