@0x706b/coc-diagnostic 中文文档教程

发布于 3年前 浏览 25 项目主页 更新于 3年前

Diagnostic Extension for CoC

诊断语言服务器 CoC 的扩展

Install

:CocInstall coc-diagnostic

image

Config

注意 : 如果你想支持默认不包含的 linter, 你应该阅读README 了解如何配置新的 linter。

linters filetypes formatters formatFiletypes 字段配置与诊断语言服务器相同。 此扩展包括 linters 中的所有 linters 配置 因此,如果您使用包含的 linter,则无需配置 linter 和格式化程序

如果 mergeConfigtrue(默认 false),则任何配置 lintersformatters默认合并 配置,这允许覆盖的特定部分 仅配置。

要为文件类型启用此插件,您必须配置 diagnostic-languageserver.filetypes 用于 linters 和 diagnostic-languageserver.formatFiletypes 用于格式化程序。

示例 coc-settings.json:

{
  // diagnostic-languageserver
  "diagnostic-languageserver.filetypes": {
    "vim": "vint",
    "email": "languagetool",
    "markdown": [ "write-good", "markdownlint" ],
    "sh": "shellcheck",
    "elixir": ["mix_credo", "mix_credo_compile"],
    "eelixir": ["mix_credo", "mix_credo_compile"],
    "php": ["phpstan", "psalm"],
    "yaml": [ "yamllint" ],
    "cmake": [ "cmake-lint", "cmakelint" ],
    "systemd": "systemd-analyze",
    ...
  },
  "diagnostic-languageserver.formatFiletypes": {
    "dart": "dartfmt",
    "elixir": "mix_format",
    "eelixir": "mix_format",
    "python": ["black", "isort"],
    "lua": "lua-format",
    "sh": "shfmt",
    "blade": "blade-formatter",
    "cmake": "cmake-format",
    ...
  }
}

所有选项:

"diagnostic-languageserver.enable": {
  "type": "boolean",
  "default": true,
  "description": "enable this extension?"
},
"diagnostic-languageserver.mergeConfig": {
  "type": "boolean",
  "default": false,
  "description": "merge config?"
},
"diagnostic-languageserver.debug": {
  "type": "boolean",
  "default": true,
  "description": "enable debug?"
},
"diagnostic-languageserver.trace.server": {
  "type": "string",
  "default": "off",
  "enum": [
    "off",
    "messages",
    "verbose"
  ],
  "description": "Trace level of diagnostic-languageserver"
},
"diagnostic-languageserver.linters": {
  "type": "object",
  "default": {},
  "description": "linters config same as diagnostic-languageserver's linters config"
},
"diagnostic-languageserver.filetypes": {
  "type": "object",
  "default": {},
  "description": "filetypes config same as diagnostic-languageserver's filetypes config"
},
"diagnostic-languageserver.formatters": {
  "type": "object",
  "default": {},
  "description": "formatters config same as diagnostic-languageserver's formatters config"
},
"diagnostic-languageserver.formatFiletypes": {
  "type": "object",
  "default": {},
  "description": "formatFiletypes config same as diagnostic-languageserver's formatFiletypes config"
}

Buy Me A Coffee ☕️

btc

图像

Diagnostic Extension for CoC

diagnostic-languageserver extension for CoC

Install

:CocInstall coc-diagnostic

image

Config

NOTE: If you want to support linter that do not include by default, you should read the README for how to config a new linter.

linters filetypes formatters formatFiletypes field config are same as diagnostic-languageserver. this extension include all linters config at linters therefor if you use the linter which have included then you don't need to config linters and formatters

If mergeConfig is true (default false) then any configuration for linters and formatters is merged with the default configuration, this allow overriding specific parts of the configuration only.

To enable this plugin for filetypes you have to config diagnostic-languageserver.filetypes for linters and diagnostic-languageserver.formatFiletypes for formatters.

example coc-settings.json:

{
  // diagnostic-languageserver
  "diagnostic-languageserver.filetypes": {
    "vim": "vint",
    "email": "languagetool",
    "markdown": [ "write-good", "markdownlint" ],
    "sh": "shellcheck",
    "elixir": ["mix_credo", "mix_credo_compile"],
    "eelixir": ["mix_credo", "mix_credo_compile"],
    "php": ["phpstan", "psalm"],
    "yaml": [ "yamllint" ],
    "cmake": [ "cmake-lint", "cmakelint" ],
    "systemd": "systemd-analyze",
    ...
  },
  "diagnostic-languageserver.formatFiletypes": {
    "dart": "dartfmt",
    "elixir": "mix_format",
    "eelixir": "mix_format",
    "python": ["black", "isort"],
    "lua": "lua-format",
    "sh": "shfmt",
    "blade": "blade-formatter",
    "cmake": "cmake-format",
    ...
  }
}

All Options:

"diagnostic-languageserver.enable": {
  "type": "boolean",
  "default": true,
  "description": "enable this extension?"
},
"diagnostic-languageserver.mergeConfig": {
  "type": "boolean",
  "default": false,
  "description": "merge config?"
},
"diagnostic-languageserver.debug": {
  "type": "boolean",
  "default": true,
  "description": "enable debug?"
},
"diagnostic-languageserver.trace.server": {
  "type": "string",
  "default": "off",
  "enum": [
    "off",
    "messages",
    "verbose"
  ],
  "description": "Trace level of diagnostic-languageserver"
},
"diagnostic-languageserver.linters": {
  "type": "object",
  "default": {},
  "description": "linters config same as diagnostic-languageserver's linters config"
},
"diagnostic-languageserver.filetypes": {
  "type": "object",
  "default": {},
  "description": "filetypes config same as diagnostic-languageserver's filetypes config"
},
"diagnostic-languageserver.formatters": {
  "type": "object",
  "default": {},
  "description": "formatters config same as diagnostic-languageserver's formatters config"
},
"diagnostic-languageserver.formatFiletypes": {
  "type": "object",
  "default": {},
  "description": "formatFiletypes config same as diagnostic-languageserver's formatFiletypes config"
}

Buy Me A Coffee ☕️

btc

image

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文