neoclide / coc-vetur

Vue language server extension for coc.nvim
219 stars 7 forks source link

coc-vetur doesn't update diagnostics #18

Closed andbar-ru closed 5 years ago

andbar-ru commented 5 years ago

Thanks for your work!

Coc-vetur doesn't update diagnostics in vue applications with typescript and imported external typescript modules. I have created minimal vue application with vue create as an example of this issue: https://github.com/andbar-ru/test-app

File https://github.com/andbar-ru/test-app/blob/master/src/components/HelloWorld.vue has error "[Vetur 2322] [E] Type '{ a: string; b: string; c: string; }' is not assignable to type 'ITestObject'." on the line 50 ("c: 'c',") But if I uncomment line 4 in the file https://github.com/andbar-ru/test-app/blob/master/src/components/types.ts to resolve this error, Vetur doesn't update diagnostic info and continues to show this error. Editing and saving file or reloading it doesn't help. Only reloading extension with the command :call CocAction('reloadExtension', 'coc-vetur') makes coc-vetur to update diagnostics. The same happens if then comment line 4 in the file types.ts -- coc-vetur doesn't show error in the file HelloWorld.vue until reloading extension. This issue happens in the last gvim and neovim (appImages)

VSCode's vetur updates diagnostics without problems.

Installed coc extensions: coc-tsserver coc-vetur coc-eslint coc-prettier coc-json coc-css

coc-settings.json:

{
  "coc.preferences.colorSupport": false,
  "coc.preferences.currentFunctionSymbolAutoUpdate": false,
  "codeLens.enable": true,
  "diagnostic.errorSign": "E",
  "diagnostic.warningSign": "W",
  "diagnostic.infoSign": "I",
  "diagnostic.hintSign": "H",
  "diagnostic.virtualText": false,
  "suggest.autoTrigger": "none",
  "suggest.noselect": false,
  "eslint.run": "onSave",
  "eslint.filetypes": ["javascript", "typescript", "vue"],
}

If you need more info, I will provide.

chemzqm commented 5 years ago

Checkout https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

andbar-ru commented 5 years ago

This is the output of vetur's CocCommand workspace.showOutput.

vetur's debug output
[Trace - 12:09:11 AM] Sending request 'initialize - (0)'.
Params: {
    "processId": 15399,
    "rootPath": "/home/wind/tmp/test-app",
    "rootUri": "file:///home/wind/tmp/test-app",
    "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
                    ]
                }
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true
            },
            "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
                    ]
                }
            },
            "codeAction": {
                "dynamicRegistration": 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
            },
            "typeDefinition": {
                "dynamicRegistration": true
            },
            "implementation": {
                "dynamicRegistration": true
            },
            "declaration": {
                "dynamicRegistration": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            }
        }
    },
    "initializationOptions": {
        "config": {
            "vetur": {
                "useWorkspaceDependencies": false,
                "completion": {
                    "autoImport": true,
                    "useScaffoldSnippets": true,
                    "tagCasing": "kebab"
                },
                "validation": {
                    "template": true,
                    "style": true,
                    "script": true
                },
                "format": {
                    "enable": true,
                    "options": {
                        "tabSize": 2,
                        "useTabs": false
                    },
                    "defaultFormatter": {
                        "html": "prettyhtml",
                        "css": "prettier",
                        "postcss": "prettier",
                        "scss": "prettier",
                        "less": "prettier",
                        "stylus": "stylus-supremacy",
                        "js": "prettier",
                        "ts": "prettier"
                    },
                    "defaultFormatterOptions": {
                        "js-beautify-html": {
                            "wrap_attributes": "force-expand-multiline"
                        },
                        "prettyhtml": {
                            "printWidth": 100,
                            "singleQuote": false,
                            "wrapAttributes": false,
                            "sortAttributes": false
                        }
                    },
                    "styleInitialIndent": false,
                    "scriptInitialIndent": false
                },
                "trace": {
                    "server": "verbose"
                },
                "dev": {
                    "logLevel": "INFO"
                },
                "experimental": {
                    "templateInterpolationService": false
                }
            },
            "emmet": {},
            "html": {},
            "javascript": {
                "showUnused": true,
                "updateImportsOnFileMove": {
                    "enable": true
                },
                "implementationsCodeLens": {
                    "enable": true
                },
                "referencesCodeLens": {
                    "enable": true
                },
                "preferences": {
                    "importModuleSpecifier": "non-relative",
                    "quoteStyle": "single"
                },
                "validate": {
                    "enable": true
                },
                "suggestionActions": {
                    "enabled": true
                },
                "suggest": {
                    "names": true,
                    "enabled": true,
                    "paths": true,
                    "autoImports": true,
                    "completeFunctionCalls": true
                },
                "format": {
                    "insertSpaceAfterCommaDelimiter": true,
                    "insertSpaceAfterConstructor": false,
                    "insertSpaceAfterSemicolonInForStatements": true,
                    "insertSpaceBeforeAndAfterBinaryOperators": true,
                    "insertSpaceAfterKeywordsInControlFlowStatements": true,
                    "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
                    "insertSpaceBeforeFunctionParenthesis": false,
                    "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
                    "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
                    "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
                    "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
                    "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
                    "insertSpaceAfterTypeAssertion": false,
                    "placeOpenBraceOnNewLineForFunctions": false,
                    "placeOpenBraceOnNewLineForControlBlocks": false
                }
            },
            "typescript": {
                "showUnused": true,
                "updateImportsOnFileMove": {
                    "enable": true
                },
                "implementationsCodeLens": {
                    "enable": true
                },
                "referencesCodeLens": {
                    "enable": true
                },
                "preferences": {
                    "importModuleSpecifier": "non-relative",
                    "quoteStyle": "single"
                },
                "suggestionActions": {
                    "enabled": true
                },
                "validate": {
                    "enable": true
                },
                "suggest": {
                    "enabled": true,
                    "paths": true,
                    "autoImports": true,
                    "completeFunctionCalls": true
                },
                "format": {
                    "insertSpaceAfterCommaDelimiter": true,
                    "insertSpaceAfterConstructor": false,
                    "insertSpaceAfterSemicolonInForStatements": true,
                    "insertSpaceBeforeAndAfterBinaryOperators": true,
                    "insertSpaceAfterKeywordsInControlFlowStatements": true,
                    "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
                    "insertSpaceBeforeFunctionParenthesis": false,
                    "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
                    "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
                    "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
                    "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
                    "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
                    "insertSpaceAfterTypeAssertion": false,
                    "placeOpenBraceOnNewLineForFunctions": false,
                    "placeOpenBraceOnNewLineForControlBlocks": false
                }
            },
            "prettier": {
                "formatterPriority": 1,
                "disableLanguages": [
                    "vue"
                ],
                "eslintIntegration": false,
                "tslintIntegration": false,
                "stylelintIntegration": false,
                "requireConfig": false,
                "onlyUseLocalVersion": false,
                "disableSuccessMessage": false,
                "statusItemText": "Prettier",
                "ignorePath": ".prettierignore",
                "printWidth": 80,
                "tabWidth": 2,
                "singleQuote": false,
                "trailingComma": "none",
                "bracketSpacing": true,
                "jsxBracketSameLine": false,
                "jsxSingleQuote": false,
                "htmlWhitespaceSensitivity": "css",
                "endOfLine": "auto",
                "parser": "babylon",
                "semi": true,
                "useTabs": false,
                "proseWrap": "preserve",
                "arrowParens": "avoid"
            },
            "stylusSupremacy": {}
        },
        "globalSnippetDir": "/home/wind/.config/Code/User/snippets/vetur"
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///home/wind/tmp/test-app",
            "name": "test-app"
        }
    ]
}

[Trace - 12:09:12 AM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "Loaded bundled typescript@3.6.3."
}

Loaded bundled typescript@3.6.3.
[Trace - 12:09:12 AM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "Vetur initialized"
}

Vetur initialized
[Trace - 12:09:12 AM] Received response 'initialize - (0)' in 1387ms.
Result: {
    "capabilities": {
        "textDocumentSync": 1,
        "completionProvider": {
            "resolveProvider": true,
            "triggerCharacters": [
                ".",
                ":",
                "<",
                "\"",
                "'",
                "/",
                "@",
                "*"
            ]
        },
        "signatureHelpProvider": {
            "triggerCharacters": [
                "("
            ]
        },
        "documentFormattingProvider": false,
        "hoverProvider": true,
        "documentHighlightProvider": true,
        "documentLinkProvider": {
            "resolveProvider": false
        },
        "documentSymbolProvider": true,
        "definitionProvider": true,
        "referencesProvider": true,
        "codeActionProvider": true,
        "colorProvider": true
    }
}

[Trace - 12:09:12 AM] Sending notification 'initialized'.
Params: {}

[Trace - 12:09:12 AM] Sending notification 'workspace/didChangeConfiguration'.
Params: {
    "settings": {
        "vetur": {
            "useWorkspaceDependencies": false,
            "completion": {
                "autoImport": true,
                "useScaffoldSnippets": true,
                "tagCasing": "kebab"
            },
            "validation": {
                "template": true,
                "style": true,
                "script": true
            },
            "format": {
                "enable": true,
                "options": {
                    "tabSize": 2,
                    "useTabs": false
                },
                "defaultFormatter": {
                    "html": "prettyhtml",
                    "css": "prettier",
                    "postcss": "prettier",
                    "scss": "prettier",
                    "less": "prettier",
                    "stylus": "stylus-supremacy",
                    "js": "prettier",
                    "ts": "prettier"
                },
                "defaultFormatterOptions": {
                    "js-beautify-html": {
                        "wrap_attributes": "force-expand-multiline"
                    },
                    "prettyhtml": {
                        "printWidth": 100,
                        "singleQuote": false,
                        "wrapAttributes": false,
                        "sortAttributes": false
                    }
                },
                "styleInitialIndent": false,
                "scriptInitialIndent": false
            },
            "trace": {
                "server": "verbose"
            },
            "dev": {
                "logLevel": "INFO"
            },
            "experimental": {
                "templateInterpolationService": false
            }
        },
        "emmet": {},
        "html": {},
        "javascript": {
            "showUnused": true,
            "updateImportsOnFileMove": {
                "enable": true
            },
            "implementationsCodeLens": {
                "enable": true
            },
            "referencesCodeLens": {
                "enable": true
            },
            "preferences": {
                "importModuleSpecifier": "non-relative",
                "quoteStyle": "single"
            },
            "validate": {
                "enable": true
            },
            "suggestionActions": {
                "enabled": true
            },
            "suggest": {
                "names": true,
                "enabled": true,
                "paths": true,
                "autoImports": true,
                "completeFunctionCalls": true
            },
            "format": {
                "insertSpaceAfterCommaDelimiter": true,
                "insertSpaceAfterConstructor": false,
                "insertSpaceAfterSemicolonInForStatements": true,
                "insertSpaceBeforeAndAfterBinaryOperators": true,
                "insertSpaceAfterKeywordsInControlFlowStatements": true,
                "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
                "insertSpaceBeforeFunctionParenthesis": false,
                "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
                "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
                "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
                "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
                "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
                "insertSpaceAfterTypeAssertion": false,
                "placeOpenBraceOnNewLineForFunctions": false,
                "placeOpenBraceOnNewLineForControlBlocks": false
            }
        },
        "typescript": {
            "showUnused": true,
            "updateImportsOnFileMove": {
                "enable": true
            },
            "implementationsCodeLens": {
                "enable": true
            },
            "referencesCodeLens": {
                "enable": true
            },
            "preferences": {
                "importModuleSpecifier": "non-relative",
                "quoteStyle": "single"
            },
            "suggestionActions": {
                "enabled": true
            },
            "validate": {
                "enable": true
            },
            "suggest": {
                "enabled": true,
                "paths": true,
                "autoImports": true,
                "completeFunctionCalls": true
            },
            "format": {
                "insertSpaceAfterCommaDelimiter": true,
                "insertSpaceAfterConstructor": false,
                "insertSpaceAfterSemicolonInForStatements": true,
                "insertSpaceBeforeAndAfterBinaryOperators": true,
                "insertSpaceAfterKeywordsInControlFlowStatements": true,
                "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
                "insertSpaceBeforeFunctionParenthesis": false,
                "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
                "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
                "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
                "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
                "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
                "insertSpaceAfterTypeAssertion": false,
                "placeOpenBraceOnNewLineForFunctions": false,
                "placeOpenBraceOnNewLineForControlBlocks": false
            }
        },
        "prettier": {
            "formatterPriority": 1,
            "disableLanguages": [
                "vue"
            ],
            "eslintIntegration": false,
            "tslintIntegration": false,
            "stylelintIntegration": false,
            "requireConfig": false,
            "onlyUseLocalVersion": false,
            "disableSuccessMessage": false,
            "statusItemText": "Prettier",
            "ignorePath": ".prettierignore",
            "printWidth": 80,
            "tabWidth": 2,
            "singleQuote": false,
            "trailingComma": "none",
            "bracketSpacing": true,
            "jsxBracketSameLine": false,
            "jsxSingleQuote": false,
            "htmlWhitespaceSensitivity": "css",
            "endOfLine": "auto",
            "parser": "babylon",
            "semi": true,
            "useTabs": false,
            "proseWrap": "preserve",
            "arrowParens": "avoid"
        },
        "stylusSupremacy": {}
    }
}

[Trace - 12:09:12 AM] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///home/wind/tmp/test-app/src/components/HelloWorld.vue",
        "languageId": "vue",
        "version": 1,
        "text": "\n\n\n\n\n\n"
    }
}

[Trace - 12:09:12 AM] Received request 'client/registerCapability - (0)'.
Params: {
    "registrations": [
        {
            "id": "c4c7c197-8996-4992-8709-591f6a166522",
            "method": "textDocument/formatting",
            "registerOptions": {
                "documentSelector": [
                    "vue"
                ]
            }
        }
    ]
}

[Trace - 12:09:12 AM] Sending response 'client/registerCapability - (0)'. Processing request took 0ms
No result returned.

[Trace - 12:09:14 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/wind/tmp/test-app/src/components/HelloWorld.vue",
    "diagnostics": []
}

All lines just after running command. No new lines if I comment or uncomment line 4 in types.ts

I added

"vetur.trace.server": "verbose"

into seetings.json of VSCode. If I change types.ts VSCode's vetur writes to log:

trace
[Trace - 1:49:53 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///home/wind/tmp/test-app/src/components/types.ts",
            "type": 2
        }
    ]
}

[Trace - 1:49:54 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/wind/tmp/test-app/src/components/HelloWorld.vue",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 49,
                    "character": 8
                },
                "end": {
                    "line": 49,
                    "character": 14
                }
            },
            "severity": 1,
            "message": "Type '{ a: string; b: string; c: string; }' is not assignable to type 'ITestObject'.\n  Object literal may only specify known properties, and 'c' does not exist in type 'ITestObject'.",
            "tags": [],
            "code": 2322,
            "source": "Vetur"
        }
    ]
}

So, coc-vetur doesn't watch changes in imported *.ts files.

coc-vetur's and vscode-vetur's log files differ very much. I can't guess crucial settings that allow vetur to watch *.ts files.

chemzqm commented 5 years ago

vetur only works on vue files.

andbar-ru commented 5 years ago

However, coc-vetur watches imported .js and .ts files after reloading when first opening *.vue files. Link to the same issue in original vetur, already closed: https://github.com/vuejs/vetur/issues/626.

chemzqm commented 5 years ago

The language client watching js and ts files https://github.com/neoclide/coc-vetur/blob/master/src/index.ts#L63, it's problem of vetur.

andbar-ru commented 5 years ago

But vetur in VSCode hasn't this problem already and watches updates in associated .ts and js files without restarting.

chemzqm commented 5 years ago

Could be it's using old vetur, just updated.

andbar-ru commented 5 years ago

Unfortunately, that didn't solve the problem. Probably, vue-language-server is responsible for that. coc-vetur uses pretty old version 0.0.62, but 0.22.4 is available.

Sorry: 0.22.4 is about vetur.

chemzqm commented 5 years ago

You should check https://www.npmjs.com/package/vue-language-server

andbar-ru commented 5 years ago

It turns out createFileSystemWatcher uses watchman. The problem has been solved after I installed it. Thanks for pointing the way. I feel this aspect should be documented.

arttobe commented 4 years ago

I am running in the same issue, how did you exactly resolve it

andbar-ru commented 4 years ago

I installed watchman: https://github.com/neoclide/coc.nvim/wiki/Install-coc.nvim#optional-install-watchman-for-file-watching