-
-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: new lsp-clients-flow
customize var to use the flow
binary in node_modules/.bin
#1889
Comments
Customization via dir locals is supported - check https://emacs-lsp.github.io/lsp-mode/page/faq/ and I think that a variable can be marked as safe either in our code or in your config.
What we can do is to do that check automatically and use the local version. But with one limitation - the project root is selected after the check if language server is present. Then in order that to work you should first add the workspace folder via M-x lsp-workspace-folders-add and then open a file. |
Another option is to support placeholders in the path, e. g.: "{workspace-root}/.npm/flowjs". Then lsp-mode will expand {workspace-root} with the correct workspace root. |
Ah, I had missed that FAQ entry. I will try it out.
I ended up doing this with a giant hammer:
Ah, I didn't know that. The main intent behind this feature request is to give us a more out-of-the-box setup. (Chasing after VSCode!) If we have to select the root beforehand, that is just another kind of configuration. Probably less complicated than the local variables setup, though 🙂 . |
If we did automatically first try to find But I think the workflow would be unintuitive to new users. They'd have their flow skipped for a typescript server, then have to investigate the logs to find out that they needed to specify the workspace root beforehand. Then they'd have to do that and restart the server for the workspace. |
We can mark the variable as safe.
Agree.
That is true. In the beginning, I thought that |
I think also that in the early stage of the project the idea was to use |
@isker Have you tried add-node-modules-path? |
We could also take the approach that I do in Apheleia, and---when configured---try to locate a per-project binary via This would also solve the issue where |
The recommended way to install flow is as a non-global (i.e. project-local) npm dependency.
Since the same npm dependency implements flow's language server, the median
lsp-mode
flow user has to customizelsp-clients-flow-server
away from the default "flow
onexec-path
" to point to their project-localflow
, located atnode_modules/.bin/flow
. (I personally have no globalflow
on my exec-path at all, which meanslsp-mode
will select the typescript server as a fallback in my flow projects when this variable is not correctly configured. Not fun!)Customizing
lsp-clients-flow-server
per-project effectively is surprisingly hard:lsp-mode
, it seems like lsp-mode selects the server before dirlocal variables are set (!?), thus the configuration has no effect until you manually restart the workspace's language server.direnv
andemacs-direnv
to put the project-localflow
on yourPATH
when visiting files within your project. However, a similar problem exists here as for dirlocal variables. lsp-mode launches a server beforedirenv-mode
has a chance to updateexec-path
. There are various workarounds proposed, but none of them work for me :).With all of that in mind, I think providing a new customize variable within
lsp-mode
itself to use the workspace-local npmflow
binary could make this a lot easier.Thanks for your consideration.
(I'm not great at emacs lisp, but if you can point me to any examples of resolving files relative to the workspace root, I think I could implement this myself.)
The text was updated successfully, but these errors were encountered: