【问题标题】:How to configure VIM Ale to use the Tidy linter for HTML?如何配置 VIM Ale 以将 Tidy linter 用于 HTML?
【发布时间】:2020-11-23 02:32:40
【问题描述】:

我正在尝试配置 vim Ale 插件以使用 Tidy 对 HTML 代码进行 lint。 我添加到我的.vimrc 文件中:

 let g:ale_linters = {
 \   'css': ['csslint'],
 \   'html': ['tidy'],
 \   'javascript': ['eslint'],
 \   'php': [''],
 \   'python': ['flake8'],
 \}

我得到了适用于 CSS、JavaScript 和 Python 的 linter,但不适用于 HTML。

:ALEInfo 输出:

Current Filetype: html
Available Linters: ['alex', 'fecs', 'htmlhint', 'proselint', 'stylelint', 'tidy', 'writegood']
Linter Aliases: 'writegood' -> ['write-good']

Enabled Linters: ['tidy']

. . . at the end of the information . . .

Command History: (executable check - success) tidy

看起来 Tidy linter 可用并已配置,但我无法让它工作。 html 文件似乎根本没有 linting。

我可以在终端中成功运行 Tidy:

> tidy test.html
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 1 - Warning: plain text isn't allowed in <head> elements
line 1 column 2 - Warning: discarding unexpected <html>
line 2 column 5 - Warning: <body> unexpected or duplicate quote mark
line 2 column 5 - Warning: discarding unexpected <body>
line 4 column 7 - Error: <bdy> is not recognized!
line 4 column 7 - Warning: discarding unexpected <bdy>
line 1 column 1 - Warning: inserting missing 'title' element
line 3 column 7 - Warning: trimming empty <p>
Info: Document content looks like HTML 3.2
8 warnings, 1 error were found!

如何让 Tidy 在 vi​​m 中使用 Ale?

【问题讨论】:

    标签: vim tidy linter vim-ale


    【解决方案1】:

    您还需要告诉 vim 在哪里可以找到整洁的可执行文件,例如,Linux 上的 tidy 或 Windows 上的 tidy.exe

    就我而言,我将此添加到我的vimrc

    let g:ale_html_tidy_executable = "D://TidyHtml//tidy-5.6.0-vc14-64b//bin//tidy.exe"
    

    在 vim 中,获取 Ale 帮助进行整理::h ale-html-tidy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 1970-01-01
      • 2017-05-07
      • 1970-01-01
      • 2016-11-04
      相关资源
      最近更新 更多