dense-analysis / ale

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

textlint results don't displayed. #4275

Closed anosillus closed 2 years ago

anosillus commented 2 years ago

Information

VIM version

NVIM v0.7.2 Build type: Release

Dependency textlint 12.2.1 textlint-rule-en-capitalization 2.0.3-1

Operating System Arch Linux 5.18.13-arch1-1

What went wrong

Textlint output is not displayed. Textlint itself working, but the linter stdin output parser isn't working.

Reproducing the bug

  1. Install textlint and textlint-rule-en-capitalization and turn on ale-texltint settings.
  2. Generate text file with incorrect grammer. ( echo my pet is a cat. > hoge.txt )
  3. Open hoge.txt, I expect the linter's output showed in vim.
  4. I don't see any message from the linter on ALE interface.

    textlint result (in commnand line)

    command textlint --rule en-capitalization -f json cat.txt output

    [{"messages":[{"type":"lint","ruleId":"en-capitalization","message":"Paragraph: Follow the standard capitalization rules for American English.\nSee https://owl.english.purdue.edu/owl/resource/592/01/","index":0,"line":1,"column":1,"range":[0,1],"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2}},"severity":2,"fix":{"range":[0,2],"text":"My"}}],"filePath":"/home/hoge.txt"}]

ALEInfo

Current Filetype: text
Available Linters: ['textlint']
   Linter Aliases:
  Enabled Linters: ['textlint']
  Ignored Linters: []
 Suggested Fixers: 
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'textlint' - Fix text files with textlint --fix
  '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 = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
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 = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '[%linter%] %s [%severity%]'
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 = 1
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
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_sign_highlight_linenrs = 0
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) textlint
(finished - exit code 1) ['sh', '-c', '''textlint'' -f json --stdin --stdin-filename ''/home/hoge.txt'' < ''/tmp/nvimBNOWc3/3/hoge.txt''']

<<<OUTPUT STARTS>>>
{
  sentence: { start: { line: 1, column: 0 }, end: { line: 1, column: 16 } }
}
[{"messages":[{"type":"lint","ruleId":"en-capitalization","message":"Paragraph: Follow the standard capitalization rules for American English.\nSee https://owl.english.purdue.edu/owl/resource/592/01/","index":0,"line":1,"column":1,"range":[0,1],"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2}},"severity":2,"fix":{"range":[0,2],"text":"My"}},{"type":"lint","ruleId":"@textlint-rule/google/capitalization","message":"Paragraph: Follow the standard capitalization rules for American English.\nSee https://owl.english.purdue.edu/owl/resource/592/01/\nhttps://developers.google.com/style/capitalization","index":0,"line":1,"column":1,"range":[0,1],"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2}},"severity":2,"fix":{"range":[0,2],"text":"My"}},{"type":"lint","ruleId":"ginger","message":"my -> My","index":0,"line":1,"column":1,"range":[0,1],"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2}},"severity":2,"fix":{"range":[0,2],"text":"My"}}],"filePath":"<text>"}]
<<<OUTPUT ENDS>>>
anosillus commented 2 years ago

Unintended processing is occurring in this process.

https://github.com/dense-analysis/ale/blob/5063804d44fe149ed39149848f92b5960f4f7164/autoload/ale/handlers/textlint.vim#L25

lines value is below

['sentence: { start: { line: 1, column: 0 }, end: { line: 1, column: 16 } }', '{"messages":[{"type":"lint","ruleId":"en-capitalization","message":"Paragraph: Follow the standard capitalization rules for American English.\nSee https://owl.english.purdue.edu/owl/resource/592/01/", index":0,"line":1,"column":1,"range":[0,1],"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2}},"severity":2,"fix":{"range":[0,2],"text":"My"}}, "{"type":"lint","ruleId":"ginger","message":"my -> My","index":0,"line":1,"column":1,"range":[0,1],"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":2}},"severity":2,"fix":{"range":[0,2],"text":"My"}}']

Vim cann't decode lines inside ale#util#FuzzyJSONDecode. Because lines is broken json.

https://github.com/dense-analysis/ale/blob/f0887d3e6178482255f11aa378124aef3699245f/autoload/ale/util.vim#L414

Thus, res receives the value {'messages': []}, an empty value, and no error message is displayed.

anosillus commented 2 years ago

Please ignore this issue, maybe this error isn't reproductive.