Conversation
|
Looks like a pretty good idea. I've added one more commit, since I noticed a problem with quotes, but feel free to tweak that as you see fit and merge whenever. 👍 To sidetrack a bit, I'm fairly unhappy with the current state of def normal(stuff)
command 'normal #{stuff}'
end
def normal!(stuff)
command 'normal! #{stuff}'
end
def type(keys)
# use feedkeys()
end
def insert(keys)
# use feedkeys('i'...)
end
def append(keys)
# use feedkeys('a'...)
endMaybe for starters, I can just re-implement I've also been doing a lot of raw vim.command #=> CommandProxy object
vim.function #=> FunctionProxy object
vim.command.echo 'ok' #=> "ok"
vim.command.normal! 'ifoo\\<cr>' #=> ""
vim.function.feedkeys('abc')
vim.function.expand('%:p')I'll think about this stuff some more, just wanted to give you an update of some recent raw ideas about expanding the gem. |
|
Thanks for the quote fix, I'm not particularly happy with how fragile that interface is regarding quoting (the evils of string interpolation, I suppose). Re the interface: I had thought that my inability to use Perhaps we're building on the wrong foundation. What if we made I was definitely taken by surprise that As an aside, I'm going to present Vimrunner at Vim London on the 26th February, I'll let you know if we get any feedback. |
Add feedkeys to more closely simulate user input.
It's tricky. My first instinct was to use commands, since they are the core building block of Vimscript. Even functions are called by using a command ( Regarding Let's say you want to call a function. The most obvious interface would be vim.command("call fnamemodify(b:some_filename, ':h')")
vim.call(:fnamemodify, '?', ':h')You can't just put a variable name there, since it'll be serialized as a string. You could do something like: vim.call(:fnamemodify, lit('b:some_filename'), ':h')And a vim.call(:fnamemodify, 'b:some_filename'.lit, ':h')
# but this globally monkeypatches string :/
vim.call(:fnamemodify, 'b:some_filename'.vim_literal, ':h')
# and this monkeypatches string, but at least it's unlikely to collide with anything
vim.call(:fnamemodify, Vimrunner::Literal.new('b:some_filename'), ':h')
# much safer, but verboseAlternatively, we could just not serialize things: vim.call(:fnamemodify, %{b:some_filename, '%:h'})But this doesn't really resolve the quoting issues, it just makes it a slightly better interface.
Sounds reasonable.
Same here. But yeah, I guess it's a good idea to just use
Yeah, I saw your tweet, hope it goes well :). Feedback would be great, especially on the public interface and on this topic. |
The current type method uses --remote-send which does not respect
mappings. As a workaround, allow access to feedkeys() which does respect
mappings as if typed by a user.