1

我正在尝试使用 SublimeLinter3 验证 Sublime Text 3(便携式)中的 xml 文件。

我已经安装了 SublimeLinter3 以及 sublimelinter-xml 包。它们都出现在已安装的软件包中。

我已经安装了 xmllint 并将其添加到我的路径中。当我在控制台中输入 xmllint 时说“输入文件名”,所以我知道 xmllint 已安装。

当我检查 SublimeLinter 首选项时,模式是背景,这意味着它应该始终检查每个更改。

但什么都没有发生。对于我能想到的任何类型的 xml 错误,编辑器中根本没有反馈。有什么方法可以启用它吗?

编辑:

这是我的设置的样子。用户设置为空。

{
"default": {
    "debug": false,
    "delay": 0.25,
    "error_color": "D02000",
    "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
    "gutter_theme_excludes": [],
    "lint_mode": "background",
    "mark_style": "outline",
    "no_column_highlights_line": false,
    "passive_warnings": false,
    "paths": {
        "linux": [],
        "osx": [],
        "windows": []
    },
    "python_paths": {
        "linux": [],
        "osx": [],
        "windows": []
    },
    "rc_search_limit": 3,
    "shell_timeout": 10,
    "show_errors_on_save": false,
    "show_marks_in_minimap": true,
    "syntax_map": {
        "python django": "python",
        "html 5": "html",
        "html (django)": "html",
        "html (rails)": "html",
        "javascript (babel)": "javascript",
        "php": "html"
    },
    "warning_color": "DDB700",
    "wrap_find": true
}

}

4

4 回答 4

1

我刚刚遇到了同样的问题,您需要的 sublime linter 的最小用户设置集(在 Linux 和 Windows 上)如下所示。再次将 debug 设置为 true,查看控制台输出很有帮助

  1. 您需要 --valid 参数来获得输出。
  2. 如果您有 dtd 文件的相对路径,您需要 xmllinter 在 xml 文件自己的目录中运行,因此您需要 "working_dir": "$file_path", 参数,

  3. 并且您需要注释掉选择器(从 sublimelinter 设置复制的默认值是空白字符串,它使 xmllint lint 所有文件(不仅仅是 .xml 文件))

以下是我的 sublimelinter 用户设置文件:

// SublimeLinter Settings - User
{
    // Set to true to print extra information in the console.
    "debug": true,

    // Linter specific settings.
    // More info: http://www.sublimelinter.com/en/stable/linter_settings.html
    // Linter specific settings except for 'styles' can also be changed
    // in sublime-project settings.
    // What settings are available is documented in the readme of the
    // specific linter plugin.
    // Example:
    "linters": {
        // The name of the linter you installed
        "xmllint": {
            // Disables the linter. The default here is 'not set'
            "disable": false,

            // Additional arguments for the command line. Either a string
            // or an array. If set to a string, we 'shlex.split' it*.
            // E.g. '--ignore D112' or ['--config', './.config/foo.ini']
            //
            // * Note: Use proper quoting around paths esp. on Windows!
            "args": ["--valid"],


            // Lint mode determines when the linter is run. The linter setting
            // will take precedence over the global setting.
            "lint_mode": "background",

            // // Determines for which views this linter will run.
            // use default selectors .. which should work
            // if we have blank selector then we lint all files, which we don't want
            // "selector": "",

            // The current working dir the lint job will run in.
            // we need this file path to get the relative dir that the .dtd file is stored in
            "working_dir": "$file_path",

        }
    },
}
于 2019-04-29T09:09:46.747 回答
0

如果您或其他人仍然需要这个,试试这个。您需要添加一些用户设置。

  1. 打开默认设置并将整个文件复制到用户设置 ( Preferences -> Package Settings -> SublimeLinter -> Settings – Default)。

  2. 在用户设置文件中,将顶级键从 更改defaultuser.

  3. linters如果设置不存在,请添加。它应该如下所示:

    "linters": {
        "xmllint": {
            "@disable": false,
            "args": [
                "--xinclude",
                "--postvalid",
                "--noout",
            ],
            "excludes": []
        }
    },
    
于 2016-07-29T04:55:57.297 回答
0

我对 Sublimelinter 和 Sublimelinter-contrib-clang 也有类似的问题。Sublimelinter-php 正在工作,但不是 Sublimelinter-contrib-clang。不确定这是否会帮助您使用 xmlint,但也许值得一试。

帮助我弄清楚的是检查控制台输出(查看 > 显示控制台),这有助于我找出哪里出了问题。后来搜索了几次,似乎我需要重新安装 xcode 的命令行工具。

我能够跑步xcode-select --install,现在它正在为我工​​作。

于 2015-10-22T10:59:24.987 回答
0

SublimeLinter的文档非常广泛,但非常值得您花时间通读一遍SublimeLinter-xmllint您可以在其Package Control 页面上找到 README ,其中有指向主要 SublimeLinter 文档的相关部分的链接,用于设置和配置。

SublimeLinter 的插件生态系统非常强大、可配置和可扩展,但不幸的是并不总是“开箱即用”,因此通常需要进行一些设置和配置。但是,提供的定制程度将弥补学习如何让一切正常工作所花费的时间。在不知道您的确切设置的情况下,我无法提供更具体的内容,但文档非常好。

于 2015-10-09T13:22:18.070 回答