-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🆕 Command-T 6.0.0 release — compendium issue #393
Comments
Yep, this is a known issue @vheon. There is no fallback implemented yet for any of these things. Possible failure modes include:
I had been postponing figuring out a solution for this because I wasn't sure what the best approach was. The problem is that the scanners all degrade "gracefully"; instead of returning errors, they effectively just return empty lists. As such, there are a number of main options, not necessarily mutually exclusive of one another:
I haven't thought deeply on it, but I feel like "2" + "3" sound like a reasonable idea, for starters. We might later want to do "4". I don't find "1" very appealing at this stage. |
This implements idea "3" from here: - #393 (comment) > we may also want to swallow `stderr` so it doesn't leak back in any > visible way (ie. that would mean changing a call to `git ...` into > `git ... 2> /dev/null` etc). The only catch is that this may make > trouble-shooting harder (users could edit out or change the redirect, > I guess). So, yeah. This is a double-edged sword, but in the next commit I am planning on dulling at least one of those edges by implementing a fallback behavior for each of these scanners.
This implements idea "2" from here: - #393 (comment) > We teach the callers to interpret an empty result list as a cue to > try again using a fallback mechanism; in an empty directory this would > give a false negative but a relatively harmless one (ie. you might run > `:CommandTRipgrep` in an empty folder, and Command-T would take that as > a cue to try again with the standard scanner, which would of course > also return an empty list). Specifically, we do this whenever `git`, `rg`, or `find` returns no results. There is a bit of duplication here because we need thunks at each site; otherwise as soon as we `require`-d the fallback finder it would do a redundant scan. I'm not going to factor that out yet because I am still not convinced that this is an optimal strategy. Want to let it bake for a while and see what happens.
I pushed 005b695 to implement a couple of those fallback ideas (specifically "2" and "3", like I said). Not sure if it's the best approach, but it's worth a shot. 🤷 |
My initial thoughts were simply to not let the error be displayed like that and maybe push a message through Anyway I'll give it a spin tomorrow at work, thanks for the quick response and fix! |
@wincent before discovering the problem with |
@vheon: I had thought about that while implementing the fallback, but didn't want to make any hasty decisions. Like, should the title include the word "fallback" to make it clear why the "wrong" scanner is being used? Would an |
In an ideal world probably a user might want the title to say something like:
So that I know what I ended up with and what I actually wanted to with a |
Because we might be wanting to change the behavior soon, it would be nice to be able to change in in _one_ place instead of three. Specifically, as per: - #393 (comment) we might be putting something in the prompt window title to indicate what happened.
As discussed here: - #393 (comment) That comment suggested being a bit more verbose: CommandT [ find (fall-backed from git) ] but here I'm going with something a little less descriptive: CommandT [fallback] seeing as the extra detail in the title doesn't tell you _what_ went wrong; really, all we can do here is show a hint that _something_ went wrong, so we might as well be brief about it. Two things to note about implementation: - One is that I am playing around here trying to figure out how much metatable magic I want in here without making it all too "clever". So here I have a `__newindex` implementation that allows us to write `prompt.name = 'fallback'` instead of `prompt:set_name('fallback')`. The former is visually cleaner, but I don't necessarily like that it hides the fact that an imperative side-effect is going to take place. I will probably "dumb this down" as opposed to trying to use the pattern in other places in a uniform way. - The other is that my earlier claims about top-down React-style dataflow are pretty much not true any more. It _was_ true at the start, when each component rendered using data passed into it; now we have muddied the waters considerably with imperative methods. I will almost certainly want to revisit this topic in the future.
@vheon Current proposal for communicating that a fallback happened is up in c16b272 — it just shows "fallback" in the end because I figure that we can't show complete diagnostic info in the title area, so there's not much value in saying more than that — it's just a cue that something didn't work. We can definitely looking at providing more detail via |
@wincent Enjoying this plugin with my neovim. One small gripe(mostly because I couldn't find it in documentation), how do I make it ignore directories (e.g: node_modules)? It slows massively because it also indexes node_modules from my project. |
Alright, I think |
@vinitkumar: If you're using the older Ruby implementation, there are a number of ways to ignore files. Using the In the newer Lua implementation, similar story — you can use |
I am using lua implementation. Perhaps, I will peek into your nvim config and see what you have done? |
Ah, there is nothing to configure if you want to use the Git finder. Just invoke vim.keymap.set('n', '<Leader>t', '<Plug>(CommandTGit)') This is (kind of) documented here. |
@wincent I'm not sure if this is actually a bug or if simply I'm not used to the sorter engine of Command-T: I'm "working" on my dotfiles (https://github.com/vheon/home) using the git scanner with this configuration If in the root directory I run but if I search for Is it on purpose? |
@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 |
As usual the RTFM would have solved my confusion without making noise here 😞 Thanks @wincent! |
As reported here: wincent/command-t#393 (comment) if `options.finders` is not set to (at least an empty) table, we freak out with: lua/wincent/commandt/init.lua:343: bad argument #1 to 'pairs' (table expected, got nil)
This is still a private function and I won't be adding it to the docs as officially supported API, but I want to provide this as a temporary workaround for the problem reported here: wincent/command-t#393 (comment) In short, the: https://github.com/jiangmiao/auto-pairs has a bug in it because it hasn't been touched since February 2019, and it wasn't written to account for the fact that Neovim mappings can now map to Lua callbacks instead of Vimscript strings (ie. via the `vim.keymap.set()` call). So, it has some code that does this: 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 our `<CR>` mapping and dies because it assumes that the returned `info` has a `'rhs'` key, but it doesn't: E716: Key not present in Dictionary: "rhs" This commit, then, allows us to make a workaround by replacing the Lua callback with a string-based mapping which _will_ have a RHS: require('wincent.commandt').setup({ mappings = { i = { ['<CR>'] = "<C-o>:lua require('wincent.commandt.private.ui').open('edit')<CR>", }, }, }) ie. we replace the standard mapping, which maps to the internal `open()` callback, with one that imperatively reaches in from the outside and calls it as seen above. Like I said, I won't be making this an official API, but I did want to provide a workaround, seeing as it may be a while before auto-pairs gets updated.
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).
As discussed here: - wincent/command-t#393 (comment)
This implements idea "3" from here: - wincent/command-t#393 (comment) > we may also want to swallow `stderr` so it doesn't leak back in any > visible way (ie. that would mean changing a call to `git ...` into > `git ... 2> /dev/null` etc). The only catch is that this may make > trouble-shooting harder (users could edit out or change the redirect, > I guess). So, yeah. This is a double-edged sword, but in the next commit I am planning on dulling at least one of those edges by implementing a fallback behavior for each of these scanners.
This implements idea "2" from here: - wincent/command-t#393 (comment) > We teach the callers to interpret an empty result list as a cue to > try again using a fallback mechanism; in an empty directory this would > give a false negative but a relatively harmless one (ie. you might run > `:CommandTRipgrep` in an empty folder, and Command-T would take that as > a cue to try again with the standard scanner, which would of course > also return an empty list). Specifically, we do this whenever `git`, `rg`, or `find` returns no results. There is a bit of duplication here because we need thunks at each site; otherwise as soon as we `require`-d the fallback finder it would do a redundant scan. I'm not going to factor that out yet because I am still not convinced that this is an optimal strategy. Want to let it bake for a while and see what happens.
Because we might be wanting to change the behavior soon, it would be nice to be able to change in in _one_ place instead of three. Specifically, as per: - wincent/command-t#393 (comment) we might be putting something in the prompt window title to indicate what happened.
As discussed here: - wincent/command-t#393 (comment) That comment suggested being a bit more verbose: CommandT [ find (fall-backed from git) ] but here I'm going with something a little less descriptive: CommandT [fallback] seeing as the extra detail in the title doesn't tell you _what_ went wrong; really, all we can do here is show a hint that _something_ went wrong, so we might as well be brief about it. Two things to note about implementation: - One is that I am playing around here trying to figure out how much metatable magic I want in here without making it all too "clever". So here I have a `__newindex` implementation that allows us to write `prompt.name = 'fallback'` instead of `prompt:set_name('fallback')`. The former is visually cleaner, but I don't necessarily like that it hides the fact that an imperative side-effect is going to take place. I will probably "dumb this down" as opposed to trying to use the pattern in other places in a uniform way. - The other is that my earlier claims about top-down React-style dataflow are pretty much not true any more. It _was_ true at the start, when each component rendered using data passed into it; now we have muddied the waters considerably with imperative methods. I will almost certainly want to revisit this topic in the future.
@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 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 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 With jiangmiao, I'd recommend running 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 Anyway, welcome to the world of trying to map common keys (cr, space, tab, and backspace) in Vim - it sucks :p Footnotes
|
Command-T 6.0.0
|command-t-upgrading|
.5-x-release
branch (if you wish to remain on the previous release serious).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 atHEAD
ofmain
, 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
nvim --version
arm64
,x86_64
etc)Summary
packer.nvim set-up
Via comment.
The text was updated successfully, but these errors were encountered: