2022-07-03

GNU DICTION - VIM Configuration

GNU DICTION is a simple tool for improving your writing, it helps to quickly identify commonly misused phrases in text files (included with windiction).

This note describes how to display GNU Diction's output inside a Quickfix list as shown in the video below:

Open windiction and click the VIM button (see figure below),

then copy and paste the clipboard content inside the configuration below:

    ""*****************************************************************************
    ""  GNU Diction
    ""*****************************************************************************

    "" paste windiction_dir and windiction_lang here from the UI

    function! GNUDiction()

        let l:currbuff =expand("%:p")
        let g:gnudiction_disp='!start cmd /c /q cd '.g:windiction_dir.' & diction_linter.exe '.g:windiction_lang.' " '.l:currbuff.' "'
        exec l:gnudiction_disp
        let &errorformat = '%f:%l:%c:%m'
        let l:dictiontmpfile=g:windiction_dir.'\\.error_list'
        execute 'silent! caddfile ' . l:dictiontmpfile
        execute 'copen'

    endfunction
    

Finally, add everything to the .vimrc file.

Alternatively, it's possible to use the Spawn command, which is part of Dispatch VIM plugin. An artificial delay is required before displaying the error list.

    ...
        let l:gnudiction_disp='Spawn! -dir='.g:windiction_dir.' diction_linter.exe '.g:windiction_lang.' "'.l:currbuff.'"'
        exec l:gnudiction_disp
        let &errorformat = '%f:%l:%c:%m'
        let l:dictiontmpfile=g:windiction_dir.'\\.error_list'
        sleep 1
     ...
    

The previous function can be called with:

   :call GNUDiction()