Skip to content

Commit

Permalink
refactor: get rid of diagnostic message
Browse files Browse the repository at this point in the history
This is in response to this feedback:

    wincent/command-t#393 (comment)

The user in question is loading Command-T like this, using packer:

    use {
      'wincent/command-t',
      run = 'cd lua/wincent/commandt/lib && make',
      config = function()
        vim.g.CommandTPreferredImplementation = 'lua'
        require('wincent.commandt').setup({})
      end
    }

and they see this whenever they run `:PackerCompile`:

    commandt.setup():
      `commandt.setup()` was called after Ruby plugin setup has already run

So, I'm removing this check as it doesn't add a lot of value. My advice,
then, is to move this statement:

    vim.g.CommandTPreferredImplementation = 'lua'

up into the top-level of the `~/.config/nvim/init.lua`. That way,
whenever Command-T's `plugin/command-t.vim` is sourced, it will do the
right thing, which means:

1. Skip doing anything if `command_t_loaded` is already set.
2. Do Lua-centric set-up instead of Ruby-centric set-up.

And then when `plugin/command-t.lua` is sourced (which will always
happen second, because Neovim loads Lua _after_ Vimscript), it will
again do the right thing (ie. do the Lua-centric instead of Ruby-centric
set-up).
  • Loading branch information
Padmamanickam authored and wincent committed Aug 27, 2022
1 parent 5d4d698 commit 013c338
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lua/wincent/commandt/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,7 @@ end
commandt.setup = function(options)
local errors = {}

if vim.g.command_t_loaded == 1 then
-- May not be an error if you (for whatever reason) are calling `setup()`
-- twice (ie. later on during a session), but it's presumed that if you're
-- doing that, you know enough about what you're doing not to understand
-- that this error message is nothing to worry about.
table.insert(errors, '`commandt.setup()` was called after Ruby plugin setup has already run')
elseif vim.g.CommandTPreferredImplementation == 'ruby' then
if vim.g.CommandTPreferredImplementation == 'ruby' then
table.insert(errors, '`commandt.setup()` was called, but `g:CommandTPreferredImplementation` is set to "ruby"')
else
vim.g.CommandTPreferredImplementation = 'lua'
Expand Down

0 comments on commit 013c338

Please sign in to comment.