How to Install and Use the SOAR SQL Optimizer Plugins for Vim, Sublime Text, and VS Code
This article explains the basic implementation of the SOAR SQL Optimizer plugin, demonstrates its lint mode output, and provides step‑by‑step instructions for installing and configuring the Vim, Sublime Text, and VS Code extensions so developers can receive automated SQL quality suggestions directly in their editors.
SOAR (SQL Optimizer And Rewriter) is an open‑source SQL‑analysis tool released by Xiaomi that can lint SQL files and suggest improvements. When the report-type is set to lint , SOAR outputs a concise report containing file name, line number, issue type, and a short description. Example output:
$ cat file.sql
select * from test
$ soar -report-type lint -query file.sql
file.sql:1:CLA.001 最外层SELECT未指定WHERE条件
file.sql:1:COL.001 不建议使用SELECT * 类型查询Vim Plugin
Ensure the soar binary is in $PATH and executable ( chmod a+x soar ).
Copy doc/example/soar.vim to ${SyntasticInstalledPath}/syntax_checkers/sql (e.g., ~/.vim/bundle/pristine/syntastic/syntax_checkers/sql ).
Edit ${SyntasticInstalledPath}/plugin/syntastic/registry.vim to add sql:['soar','sqlint'] .
Update ~/.vimrc to enable Syntastic pop‑ups.
After these steps, opening a file in Vim and saving will display SOAR’s suggestions.
Sublime Text 3 Plugin
Make the soar binary executable ( chmod a+x soar ).
Install SublimeLinter (see its documentation).
Clone the plugin repository: git clone https://github.com/liipx/SublimeLinter-soar.git .
Add the following to your SublimeLinter user settings:
{
"linters": {
"soar": {
"soar_path": "your_soar_path"
}
}
}Restart Sublime Text and open an SQL file to see the suggestions.
VS Code Plugin
Make the soar binary executable ( chmod a+x soar ) and ensure it is in $PATH .
Locate the VS Code extensions folder ( ${HOME}/.vscode/extensions on macOS/Linux, %USERPROFILE%\.vscode\extensions on Windows).
Clone the extension source: git clone https://github.com/liipx/vscode-extension-soar .
Follow the README to compile the TypeScript client and server, then reload VS Code.
After installation, opening an SQL file will trigger SOAR’s analysis and display diagnostics.
Conclusion
SOAR is not only for DBAs; it aims to improve SQL quality throughout its lifecycle, benefiting developers, DBAs, and operations engineers alike. By integrating SOAR into popular editors, users can receive real‑time feedback and write higher‑quality SQL code.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.