dense-analysis / ale

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

proselint not working for text and markdown #518

Closed chew-z closed 7 years ago

chew-z commented 7 years ago

I am trying to use proselint and also experimenting with vale linter for markdown and text files but no joy.

There are obvious warnings in my text but ALE is ignoring them and showing that everything is OK.

My ALEInfo

Current Filetype: text
Available Linters: ['proselint', 'vale']
  Enabled Linters: ['proselint', 'vale']
 Linter Variables:
 Global Variables:
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_warning_str = 'W'
let g:ale_enabled = 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_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'mail': ['proselint'], 'perl': ['perl', 'perlcritic'], 'python': ['flake
8'], 'html': ['tidy'], 'javascript': ['flow'], 'text': ['proselint', 'vale'], 'markdown': ['proselint', 'vale'
]}
let g:ale_open_list = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 1
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', '⚠ %d', '⬥ ok']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:
(finished - exit code 1) ['/usr/local/bin/zsh', '-c', 'proselint /var/folders/fr/ljhkg84n6sq_ts6mzf4mymf00000g
n/T/v3SNu66/0/Taurus\ December\ SM.txt']
(finished - exit code 0) ['/usr/local/bin/zsh', '-c', 'vale /var/folders/fr/ljhkg84n6sq_ts6mzf4mymf00000gn/T/v
3SNu66/1/Taurus\ December\ SM.txt']

.vimrc

let g:ale_linters = {
            \   'html': ['tidy'],
            \   'javascript': ['flow'],
            \   'mail': ['proselint'],
            \   'markdown': ['proselint', 'vale'],
            \   'perl': ['perl', 'perlcritic'],
            \   'python': ['flake8'],
            \   'text': ['proselint', 'vale'],
            \   'vim': ['vint'],
            \   }
" 
let g:ale_lint_on_enter = 1
" Status line
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
" Message format
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'

output of :! proselint "%"

:! proselint "/Users/rrj/Notes/Astro/Taurus December SM.txt"
/Users/rrj/Notes/Astro/Taurus December SM.txt:3:44: garner.phrasal_adjectives.ly No hyphen is necessary in phr
asal adjectives with an adverb ending in -ly, unless the -ly adverb is part of a longer phrase
/Users/rrj/Notes/Astro/Taurus December SM.txt:5:79: weasel_words.very Substitute 'damn' every time you're incl
ined to write 'very;' your editor will delete it and the writing will be just as it should be. Found 5 times e
lsewhere.
/Users/rrj/Notes/Astro/Taurus December SM.txt:13:81: cliches.write_good 'on a roll!' is a cliché.
/Users/rrj/Notes/Astro/Taurus December SM.txt:13:90: leonard.exclamation.30ppm More than 30 ppm of exclamation
s. Keep them under control.
/Users/rrj/Notes/Astro/Taurus December SM.txt:40:711: corporate_speak.misc Minimize your use of corporate catc
hphrases like this one.
/Users/rrj/Notes/Astro/Taurus December SM.txt:60:353: garner.preferred_forms 'Meanwhile,' is the preferred for
m.

shell returned 1 

output of :! vale "%"

32:193  warning  Consider removing 'actually'    vale.Editorializing
 34:254  warning  Consider removing 'might'       vale.Hedging
 36:34   warning  Consider using 'some' instead   vale.Wordiness
                  of 'some of the'
 40:9    warning  Consider removing 'likely'      vale.Hedging
 40:168  warning  Consider removing 'very'        vale.Editorializing
 40:436  warning  Consider removing 'could'       vale.Hedging
 42:6    warning  Consider removing 'might'       vale.Hedging
 42:497  warning  Consider removing 'might'       vale.Hedging
 46:11   warning  Consider removing 'likely'      vale.Hedging
 46:545  warning  Consider using 'right' or       vale.ComplexWords
                  'exact' instead of 'accurate'
 46:554  warning  Consider using 'discuss'        vale.ComplexWords
                  instead of 'address'
 48:17   warning  Consider removing 'appear to    vale.Hedging
                  be'
 52:1    warning  Consider using 'about' instead  vale.ComplexWords
                  of 'Concerning'
 54:231  warning  Consider removing               vale.Editorializing
                  'exceedingly'
 58:43   warning  Consider removing 'somewhat'    vale.Hedging
 60:44   warning  Consider removing 'might'       vale.Hedging
 60:100  warning  Consider using 'about' instead  vale.ComplexWords
                  of 'concerning'
 62:268  warning  Consider removing 'possibly'    vale.Hedging
 64:35   warning  Consider removing 'likely'      vale.Hedging
 64:51   warning  Consider removing 'quite'       vale.Editorializing
 72:45   warning  Consider removing 'very'        vale.Editorializing
 72:50   warning  Consider removing 'likely'      vale.Hedging
 76:354  warning  Consider using 'merge' instead  vale.ComplexWords
                  of 'consolidate'
 78:188  warning  Consider using 'about' instead  vale.ComplexWords
                  of 'concerning'
 80:162  warning  Consider using 'send' instead   vale.ComplexWords
                  of 'transmit'
 82:116  warning  Consider removing               vale.Editorializing
                  'surprisingly'
 84:375  warning  Consider using 'lack(s)'        vale.Litotes
                  instead of 'not have'
 86:259  warning  Consider removing 'likely'      vale.Hedging
 92:259  warning  Consider removing 'very'        vale.Editorializing

✖ 0 errors, 44 warnings and 0 suggestions in 1 file.

vale.vim linter in /ale/ale_linters/markdown

call ale#linter#Define('markdown', {
\   'name': 'vale',
\   'executable': 'vale',
\   'command': "vale %",
\   'callback': 'ale#handlers#unix#HandleAsWarning',
\})
w0rp commented 7 years ago

I have fixed the proselint bug. The spaces in the filename weren't being handled correctly.

For the vale linter, you'll need to write a new function for parsing the errors, or you'll have to see if you can pass some options to vale to make it output errors in a format that can be parsed by the ale#handlers#unix#HandleAsWarning function.

chew-z commented 7 years ago

vale has the ability to change output format with --output=line.

Now it is working beautifully. Thank you... :+1:

Plugin content below. I will also try with --ext='.md' option of vale.

call ale#linter#Define('markdown', {
\   'name': 'vale',
\   'executable': 'vale',
\   'command': "vale --output=line %t",
\   'callback': 'ale#handlers#unix#HandleAsWarning',
\})
w0rp commented 7 years ago

Cool. Feel free to open a pull request for vale whenever.

yohannes commented 4 years ago

Hi @chew-z & @w0rp ,

I am not sure what I did wrong in my settings. But I can't have ale display any linting error when processing markdown file via vale. Here's outputs of some of the files.

ALEInfo:

Current Filetype: markdown
Available Linters: ['alex', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']
   Linter Aliases:
'remark_lint' -> ['remark-lint']
'writegood' -> ['write-good']
  Enabled Linters: ['vale']
 Suggested Fixers:
  'prettier' - Apply prettier to a file.
  'remark-lint' - Fix markdown files with remark-lint
  '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:
let g:ale_markdown_remark_lint_executable = 'remark'
let g:ale_markdown_remark_lint_options = ''
let g:ale_markdown_remark_lint_use_global = 0
 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 = '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_fixers = {}
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 = {'markdown': ['vale'], 'text': ['vale']}
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 = '[%linter%] %s [%severity%]'
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 = 0
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) vale
(finished - exit code 0) ['/bin/zsh', '-c', 'vale --output=JSON ''/var/folders/kx/3dgbmvjx14n9nk7f6w0px7l80000gn/T/v8nPkws/2/README.md''']
<<<OUTPUT STARTS>>>
{}
<<<OUTPUT ENDS>>>

.vimrc:

 let g:ale_linters = {'markdown': ['vale'], 'text': ['vale']}
 let g:airline#extensions#ale#enabled = 1
 let g:ale_fix_on_save = 1
 let g:ale_lint_on_enter = 1

vale --config "/Users/yohanes.wijaya/.config/vale/.vale.ini"


 README.md
 1:3     suggestion  'vale-boilerplate' should use   Microsoft.Headings     
                     sentence-style capitalization.                         
 1:3     warning     'vale-boilerplate' should use   Google.Headings        
                     sentence-style capitalization.                         
 3:6     suggestion  Try to avoid using 'is'.        write-good.E-Prime     
 7:11    suggestion  'is optimised' looks like       Microsoft.Passive      
                     passive voice.                                         
 7:11    warning     'is optimised' may be passive   write-good.Passive     
                     voice. Use active voice if you                         
                     can.                                                   
 7:11    suggestion  In general, use active voice    Google.Passive         
                     instead of passive voice ('is                          
                     optimised').                                           
 7:11    suggestion  Try to avoid using 'is'.        write-good.E-Prime     
 7:38    warning     'however' is too wordy.         write-good.TooWordy    
 7:47    warning     Try to avoid using              Google.We              
                     first-person plural like 'we'.                         
 7:47    warning     Try to avoid using              Microsoft.We           
                     first-person plural like 'we'.                         
 12:6    suggestion  Try to avoid using 'is'.        write-good.E-Prime     
 16:17   suggestion  Try to avoid using 'is'.        write-good.E-Prime     
 16:20   warning     Consider removing 'extremely'.  Microsoft.Adverbs      
 16:20   warning     'extremely' is a weasel word!   write-good.Weasel      
 18:50   warning     Avoid using 'will'.             Google.Will            
 18:120  warning     'However' is too wordy.         write-good.TooWordy    
 18:132  warning     Try to avoid using              Google.We              
                     first-person plural like 'we'.                         
 18:132  warning     Try to avoid using              Microsoft.We           
                     first-person plural like 'we'.                         
 18:173  warning     Avoid using 'will'.             Google.Will            
 20:17   suggestion  Try to avoid using 'is'.        write-good.E-Prime     
 30:6    suggestion  Try to avoid using 'is'.        write-good.E-Prime     
 30:6    warning     'is' is repeated!               write-good.Illusions   
 34:87   suggestion  Consider using 'has' instead    Microsoft.ComplexWords 
                     of 'contains'.                                         

✖ 0 errors, 13 warnings and 10 suggestions in 1 file.

vale.vim linter in /ale/ale_linters/markdown

" Author: chew-z https://github.com/chew-z
" Description: vale for Markdown files

call ale#linter#Define('markdown', {
 \   'name': 'vale',
 \   'executable': 'vale',
 \   'command': 'vale --output=JSON %t',
 \   'callback': 'ale#handlers#vale#Handle',
 \})