emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xref completion


From: William Xu
Subject: Re: Xref completion
Date: Sun, 06 Dec 2020 15:00:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin)

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. 

> 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".

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<------------------------------------- 

-- 
William




reply via email to

[Prev in Thread] Current Thread [Next in Thread]