---
- name: Create doom directory
  file:
    path: ~/.config/doom
    state: directory
    mode: 0755

- name: Copy files
  synchronize:
    src: doom/
    dest: ~/.config/doom/
    recursive: yes

- name: Copy doom config
  template:
    src: config.j2
    dest: ~/.config/doom/config.el
    force: yes
    mode: 0644

- name: Clone Doom Emacs
  git:
    depth: 1
    repo: https://github.com/hlissner/doom-emacs.git
    dest: ~/.config/emacs

- name: Run 'doom install'
  command:
    cmd: ~/.config/emacs/bin/doom -y install
    creates: ~/.config/emacs/.local/env

- block:
    - name: Clone parinfer-rust
      git:
        depth: 1
        repo: https://github.com/eraserhd/parinfer-rust.git
        dest: '{{ parinfer_dir }}'

    - name: Build parinfer-rust
      command: cargo build --release --features emacs
      args:
        chdir: '{{ parinfer_dir }}'
        creates: '{{ parinfer_dir }}/target/release/libparinfer_rust.so'
  vars:
    - parinfer_dir: ~/.config/emacs/.local/etc/parinfer-rust
  tags: parinfer
