nwolverson / purescript-language-server

MIT License
184 stars 42 forks source link

Not launching with NPM bin for purs executable #56

Closed sriharshachilakapati closed 5 years ago

sriharshachilakapati commented 5 years ago

We had some projects that are using different purescript compiler versions, and hence I decided to add the purescript version that we use as an NPM dev-dependency so that everyone will have the same compiler version.

However, I'm having some trouble trying to launch multiple projects at the same time (in different NVIM instances of course). I looked into the configuration, and added the purescript.addNpmPath key to true in the config JSON, but still using npm-bin was coming out as false.

let config =
    \ { 'purescript.autoStartPscIde': v:true
    \ , 'purescript.pscIdePort': v:null
    \ , 'purescript.autocompleteAddImport': v:true
    \ , 'purescript.pursExe': 'purs'
    \ , 'purescript.trace.server': 'verbose'
    \ , 'purescript.addNpmPath': v:true
    \ }

This is the output I'm getting from the language server client. Can you explain what am I doing wrong here?

[LC] [Log] Starting with args: [ "/Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/node", "/Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/purescript-language-server", "--stdio", "--config", "{\"purescript.pscIdePort\": null, \"purescript.addNpmPath\": true, \"purescript.autocompleteAddImport\": true, \"purescript.trace.server\": \"verbose\", \"purescript.autoStartPscIde\": true, \"purescript.pursExe\": \"purs\"}" ]
[LC] [Log] Starting with cwd: /Users/sriharshachilakapati/Projects/*****-*******-**** and using root path: /Users/sriharshachilakapati/Projects/*****-*******-****
[LC] [Info] Resolved IDE server paths (npm-bin: false) from PATH of /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin:/Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin:/Users/sriharshachilakapati/.jenv/shims:/Users/sriharshachilakapati/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin:/Users/sriharshachilakapati/.jenv/shims:/Users/sriharshachilakapati/bin:/Users/sriharshachilakapati/Library/Android/sdk/build-tools/:/Users/sriharshachilakapati/Library/Android/sdk/platform-tools/:/Users/sriharshachilakapati/Library/Android/sdk/tools/:/Users/sriharshachilakapati/Library/Android/sdk/build-tools/:/Users/sriharshachilakapati/Library/Android/sdk/platform-tools/:/Users/sriharshachilakapati/Library/Android/sdk/tools/ (1st is used):
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/purs: 0.12.3
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin/purs: 0.11.7
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin/purs: 0.11.7
[LC] [Warning] Found multiple IDE server executables; using /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/purs
[LC] [Info] Found existing port from file: 15275
[LC] [Info] Starting IDE server on port 15965 with cwd
[LC] [Log] Started IDE server (port 15965)
[LC] [Info] [Error] Version mismatch for the externs at: /Users/sriharshachilakapati/Projects/*****-*******-****/output/Control.Monad.Except.Trans/externs.js Expected: 0.12.3 Found: 0.12.2
sriharshachilakapati commented 5 years ago

This is because of incorrect understanding of VS-Code plugin architecture. I didn't know that VSCode will strip the section name and give only the rest.

From NVIM, I have to pass this configuration instead:

let config =
    \ { 'autoStartPscIde': v:true
    \ , 'pscIdePort': v:null
    \ , 'autocompleteAddImport': v:true
    \ , 'pursExe': 'purs'
    \ , 'addNpmPath': v:true
    \ }

I also cannot find the use of the string trace.server in the language server, so I guess it is VS Code's plugin parameter and not for the language server. The best I can do instead is to set LanguageClient's options:

let g:LanguageClient_trace="verbose"
let g:LanguageClient_loggingLevel="INFO"

Got confused by this because I have to send the prefix purescript. to commands. Can this be added to the readme file to avoid confusion?

sriharshachilakapati commented 5 years ago

But even after changing the configuration to that, this is not being picked up. New traces.

[LC] Project root: /Users/sriharshachilakapati/Projects/*****-*******-****
[LC] [Info] Starting IDE server
[LC] [Log] PureScript Language Server started
[LC] [Info] {"capabilities":{"textDocument":{"colorProvider":null,"completion":{"completionItem":{"snippetSupport":false}},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true}}},"processId":47249,"rootPath":"/Users/sriharshachilakapati/Projects/*****-*******-****","rootUri":"file:///Users/sriharshachilakapati/Projects/*****-*******-****","trace":"off"}
[LC] [Log] Starting with args: ["/Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/node","/usr/local/bin/purescript-language-server","--stdio","--config","{\"purescript.pscIdePort\": null, \"purescript.addNpmPath\": true, \"purescript.autocompleteAddImport\": true, \"purescript.trace.server\": \"verbose\", \"addNpmPath\": true, \"purescript.autoStartPscIde\": true, \"purescript.pursExe\": \"purs\"}"]
[LC] [Log] Starting with cwd: /Users/sriharshachilakapati/Projects/*****-*******-**** and using root path: /Users/sriharshachilakapati/Projects/*****-*******-****
[LC] [Info] Resolved IDE server paths (npm-bin: false) from PATH of /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin:/Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin:/Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin:/Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin:/Users/sriharshachilakapati/.jenv/shims:/Users/sriharshachilakapati/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin:/Users/sriharshachilakapati/.jenv/shims:/Users/sriharshachilakapati/bin:/Users/sriharshachilakapati/Library/Android/sdk/build-tools/:/Users/sriharshachilakapati/Library/Android/sdk/platform-tools/:/Users/sriharshachilakapati/Library/Android/sdk/tools/:/Users/sriharshachilakapati/Library/Android/sdk/build-tools/:/Users/sriharshachilakapati/Library/Android/sdk/platform-tools/:/Users/sriharshachilakapati/Library/Android/sdk/tools/ (1stis used):
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/purs: 0.12.3
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin/purs: 0.11.7
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/purs: 0.12.3
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin/purs: 0.11.7
[LC] [Info] /Users/sriharshachilakapati/.nvm/versions/node/v9.5.0/bin/purs: 0.11.7
[LC] [Warning] Found multiple IDE server executables; using /Users/sriharshachilakapati/.nvm/versions/node/v11.9.0/bin/purs
[LC] [Info] Found existing port from file: 15345

Any ideas where I'm doing wrong?

sriharshachilakapati commented 5 years ago

@nwolverson Can you please help me out regarding this issue?

I think it's only a configuration issue, but need help in figuring out the correct JSON to pass to language server.

sriharshachilakapati commented 5 years ago

Bump

sriharshachilakapati commented 5 years ago

Finally was able to figure out after going through the atom-ide plugin's code. This is the correct config to be passed.

let config =
    \ { 'autoStartPscIde': v:true
    \ , 'pscIdePort': v:null
    \ , 'autocompleteAddImport': v:true
    \ , 'pursExe': 'purs'
    \ , 'addNpmPath': v:true
    \ }

let configWrapper =
    \ { 'purescript': config
    \ }

Sending configWrapper now to language server solved this issue. However, this information is hard to find. Can you add this to the README?