1
votes

I am trying to validate xml files in Sublime Text 3 (portable) using SublimeLinter3.

I have installed SublimeLinter3 as well as sublimelinter-xml packages. Both of them show up in installed packages.

I have installed xmllint and added it to my path. When I type xmllint in console is says "enter file name", so I know xmllint is installed.

When I check SublimeLinter preferences, the mode is background, meaning it should always be checking on every change.

But nothing is happening. There is not feedback in the editor at all, for any sort of xml error I can come up with. Is there some sort of way to enable it?

EDIT:

Here is what my settings look like. User settings are empty.

{
"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
Have you configured SublimeLinter and the plugin properly? - MattDMo
I have done what I have listed. No where on the SublimeLinter website is there configuration instructions. Just install and usage. I have read them both. If there are more steps to configure I can not find them... - Scorb

4 Answers

1
votes

I have just had this same problem, and the minimum set of user settings for sublime linter that you need (on Linux and windows) is shown below. Again setting debug to true, and viewing console output is a great help

  1. You need the --valid args to get output.
  2. You need the xmllinter to run in the xml file's own directory, if you have relative paths to a dtd file, thus you need the "working_dir": "$file_path", argument,

  3. And you need the selector commented out (the default copied across from sublimelinter settings is the blank string which makes xmllint lint all files (not just .xml files))

Following is my sublimelinter user settings file:

// 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",

        }
    },
}
0
votes

The documentation for SublimeLinter is quite extensive, but it will be very much worth your time to read through it all. You can find the README for SublimeLinter-xmllint on its Package Control page, where there are links to the relevant sections of the main SublimeLinter documentation for setup and configuration.

The plugin ecosystem for SublimeLinter is very powerful, configurable, and extensible, but unfortunately doesn't always necessarily work "right out of the box", so usually some setup and configuration is required. However, the degree of customization offered will make up for the time spent learning how to get everything working properly. Without knowing your exact setup I can't offer anything more specific, but the documentation is quite good.

0
votes

I had a similar problem with Sublimelinter and Sublimelinter-contrib-clang. Sublimelinter-php was working, but not Sublimelinter-contrib-clang. Not sure if this will help you or not with xmlint, but maybe it's worth a shot.

What helped me figure that out was checking out the console output (View > Show Console), which helped me figure out where things were going wrong. A couple searches later, it seemed that I needed to re-install xcode's command line tools.

I was able to run xcode-select --install and it's now working for me.

0
votes

In case you or someone else needs this still, try this. You need to add some user settings.

  1. Open the default settings and copy the entire file into user settings (Preferences -> Package Settings -> SublimeLinter -> Settings – Default).

  2. In the user settings file, change the top-level key from default to user.

  3. Add the linters setting if it doesn't exist. It should look like this:

    "linters": {
        "xmllint": {
            "@disable": false,
            "args": [
                "--xinclude",
                "--postvalid",
                "--noout",
            ],
            "excludes": []
        }
    },