Skip to content

Commit 0d82c26

Browse files
authored
Add files via upload
1 parent 2fb9ac6 commit 0d82c26

File tree

4 files changed

+245
-0
lines changed

4 files changed

+245
-0
lines changed

nvim-defx.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import os
2+
import sys
3+
import neovim
4+
import subprocess
5+
import re
6+
from time import sleep
7+
8+
9+
def main():
10+
11+
oyo = {}
12+
cnt = 0
13+
14+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
15+
print("Searching Neovim instances...")
16+
for are in hoge:
17+
if re.search(r'nvim', are):
18+
num0 = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
19+
print("\t" + are, end="")
20+
oyo[num0] = False
21+
cnt += 1
22+
23+
print("Starting new Neovim instance.")
24+
25+
subprocess.Popen("C:\\Users\\masa300V\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -p \"Neovim\"")
26+
sleep(3)
27+
28+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
29+
for are in hoge:
30+
if re.search(r'nvim', are):
31+
num = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
32+
if oyo.get(num, True):
33+
print('Using new nvim %s.' % num)
34+
servername = "\\\\.\\pipe\\nvim-" + num + "-0"
35+
print(servername)
36+
37+
try:
38+
nvim = neovim.attach("socket", path=servername)
39+
except Exception:
40+
print("Neovim not found")
41+
return 1
42+
43+
if len(sys.argv) > 2:
44+
return
45+
46+
if len(sys.argv) == 1:
47+
path = os.path.abspath(os.getcwd())
48+
49+
if len(sys.argv) == 2:
50+
path = os.path.abspath(sys.argv[1])
51+
52+
print(path)
53+
54+
path2 = re.sub(r' ', r'\ ', path.replace(os.path.sep, '/'))
55+
print(':Defx %s' % path2)
56+
nvim.command(':Defx %s' % path2)
57+
58+
nvim.close()
59+
60+
if __name__ == "__main__":
61+
ret = main()
62+
sys.exit(ret)
63+

nvim-wt-diff.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import os
2+
import sys
3+
import neovim
4+
import subprocess
5+
import re
6+
from time import sleep
7+
8+
9+
def main():
10+
11+
oyo = {}
12+
cnt = 0
13+
14+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
15+
print("Searching Neovim instances...")
16+
for are in hoge:
17+
if re.search(r'nvim', are):
18+
num0 = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
19+
print("\t" + are, end="")
20+
oyo[num0] = False
21+
cnt += 1
22+
23+
print("Starting new Neovim instance.")
24+
25+
subprocess.Popen("C:\\Users\\masa300V\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -p \"Neovim\"")
26+
sleep(3)
27+
28+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
29+
for are in hoge:
30+
if re.search(r'nvim', are):
31+
num = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
32+
if oyo.get(num, True):
33+
servername = "\\\\.\\pipe\\nvim-" + num + "-0"
34+
print('Using new nvim %s.' % servername)
35+
36+
try:
37+
nvim = neovim.attach("socket", path=servername)
38+
except Exception:
39+
print("Neovim not found")
40+
return 1
41+
42+
if len(sys.argv) <= 1:
43+
return
44+
45+
path = sys.argv[1]
46+
# path = ".bashrc"
47+
nvim.command(':e %s' % os.path.abspath(path))
48+
49+
path2 = sys.argv[2]
50+
nvim.command(':vertical diffsplit %s' % os.path.abspath(path2))
51+
52+
nvim.close()
53+
54+
55+
if __name__ == "__main__":
56+
ret = main()
57+
sys.exit(ret)
58+

nvim-wt-new.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import os
2+
import sys
3+
import neovim
4+
import subprocess
5+
import re
6+
from time import sleep
7+
8+
9+
def main():
10+
11+
oyo = {}
12+
cnt = 0
13+
14+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
15+
print("Searching Neovim instances...")
16+
for are in hoge:
17+
if re.search(r'nvim', are):
18+
num0 = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
19+
print("\t" + are, end="")
20+
oyo[num0] = False
21+
cnt += 1
22+
23+
print("Starting new Neovim instance.")
24+
25+
subprocess.Popen("C:\\Users\\masa300V\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -p \"Neovim\"")
26+
sleep(3)
27+
28+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
29+
for are in hoge:
30+
if re.search(r'nvim', are):
31+
num = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
32+
# print(are,end="")
33+
# print(num)
34+
if oyo.get(num, True):
35+
print('Using new nvim %s.' % num)
36+
servername = "\\\\.\\pipe\\nvim-" + num + "-0"
37+
print(servername)
38+
39+
try:
40+
nvim = neovim.attach("socket", path=servername)
41+
except Exception:
42+
print("Neovim not found")
43+
return 1
44+
45+
if len(sys.argv) > 2:
46+
return
47+
48+
if len(sys.argv) == 2:
49+
path = os.path.abspath(sys.argv[1])
50+
51+
print(path)
52+
53+
path2 = re.sub(r' ', r'\ ', path.replace(os.path.sep, '/'))
54+
print(':e %s' % path2)
55+
nvim.command(':e %s' % path2)
56+
57+
nvim.close()
58+
59+
if __name__ == "__main__":
60+
ret = main()
61+
sys.exit(ret)
62+

nvim-wt-reuse.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import os
2+
import sys
3+
import neovim
4+
import subprocess
5+
import re
6+
from time import sleep
7+
8+
9+
def main():
10+
11+
oyo = {}
12+
cnt = 0
13+
14+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
15+
print("Searching Neovim instances...")
16+
for are in hoge:
17+
if re.search(r'nvim', are):
18+
num0 = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
19+
print("\t" + are, end="")
20+
oyo[num0] = False
21+
cnt += 1
22+
23+
if cnt == 0:
24+
print("Starting new Neovim instance.")
25+
26+
subprocess.Popen("C:\\Users\\masa300V\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -p \"Neovim\"")
27+
sleep(3)
28+
29+
hoge = subprocess.Popen("pipelist64.exe", stdout=subprocess.PIPE, text=True).stdout.readlines()
30+
for are in hoge:
31+
if re.search(r'nvim', are):
32+
num = re.sub(r'^nvim-([0-9]*)-[0-9].*$', r'\1', are).strip('\n')
33+
if oyo.get(num, True):
34+
servername = "\\\\.\\pipe\\nvim-" + num + "-0"
35+
print('Using new nvim %s.' % servername)
36+
elif cnt > 1:
37+
print("Multiple existing Neovim instances.")
38+
sleep(3)
39+
return
40+
else:
41+
print("Using the existing Neovim instance.")
42+
servername = "\\\\.\\pipe\\nvim-" + num0 + "-0"
43+
44+
try:
45+
nvim = neovim.attach("socket", path=servername)
46+
except Exception:
47+
print("Neovim not found")
48+
return 1
49+
50+
if len(sys.argv) <= 1:
51+
return
52+
53+
path = sys.argv[1]
54+
nvim.command(':e %s' % os.path.abspath(path))
55+
56+
nvim.close()
57+
58+
59+
if __name__ == "__main__":
60+
ret = main()
61+
sys.exit(ret)
62+

0 commit comments

Comments
 (0)