kana / vim-smartword

Vim plugin: Smart motions on words
http://www.vim.org/scripts/script.php?script_id=2470
70 stars 8 forks source link

Using vim-smartword with CamelCaseMotion #8

Open nilsboy opened 8 years ago

nilsboy commented 8 years ago

I can't get vim-smartword to work in conjunction with CamelCaseMotion. With the vimrc below smartword is working but without CamelCaseMotion.

What am I missing? Thanx for your Help.

This is a runnable test case vimrc:

set expandtab
set autoindent
set smarttab
set tabstop=2
set softtabstop=2
set shiftwidth=2

" Test:
" CamelCaseMotion-foo_bar
" - name: FooBarBaz

let g:plugin_dir = expand('~/.vim/dein')
let g:dein_dir = g:plugin_dir . '/repos/github.com/Shougo/dein.vim'
execute 'set runtimepath+=' . g:dein_dir

if !isdirectory(g:dein_dir)
  call mkdir(g:dein_dir, 'p')
  silent execute printf('!git clone --depth 1 %s %s', 'http://github.com/Shougo/dein.vim', g:dein_dir)
endif

call dein#begin(g:plugin_dir)

" Let dein manage dein
call dein#add('Shougo/dein.vim')

call dein#add('bkad/CamelCaseMotion')
" map <silent> w <Plug>CamelCaseMotion_w
" map <silent> b <Plug>CamelCaseMotion_b

call dein#add('kana/vim-smartword')
map w  <Plug>(smartword-w)
map b  <Plug>(smartword-b)
map <Plug>(smartword-basic-w)  <Plug>CamelCaseMotion_w
map <Plug>(smartword-basic-b)  <Plug>CamelCaseMotion_b

call dein#end()

if dein#check_install() 
  call dein#install()
endif

autocmd VimEnter * call dein#call_hook('post_source')

filetype plugin indent on

finish
sainnhe commented 2 years ago

For people who encountered the same problem, try autocmd:

function s:smartword_mappings() abort
  map <Plug>(smartword-basic-w) <Plug>CamelCaseMotion_w
  map <Plug>(smartword-basic-b) <Plug>CamelCaseMotion_b
  map <Plug>(smartword-basic-e) <Plug>CamelCaseMotion_e
endfunction
augroup SmartWordCustom
  autocmd!
  autocmd VimEnter * call <SID>smartword_mappings()
augroup END