-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new command: consult-lsp-file-symbols #13
Conversation
Thanks for the contribution, I'll take some time to check those!
|
consult-lsp.el
Outdated
(when consult-lsp-use-marginalia | ||
(require 'marginalia)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check shouldn't be necessary, because a user who wants to use marginalia is going to activate the minor-mode anyway, thus automatically requiring 'marginalia
consult-lsp.el
Outdated
(propertize (format " (%s)" | ||
(alist-get (get-text-property 0 'consult--type cand) | ||
lsp-symbol-kinds)) 'face 'font-lock-type-face) | ||
(when consult-lsp-use-marginalia |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that line should have the condition (and consult-lsp-use-marginalia (bound-and-true-p 'marginalia-mode))
consult-lsp.el
Outdated
(let ((line (thread-first symbol | ||
(lsp:document-symbol-selection-range) | ||
(lsp:range-start) | ||
(lsp:position-line) | ||
(lsp-translate-line))) | ||
(cbeg (thread-first symbol | ||
(lsp:document-symbol-selection-range) | ||
(lsp:range-start) | ||
(lsp:position-character) | ||
(lsp-translate-column))) | ||
(cend (thread-first symbol | ||
(lsp:document-symbol-selection-range) | ||
(lsp:range-end) | ||
(lsp:position-character) | ||
(lsp-translate-column)))) | ||
(let ((beg (lsp--line-character-to-point line cbeg)) | ||
(end (lsp--line-character-to-point line cend)) | ||
(marker (make-marker))) | ||
(set-marker marker beg) | ||
;; Pre-condition to respect narrowing | ||
(unless (or (< beg (point-min)) | ||
(> end (point-max))) | ||
(push (consult--location-candidate | ||
(consult--buffer-substring beg end 'fontify) | ||
marker | ||
(1+ line) | ||
'consult--type (lsp:symbol-information-kind symbol) | ||
'consult--name (lsp:symbol-information-name symbol)) | ||
candidates))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this is more of task for myself that I note here to remember) I will probably extract that snippet into its own consult-lsp--file-symbols--transformer
function, as I used the same naming convention for the functions that transform LSP data to candidates.
I think I should do better work around fontification, not sure how/if it's possible by using the LSP provided name though. I'd still rather lose the fontification and have the full |
I was not expecting such a detailed response in such a short time, interesting work!
I will try to review your branch and think about how I can contribute as soon as I have a bit of time. Cheers! |
Hi, Actually I pushed work directly on this branch (forgot GH allows to do that), so you can ignore the
(concat
(buffer-substr ... 'fontify)
(format " (%s)" (details?)) I might try to check later. |
Thanks for the idea, I'll merge it as is to work on #17 now, but if anything seems weird feel free to open a new PR ! |
Hello, thanks for the very useful package!
I have implemented an additional command which allows quickly searching through the symbols in the current file in a manner very similar to consult-line. Some general comments:
Let me know what you think!