dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.59k stars 1.44k forks source link

Extra flag for sqlfmt causes file to be replaced by a warning #2808

Open jgarst opened 5 years ago

jgarst commented 5 years ago

VIM version NVIM v0.4.2 Build type: Release

Operating System: Arch Linux

What went wrong

Formatting with the sqlfmt fixer causes all text to be replaced with unknown shorthand flag: 'w' in -w

changing sqlfmt.vim from

    return {
    \   'command': ale#Escape(l:executable)
    \       . ' -w'
    \       . (empty(l:options) ? '' : ' ' . l:options),
    \}

to

   return {
    \   'command': ale#Escape(l:executable)
    \       . (empty(l:options) ? '' : ' ' . l:options),
    \}

fixes the issue

Reproducing the bug

  1. have sqlfmt installed through the aur package or binary
  2. set g:ale_fixers to {'sql': ['sqlfmt']}
  3. run ALEFix

then file is replaced with error text

It is possible this is a fixer name collision, and this fixer setup is intended for a different sql formatter. But I haven't been able to find that formatter?

:ALEInfo

Current Filetype: sql Available Linters: ['sqlint'] Enabled Linters: ['sqlint'] Suggested Fixers: 'pgformatter' - A PostgreSQL SQL syntax beautifier 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'sqlfmt' - Fix SQL files with sqlfmt. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. Linter Variables:

Global Variables:

let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = 0 let g:ale_command_wrapper = '' let g:ale_completion_delay = v:null let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = v:null let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '%code: %%s' let g:ale_echo_msg_info_str = 'Info' let g:ale_echo_msg_warning_str = 'Warning' let g:ale_enabled = 1 let g:ale_fix_on_save = 0 let g:ale_fixers = {'sql': ['sqlfmt']} let g:ale_history_enabled = 1 let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 200 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {} let g:ale_linters_explicit = 0 let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 let g:ale_loclist_msg_format = '%code: %%s' let g:ale_lsp_root = {} let g:ale_max_buffer_history_size = 20 let g:ale_max_signs = -1 let g:ale_maximum_file_size = v:null let g:ale_open_list = 0 let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_set_balloons = 0 let g:ale_set_highlights = 1 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = 1 let g:ale_sign_error = '>>' let g:ale_sign_info = '--' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = '>>' let g:ale_sign_style_warning = '--' let g:ale_sign_warning = '--' let g:ale_statusline_format = v:null let g:ale_type_map = {} let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 0 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History:

(executable check - success) sqlint (finished - exit code 0) ['/usr/bin/bash', '-c', 'sqlint < ''/tmp/nvim35UVni/1/scratch.sql''']

<<>>

(finished - exit code 2) ['/usr/bin/bash', '-c', '''sqlfmt'' -w < ''/tmp/nvim35UVni/2/scratch.sql'''] (finished - exit code 1) ['/usr/bin/bash', '-c', 'sqlint < ''/tmp/nvim35UVni/3/scratch.sql''']

<<>> stdin:1:1:ERROR syntax error at or near "unknown" <<>>

(finished - exit code 1) ['/usr/bin/bash', '-c', 'sqlint < ''/tmp/nvim35UVni/4/scratch.sql''']

<<>> stdin:1:1:ERROR syntax error at or near "unknown" <<>>

jgarst commented 5 years ago

It does look like the autoloaded fixer expects https://github.com/jackc/sqlfmt, and I had https://github.com/mjibson/sqlfmt installed.

I'll leave this issue up, because it was a really easy mistake to make.

w0rp commented 5 years ago

I think it's worth detecting this and handling it.