dense-analysis / ale

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

Highlight blank line at the top of PHP file as a syntax error #939

Closed yramagicman closed 6 years ago

yramagicman commented 7 years ago

Forgive me if this is the wrong place to file this bug, but I just spent an hour debugging a PHP program that wasn't working because I had a blank line at the top of the file. Is there a way ale can highlight that as a syntax error?

w0rp commented 7 years ago

If php gives you a syntax error for the file, then that could help.

Could you paste the output of :ALEInfo when you have a blank line at the top of a file? There might be something from some program we can parse in there. Or maybe php itself will return some message we could parse, which isn't being captured at the moment.

yramagicman commented 7 years ago
Current Filetype: php
Available Linters: ['hack', 'langserver', 'php', 'phpcs', 'phpmd', 'phpstan']
  Enabled Linters: ['hack', 'langserver', 'php', 'phpcs', 'phpmd', 'phpstan']
 Linter Variables:
let g:ale_php_langserver_executable = 'php-language-server.php'
let g:ale_php_langserver_use_global = 0
let g:ale_php_phpcs_executable = 'phpcs'
let g:ale_php_phpcs_standard = ''
let g:ale_php_phpcs_use_global = 0
let g:ale_php_phpmd_ruleset = 'cleancode,codesize,controversial,design,naming,unusedcode'
let g:ale_php_phpstan_executable = 'phpstan'
let g:ale_php_phpstan_level = '4'
 Global Variables:
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
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_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_open_list = 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 = 0
let g:ale_sign_error = '>>'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:
(finished - exit code 0) ['/usr/bin/zsh', '-c', 'php -l -d error_reporting=E_ALL -d display_errors=1 -- < ''/tmp/vnjyLvR/71/db_manager.php''']
<<<OUTPUT STARTS>>>
No syntax errors detected in -
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/bin/zsh', '-c', 'php -l -d error_reporting=E_ALL -d display_errors=1 -- < ''/tmp/vnjyLvR/72/db_manager.php''']
<<<OUTPUT STARTS>>>
No syntax errors detected in -
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/bin/zsh', '-c', 'php -l -d error_reporting=E_ALL -d display_errors=1 -- < ''/tmp/vnjyLvR/73/db_manager.php''']
<<<OUTPUT STARTS>>>
No syntax errors detected in -
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/bin/zsh', '-c', 'php -l -d error_reporting=E_ALL -d display_errors=1 -- < ''/tmp/vnjyLvR/74/db_manager.php''']
<<<OUTPUT STARTS>>>
No syntax errors detected in -
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/bin/zsh', '-c', 'php -l -d error_reporting=E_ALL -d display_errors=1 -- < ''/tmp/vnjyLvR/75/db_manager.php''']
<<<OUTPUT STARTS>>>
No syntax errors detected in -
<<<OUTPUT ENDS>>>

Php isn't seeing the blank line as a syntax error.

w0rp commented 7 years ago

Maybe there is a PHP linter out there which will complain about this.

yramagicman commented 7 years ago

Is there one you're already aware of that does that? I'll look around, but recommendations are always helpful.

w0rp commented 7 years ago

I'm not aware of one myself, but I wouldn't be surprised if there is one.

adriaanzon commented 6 years ago

Strange, for me the PHP linter does give an error about it:

image

w0rp commented 6 years ago

It's up to the tools to report this as an error. Some tool might do that.