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

Add option to check prefix override. #26

Open
nametake opened this issue Nov 2, 2019 · 4 comments
Open

Add option to check prefix override. #26

nametake opened this issue Nov 2, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@nametake
Copy link

nametake commented Nov 2, 2019

Hi, thank you for the great plugin. I use it very conveniently.

But I don't want to check if the prefix overrides other commands.

This is because I disable popup and use the prefix set in gopher_map in the prefix of another plugin command.

So how about adding the following options?

let g:gopher_map = {
      \   '_check_map': 0,
      \ }

And, ftplugin/go.vim.

  let s:is_check = g:gopher_map['_check_map']
  let s:has_norm = s:is_check ? mapcheck(g:gopher_map['_nmap_prefix'], 'n') isnot# '' : 0
  let s:has_ins  = s:is_check ? mapcheck(g:gopher_map['_imap_prefix'], 'i') isnot# '' : 0

Thanks.

@arp242
Copy link
Owner

arp242 commented Nov 3, 2019

I'm trying to understand your use case, but I'm not sure if I follow exactly what the source of your problem is. I don't understand what you mean with "use the prefix set in gopher_map in the prefix of another plugin command". Do you mean you have the prefer (e.g. ;) mapped to something else as well? Maybe you can share the relevant parts of the configuration?

I'd prefer to avoid adding another setting and just do the The Right Thing™ instead, if that's possible.

@nametake
Copy link
Author

nametake commented Nov 4, 2019

Thank you for your reply. And sorry for not enough information.

GoDiag's result is below.

VERSION
    VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 23 2019 15:11:17); macOS 版
    go version go1.13.4 darwin/amd64; GOPATH=/Users/nametake/go; GOROOT=/usr/local/Cellar/g
o/1.13.4/libexec; GO111MODULE=auto
    gopher.vim version 6404926 2019-10-31 14:01:58  0800 (4 days ago) Don't override existi
ng user mappings

VARIABLES
    gopher_highlight      ['string-spell', 'string-fmt']
    gopher_build_flags    []
    gopher_build_tags     []
    gopher_tag_transform   snakecase
    gopher_tag_default     json
    gopher_map            {'_default': 1, 'return': 'r', 'implement': 'm', 'error': 'e', '_
imap_ctrl': 1, '_popup': 1, '_nmap_prefix': ';', '_imap_prefix': '<C-k>', 'if': 'i'}
    gopher_tag_complete   ['db', 'json', 'json,omitempty', 'yaml']
    gopher_debug          []

COMMAND HISTORY (newest on top)

And, the minimum configuration .vimrc I am thinking of is below.

function AnotherPluginFunc() abort
  echomsg 'func'
endfunction

nnoremap <Plug>(another-plugin-cmd) :<C-u>call AnotherPluginFunc()<CR>

nmap ;a <Plug>(another-plugin-cmd)

call plug#begin('~/.vim/plugged')

Plug 'arp242/gopher.vim'
let g:gopher_map = {
      \   '_popup': 0,
      \ }

call plug#end()

With the above vimrc configuration, the following error message is displayed when vim starts.

gopher.vim: skipping normal mode mappings as ; is already mapped to <Plug>(another-plugin-cmd)

I want to use gopher.vim commands (e.g. ;r) without using popup.

I also want to use the prefix used in gopher.vim as a prefix for other commands.

Thank you.

arp242 added a commit that referenced this issue Nov 4, 2019
This reverts commit 6404926.

It's more complex than I thought, and may break things for some users.
See #26.
@arp242
Copy link
Owner

arp242 commented Nov 4, 2019

Right, I see what you mean now: you have ;a – which is not a gopher.vim mapping – mapped to something unrelated, and that's needlessly preventing all the mappings. Thanks for explaining.

So how it should work is something like:

  • Popup menu enabled: works as it is now, since it hijacks all of ; (although arguably it shouldn't and work with timeout/ttimeoutlike regular Vim mappings?)
  • Popup menu disabled and exactly ; is mapped: don't need to do anything.
  • Popup menu disabled and ;i or any other gopher.vim mapping is mapped: display a warning.

I think that would work?

It's not a simple change, and I want to work on another project this week. I've reverted this change for the time being, until I can do it right. Updating to the latest master should fix things for you for now.

@nametake
Copy link
Author

nametake commented Nov 4, 2019

Thank you for your quick response!

After updating to master, no errors occurred.

  • Popup menu enabled: works as it is now, since it hijacks all of; (although arguably it shouldn't and work with timeout / ttimeoutlike regular Vim mappings?)
  • Popup menu disabled and exactly ; is mapped: don't need to do anything.
  • Popup menu disabled and ;i or any other gopher.vim mapping is mapped: display a warning.

I think the above is the best!

Thank you very much.

@arp242 arp242 added the bug Something isn't working label Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants