reddit / emacs

Configuring Emacs/Spacemacs to use flow-ls at a specific directory

jaydevel · 2022-05-26 19:20
I'm currently trying to use Spacemacs, because I love Vim's keybindings and found Spacemacs to be easy to install. The projects I'm working on have the following directory structure (company's repo, can't change it): /someproject/package.json (I don't use this) /someproject/pyproject.toml (The root is a Python project) /someproject/webapp/package.json (webapp is the root of a React/Flow project, does not contain any Python file) /someproject/webapp/.flowconfig (This is where flow-lsp should start) Python works like a charm! I'm still trying to properly configure Javascript/Flow in my Spacemacs installation, though. What I want is that, when I open a JS file inside webapp, it starts flow-lsp at the `/someproject/webapp` directory. However, flow-lsp is started at `/someproject`, which will fail because /someproject does not contain a .flowconfig file. My Spacemacs configuration layers is: dotspacemacs-configuration-layers '( (javascript :variables javascript-backend 'lsp js2-mode-show-strict-warnings nil js2-mode-show-parse-errors nil ) ... (lsp :variables lsp-lens-enable 1 lsp-use-lsp-ui 1 lsp-headerline-breadcrumb-segments '(project file symbols)) ...) I tried many combinations for the `projectile-project-root-functions` , this is the current one: '(projectile-project-root-functions '(projectile-root-top-down projectile-root-bottom-up projectile-root-local)) When I try to open a Javascript file, Emacs is stuck and I'm only able to know what's going on after I send SIGUSR2 to the process. I then can see that it's trying to load flow-ls and failing (and doing so infinitely): Could not open_in_bin: '/home/myuser/code/someproject/.flowconfig' ((Sys_error "/home/myuser/code/someproject/.flowconfig: No such file or directory")) Creating a `.projectile` in webapp does not work. How can I tell emacs to use the webapp directory for flow-ls?
yyoncho · 2022-05-26 19:34
use M-x lsp-workspace-folders-add/remove. lsp-mode will pick the nearest root.
jaydevel · 2022-05-30 15:24
Worked like a charm, thank you!