Skip to content

Commit 0911a3f

Browse files
committed
Add a toggle-able Grammalecte function
1 parent 3b41fa6 commit 0911a3f

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

Diff for: README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ of Grammalecte into your ~/.vimrc file using something like:
6262

6363
## Description ##
6464

65-
The Grammalecte plugin defines 2 commands :GrammalecteCheck and
66-
:GrammalecteClean.
65+
The Grammalecte plugin defines 3 commands :GrammalecteCheck, :GrammalecteClean
66+
and :Grammalecte.
6767

6868
:GrammalecteCheck
6969

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

86+
:Grammalecte
87+
88+
Use the :Grammalecte command to toggle checking of grammar mistakes. It
89+
allows you to define toggle remap like:
90+
91+
nnoremap <Leader>tg :Grammalecte<Return>
92+
8693
See :help Grammalecte for more details.
8794

8895
## License ##

Diff for: doc/Grammalecte.txt

+12-5
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ colorscheme:
164164

165165
6. Features *grammalecte-features*
166166

167-
The Grammalecte plugin defines 2 commands |:GrammalecteCheck| and
168-
|:GrammalecteClean|.
167+
The Grammalecte plugin defines 3 commands |:GrammalecteCheck|,
168+
|:GrammalecteClean| and |:Grammalecte|.
169169

170-
:GrammalecteCheck *:GrammalecteCheck*
170+
:GrammalecteCheck *:GrammalecteCheck*
171171

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

182-
:GrammalecteClear *:GrammalecteClear*
182+
:GrammalecteClear *:GrammalecteClear*
183183

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

188-
The two commands are also available from the menu in gvim: >
188+
:Grammalecte *:Grammalecte*
189+
190+
Use the |:Grammalecte| command to toggle checking of grammar mistakes. It
191+
allows you to define toggle remap like:
192+
193+
nnoremap <Leader>tg :Grammalecte<Return>
194+
195+
The two main commands are also available from the menu in gvim: >
189196
190197
Plugin -> Grammalecte -> Check
191198
-> Clear

Diff for: plugin/Grammalecte.vim

+17
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ function s:GrammalecteClear() "{{{1
302302
unlet! s:grammalecte_text_winid
303303
endfunction
304304

305+
function s:Grammalecte(bang, line1, line2)
306+
if a:bang
307+
if exists('s:grammalecte_text_winid')
308+
call s:GrammalecteClear()
309+
endif
310+
else
311+
if exists('s:grammalecte_text_winid') == 0
312+
call s:GrammalecteCheck(a:line1, a:line2)
313+
else
314+
call s:GrammalecteClear()
315+
end
316+
end
317+
endfunction
318+
305319
hi def link GrammalecteCmd Comment
306320
hi def link GrammalecteErrorCount Title
307321
hi def link GrammalecteLabel Label
@@ -319,4 +333,7 @@ endif
319333
com! -nargs=0 GrammalecteClear :call s:GrammalecteClear()
320334
com! -nargs=0 -range=% GrammalecteCheck :call s:GrammalecteCheck(<line1>,
321335
\ <line2>)
336+
com! -nargs=0 -range=% -bar -bang Grammalecte :call s:Grammalecte(<bang>0,
337+
\ <line1>,
338+
\ <line2>)
322339
" vim: fdm=marker

0 commit comments

Comments
 (0)