- name: Check if user is not root
  meta: end_play
  when: ansible_facts.user_id == "root"

- name: Install zsh
  package:
    name:
      - zsh
    state: latest
  become: yes

- name: Setup Oh-my-zsh using yay/pacman
  community.general.pacman:
    name: 
      - oh-my-zsh
      - oh-my-zsh-plugin-autosuggestions
      - fast-syntax-highlighting
    state: latest
    executable: yay
  when: ansible_facts.distribution == "Archlinux"
  become: yes

- name: Setup Oh-my-zsh using sh
  command: 'sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"'
  when: ansible_facts.distribution != "Archlinux"
  become: yes

- name: Symlink custom-plugins
  file:
    src: "/usr/share/zsh/plugins/fast-syntax-highlighting"
    dest: "/usr/share/oh-my-zsh/custom/plugins/"
    state: link


- name: Deploy user-config-file
  ansible.builtin.copy:
    src: .zshrc
    dest: "{{ ansible_facts.env.HOME }}/"

- name: Symlink oh-my-zsh user-settings folder from shared
  file:
    src: "/usr/share/oh-my-zsh/"
    dest: "{{ ansible_facts.env.HOME }}/.oh-my-zsh"
    state: link
