Skip to content

Commit

Permalink
Fallback for Neovim's deprecated behave command
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Dec 19, 2024
1 parent 0e8e37a commit 3f06874
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions autoload/novim_mode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function! s:InsertAndSelectionBehaviour()
" So far I know `xterm` selection behaviour is critical for autocompletion plugins
" that do things like paste a snippet with placeholders that get selected and hence
" replaced when you start typing.
autocmd InsertEnter * behave xterm
autocmd InsertEnter * call g:BehaveXterm()
augroup END

" Make 'v' commands default to Visual mode.
Expand All @@ -79,6 +79,29 @@ function! s:InsertAndSelectionBehaviour()
set selectmode+=cmd
endfunction

" Mostly changes the way selection works.
" See: http://vimdoc.sourceforge.net/htmldoc/gui.html#:behave
" An extract from the docs about the difference between `behave mswin`
" and `behave xterm`:
" mswin xterm
" 'selectmode' 'mouse,key' ''
" 'mousemodel' 'popup' 'extend'
" 'keymodel' 'startsel,stopsel' ''
" 'selection' 'exclusive' 'inclusive'
function! g:BehaveMSWin()
set selection=exclusive
set mousemodel=popup
set selectmode=mouse,key
set keymodel=startsel,stopsel
endfunction

function! g:BehaveXterm()
set selection=inclusive
set mousemodel=extend
set selectmode=
set keymodel=
endfunction

" All shortcuts in one function so they can be more easily controlled.
function! g:SetNoVimModeShortcuts()
" Basic interactions with the editor
Expand Down Expand Up @@ -376,16 +399,7 @@ function! g:novim_mode#StartNoVimMode()
endfunction

function! novim_mode#EnterSelectionMode(type)
" Mostly changes the way selection works.
" See: http://vimdoc.sourceforge.net/htmldoc/gui.html#:behave
" An extract from the docs about the difference between `behave mswin`
" and `behave xterm`:
" mswin xterm
" 'selectmode' 'mouse,key' ''
" 'mousemodel' 'popup' 'extend'
" 'keymodel' 'startsel,stopsel' ''
" 'selection' 'exclusive' 'inclusive'
behave mswin
call g:BehaveMSWin()

if a:type == 'left'
execute "normal! \<S-Left>"
Expand Down

0 comments on commit 3f06874

Please sign in to comment.