Eglot has some rules of thumb around how to find (guess) the project root. My guess is if no .git
then it would default to the directory where you opened emacs, or it would throw an error complaining about no :rootDirectory
, and that it must be manually configured. But I have not tried this.
From the eglot manal:
When Eglot starts a server program, it does so in the project’s root directory, which is usually the top-level directory of the project’s directory hierarchy. This ensures the language server has the same comprehensive view of the project’s files as you do.
For example, if you visit the file ~/projects/fooey/lib/x.foo and x.foo belongs to a project rooted at ~/projects/fooey (perhaps because a .git directory exists there), then M-x eglot causes the server program to start with that root as the current working directory. The server then will analyze not only the file lib/x.foo you visited, but likely also all the other *.foo files under the ~/projects/fooey directory.