You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason finddir returns the full path on my system so getCwd() . finddir() causes the path to be /Users/user/path/to/project//Users/user/path/to/project/node_modules/.... I had to remove getCwd() calls from rescript#UpdateProjectEnv() and it all works. It's probably something about my setup but I cannot figure it out.
I've been running into an issue that looks very similar.
I can reproduce it by simply cloning the official project template and changing the current working directory to src. Plugin no longer works.
$ git clone https://github.com/rescript-lang/rescript-project-template.git
$ cd rescript-project-template
$ npm install
$ vim src/Demo.src # Works
$ cd src
$ vim Demo.src # FAIL
A bit more involved way to reproduce the problem is to create a monorepo setup with a single top-level node_modules and to change the current working directory to something more specific than the project root.
Minimal setup using npm workspaces (requires a relatively recent version of npm):
$ vim --version|head -n 1
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 13 2021 05:04:57)
$ vim packages/mydemo/src/Demo.res # Works
$ (cd ..; vim demo/packages/mydemo/src/Demo.res) # Works
$ (cd packages; vim mydemo/src/Demo.res) # FAIL
$ (cd packages/mydemo; vim src/Demo.res) # FAIL
$ (cd packages/mydemo/src; vim Demo.res) # FAIL
diff --git a/autoload/rescript.vim b/autoload/rescript.vim
index 14a7486..a3dcbc0 100644
--- a/autoload/rescript.vim
+++ b/autoload/rescript.vim
@@ -38,16 +38,16 @@ function! rescript#UpdateProjectEnv()
else
" Here we are handling a project that is based on the rescript npm package
" This package only uses a rescript.exe, no bsc, nor bsb
- let g:rescript_exe = getcwd() . "/" . l:res_bin_dir . "/rescript.exe"
+ let g:rescript_exe = fnamemodify(l:res_bin_dir, ":p:h") . "/rescript.exe"
endif
" These variables are only used in legacy mode (bs-platform based projects)
- let g:rescript_bsc_exe = getcwd() . "/" . l:res_bin_dir . "/bsc.exe"
- let g:rescript_bsb_exe = getcwd() . "/" . l:res_bin_dir . "/bsb.exe"
+ let g:rescript_bsc_exe = fnamemodify(l:res_bin_dir, ":p:h") . "/bsc.exe"
+ let g:rescript_bsb_exe = fnamemodify(l:res_bin_dir, ":p:h") . "/bsb.exe"
" Note that this doesn't find bsconfig when the editor was started without a
" specific file within the project
- let g:rescript_project_config = getcwd() . "/" . findfile("bsconfig.json", ".;")
+ let g:rescript_project_config = findfile("bsconfig.json", ".;")
" Try to find the nearest .git folder instead
if g:rescript_project_config == ""
After applying the patch all working directories seem to work as expected (both in vim and in Neovim).
The latter three will call rescript-editor-analysis.exe. The detected path shown by :RescriptInfo remains correct but the returned data is just null whenever the current working directory is something more specific than project root. This can be demonstrated with the official project template just by running cd src and trying to use those commands.
As a side note, I noticed that the analysis exe returns null type hint when no type hint is available. This causes a nasty-looking error message which could be handled better.
Activity
ryyppy commentedon Jul 6, 2021
what vim / nvim version?
leeN commentedon Aug 20, 2021
I have the same issue.
Vim: 8.2
Included patches: 1-2891
rnmmnen commentedon Feb 2, 2022
I've been running into an issue that looks very similar.
I can reproduce it by simply cloning the official project template and changing the current working directory to
src. Plugin no longer works.A bit more involved way to reproduce the problem is to create a monorepo setup with a single top-level
node_modulesand to change the current working directory to something more specific than the project root.Minimal setup using npm workspaces (requires a relatively recent version of npm):
Reproduction using Apple's default vim:
Reproduction using latest Neovim:
These changes fix the issue for me:
After applying the patch all working directories seem to work as expected (both in vim and in Neovim).
rnmmnen commentedon Feb 2, 2022
…or one could modify the l:res_bin_dir variable before these lines to save some cycles. 😉
rnmmnen commentedon Feb 11, 2022
Okay, the changes above were just a partial fix.
They fixed these:
rescript#Format(:RescriptFormat)rescript#Clean(:RescriptCleanand:RescriptCleanWithDeps)rescript#Build(:RescriptBuildand:RescriptBuildWithDeps)rescript#ReasonToRescript, too (:RescriptUpgradeFromReason)Didn't fix these:
rescript#TypeHint(:RescriptTypeHint)rescript#JumpToDefinition(:RescriptJumpToDefinition)rescript#Complete(omni completion).The latter three will call
rescript-editor-analysis.exe. The detected path shown by:RescriptInforemains correct but the returned data is justnullwhenever the current working directory is something more specific than project root. This can be demonstrated with the official project template just by runningcd srcand trying to use those commands.rnmmnen commentedon Feb 11, 2022
As a side note, I noticed that the analysis exe returns
nulltype hint when no type hint is available. This causes a nasty-looking error message which could be handled better.ryyppy commentedon Feb 14, 2022
Interesting 🤔
Thanks for the instructions to reproduce this issue. Will try it myself.