---
- name: Acquiring home of current user
  when: ansible_facts["system"] == "Linux"
  ansible.builtin.shell:
    cmd: "echo ~{{ ansible_user }}"
  register: ansible_user_home
- name: Acquiring current user
  when: ansible_facts["system"] == "Linux"
  ansible.builtin.shell:
    cmd: "echo {{ ansible_user }}"
  register: current_user
- name: Creating directory tree for NeoViM configuration files
  ansible.builtin.file:
    path: "{{ ansible_user_home.stdout }}/.config/nvim"
    recurse: true
    owner: "{{ ansible_user }}"
    group: "{{ ansible_user }}"
    state: directory
- name: Configuring NeoViM
  become: true
  become_user: "{{ current_user.stdout }}"
  ansible.builtin.copy:
    src: user/config/nvim/init.vim
    dest: "{{ ansible_user_home.stdout }}/.config/nvim/init.vim"
    owner: "{{ ansible_user }}"
    group: "{{ ansible_user }}"
    mode: "644"
    force: true
    backup: true
