Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Support `:set` in `.vimrc`

Open elazarcoh opened this issue 3 years ago • 0 comments

What this PR does / why we need it: Add support for set in vimrc.

Which issue(s) this PR fixes fixes: #7055

Special notes for your reviewer: To make use of the already existing SetCommand, I needed to allow passing a null as the VimState, which might not be the best solution to tackle this. The SetCommand not really needs the vimState to handle the vimrc usecase, I think. An alternative approach is to parse the vimrc, and capture all the operations that needs vimState into a list, which we'll execute later when we have a vimState. Something like:

class Vimrc {
  public load(vimrcPath) {
     const lines = ...
     for (const line in lines) {
       const action: ((_: VimState) => void) | undefined = parseLine(line);
       if (action) this.actions.push(action)
    }
  }
 public onStart(vimState) {
    for (const action in this.actions) {
      action(vimState);
    }
  } 
}

elazarcoh avatar Aug 09 '22 12:08 elazarcoh