Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping no longer works if delimiteMate plugin is installed #133

Closed
grr opened this issue Apr 4, 2022 · 1 comment
Closed

Mapping no longer works if delimiteMate plugin is installed #133

grr opened this issue Apr 4, 2022 · 1 comment

Comments

@grr
Copy link

grr commented Apr 4, 2022

After commit e6d11b2, the mapping no longer works if the delimiteMate plugin is installed.

Minimal vimrc that exhibits problem:

execute pathogen#infect()
set backspace=indent,eol,start
filetype plugin indent on
let g:delimitMate_expand_cr = 1

Tested on:

Vim 8.2.4324
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 21 2022 22:47:27)
macOS version - arm64
Included patches: 1-4324
Compiled by MacPorts
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           -python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
-cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
system vimrc file: "/opt/local/etc/vimrc"
    user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
    user exrc file: "$HOME/.exrc"
    defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/opt/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -DMACOS_X -DMACOS_X_DARWIN -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64 -o vim -lm -lncurses -liconv -lintl -framework AppKit
MacVim 8.2.3455 (172)
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 24 2021 14:13:29)
macOS version - arm64
Included patches: 1-3455
Compiled by GitHub Actions
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +file_in_path      -mouse_sysmouse    +tag_binary
+arabic            +find_in_path      +mouse_urxvt       -tag_old_static
+autocmd           +float             +mouse_xterm       -tag_any_white
+autochdir         +folding           +multi_byte        -tcl
-autoservername    -footer            +multi_lang        +termguicolors
+balloon_eval      +fork()            -mzscheme          +terminal
+balloon_eval_term +fullscreen        +netbeans_intg     +terminfo
+browse            +gettext           +num64             +termresponse
++builtin_terms    -hangul_input      +odbeditor         +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl/dyn          +title
+clientserver      +job               +persistent_undo   +toolbar
+clipboard         +jumplist          +popupwin          +transparency
+cmdline_compl     +keymap            +postscript        +user_commands
+cmdline_hist      +lambda            +printer           +vartabs
+cmdline_info      +langmap           +profile           +vertsplit
+comments          +libcall           +python/dyn        +virtualedit
+conceal           +linebreak         +python3/dyn       +visual
+cryptv            +lispindent        +quickfix          +visualextra
+cscope            +listcmds          +reltime           +viminfo
+cursorbind        +localmap          +rightleft         +vreplace
+cursorshape       +lua/dyn           +ruby/dyn          +wildignore
+dialog_con_gui    +menu              +scrollbind        +wildmenu
+diff              +mksession         +signs             +windows
+digraphs          +modify_fname      +smartindent       +writebackup
+dnd               +mouse             -sodium            -X11
-ebcdic            +mouseshape        -sound             -xfontset
+emacs_tags        +mouse_dec         +spell             +xim
+eval              -mouse_gpm         +startuptime       -xpm
+ex_extra          -mouse_jsbterm     +statusline        -xsmp
+extra_search      +mouse_netterm     -sun_workshop      -xterm_clipboard
-farsi             +mouse_sgr         +syntax            -xterm_save
system vimrc file: "$VIM/vimrc"
    user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
    user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknow
n-pragmas -pipe -DMACOS_X -DMACOS_X_DARWIN -g -O2 -arch x86_64 -arch arm64 -D_REENTRA
NT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -Wall -Wextra -Wshadow -Werror -Wno-error=mi
ssing-field-initializers -Wno-error=deprecated-declarations -Wno-error=unused-functio
n
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml
/lib -L/usr/local/opt/[email protected]/lib -L/usr/local/opt/readline/lib -L. -fstack-prote
ctor-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.
1/lib -L/usr/local/opt/readline/lib -arch x86_64 -arch arm64 -L/usr/local/lib -o Vim
-lm -lncurses -liconv /usr/local/lib/libintl.a -framework AppKit -fstack-protector -L
/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
@tpope
Copy link
Owner

tpope commented Apr 4, 2022

It's this:

https://github.com/Raimondi/delimitMate/blob/537a1da0fa5eeb88640425c37e545af933c56e1b/plugin/delimitMate.vim#L398-L399

delimitMate is creating a buffer local map before the buffer is initialized and before all plugins have loaded. This is, at best, a hack, and there's not a good way for Endwise to work around it. It worked in older versions because Endwise wasn't verifying the map it was combining with was global, but this caused other problems.

But that's just the first problem. Endwise maps <CR> globally, and supports combining with other global maps. delimitMate maps <CR> in every buffer, and doesn't support combining with any other maps in any capacity. So "fixing" this (e.g., with a VimEnter event), will only cause Endwise to win rather than delimitMate.

But luckily there's a workaround. If you define delimitMate's <CR> map globally, Endwise can combine with it, without any special support from delimitMate. This vimrc works:

execute pathogen#infect()
set backspace=indent,eol,start
filetype plugin indent on
if empty(maparg('<CR>', 'i'))
  imap <CR> <Plug>delimitMateCR
endif

(The empty(maparg('<CR>', 'i')) prevents breaking things if you :source ~/.vimrc after Vim is already up and running.)

My recommendation to the delimitMate author, if they see this, is to switch to a global <CR> map. Mapping it in every single buffer (or all buffers with a few exceptions) is just making things difficult for little gain. Although beware of edge cases like the command-line-window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants