Open RenWenshan opened 6 years ago
Please send a pull request and we will add it!
Given how eglot-server-programs
is laid out, it might make more sense to have Flow users specify the Flow command in their project's .dir-locals.el
. Since using the language server makes sense only for JavaScript projects with a .flowconfig
file, we can't simply prioritize the Flow server over the other JS servers in eglot-server-programs
lest we attempt to start the Flow server in a JS file corresponding to some non-Flow project.
What lsp-mode
does is (roughly): it prioritizes the Flow server over other JS servers when deciding what server to start, but it also checks for a .flowconfig
in the root directory, and if it detects none, then it will try to start a server with some lower priority.
Hmm, it would be beneficial to have it work OOTB though.
We already have eglot--eclipse-jdt-contact
, so why couldn't we add something similar for JS implementing a logic similar to the one used by lsp-mode
?
Oh, I wasn't aware that eglot-server-programs could have functions. Then I think your suggestion would work for JS as well.
On Thu, Jan 13, 2022 at 8:47 PM Stefan Kangas @.***> wrote:
Hmm, it would be beneficial to have it work OOTB though.
We already have eglot--eclipse-jdt-contact, so why couldn't we add something similar for JS implementing a logic similar to the one used by lsp-mode?
— Reply to this email directly, view it on GitHub https://github.com/joaotavora/eglot/issues/109#issuecomment-1012771356, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG65GOUKUAR5Y52XPB23NE3UV6TF7ANCNFSM4FUSCTVQ . You are receiving this because you commented.Message ID: @.***>
Has anyone been able to get eglot to work with the Flow server in a mono-repository?
eglot is always terminating immediately after I run it, complaining that it cannot find the .flowconfig
file. The reason for this is that somehow the flow server is not looking for it in the repository's root directory:
[stderr] Could not open_in_bin: '/home/miguel.guedes/repository/packages/libs/common/src/.flowconfig' ((Sys_error
[stderr] "/home/miguel.guedes/repository/packages/libs/common/src/.flowconfig: No such file or directory"))
You can see above that it complains that it can't find .flowconfig
in packages/libs/common/src
.
Is a special workspace configuration setting required?
Full initialization contents: https://pastebin.com/wSSdjgja
The command I specify to eglot is simply flow lsp
, as per the follow entry in my .dir-locals.el
:
(eval . (progn
(add-to-list 'eglot-server-programs
`(js-mode . ("/home/miguel.guedes/repository/node_modules/.bin/flow" "lsp")))))
To add something to eglot-server-programs
in .dir-locals
, don't use eval
, just set the variable directly, like this
((c++-mode . ((eglot-server-programs . ((c++-mode . "my-super-special-language-server"))))))
As to why your flow
program is looking for its configuration file there is beyond me :shrug: What does M-: (project-current)
say when you're in the file where you (presumably) typed M-x eglot
?
Thanks @joaotavora! Turns out the issue ran much deeper. I was using the projectile
package and it was somehow interfering with the project
package, causing eglot
to fail to determine the project's root directory.
In other words, my setup was (confusingly) at fault.
Good news. Eglot doesn't understand "projectile" things, because it doesn't depend on things that are outside Emacs. it only understands the default project.el
package, which is the official one in Emacs.
Given that the flow language server is now a public archive would it be safe to close the conversation?
language server: https://github.com/flowtype/flow-language-server