Flush automatically when file is added/removed
-
anonymous
Hi there,
CommandT is great, just what I was looking for. Except for one thing: would it be possible to make it flush the cached file list automatically when a file is created or deleted? Invoking :CommandTFlush every time is bit annoying.
-
Greg Hurrell
This could probably be added as an option, but it wouldn't default to being on because the speed hit when having to rescan a large project with thousands of files would be unacceptable.
I imagine there are some autocmds that could be hooked in to when new files are created from within Vim, and that's what would have to be used here. Perhaps
BufNewfile
orBufWritePost
.Files created outside of Vim (eg. on the command line) can't be efficiently automatically detected in any kind of platform-independent way, so that would leave polling, which has to be ruled out too because it would be quite resource intensive.
One thing you could do in the meantime is bind
:CommandTFlush
to something that is easier for you to invoke, like<Leader>ctf
or whatever. -
Greg Hurrell
Added a ticket for this in the issue tracker so it doesn't slip off the radar; see ticket #1626.
-
anonymous
Is there a possibility to invoke the flush from the outside... say a bash script? The cache has to be flushed whenever I perform a git checkout or git pull and it would be helpful to tie those commands together.
-
Greg Hurrell
Not sure, to be honest, as I've never tried it.
You have two options, I think:
One is to check the Vim man page and see if any of the options will allow you to send a command to an existing Vim instance; these ones look promising:
--remote Connect to a Vim server and make it edit the files given in the rest of the arguments. If no server is found a warning is given and the files are edited in the current Vim. --remote-expr {expr} Connect to a Vim server, evaluate {expr} in it and print the result on stdout. --remote-send {keys} Connect to a Vim server and send {keys} to it. --remote-silent As --remote, but without the warning when no server is found. --remote-wait As --remote, but Vim does not exit until the files have been edited. --remote-wait-silent As --remote-wait, but without the warning when no server is found. --serverlist List the names of all Vim servers that can be found. --servername {name} Use {name} as the server name. Used for the current Vim, unless used with a --remote argument, then it's the name of the server to connect to.
The other is to do your Git operations from inside Vim itself (for example, using Tim Pope's fugitive.vim), in which case you can fairly easily add mappings to do both the Git operation and the Command-T flush in one hit.
Reply
This topic is now closed.