|
From: | Dmitry Gutov |
Subject: | Re: Xref completion |
Date: | Sun, 6 Dec 2020 23:01:36 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 06.12.2020 16:00, William Xu wrote:
Dmitry Gutov <dgutov@yandex.ru> writes:It could also be a limitation of the LSP protocol (looking at https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#location, it doesn't have a field for "line text").Would have been nicer if the protocol supports it, then one won't have to look into the file manually.
Someone should probably look into bringing that up to LSP folks, but even if successful, that's going to be a long process.
But if so, maybe Eglot could visit the files preemptively and extract the line contents. Unlike some other operations, there's unlikely to be many results in that list, so it shouldn't take long. It seems to be trying to do something like this already: https://github.com/joaotavora/eglot/blob/master/eglot.el#L1927, maybe file a report for this particular case.Thanks for the info. My usecase is running the ccls via docker, so the file path reported by ccls is inside the docker. No wonder Eglot fails to find the file, thus falling back to so called "dumb strategy".
IDK, if Eglot knows how to navigate to a file, it will know how to read a line from it. So it should be possible to add that behavior.
What the performance is going to be, however, is something we'll only know after we try.
I could work around it by changing the file path: ---------------------------------8<------------------------------------- (defun xwl-convert-to-docker-path (file) (if (and (string-match "foo" (cdr (project-current))) (string-match "^/usr/include/" file)) (concat "/docker:foo:" file) file)) (defun xwl-check-docker (orig-fun file &rest args) (or (ignore-errors (apply orig-fun (cons file args))) (apply orig-fun (cons (xwl-convert-to-docker-path file) args)))) (advice-add 'file-readable-p :around 'xwl-check-docker) (advice-add 'insert-file-contents :around 'xwl-check-docker) ---------------------------------8<-------------------------------------
Advising these common functions looks suspicious to me. But hey, if it works, it works. You could also try editing the project via Tramp. Not sure if Eglot supports that (if it does not, adding support shouldn't be too hard), but apparently lsp-mode does.
[Prev in Thread] | Current Thread | [Next in Thread] |