vim - 如何配置 VIM Ale 以将 Tidy linter 用于 HTML?

标签 vim tidy linter vim-ale

我正在尝试配置 vim Ale 插件以使用 Tidy 来检查 HTML 代码。 我添加到我的 .vimrc 文件:

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

我的 linters 适用于 CSS、JavaScript 和 Python,但不适用于 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 可执行文件,例如,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

关于vim - 如何配置 VIM Ale 以将 Tidy linter 用于 HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63222422/

相关文章:

带自动缩进的 Vim 软换行

ruby - "dyld: Library not loaded", "libruby.1.9.1.dylib"在命令行调用"mvim ."时

vim "modifiable"已关闭

vim - 默认情况下,为VIM或GVIM的某些文件扩展名添加语法突出显示

r - 列表中的 bind_rows 即使 class() 不同

c++ - 在 Visual C++ 2010 Windows 窗体项目中使用 HTML Tidy

MacOS X 上的 HTML5 格式? (最好使用 TextMate)

r - 如何在 VSCode 中使用驼峰命名法禁用变量名称的 linter(使用 R 时)?

python - 如何将 Pylint 或其他 linters 与 Jupyter 笔记本一起使用?

javascript - ESLint 未检测到导入的 React 组件