Git Product home page Git Product logo

Comments (11)

kana avatar kana commented on May 21, 2024

You have to use :normal instead of feedkeys().

feedkeys() only pushes characters into the input queue. When Vim becomes idle and the input queue is not empty, Vim will take a character from the input queue and processes it as if user typed the character. And Vim will never be idle while running a test script, because Vim is always busy to execute each line in the test script.

While :normal {command} directly executes Normal mode {command}. This is the proper way to emulate Normal mode commands in a test script in most situations.

from vim-vspec.

nosami avatar nosami commented on May 21, 2024

Thanks for the reply! That makes sense, but what I'm actually trying to do though is simulate triggering omnicomplete with <c-x><c-o> in insert mode. I don't think that's possible using :normal ?

from vim-vspec.

kana avatar kana commented on May 21, 2024

Try :execute 'normal!' "a\<C-x>\<C-o>".

from vim-vspec.

nosami avatar nosami commented on May 21, 2024

I can't get that to work. Even if I try just :normal "a\<C-x>\<C-o>" manually (with quotes), it doesn't seem to do anything. I tried a bunch of different variations.

If I remove the quotes, then is inserted into the document. call feedkeys() does what I want (if I invoke it manually), I understand your explanation for why it won't work in a script though.

Thanks for your help. Maybe it's not possible.

from vim-vspec.

kana avatar kana commented on May 21, 2024

Don't remove :execute! Try :execute 'normal!' "a\<C-x>\<C-o>".

from vim-vspec.

nosami avatar nosami commented on May 21, 2024

I should have mentioned, I tried that first of all before I started trying to change the command. It has no effect.

from vim-vspec.

nosami avatar nosami commented on May 21, 2024

This doesn't seem to be a vspec issue. Feel free to close.

Thanks anyway!

from vim-vspec.

kana avatar kana commented on May 21, 2024

I confirmed :normal can invoke omni completion with the following steps:

filetype plugin on

describe ':normal'
  before
    enew!
    setfiletype html
  end

  it 'can invoke omni completion'
    execute 'normal!' "a<div i\<C-x>\<C-o>"
    Expect getline(1) ==# '<div id="'
  end
end

from vim-vspec.

kana avatar kana commented on May 21, 2024

If you still have troubles, please paste the actual test script you wrote. I couldn't give a proper advice without it.

from vim-vspec.

nosami avatar nosami commented on May 21, 2024

Your script works for me too. Thank you so much for your time. I appreciate it!

I need to dig around a bit more to see what I'm doing wrong in my script.

from vim-vspec.

kana avatar kana commented on May 21, 2024

I added notes on how to emulate user input into the document.
Since vspec runs a test script with a plain Vim like vim -u NONE -i NONE -N, plugins and filetype plugins are not loaded by default. So that I think the core problem you encountered that you didn't write :filetype plugin on in test scripts. You succeeded to trigger omni completion, but the current buffer didn't have filetype, so nothing happened.

from vim-vspec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.