{"action":"created","issue":{"url":"https://api.github.com/repos/joaotavora/eglot/issues/76","repository_url":"https://api.github.com/repos/joaotavora/eglot","labels_url":"https://api.github.com/repos/joaotavora/eglot/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/joaotavora/eglot/issues/76/comments","events_url":"https://api.github.com/repos/joaotavora/eglot/issues/76/events","html_url":"https://github.com/joaotavora/eglot/issues/76","id":351818845,"node_id":"MDU6SXNzdWUzNTE4MTg4NDU=","number":76,"title":"Enabling eglot in files outside current project after following xrefs","user":{"login":"mkcms","id":10572727,"node_id":"MDQ6VXNlcjEwNTcyNzI3","avatar_url":"https://avatars2.githubusercontent.com/u/10572727?v=4","gravatar_id":"","url":"https://api.github.com/users/mkcms","html_url":"https://github.com/mkcms","followers_url":"https://api.github.com/users/mkcms/followers","following_url":"https://api.github.com/users/mkcms/following{/other_user}","gists_url":"https://api.github.com/users/mkcms/gists{/gist_id}","starred_url":"https://api.github.com/users/mkcms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkcms/subscriptions","organizations_url":"https://api.github.com/users/mkcms/orgs","repos_url":"https://api.github.com/users/mkcms/repos","events_url":"https://api.github.com/users/mkcms/events{/privacy}","received_events_url":"https://api.github.com/users/mkcms/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-08-18T13:03:48Z","updated_at":"2018-12-13T15:57:14Z","closed_at":null,"author_association":"COLLABORATOR","body":"When I find a definition outside current project, eglot is either not enabled or enabled, but using a different server. I'd like to have it enabled and using the same server where it came from, unless I explicitly started it with `eglot` or there was already a server managing this buffer started with `eglot-ensure`, but not in a transient project."},"comment":{"url":"https://api.github.com/repos/joaotavora/eglot/issues/comments/447020149","html_url":"https://github.com/joaotavora/eglot/issues/76#issuecomment-447020149","issue_url":"https://api.github.com/repos/joaotavora/eglot/issues/76","id":447020149,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzAyMDE0OQ==","user":{"login":"joaotavora","id":387011,"node_id":"MDQ6VXNlcjM4NzAxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/387011?v=4","gravatar_id":"","url":"https://api.github.com/users/joaotavora","html_url":"https://github.com/joaotavora","followers_url":"https://api.github.com/users/joaotavora/followers","following_url":"https://api.github.com/users/joaotavora/following{/other_user}","gists_url":"https://api.github.com/users/joaotavora/gists{/gist_id}","starred_url":"https://api.github.com/users/joaotavora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaotavora/subscriptions","organizations_url":"https://api.github.com/users/joaotavora/orgs","repos_url":"https://api.github.com/users/joaotavora/repos","events_url":"https://api.github.com/users/joaotavora/events{/privacy}","received_events_url":"https://api.github.com/users/joaotavora/received_events","type":"User","site_admin":false},"created_at":"2018-12-13T15:57:14Z","updated_at":"2018-12-13T15:57:14Z","author_association":"OWNER","body":"> There's no request method AFAICS. But what I was thinking is using xref-after-jump-hook to detect when eglot opened a file in some directory, then adding that directory to project-external-roots\r\n\r\nYou're always free to try of course, but eventually one would have to solve the following problems, or at least a part of the following problems:\r\n\r\n* how are you going to tell the function that you put in `xref-after-jump-hook` that you came from a particular `eglot-lsp-server` instance? A variable? Keep in mind that the `*xref*` buffer can sometimes be used and sometiems not, and it can linger on for a while, so it would have to be a buffer-local variable of that specific buffer.  But how to set it there?  All you have is `xref--xref-buffer-mode-hook` . \r\n\r\n* when you land in a file and you know the `eglot-lsp-server` what are you going to do? I think it is too late by the time of `xref-after-jump-hook`.  You want the external roots of the `eglot-lsp-server`s' project to be correctly setup so that by the time you find that file, `eglot--maybe-activate-editing-mode` does its job and eglot is all setup there.\r\n\r\n* Then you have the problem of some directories (some \"roots\") being shared by more than one project, which means they are shared by more than one server.  I say we warn the user, at the most and only if it's easy to tell what happened, and don't even try to tackle this problem for now.\r\n\r\nI think the best way to solve this is to greedily and collect directories to feed `project-external-roots` as soon as we get them from the server like in `xref-backend-definitions` and, if they are outside `project-roots`, save them in the server as `external-roots`.  Then, in a global `:around` method for `project-external-roots` try to match the `PROJECT` argument to one of our servers (using `eglot--servers-by-project`) and return those dirs along with whatever `call-next-method` returns.\r\n\r\nNow `project.el` and the usual Eglot machinery should hopefully do the rest so that when you go to an xref everything should be setup neatly. Unfortunately, it's not enough because I don't think `project-current` considers external roots.  So we probably have to add a global `eglot--find-project` to `project-find-functions` (desirably at the end)  that returns the matching project, or nil.\r\n\r\nMakes sense?\r\n\r\n"}}
{"actor":{"display_login":"joaotavora"}}