-
Notifications
You must be signed in to change notification settings - Fork 2
/
neovim-reload.py
executable file
·47 lines (33 loc) · 998 Bytes
/
neovim-reload.py
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
#!/usr/bin/env python3
#
# dwm-theme-switcher
#
# (c) 2017 Daniel Jankowski
import os
from neovim import attach
def get_all_instances():
instances = []
# get the content of /tmp
directory_content = os.listdir('/tmp')
for directory in directory_content:
# check if it contains directories starting with nvim
if directory.startswith('nvim'):
# check if the nvim directories contains a socket
dc = os.listdir('/tmp/' + directory)
if '0' in dc:
instances.append('/tmp/' + directory + '/0')
return instances
def reload(instance):
# connect over the socker
nvim = attach('socket', path=instance)
# execute the reload command
nvim.command('source ~/.vimrc')
def main():
# search for neovim instances
instances = get_all_instances()
# connect to instances and reload them
for instance in instances:
reload(instance)
pass
if __name__ == '__main__':
main()