Skip to content

Commit

Permalink
refactor(lua): get rid of g:CommandTSuppressRubyDeprecationWarning
Browse files Browse the repository at this point in the history
As noted in the previous commit, this seems like the right thing to do,
allowing us to get rid of a potentially confusing and redundant setting.

The only downside here is that we lose the prompt to automatically apply
the setting. Strictly speaking, I didn't _have_ to remove that, but it
felt a bit intrusive, and the `input()` call _did_ mess up the colors
like I said. So, this means the user _has_ to take action in order to
avoid seeing the message every time. That might be a bit annoying,
forcing a choice on the user, but it will at least ensure awareness.
Fingers crossed, I won't come to regret this decision.

Oh well, a new prompt like this _is_ a breaking change no matter what,
which is why this is going out with a major version bump (although as
noted elsewhere, SemVer doesn't mean much in the Vim world).

See: wincent/command-t#391
  • Loading branch information
Padmamanickam authored and wincent committed Jul 23, 2022
1 parent d544424 commit e0180c1
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions plugin/command-t.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ let s:prefers_ruby=get(g:, 'CommandTPreferredImplementation', 'unset') ==? 'ruby
let s:prefers_lua=get(g:, 'CommandTPreferredImplementation', 'unset') ==? 'lua'
let s:has_preference=s:prefers_ruby || s:prefers_lua

if has('nvim') &&
\ !s:has_preference &&
\ !get(g:, 'CommandTSuppressRubyDeprecationWarning', 0)
let s:lua_suppression = 'vim.g.CommandTSuppressRubyDeprecationWarning = 1'
let s:vimscript_suppression = 'let g:CommandTSuppressRubyDeprecationWarning=1'
if has('nvim') && !s:has_preference
let s:lua_suppression=[
\ ['To select Ruby (for the v6.0 series, the default):', "vim.g.CommandTPreferredImplementation = 'ruby'"],
\ ['To select Lua (from v7.0, will be the new default):', "require('wincent.commandt').setup()"]
\ ]
let s:vimscript_suppression=[
\ ['To select Ruby (for the v6.0 series, the default):', "let g:CommandTPreferredImplementation='ruby'"],
\ ['To select Lua (from v7.0, will be the new default):', "let g:CommandTPreferredImplementation='lua'"]
\ ]
let s:suppression=exists('$MYVIMRC') && match($MYVIMRC, '\c\.lua') > 0
\ ? s:lua_suppression
\ : s:vimscript_suppression
echohl WarningMsg
echo 'Notice'
echo '------'
Expand All @@ -26,32 +33,14 @@ if has('nvim') &&
echo 'See `:help command-t-upgrading` for information on how to choose'
echo 'between the Lua and the Ruby implementations.'
echo "\n"
echo 'To suppress this warning, add this to your vimrc:'
echo 'To suppress this warning, add one of these to your vimrc:'
echo "\n"
if exists('$MYVIMRC') && match($MYVIMRC, '\c\.lua') > 0
echo ' ' . s:lua_suppression
else
echo ' ' . s:vimscript_suppression
endif
echo "\n"
if exists('$MYVIMRC')
echo 'Your vimrc is currently at:'
echo "\n"
echo ' ' . $MYVIMRC
for [s:label, s:instruction] in s:suppression
echo ' ' . s:label
echo ' ' . s:instruction
echo "\n"
let s:response=trim(input('Would you like to add this line to it now? (y/n) '))
echo "\n"
if s:response ==? 'y' || s:response ==? 'ye' || s:response ==? 'yes'
if match($MYVIMRC, '\c\.lua') > 0
call writefile([s:lua_suppression], $MYVIMRC, 'a')
else
call writefile([s:vimscript_suppression], $MYVIMRC, 'a')
end
endif
endif
endfor
echohl none
" BUG: highlighting is all messed up after this... (until next focus-gained
" event; probably specific to my local set-up)
else
let s:prefers_ruby=1
endif
Expand Down

0 comments on commit e0180c1

Please sign in to comment.