forked from nemonik/hands-on-DevOps-gen2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneovim.yaml
333 lines (291 loc) · 11.3 KB
/
neovim.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
---
- name: Ensure neovim is installed and config for a vs code-like experience
hosts: factory
tasks:
- name: When MacOSX ensure Homebrew packages are installed
block:
- name: Update homebrew and upgrade all packages
community.general.homebrew:
update_homebrew: yes
upgrade_all: yes
- name: When MacOSX ensure neovim (nvim) is installed
community.general.homebrew:
name:
- nvim
- node
- yarn
- fzf
- watchman
- pylint
- mypy
- black
- poetry
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
when: ( ansible_distribution == 'MacOSX' )
- name: When Archlinux ensure pacman packages are installed
block:
- name: Update pacman and upgrade all packages
community.general.pacman:
update_cache: yes
upgrade: yes
become: yes
- name: Ensure pacman packages are installed
community.general.pacman:
name:
- neovim
- nodejs-lts-fermium
- npm
- yarn
- python-black
- mypy
- python-pylint
- python-poetry
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
- name: Install packages from AUR using a yay AUR helper
community.general.pacman:
name:
- fzf
- watchman-bin
- python-black
state: latest
executable: yay
when: ( ansible_distribution == 'Archlinux' )
- name: When Rocky 8 ensure dnf packages are installed
block:
- name: Ensure dnf packages are installed
ansible.builtin.dnf:
name:
- curl
- fuse
- fuse-libs
state: latest
update_cache: yes
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
- name: Ensure node is installed
block:
- name: Get stat for /usr/local/bin/node
ansible.builtin.stat:
path: /usr/local/bin/node
register: st
- name: Install nodejs
block:
- name: Enable node.js yum repository provided by the Node.js official website
ansible.builtin.shell: |
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
become: yes
- name: Install node.js dnf package
ansible.builtin.dnf:
name: nodejs
state: latest
update_cache: yes
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
when: not st.stat.exists
- name: Ensure neovim is installed
block:
- name: Get stat for /usr/local/bin/nvim
ansible.builtin.stat:
path: /usr/local/bin/nvim
register: st
- name: Install neovim from appimage retrieved from GitHub
ansible.builtin.get_url:
url: https://github.com/neovim/neovim/releases/download/stable/nvim.appimage
dest: /usr/local/bin/nvim
mode: '755'
become: yes
when: not st.stat.exists
- name: Ensure yarn is installed
block:
- name: Get stat for /bin/yarn
ansible.builtin.stat:
path: /bin/yarn
register: st
- name: Ensure yarn is installed
block:
- name: Add yarn repo
ansible.builtin.shell: |
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
become: yes
- name: Ensure yarn package is installed
ansible.builtin.dnf:
name: yarn
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
when: not st.stat.exists
- name: ensure python modules are installed
pip:
name:
- black
- mypy
- pylint
- poetry
extra_args: --user
- name: ensure fzf is installed
block:
- name: Get stat for /bin/fzf
ansible.builtin.stat:
path: /bin/fzf
register: st
- name: Ensure fzf is installed
block:
- name: Ensure pexect python module is installed
pip:
name: pexpect
become: yes
- name: Install fzf from source
ansible.builtin.git:
repo: 'https://github.com/junegunn/fzf.git'
dest: /tmp/fzf
depth: 1
clone: yes
update: yes
become: yes
- name: Generic question with multiple different responses
ansible.builtin.expect:
echo: yes
chdir: /tmp/fzf
command: ./install
responses: {
'Do you want to enable fuzzy auto-completion(.*)': 'y',
'Do you want to enable key bindings(.*)': 'y',
'Do you want to update your shell configuration files(.*)': 'n'
}
become: yes
- name: Cleanup fzf install
file:
state: absent
path: /tmp/fzf
become: yes
when: not st.stat.exists
- name: ensure watchman is installed
ansible.builtin.shell: |
cd /tmp
wget https://github.com/facebook/watchman/archive/refs/tags/v2021.08.30.00.tar.gz
tar -zxf v2021.08.30.00.tar.gz
cd watchman*
mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman
cp bin/* /usr/local/bin
cp lib/* /usr/local/lib
chmod 755 /usr/local/bin/watchman
chmod 2777 /usr/local/var/run/watchman
become: yes
when: ( ansible_distribution == 'Rocky' )
- name: Ensure pynvim python module is installed for coc-pyright
ansible.builtin.shell: |
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
python3 -m pip install --user --upgrade pynvim
args:
executable: /bin/bash
#- name: Ensure black python module is installed for coc-pyright to be able to call on black for formatting
# ansible.builtin.shell: bash -c "python3 -m pip install --user --upgrade black"
- name: Ensure solargraph gem is installed for coc-solargraph
ansible.builtin.shell: |
[[ -s "$HOME/.rvm/scripts/rvm" ]]
source "$HOME/.rvm/scripts/rvm"
gem install solargraph
args:
executable: /bin/bash
# See: https://prettier.io/docs/en/install.html
#
- name: Ensure prettier is installed
block:
- name: Ensure {{ HOME }}/.local/bin exist
ansible.builtin.file:
path: "{{ HOME}}/.local/bin"
state: directory
- name: Ensure package.json exists
ansible.builtin.shell: sh -c "npm init --yes"
- name: Install "prettier" node.js package.
community.general.npm:
name: "prettier"
path: "{{ HOME }}/.local/bin"
state: latest
- name: Install "neovim" node.js package globally
block:
- community.general.npm:
name: "neovim"
global: yes
state: latest
when: ( ansible_distribution == 'MacOSX' )
- community.general.npm:
name: "neovim"
global: yes
state: latest
become: yes
when: ( ansible_distribution == 'Archlinux' )
- name: Does `{{ HOME }}/.prettierrc.json` file exist?
ansible.builtin.stat:
path: "{{ HOME }}/.prettierrc.json"
register: prettierrc
- name: Configure `{{ HOME }}/.prettierrc.json`, only if doesn't exist
ansible.builtin.shell: sh -c "echo {}> ~/.prettierrc.json"
when: not prettierrc.stat.exists
- name: Does `{{ HOME }}/.prettierignore` file exist?
ansible.builtin.stat:
path: "{{ HOME }}/.prettierignore"
register: prettierignore
- name: Configure `{{ HOME }}/.prettierignore`, only if doesn't exist
ansible.builtin.shell: sh -c "echo '# Ignore artifacts:'> ~/.prettierignore"
when: not prettierignore.stat.exists
- name: Ensure then Minimalist Vim Plugin Manager is installed
ansible.builtin.shell: sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
- name: Create {{ HOME }}/.config/nvim directory, if it does not exist
ansible.builtin.file:
path: "{{ HOME }}/.config/nvim"
state: directory
- name: Copy nvim init.vim configuration file into place
ansible.builtin.copy:
src: files/init.vim
dest: "{{ HOME }}/.config/nvim/init.vim"
- name: Setting BLACK_PATH when OSX
set_fact:
BLACK_PATH: /usr/local/bin
when: ( ansible_distribution == 'MacOSX' )
- name: Setting BLACK_PATH when Archlinux or Rocky 8
set_fact:
BLACK_PATH: /usr/local/bin
when: ( ansible_distribution == 'Archlinux' ) or ( ansible_distribution == 'Rocky' )
- name: Template coc-settings.json configuration file into place
ansible.builtin.template:
src: templates/coc-settings.json.tpl
dest: "{{ HOME }}/.config/nvim/coc-settings.json"
- name: Ensure Powerline fonts are installed for Vim Airline plugin
block:
- name: Ensure {{ HOME }}/.config path exists
ansible.builtin.file:
path: "{{ HOME }}/.config"
state: directory
- name: Shallow git clone Powerline fonts
ansible.builtin.git:
repo: "https://github.com/powerline/fonts.git"
dest: "{{ HOME }}/.config/powerline"
depth: 1
force: yes
- name: Install Powerline fonts
ansible.builtin.shell: |
cd $HOME/.config/powerline
./install.sh