Giter VIP home page Giter VIP logo

Comments (16)

nwolverson avatar nwolverson commented on July 21, 2024 1

Great you got it working. Just now I'm firmly of the mind that the root directory should be passed to the language server correctly corresponding to the actual PS project root; in particular if a higher-level directory is passed there could be multiple PS projects somewhere under that, and this server is not multi-root capable (not to mention they might be under dependencies). I'm open to a config option pointing to the actual project root if that is generally useful, though it's a bit redundant.

Regarding the first hover, I wonder if that's just a timing issue, the purs ide server process is started up which must load module information, maybe just wasn't ready?

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

Here's what I got so far. I've installed the server, set up the language server client to start the server for purescript files. It works using stdio so the --stdio flag is added. I also noted in #38 that you suggested adding an empty config since the server needs it and this is what vscode does. Without the --config {} flag the server doesn't output anything. Then, opening a purescript file in a newly initialized project gives the following output on the client and server:

nvim src/Main.purs

LanguageServer.log :

(node:27970) UnhandledPromiseRejectionWarning: Error: Message not handled: MethodCall { jsonrpc: Some(V2), method: "window/showMessageRequest", params: Map({"actions": Array([]), "message": String("It doesn\'t look like the workspace root is a PureScript project (has bower.json/psc-package.json). The PureScript project should be opened as a root workspace folder."), "type": Number(1)}), id: Num(0) }
    at new ResponseError (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/messages.js:46:28)
    at handleResponse (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:430:48)
    at processMessageQueue (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:258:17)
    at Immediate.<anonymous> (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:242:13)
    at processImmediate (timers.js:632:19)
(node:27970) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27970) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

LanguageClient.log :

11:11:00 ERROR main src/vim.rs:60 Error handling message: Message not handled: MethodCall { jsonrpc: Some(V2), method: "window/showMessageRequest", params: Map({"actions": Array([Object({"title": String("Build project")})]), "message": String("Output directory does not exist at \'output\'. Ensure project is built, or check configuration of output directory and build command."), "type": Number(2)}), id: Num(1) }

Message: {"jsonrpc":"2.0","method":"window/showMessageRequest","params":{"actions":[{"title":"Build project"}],"message":"Output directory does not exist at 'output'. Ensure project is built, or check configuration of output directory and build command.","type":2},"id":1}

Error: ErrorMessage { msg: "Message not handled: MethodCall { jsonrpc: Some(V2), method: \"window/showMessageRequest\", params: Map({\"actions\": Array([Object({\"title\": String(\"Build project\")})]), \"message\": String(\"Output directory does not exist at \\\'output\\\'. Ensure project is built, or check configuration of output directory and build command.\"), \"type\": Number(2)}), id: Num(1) }" }
11:11:00 INFO main src/vim.rs:93 => Some("purescript") {"jsonrpc":"2.0","error":{"code":-32603,"message":"Message not handled: MethodCall { jsonrpc: Some(V2), method: \"window/showMessageRequest\", params: Map({\"actions\": Array([Object({\"title\": String(\"Build project\")})]), \"message\": String(\"Output directory does not exist at \\'output\\'. Ensure project is built, or check configuration of output directory and build command.\"), \"type\": Number(2)}), id: Num(1) }"},"id":1}
11:11:00 INFO reader-purescript src/vim.rs:396 <= Some("purescript") {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"Error: Message not handled: MethodCall { jsonrpc: Some(V2), method: \"window/showMessageRequest\", params: Map({\"actions\": Array([Object({\"title\": String(\"Build project\")})]), \"message\": String(\"Output directory does not exist at \\'output\\'. Ensure project is built, or check configuration of output directory and build command.\"), \"type\": Number(2)}), id: Num(1) }\n    at new ResponseError (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/messages.js:46:28)\n    at handleResponse (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:430:48)\n    at processMessageQueue (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:258:17)\n    at Immediate.<anonymous> (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:242:13)\n    at processImmediate (timers.js:632:19)"}}
11:11:00 INFO main src/languageclient.rs:1869 Begin window/logMessage
11:11:00 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"s:Echomsg","params":["[Error] Error: Message not handled: MethodCall { jsonrpc: Some(V2), method: \"window/showMessageRequest\", params: Map({\"actions\": Array([Object({\"title\": String(\"Build project\")})]), \"message\": String(\"Output directory does not exist at \\'output\\'. Ensure project is built, or check configuration of output directory and build command.\"), \"type\": Number(2)}), id: Num(1) }\n    at new ResponseError (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/messages.js:46:28)\n    at handleResponse (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:430:48)\n    at processMessageQueue (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:258:17)\n    at Immediate.<anonymous> (/Users/alextes/.nvm/versions/node/v11.6.0/lib/node_modules/purescript-language-server/node_modules/vscode-jsonrpc/lib/main.js:242:13)\n    at processImmediate (timers.js:632:19)"]}
11:11:00 INFO main src/languageclient.rs:1878 End window/logMessage

Not sure where to go from here. I could start comparing this server's initialization to others, but I'm guessing that would be a steep climb. Maybe you have a better suggestion for where to go from here?

from purescript-language-server.

nwolverson avatar nwolverson commented on July 21, 2024

So it looks like the server is starting up and trying to do a window/showMessageRequest because it's not being run in the expected context of a PureScript project - but I'm not clear where the "Message not handled" is coming from - I wonder if this is supported on the language client side, but I'm confused why the error is raised on the server - I'm guessing the failure bounces back to the server which then seems to be logging it to the client via window/logMessage...

It looks like window/showMessageRequest is not supported autozimu/LanguageClient-neovim#177

Regarding "a purescript project" - what the message is trying to tell you is that the workspace folder (cwd of the lsp server? I forget) should be a PS project with bower.json or psc-package.json, best also build normally before starting (eg with pulp) so that that folder has an output directory at output.

Definitely interested in trying to get this running with other clients, I started last night trying to improve command line options a little and allow writing messages to a log file which could also help with such integrations.

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

I came across the 'you didn't build the project error.' The above output is after running pulp build.

I think we can skip supporting the showMessageRequest. I'm guessing the value of the Build Project action is minor for vim users. Not to mention the difficulty of making the client + neovim throw up some interactable notification. Which like you mentioned, is probably offered because the server is not seeing the output/ folder in the project directory, and less interesting anyway as soon as it does. The client also appears fine not handling the request and moving on. Whether the server is too I guess we'll find out after the working directory gets set correctly.

I notice that whenever I open a file of a certain filetype for the first time, the language client flashes a message that it's telling the server what this file's project root is. I guess I can start by figuring out if this path is passed correctly on initialization for purescript files.

from purescript-language-server.

nwolverson avatar nwolverson commented on July 21, 2024

As long as the showMessageRequest produces a bunch of error spam it has the intended effect of raising the issue it is mentioning :)

I have a feeling that the server may be using its cwd instead of the workspace root it's passed, I can believe they happen to be the same for the existing plugins but the assumption is not valid (also I think the way this worked changed in some version of the protocol). I'll check this logic later

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

I took a look at the source code but I'm not quite there when it comes to PureScript 😅 , I can see where it's pulling out the path but can't tell if it's being replaced or how to log it before it's passed along.

from purescript-language-server.

nwolverson avatar nwolverson commented on July 21, 2024

So I see I was using rootPath which is now deprecated in favour of rootUri for build and IDE server things, but the checks on output and package file were using the cwd instead.

I've just pushed 0.12.4 which should fix all this to prefer rootUri > rootPath > cwd.

Also should be able to pass --log <file> to dump logs to a file for the messages that are sent to the client (there is some config to log more from the underlying IDE server which will be included in this)

workspaceFolders are not used, the server does not support multi-root natively (launch 1 per root folder instead)

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

Awesome. That diff will be a good lesson in PureScript. I'll try and test later today!
Thanks!

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

There still seem to be different expectations between the client and the server 🙈 .
With the clean project src/ ends up being inferred as root.

11:03:28 INFO main src/languageclient.rs:1685 Begin textDocument/didOpen
11:03:28 INFO main src/languageclient.rs:30 Some arguments are not available. Requesting from vim. Keys: ["text"]. Exps: ["LSP#text()"]
11:03:28 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text()]"],"id":14}
11:03:28 INFO reader-main src/vim.rs:396 <= None {"id": 14, "jsonrpc": "2.0", "result": [["module Main where", "", "import Prelude", "import Effect (Effect)", "import Effect.Console (log)", "", "main :: Effect Unit", "main = do", "  log \"Hello sailor!\"", ""]]}
11:03:28 INFO main src/languageclient.rs:49 gather_args: [LanguageId, Filename, Text] = [String("purescript"), String("/Users/alextes/code/pls/src/Main.purs"), Array([String("module Main where"), String(""), String("import Prelude"), String("import Effect (Effect)"), String("import Effect.Console (log)"), String(""), String("main :: Effect Unit"), String("main = do"), String("  log \"Hello sailor!\""), String("")])]
11:03:28 INFO main src/vim.rs:93 => Some("purescript") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"purescript","text":"module Main where\n\nimport Prelude\nimport Effect (Effect)\nimport Effect.Console (log)\n\nmain :: Effect Unit\nmain = do\n  log \"Hello sailor!\"\n","uri":"file:///Users/alextes/code/pls/src/Main.purs","version":0}}}
11:03:28 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"execute","params":["setlocal omnifunc=LanguageClient#complete"],"id":15}
11:03:28 INFO reader-main src/vim.rs:396 <= None {"id": 15, "jsonrpc": "2.0", "result": 0}
11:03:28 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/Users/alextes/code/pls/src/Main.purs","LanguageClient_projectRoot","/Users/alextes/code/pls/src"]}
11:03:28 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientTextDocumentDidOpenPost"]}
11:03:28 INFO main src/languageclient.rs:1723 End textDocument/didOpen

Which causes the server to look for output in:

[Info] Retrying starting server after 500ms: Error: Couldn't locate your output directory at: /Users/alextes/code/pls/src/output/

Oddly, and perhaps best to ignore for now, I have another project where the frontend and backend share a repo. Putting the frontend and thus PS project one level down from the root, here the opposite happens and the output/ directory is checked for in the real root, one level up from the PS root 🙈 :

10:59:21 INFO main src/languageclient.rs:1685 Begin textDocument/didOpen
10:59:21 INFO main src/languageclient.rs:30 Some arguments are not available. Requesting from vim. Keys: ["text"]. Exps: ["LSP#text()"]
10:59:21 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text()]"],"id":14}
10:59:21 INFO reader-main src/vim.rs:396 <= None {"id": 14, "jsonrpc": "2.0", "result": [["module Main where", "", "import Prelude", "import Effect (Effect)", "import Effect.Console (log)", "", "main :: Effect Unit", "main = do", "  log \"Hello sailor!\"", ""]]}
10:59:21 INFO main src/languageclient.rs:49 gather_args: [LanguageId, Filename, Text] = [String("purescript"), String("/Users/alextes/code/supple/frontend-ps/src/Main.purs"), Array([String("module Main where"), String(""), String("import Prelude"), String("import Effect (Effect)"), String("import Effect.Console (log)"), String(""), String("main :: Effect Unit"), String("main = do"), String("  log \"Hello sailor!\""), String("")])]
10:59:21 INFO main src/vim.rs:93 => Some("purescript") {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"purescript","text":"module Main where\n\nimport Prelude\nimport Effect (Effect)\nimport Effect.Console (log)\n\nmain :: Effect Unit\nmain = do\n  log \"Hello sailor!\"\n","uri":"file:///Users/alextes/code/supple/frontend-ps/src/Main.purs","version":0}}}
10:59:21 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"execute","params":["setlocal omnifunc=LanguageClient#complete"],"id":15}
10:59:21 INFO reader-main src/vim.rs:396 <= None {"id": 15, "jsonrpc": "2.0", "result": 0}
10:59:21 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"setbufvar","params":["/Users/alextes/code/supple/frontend-ps/src/Main.purs","LanguageClient_projectRoot","/Users/alextes/code/supple"]}
10:59:21 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"s:ExecuteAutocmd","params":["LanguageClientTextDocumentDidOpenPost"]}
10:59:21 INFO main src/languageclient.rs:1723 End textDocument/didOpen
[Error] Error: Couldn't locate your output directory at: /Users/alextes/code/supple/output/

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

Ah, figured out why the latter is happening. Spotted a:

11:09:01 ERROR main src/languageclient.rs:1986 Error: ErrorMessage { msg: "No project root found! languageId: purescript" }

Haven't looked at the underlying logic, but git folder is one factor. My clean PureScript project wasn't initialized as a git repo. It would be cool if the nested PureScript project case is handled, but I'd suggest I make a separate issue for that now, and if upvotes come in we can take it from there.

So, after initializing a git repo, the language client finds the root and communicates
Hoorray 🙌 , we have a working language client. Thanks!

There is one odd bug remaining. The first hover does nothing, subsequent hovers succeed. Here is what the client logs for the first and second hover command. The two are separated by whitespace. The server log is clean.

11:20:29 INFO reader-main src/vim.rs:396 <= None {"id": 1, "jsonrpc": "2.0", "method": "textDocument/hover", "params": {"bufnr": 1, "character": 2, "handle": true, "languageId": "purescript", "line": 8, "text": ["module Main where", "", "import Prelude", "import Effect (Effect)", "import Effect.Console (log)", "", "main :: Effect Unit", "main = do", "  log \"Hello sailor!\"", ""], "filename": "/Users/alextes/code/pls/src/Main.purs"}}
11:20:29 INFO main src/languageclient.rs:1728 Begin textDocument/didChange
11:20:29 INFO main src/languageclient.rs:49 gather_args: [Bufnr, LanguageId, Filename] = [Number(1), String("purescript"), String("/Users/alextes/code/pls/src/Main.purs")]
11:20:29 INFO main src/languageclient.rs:30 Some arguments are not available. Requesting from vim. Keys: ["LSP#text(1)"]. Exps: ["LSP#text(1)"]
11:20:29 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text(1)]"],"id":17}
11:20:29 INFO reader-main src/vim.rs:396 <= None {"id": 17, "jsonrpc": "2.0", "result": [["module Main where", "", "import Prelude", "import Effect (Effect)", "import Effect.Console (log)", "", "main :: Effect Unit", "main = do", "  log \"Hello sailor!\"", ""]]}
11:20:29 INFO main src/languageclient.rs:49 gather_args: ["LSP#text(1)"] = [Array([String("module Main where"), String(""), String("import Prelude"), String("import Effect (Effect)"), String("import Effect.Console (log)"), String(""), String("main :: Effect Unit"), String("main = do"), String("  log \"Hello sailor!\""), String("")])]
11:20:29 INFO main src/languageclient.rs:1752 Texts equal. Skipping didChange.
11:20:29 INFO main src/languageclient.rs:987 Begin textDocument/hover
11:20:29 INFO main src/languageclient.rs:49 gather_args: [LanguageId, Filename, Line, Character, Handle] = [String("purescript"), String("/Users/alextes/code/pls/src/Main.purs"), Number(8), Number(2), Bool(true)]
11:20:29 INFO main src/vim.rs:93 => Some("purescript") {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":2,"line":8},"textDocument":{"uri":"file:///Users/alextes/code/pls/src/Main.purs"}},"id":18}
11:20:29 INFO reader-purescript src/vim.rs:396 <= Some("purescript") {"jsonrpc":"2.0","id":18,"result":null}
11:20:29 INFO main src/languageclient.rs:1034 End textDocument/hover
11:20:29 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","result":null,"id":1}










11:20:39 INFO reader-main src/vim.rs:396 <= None {"id": 2, "jsonrpc": "2.0", "method": "textDocument/hover", "params": {"bufnr": 1, "character": 2, "handle": true, "languageId": "purescript", "line": 8, "text": ["module Main where", "", "import Prelude", "import Effect (Effect)", "import Effect.Console (log)", "", "main :: Effect Unit", "main = do", "  log \"Hello sailor!\"", ""], "filename": "/Users/alextes/code/pls/src/Main.purs"}}
11:20:39 INFO main src/languageclient.rs:1728 Begin textDocument/didChange
11:20:39 INFO main src/languageclient.rs:49 gather_args: [Bufnr, LanguageId, Filename] = [Number(1), String("purescript"), String("/Users/alextes/code/pls/src/Main.purs")]
11:20:39 INFO main src/languageclient.rs:30 Some arguments are not available. Requesting from vim. Keys: ["LSP#text(1)"]. Exps: ["LSP#text(1)"]
11:20:39 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"eval","params":["[LSP#text(1)]"],"id":19}
11:20:39 INFO reader-main src/vim.rs:396 <= None {"id": 19, "jsonrpc": "2.0", "result": [["module Main where", "", "import Prelude", "import Effect (Effect)", "import Effect.Console (log)", "", "main :: Effect Unit", "main = do", "  log \"Hello sailor!\"", ""]]}
11:20:39 INFO main src/languageclient.rs:49 gather_args: ["LSP#text(1)"] = [Array([String("module Main where"), String(""), String("import Prelude"), String("import Effect (Effect)"), String("import Effect.Console (log)"), String(""), String("main :: Effect Unit"), String("main = do"), String("  log \"Hello sailor!\""), String("")])]
11:20:39 INFO main src/languageclient.rs:1752 Texts equal. Skipping didChange.
11:20:39 INFO main src/languageclient.rs:987 Begin textDocument/hover
11:20:39 INFO main src/languageclient.rs:49 gather_args: [LanguageId, Filename, Line, Character, Handle] = [String("purescript"), String("/Users/alextes/code/pls/src/Main.purs"), Number(8), Number(2), Bool(true)]
11:20:39 INFO main src/vim.rs:93 => Some("purescript") {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":2,"line":8},"textDocument":{"uri":"file:///Users/alextes/code/pls/src/Main.purs"}},"id":20}
11:20:39 INFO reader-purescript src/vim.rs:396 <= Some("purescript") {"jsonrpc":"2.0","id":20,"result":{"contents":{"kind":"markdown","value":"```purescript\nlog :: String → Effect Unit\n```\nWrite a message to the console.\n"},"range":null}}
11:20:39 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"execute","params":["silent! pedit! +setlocal\\ buftype=nofile\\ nobuflisted\\ noswapfile\\ nonumber\\ filetype=markdown __LanguageClient__"],"id":21}
11:20:40 INFO reader-main src/vim.rs:396 <= None {"id": 21, "jsonrpc": "2.0", "result": 0}
11:20:40 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"bufnr","params":["__LanguageClient__"],"id":22}
11:20:40 INFO reader-main src/vim.rs:396 <= None {"id": 22, "jsonrpc": "2.0", "result": 3}
11:20:40 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","method":"nvim_buf_set_lines","params":[3,0,-1,0,["```purescript","log :: String → Effect Unit","```","Write a message to the console."]],"id":23}
11:20:40 INFO reader-main src/vim.rs:396 <= None {"id": 23, "jsonrpc": "2.0", "result": null}
11:20:40 INFO main src/languageclient.rs:1034 End textDocument/hover
11:20:40 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","result":{"contents":{"kind":"markdown","value":"```purescript\nlog :: String → Effect Unit\n```\nWrite a message to the console.\n"},"range":null},"id":2}

from purescript-language-server.

alextes avatar alextes commented on July 21, 2024

Hm, no it does seem to return nothing for the first requested type hover regardless of how long I wait. It's minor. I'm happy to ignore it for now. Thanks for helping with this!

from purescript-language-server.

sriharshachilakapati avatar sriharshachilakapati commented on July 21, 2024

I was able to start it, and build through it with default configuration. Auto complete, error/warning reporting, quick fix, goto definition and hover all seems to work by default. I'm using the same plugin as above, and the latest release of purescript-language-server.

However, I'm unable to get the command addImport to work however. Here is how I'm writing the function.

function! LCCallback(...)
    echom json_encode(a:000)
endfunction

function! PaddImport()
    let l:command =
        \ { 'command': 'purescript.addCompletionImport'
        \ , 'arguments': [ expand('<cword>'), v:null, expand('%:p') ]
        \ ]

    call LanguageClient#Call('workspace/executeCommand', l:command, function('LCCallback'))
endfunction

However when trying to call this function, I'm receiving the following response:

[{"id": 3, "jsonrpc": "2.0", "result": null}]

I'm not sure if I need to open a new issue here, or continue. I'll be happy to create a new issue if you think so. By the way, what am I doing wrong?

This is the same response I'm getting for purescript.build command too.

from purescript-language-server.

sriharshachilakapati avatar sriharshachilakapati commented on July 21, 2024

As I see in the code, the syntax is found to be

addCompletionImport :: String -> Maybe String -> Maybe String -> DocumentUri -> Command
addCompletionImport ident mod qual uri = c addCompletionImportCmd $
  Just [ unsafeToForeign ident, unsafeToForeign $ toNullable mod, unsafeToForeign $ toNullable qual, unsafeToForeign uri ]

So I changed my command arguments to

[ expand('<cword>'), v:null, v:null, expand('%:p') ]

and started recieving this error:

17:41:41 INFO unnamed src/language_server_protocol.rs:78 gather_args: ["command", "arguments"] = [String("purescript.addCompletionImport"), Array([String("spy"), Null, Null, String("/Users/sriharshachilakapati/Projects/*/src/**/Flow.purs")])]
17:41:41 INFO unnamed src/rpcclient.rs:137 => Some("purescript") {"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"arguments":["spy",null,null,"/Users/sriharshachilakapati/Projects/*/src/**/Flow.purs"],"command":"purescript.addCompletionImport"},"id":5}
17:41:41 INFO reader-Some("purescript") src/rpcclient.rs:83 <= Some("purescript") {"jsonrpc":"2.0","id":5,"error":{"code":-32603,"message":"Request workspace/executeCommand failed with message: Cannot read property 'version' of undefined"}}
17:41:41 ERROR unnamed src/rpchandler.rs:13 Error handling message: Error: Failure { jsonrpc: Some(V2), error: Error { code: InternalError, message: "Request workspace/executeCommand failed with message: Cannot read property \'version\' of undefined", data: None }, id: Num(5) }

Error: ErrorMessage { msg: "Error: Failure { jsonrpc: Some(V2), error: Error { code: InternalError, message: \"Request workspace/executeCommand failed with message: Cannot read property \\\'version\\\' of undefined\", data: None }, id: Num(5) }" }

@nwolverson Can you please explain where the error is coming and why?

from purescript-language-server.

nwolverson avatar nwolverson commented on July 21, 2024

Looking at a trace of the communication from an existing client, I suspect this version is something handled by the lsp library being used.

Here's an example of what vscode outputs for this trace (filename redacted):

Params: {
    "command": "purescript.addCompletionImport",
    "arguments": [
        "fail",
        "Foreign",
        null,
        "file:///path/to/file/File.purs"
    ]

(The "addCompletionImport` command is designed to be used from the completion items returned from autocomplete - there should be a command property which gives that command + appropriate arguments; but alternatively a call without the module specified should return back an array of possible imports, you can see here it being used where it will be called a 2nd time if you need to select a module)

from purescript-language-server.

sriharshachilakapati avatar sriharshachilakapati commented on July 21, 2024

Thanks for the example!!! I forgot that it expects an URI as the last parameter.

Changing

[ expand('<cword>'), v:null, v:null, expand('%:p') ]

to

[ expand('<cword>'), v:null, v:null, 'file://' . expand('%:p') ]

Made it work!! Thanks a lot for the fast reply!

from purescript-language-server.

sriharshachilakapati avatar sriharshachilakapati commented on July 21, 2024

Finally everything is usable and I've pushed it to my dotfiles repo. You can find the commit here: sriharshachilakapati/dotfiles@ef8eed2

This however, codeAction is being applied twice, and also imports. I'll open another issue for it, after spending some time to understand if this is an issue of LanguageClient or the LanguageServer.

from purescript-language-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.