Skip to content

Commit 25f6d17

Browse files
committed
feat: add g:pydocstring_enable_mapping option
Add new option to allow users to disable mappings entirely. Previously, users only had the option to override the default mapping with another one.
1 parent ae9b634 commit 25f6d17

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

doc/pydocstring.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ g:pydocstring_enable_comment *g:pydocstring_enable_comment*
161161

162162
Default value is '1'
163163

164+
g:pydocstring_enable_mapping *g:pydocstring_enable_mapping*
165+
Disable this option to prevent pydocstring from creating any
166+
key mapping to the `:Pydocstring` command.
167+
Note: this value is overridden if you explicitly create a
168+
mapping in your vimrc, such as if you do:
169+
170+
nmap <silent> <C-m> <Plug>(pydocstring)
171+
172+
Default value is '1'
173+
164174
==============================================================================
165175
EXAMPLE *pydocstring-vim-example*
166176

@@ -196,6 +206,10 @@ Override default mapping.
196206

197207
nmap <silent> <C-m> <Plug>(pydocstring)
198208

209+
To disable mappings entirely, add the following to your .vimrc or _vimrc.
210+
211+
let g:pydocstring_enable_mapping = 0
212+
199213

200214
==============================================================================
201215
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:

ftplugin/python/pydocstring.vim

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ set cpo&vim
1010

1111
command! -nargs=0 -buffer -complete=customlist,pydocstring#insert Pydocstring call pydocstring#insert()
1212

13-
nnoremap <silent> <buffer> <Plug>(pydocstring) :call pydocstring#insert()<CR>
14-
if !hasmapto('<Plug>(pydocstring)')
15-
nmap <silent> <C-l> <Plug>(pydocstring)
13+
if !exists('g:pydocstring_enable_mapping')
14+
let g:pydocstring_enable_mapping = 1
15+
endif
16+
17+
if g:pydocstring_enable_mapping == 1 || hasmapto('<Plug>(pydocstring)')
18+
nnoremap <silent> <buffer> <Plug>(pydocstring) :call pydocstring#insert()<CR>
19+
if !hasmapto('<Plug>(pydocstring)')
20+
nmap <silent> <C-l> <Plug>(pydocstring)
21+
endif
1622
endif
1723

1824
let &cpo = s:save_cpo

0 commit comments

Comments
 (0)