tokoro10g / matlab-langserver

Language Server using MATLAB Engine
13 stars 1 forks source link

Can I expect this to work with r2019b? #10

Closed moetayuko closed 4 years ago

moetayuko commented 4 years ago

My OS is archlinux, matlab version is r2019b, and the lsp client is coc.nvim. To make it easier to invoke the jar I wrote a .sh to wrap the Usage section of readme, that's the background.

The jar starts, but not seem to be doing anything, which is similar to https://github.com/tokoro10g/matlab-langserver/issues/9

Following the comments there, this file was used for the test. Concretely I run go to definition on the yout variable, and the logs are as follows, they were captured after running vim ode4.m.

[Trace - 下午8:45:59] Sending request 'initialize - (0)'.
Params: {
    "processId": 457120,
    "rootPath": "/home/dianlujitao",
    "rootUri": "file:///home/dianlujitao",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional"
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                }
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": false,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                }
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                }
            },
            "definition": {
                "dynamicRegistration": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                }
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true
            },
            "implementation": {
                "dynamicRegistration": true
            },
            "declaration": {
                "dynamicRegistration": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            }
        },
        "window": {
            "workDoneProgress": true
        }
    },
    "initializationOptions": {},
    "trace": "verbose",
    "workspaceFolders": [],
    "clientInfo": {
        "name": "coc.nvim",
        "version": "0.0.78"
    },
    "workDoneToken": "7dfb2637-4dfe-4d0d-bb3d-eb4a9aa143da"
}

2020-07-23 20:45:59.248 [main] INFO  org.tokor.lspmatlab.Application {} - Starting server
2020-07-23 20:45:59.546 [main] INFO  org.tokor.lspmatlab.MATLABEngineSingleton {} - Could not find existing sessions. Starting MATLAB Engine...
[Trace - 下午8:45:59] Received response 'initialize - (0)' in 509ms.
Result: {
    "capabilities": {
        "textDocumentSync": 1,
        "completionProvider": {
            "resolveProvider": true
        },
        "signatureHelpProvider": {
            "triggerCharacters": [
                "("
            ]
        },
        "definitionProvider": true,
        "codeActionProvider": true,
        "executeCommandProvider": {
            "commands": [
                "engine.run",
                "engine.runLine"
            ]
        },
        "workspace": {
            "workspaceFolders": {
                "supported": true,
                "changeNotifications": true
            }
        }
    }
}

[Trace - 下午8:45:59] Sending notification 'initialized'.
Params: {}

[Trace - 下午8:45:59] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///home/dianlujitao/ode4.m",
        "languageId": "matlab",
        "version": 1,
        "text": "function yout = ode4(F,t0,h,tfinal,y0)\n% ODE4  Classical Runge-Kutta ODE solver.\n%   yout = ODE4(F,t0,h,tfinal,y0) uses the classical\n%   Runge-Kutta method with fixed step size h on the interval\n%      t0 <= t <= tfinal\n%   to solve\n%      dy/dt = F(t,y)\n%   with y(t0) = y0.\n\n%   Copyright 2014 - 2015 The MathWorks, Inc.\n\n   y = y0;\n   yout = y;\n   for t = t0 : h : tfinal-h\n      s1 = F(t,y);\n      s2 = F(t+h/2, y+h*s1/2);\n      s3 = F(t+h/2, y+h*s2/2);\n      s4 = F(t+h, y+h*s3);\n      y = y + h*(s1 + 2*s2 + 2*s3 + s4)/6;\n      yout = [yout; y];\n   end\n"
    }
}

[Trace - 下午8:45:59] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "MATLAB Language Server Initialized"
}

[Info  - 下午8:45:59] MATLAB Language Server Initialized
-------NOTICE, vim initialized, run "go to definition" now----------
[Trace - 下午8:46:15] Sending request 'textDocument/definition - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///home/dianlujitao/ode4.m"
    },
    "position": {
        "line": 19,
        "character": 16
    }
}

2020-07-23 20:46:15.858 [ForkJoinPool.commonPool-worker-1] INFO  org.tokor.lspmatlab.MATLABTextDocumentService {} - Definition: l19:16/545
[Trace - 下午8:46:15] Received response 'textDocument/definition - (1)' in 103ms.
No result returned.
❯ java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

Anything wrong with my setup? Thanks in advance.

tokoro10g commented 4 years ago

Your setup is fine. The problem is that searching for the variable's definition is not supported at this stage. (and as you may notice, this project is no longer maintained, so there's very few chance to get this feature.) You can only find the m-file location of functions.

related: https://github.com/tokoro10g/matlab-langserver/blob/master/src/main/java/org/tokor/lspmatlab/MATLABTextDocumentService.java#L180

moetayuko commented 4 years ago

Thanks for the clarification