freitass / todo.txt-vim

Vim plugin for Todo.txt
486 stars 121 forks source link

some mappings are not working as intended #42

Closed iamdionysus closed 9 years ago

iamdionysus commented 9 years ago

For example, I have this setting in my vimrc.

let mapleader = ' '
let maplocalleader = ' '
nnoremap <Leader>b :CtrlPBuffer<cr>
nnoremap <Leader>k :bprevious\|bdelete \#<cr>

However, hasmapto function is not checking my setting correctly.

:echo hasmapto("<leader>k",'n') "  => 0
:echo hasmapto("<localleader>k",'n') "  => 0
:echo hasmapto("<leader>b",'n') " => 1
:echo hasmapto("<localleader>b",'n') " => 1

It leads to the whole mapping checking behaves in a strange way. Is there anyway I can globally disable the mapping instead of checking mapping respectively?

freitass commented 9 years ago

@iamdionysus, please help me understand how this relates to todo.txt-vim. I created a new vimrc with that configuration (no plugins) and all of the hasmapto calls returned 0. A minimal vimrc that reproduces the problem might help figuring out a solution.

iamdionysus commented 9 years ago

After I tested as you said, I found how this relates to todo.txt-vim. hasmapto checking itself should not be used for your intention.

:echo hasmapto(":<Leader>b") " => 0
:echo hasmapto(":CtrlPBuffer<cr>") " => 1

Please take a look at the help of hasmapto function :help hasmapto. It is checking rhs not the lhs.

For you information, vim-fugitive is mapping keys when the user does not refuse it.

 if !exists('g:fugitive_no_maps')
      cnoremap <buffer> <expr> <C-R><C-G> fnameescape(<SID>recall())
      nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR>
endif
freitass commented 9 years ago

@iamdionysus, thanks for the explanation. Now I understood that I'm using the hasmapto the wrong way. Originally those checkings before the mappings were introduced to avoid conflicts with other plugins. However, since was replaced by I don't see why I should worry about that anymore. Would it solve your problem if those checkings were removed?

iamdionysus commented 9 years ago

It sounds great. I'll probably map some keys for myself.