thesave / SublimeLinter-contrib-lacheck

This linter plugin for SublimeLinter provides an interface to lacheck.
MIT License
2 stars 1 forks source link

Only linting saved file #2

Open fredrikpaues opened 5 years ago

fredrikpaues commented 5 years ago

It appears that the package is only linting the saved file. I'm not sure but I believe that other linters are linting the view (that is, the text as seen on the screen) and not the saved file. And also that the errors update automatically to any changes made in the shown text. Shouldn't contrib-lacheck work the same way?

thesave commented 5 years ago

Sorry for the very late reply. Correct me if I'm wrong, but I find no indication in my linter of a particular lint_mode. Hence, SublimeLinter should use the one set in its configuration [1].

[1] http://www.sublimelinter.com/en/stable/linter_settings.html#lint-mode

fredrikpaues commented 5 years ago

I can't remember this issue. (My computer crashed and it seems that I can't replicate the problem.) But thanks for getting back and for pointing me to lint_mode.

fredrikpaues commented 5 years ago

I saw the issue now again. Let me post a MWE. When saved, the file below causes a lint error on line 5 reading lacheck: Whitespace before punctuation mark in ".

\documentclass{article}
\begin{document}
  One equation could be
  \begin{align}
    x + 1 = 5
    .
  \end{align}
\end{document}

If I move the period on line 6 to line 5 directly after 5 like below, then the error stays until I save. Then it disappears.

\documentclass{article}
\begin{document}
  One equation could be
  \begin{align}
    x + 1 = 5.
  \end{align}
\end{document}

My SublimeLinter settings are

{
    "debug": true,
    "delay": 0.25,
    "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
    "lint_mode": "background",
    "linters":
    {
        "chktex":
        {
            "@disable": false,
            "args":
            [
            ],
            "erroron":
            [
                16
            ],
            "excludes":
            [
            ],
            "inputfiles":
            [
                0
            ],
            "nowarn":
            [
                22,
                30
            ]
        },
        "csslint":
        {
            "@disable": false,
            "args":
            [
            ],
            "errors": "",
            "excludes":
            [
            ],
            "ignore": "",
            "warnings": ""
        },
        "flake8":
        {
            "@disable": false,
            "args":
            [
            ],
            "builtins": "",
            "excludes":
            [
            ],
            "executable": "",
            "ignore": "",
            "jobs": "1",
            "max-complexity": -1,
            "max-line-length": null,
            "select": "",
            "show-code": false
        },
        "gfortranfixedform":
        {
            "@disable": false,
            "args":
            [
            ],
            "excludes":
            [
            ]
        },
        "gfortranmodern":
        {
            "@disable": false,
            "args":
            [
            ],
            "excludes":
            [
            ]
        },
        "jshint":
        {
            "@disable": false,
            "args":
            [
            ],
            "excludes":
            [
            ]
        },
        "jsl":
        {
            "@disable": false,
            "args":
            [
            ],
            "excludes":
            [
            ]
        },
        "scss":
        {
            "@disable": false,
            "args":
            [
                "--config",
                "C:/Users/fredr/AppData/Roaming/Sublime Text 3/Packages/User/SublimeLinter/scsslint.yml"
            ],
            "exclude-linter": "",
            "excludes":
            [
            ],
            "include-linter": ""
        }
    },
    "no_column_highlights_line": false,
    "paths":
    {
        "linux":
        [
        ],
        "osx":
        [
        ],
        "windows":
        [
            "C:/Users/Fredrik/AppData/Roaming/npm"
        ]
    },
    "show_marks_in_minimap": true,
    "syntax_map":
    {
        "html (django)": "html",
        "html (rails)": "html",
        "html 5": "html",
        "javascript (babel)": "javascript",
        "magicpython": "python",
        "php": "html",
        "python django": "python",
        "pythonimproved": "python"
    },
}
thesave commented 5 years ago

Thanks for your MWE :)

I looked a bit into this. The "problem" seems to be lacheck, which works only over files [1]. Indeed, in the plugin, I launch lacheck with the parameter ${file} which points the tool to the file you are editing. Although the linter can be invoked asynchronously with the "background" lint setting, you see no changes because the file is not saved and the tool "sees" the unmodified version (in your example, the one you save in the first place to show the error).

I skimmed through the documentation for SublimeLinter but unfortunately, I couldn't find a reference on how to implement an "online" plugin. More precisely, I could not find an example of how you can get the reference to the temporary file that contains your current-not-saved-yet-edits.

Any help here is more than welcome :)

[1] https://linux.die.net/man/1/lacheck

fredrikpaues commented 5 years ago

It should be easy for SublimeLinter to create a temporary file for lacheck to lint,[1] but I haven't managed to figure out how it should be done. I have forked your linter and tried to set tempfile_suffix = None (and '.tex' etc.) but I can't seem to get it to work. I guess I am doing something wrong.

[1] http://www.sublimelinter.com/en/stable/linter_attributes.html#tempfile-suffix

thesave commented 5 years ago

That's also my conclusion, but I fail to understand how to "intercept" that temp file. Please, let me know if you make any progress on that.

fredrikpaues commented 5 years ago

The documentation says that should be done automatically: "When tempfile_suffix is set, the filename will be the temp filename."