dense-analysis / ale

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

Uncrustify requires to specify the language when is reading from stdin #2546

Open TheAifam5 opened 5 years ago

TheAifam5 commented 5 years ago

Information

VIM version

NVIM v0.3.6 Build type: Release SpaceVIM: SpaceVim 1.2.0-dev-c2d56dd4

Operating System: ArchLinux

What went wrong

As in help of the uncrustify says:

If reading from stdin, you should specify the language using -l
or specify a filename using --assume for automatic language detection.

The file is currently applied as a stdin to uncrustify.

Workaround

autocmd BufEnter *.c,*.cpp,*.h,*.hpp call myspacevim#fix_uncrustify()
function! myspacevim#fix_uncrustify()
  " Get project directory
  let currdir = getcwd()

  " Fix the uncrustify options
  let g:ale_c_uncrustify_options = '-l ' . &filetype . ' -c "' . currdir . '/uncrustify.cfg"' 
endfunction

Reproducing the bug

  1. Create a folder
  2. Make a cpp file inside
  3. Generate a configuration file using uncrustify --update-config-with-doc -o uncrustify.cfg
  4. Open VIM and open the file created at 2.
  5. Voilà.

:ALEInfo


 Current Filetype: cpp
Available Linters: ['ccls', 'clang', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'flawfinder', 'gcc']
   Linter Aliases:
'gcc' -> ['g++']
  Enabled Linters: ['ccls']
 Suggested Fixers: 
  'clang-format' - Fix C/C++ and cuda files with clang-format.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'uncrustify' - Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.
 Linter Variables:

let g:ale_cpp_ccls_executable = 'ccls'
let g:ale_cpp_ccls_init_options = {}
 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 = '%severity%: %linter%: %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 = 1
let g:ale_fixers = {'c': ['uncrustify'], 'cpp': ['uncrustify']}
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 = 750
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'c': ['ccls'], 'cpp': ['ccls']}
let g:ale_linters_explicit = 1
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%severity%: %linter%: %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 = ['✗ %d', '⚡ %d', '✔ OK']
let g:ale_type_map = {}
let g:ale_use_global_executables = 1
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:

(started) ['/usr/bin/zsh', '-c', '''ccls''']
(finished - exit code 0) ['/usr/bin/zsh', '-c', '''uncrustify'' --no-backup -l cpp -c "/home/theaifam5/Documents/Projects/xxxx/uncrustify.cfg" < ''/tmp/nvimm7E8hd/10/xs_vtable_manager.hpp''']
RyanSquared commented 5 years ago

related: #2259

w0rp commented 5 years ago

This can be fixed by using the filetype from Vim.