Skip to content
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

Non-interactive installation of vim plugins #2

Open
jan-warchol opened this issue Nov 11, 2015 · 3 comments
Open

Non-interactive installation of vim plugins #2

jan-warchol opened this issue Nov 11, 2015 · 3 comments

Comments

@jan-warchol
Copy link
Owner

I would like to install all vim plugins as part of the dotfiles role. However, vim plugin managers (including vim-plug) all seem to be designed for interactive use - in particular, their output is an incomprehensible mess when viewed not through a tty (for example, I didn't find a way to disable color codes).

I tried doing something like this, but Ansible didn't manage to parse the output correctly and task status was reported wrongly:

- name: install vim plugins defined in .vimrc
  shell: vim +PlugInstall +qall
  register: vim_plug_output
  changed_when: "'Installing' in vim_plug_output"
@jan-warchol jan-warchol changed the title Non-interactive installation of vim plu Non-interactive installation of vim plugins Nov 11, 2015
@jan-warchol
Copy link
Owner Author

There is another problem: if my .vimrc uses a colorscheme that comes from a plugin, vim throws errors when I run it for the first time (because the plugins are not installed yet, so the colorscheme is not available). Worst of all, it asks me to confirm whether I want to continue, which means that non-interactive ansible task will hang on that.

@jwalton3141
Copy link

changed_when: "'Installing' in vim_plug_output" won't work as "Installing" is shown for all Plugins (regardless of whether they've already been installed).

However, the following seems to behave as desired:

- name: Install vim plugins
  shell: vim '+PlugInstall --sync' +qall
  register: vim_plug_output
  changed_when: "'Resolving deltas' in vim_plug_output.stdout"

@jwalton3141
Copy link

re. the colorscheme issue: yep, agreed. I experienced this exact problem also.

My solution was to install the desired colours manually, before installing the vim plugins. I settled on something like:

- name: Ensure destination exists for vim colours
  file:
    dest: $HOME/.vim/colors
    state: directory

- name: Install snazzy colours for vim
  get_url:
    url: https://raw.githubusercontent.com/connorholyday/vim-snazzy/master/colors/snazzy.vim
    dest: $HOME/.vim/colors

- name: Copy vimrc to $HOME
  copy:
    src: vimrc
    dest: $HOME/.vimrc

- name: Install vim plugins
  shell: vim '+PlugInstall --sync' +qall
  register: vim_plug_output
  changed_when: "'Resolving deltas' in vim_plug_output.stdout"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants