From 70939c41f37173873096ec7cd5ad45e32f84b0cb Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Sun, 25 Jun 2017 21:29:47 +0700 Subject: Actually compare `has('timers')` to something :/ This properly deals with versions of VIm that don't support timers. So that older versions of Vim still work but run into the bug where some panes get insertmode inappropriately set. Touches #4 --- README.md | 2 ++ autoload/novim_mode.vim | 12 ++++++++---- plugin/novim_mode.vim | 12 +++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e8d279f..08a851a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ Use your favourite plugin manager, eg, for vim-plug; `Plug 'tombh/novim-mode'` +Note that Vim before v7.5 and Neovim before v0.1.5 have a bug where Insert Mode is inappropriately set for some panes. + ## Usage Most keybindings should work as you might expect from, say Atom or Sublime Text; `SHIFT+ARROW` to select and `CTRL+C/V` to copy/paste. But don't expect Vim to completely bend to your will, it is still useful to familiarise yourself with some of Vim's basic concepts. For instance you may on occasion find yourself stuck in a particular Vim mode, like when pasting text without 'Paste Mode' then inserted text can trigger random mappings. In such case `CTRL+Q` may not kill Vim and you'll need to find a way of getting to Normal Mode and typing `:q` then ``. Such is life with Vim, this plugin is highly unlikely to ever change that. (BTW conventional pasting is on by default, but to exit an errant 'Paste Mode' use `:set nopaste`.) diff --git a/autoload/novim_mode.vim b/autoload/novim_mode.vim index f93e29f..90aecc5 100644 --- a/autoload/novim_mode.vim +++ b/autoload/novim_mode.vim @@ -44,10 +44,14 @@ function! s:InsertAndSelectionBehaviour() " Intelligently set/unset insertmode augroup start_insertmode autocmd! - " The timer here delays the call to check whether the current buffer - " is an editable one. Without the delay, the check is often too early - " to correctly get the value of `&buftype`, etc. - autocmd BufEnter * call timer_start(1, {->execute('call s:InsertMode()')}) + if has('timers') == 1 + " The timer here delays the call to check whether the current buffer + " is an editable one. Without the delay, the check is often too early + " to correctly get the value of `&buftype`, etc. + autocmd BufEnter * call timer_start(1, {->execute('call s:InsertMode()')}) + else + autocmd BufEnter * call s:InsertMode() + endif augroup END " Mostly changes the way selection works. diff --git a/plugin/novim_mode.vim b/plugin/novim_mode.vim index 97d61c6..c30d5de 100644 --- a/plugin/novim_mode.vim +++ b/plugin/novim_mode.vim @@ -37,12 +37,14 @@ endfunction call s:init_settings(s:settings) -" Plugin entry point -if has('timers') - call g:novim_mode#StartNoVimMode() -else - echo 'Novim-mode will not work this version of Vim (no `timer` support).' +if has('timers') == 0 + echo "Novim-mode: Your Vim version (Vim <7.5 or Neovim <0.1.5) doesn't " + echo "support `timer()`, which causes a bug where Insert Mode is " + echo "innapropriately set for some panes." endif +" Plugin entry point +call g:novim_mode#StartNoVimMode() + let &cpo = s:save_cpo unlet s:save_cpo -- cgit v1.2.3-70-g09d2