Skip to content

Commit

Permalink
Add a toggle-able Grammalecte function
Browse files Browse the repository at this point in the history
  • Loading branch information
akarzim committed Nov 3, 2017
1 parent 3b41fa6 commit 0911a3f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ of Grammalecte into your ~/.vimrc file using something like:

## Description ##

The Grammalecte plugin defines 2 commands :GrammalecteCheck and
:GrammalecteClean.
The Grammalecte plugin defines 3 commands :GrammalecteCheck, :GrammalecteClean
and :Grammalecte.

:GrammalecteCheck

Expand All @@ -83,6 +83,13 @@ Use the :GrammalecteClear command to clear highlighting of grammar
mistakes, close the scratch window containing the list of errors, clear
and close the location-list.

:Grammalecte

Use the :Grammalecte command to toggle checking of grammar mistakes. It
allows you to define toggle remap like:

nnoremap <Leader>tg :Grammalecte<Return>

See :help Grammalecte for more details.

## License ##
Expand Down
17 changes: 12 additions & 5 deletions doc/Grammalecte.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ colorscheme:

6. Features *grammalecte-features*

The Grammalecte plugin defines 2 commands |:GrammalecteCheck| and
|:GrammalecteClean|.
The Grammalecte plugin defines 3 commands |:GrammalecteCheck|,
|:GrammalecteClean| and |:Grammalecte|.

:GrammalecteCheck *:GrammalecteCheck*
:GrammalecteCheck *:GrammalecteCheck*

Use the |:GrammalecteCheck| command to check the grammar in the current
buffer. This will highlight errors in the buffer. It will also open a new
Expand All @@ -179,13 +179,20 @@ grammar between lines 100 and 200 in buffer with :100,200GrammalecteCheck,
check grammar in the visual selection with :<',>'GrammalecteCheck, etc.
The default range is 1,$ (whole buffer).

:GrammalecteClear *:GrammalecteClear*
:GrammalecteClear *:GrammalecteClear*

Use the |:GrammalecteClear| command to clear highlighting of grammar
mistakes, close the scratch window containing the list of errors, clear
and close the location-list.

The two commands are also available from the menu in gvim: >
:Grammalecte *:Grammalecte*

Use the |:Grammalecte| command to toggle checking of grammar mistakes. It
allows you to define toggle remap like:

nnoremap <Leader>tg :Grammalecte<Return>

The two main commands are also available from the menu in gvim: >
Plugin -> Grammalecte -> Check
-> Clear
Expand Down
17 changes: 17 additions & 0 deletions plugin/Grammalecte.vim
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,20 @@ function s:GrammalecteClear() "{{{1
unlet! s:grammalecte_text_winid
endfunction

function s:Grammalecte(bang, line1, line2)
if a:bang
if exists('s:grammalecte_text_winid')
call s:GrammalecteClear()
endif
else
if exists('s:grammalecte_text_winid') == 0
call s:GrammalecteCheck(a:line1, a:line2)
else
call s:GrammalecteClear()
end
end
endfunction

hi def link GrammalecteCmd Comment
hi def link GrammalecteErrorCount Title
hi def link GrammalecteLabel Label
Expand All @@ -319,4 +333,7 @@ endif
com! -nargs=0 GrammalecteClear :call s:GrammalecteClear()
com! -nargs=0 -range=% GrammalecteCheck :call s:GrammalecteCheck(<line1>,
\ <line2>)
com! -nargs=0 -range=% -bar -bang Grammalecte :call s:Grammalecte(<bang>0,
\ <line1>,
\ <line2>)
" vim: fdm=marker

0 comments on commit 0911a3f

Please sign in to comment.