Do not change/set `switchbuf=useopen`
It gets set using setlocal, but is a global setting.
https://github.com/fs111/pydoc.vim/blob/master/ftplugin/python_pydoc.vim#L120
we could guard it with a config setting, which is on by default for backwards compatibility. Do you feel like giving that a try?
I would not add a config option for this: after all this is a config that the user is meant to make (globally).
If it was particular useful in special cases, it could be set/changed using a FileType autocommand for example. The docs could mention how to do this and provide a link to this setting's documentation.
An idea might be to use autocommands to override it when the user enters a pydoc buffer (and restore it), but that's probably not worth it.
It has been like this for roughly 12 years, so it should be backwards compatible IMO
It has been like this for roughly 12 years, so it should be backwards compatible IMO
You have a point there, but I would consider it to be just an old bug then, especially given that it uses setlocal, while it's a global setting.
It took me quite some effort back then to figure out that pydoc was changing this setting, and I think that more users are being annoyed by this than being helped.
Adding a setting for this just feels wrong, but you could start with the following patch:
diff --git i/ftplugin/python_pydoc.vim w/ftplugin/python_pydoc.vim
index 88d1ebd..f19f7fa 100644
--- i/ftplugin/python_pydoc.vim
+++ w/ftplugin/python_pydoc.vim
@@ -117,7 +117,12 @@ if !exists('g:pydoc_open_cmd')
let g:pydoc_open_cmd = 'split'
endif
-setlocal switchbuf=useopen
+" Override `switchbuf` setting by default, unless g:pydoc_no_switchbuf is
+" provided.
+if !exists('g:pydoc_no_switchbuf')
+ set switchbuf=useopen
+endif
+
highlight pydoc cterm=reverse gui=reverse
function! s:GetWindowLine(value)
I have just removed this line locally.