vim - 如何配置 VIM Ale 以将 Tidy linter 用于 HTML?
问题描述
我正在尝试将 vim Ale 插件配置为使用 Tidy 来整理 HTML 代码。我添加到我的.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 在 vim 中与 Ale 一起工作?
解决方案
您还需要知道vim
在哪里可以找到整洁的可执行文件,例如,tidy
在 Linux 上或tidy.exe
在 Windows 上。
就我而言,我将此添加到我的vimrc
:
let g:ale_html_tidy_executable = "D://TidyHtml//tidy-5.6.0-vc14-64b//bin//tidy.exe"
在 vim 中,让 Ale 帮助整理::h ale-html-tidy
推荐阅读
- react-native - 反应原生:useSelector redux 为空
- android - 如何在线性布局中放置 4 种颜色
- c# - 如何在 GUI 上的 WPF 中绘制 android 或 i-phone 上的电池电量
- reactjs - 使用 React 进行画布上下文操作
- javascript - React Native Chrome 自定义选项卡不起作用
- github - “在(我的应用程序)未检测到源存储库。请检查 URL 并重试。”
- php - 如何在 CGridView Yii1.1 中编写这个 html 部分
- android - Android - Recyclerview 与 viewholder 内的 webview 滞后
- flutter - 在颤振中,如何在输入文本前创建扩展点
- c# - 将相同的属性值分配给其他