-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvscode.py
121 lines (100 loc) · 3.81 KB
/
vscode.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
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
## @file
## @brief VSCode Language Server for live `metaL`
from metaL import *
## @defgroup lsp
## @brief VSCode Language Server for live `metaL`
## @{
class lspModule(anyModule):
ves = 'vscode-extension-samples'
samples = {
'hello': 'helloworld-minimal-sample',
'lsp-sample': 'lsp-sample',
}.items()
def __init__(self, V=None):
super().__init__(V)
self.httpd = jsFile('httpd')
self.diroot // self.httpd
self.httpd // '''
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\\n');
}).listen(30000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:30000/');'''
self.httpd.sync()
self.init_njs_vscode()
self.init_njs_package()
def init_njs_package(self):
self.package = jsonFile('package')
self.diroot // self.package
self.package // (S('{', '}') //
f'"name":"{self}",' //
f'"description": "{self["TITLE"]}",' //
'"version": "0.0.1",' //
f'"publisher": "{self["AUTHOR"]}",' //
f'"repository": "{self["GITHUB"]}",'//\
f'"main":"./{self.extension}"'
)
self.package.sync()
def init_njs_vscode(self):
self.extension = jsFile('extension')
self.diroot // self.extension
self.extension // "const vscode = require('vscode');"
self.extension.sync()
def init_mk(self):
super().init_mk()
# self.mk.all // (S('.PHONY:all\nall:')//'node httpd.js')
self.mk.all // (S('.PHONY:all\nall:') //
'npm install' //
'npm run compile'
)
self.mk.install //\
f'-git clone https://github.com/microsoft/{lspModule.ves}.git'
for loc, ves in lspModule.samples:
self.mk.install //\
f'ln -fs {lspModule.ves}/{ves} {loc}'
self.mk.update //\
f'cd {lspModule.ves} ; git pull -v origin master'
self.mk.sync()
def init_giti(self):
super().init_giti()
self.giti.mid //\
f'/{lspModule.ves}'
for loc, ves in lspModule.samples:
self.giti.mid //\
f'/{loc}'
self.giti.sync()
def init_apt(self):
super().init_apt()
(self.apt // 'code nodejs').sync()
def init_vscode_settings(self):
super().init_vscode_settings()
self.vscode.watcher //\
f'"**/{lspModule.ves}/**":true,'
for loc, ves in lspModule.samples:
self.vscode.watcher //\
f'"**/{loc}/**":true,'
self.vscode.settings.sync()
def init_vscode_launch(self):
super().init_vscode_launch()
self.vscode.launch.it // (S('{', '}') //
'"name": "Run Extension",' //
'"type": "extensionHost",' //
'"request": "launch",' //
'"runtimeExecutable": "${execPath}",' //
'"args": ["--extensionDevelopmentPath=${workspaceFolder}"]')
self.vscode.launch.sync()
MODULE = lspModule()
MODULE['TITLE'] = TITLE = Title('VSCode Language Server for live `metaL`')
MODULE.init_njs_package()
MODULE['ABOUT'] = ABOUT = '''
VSCode Language Server Protocol (LSP) host that runs `metaL` in a live session:
* https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
* https://github.com/microsoft/vscode-extension-samples/tree/master/lsp-sample
parsers:
* https://tree-sitter.github.io/tree-sitter/
'''
README = README(MODULE)
MODULE['dir'] // README
README.sync()
## @}