@@ -9,7 +9,27 @@ local function get_probe_dir(root_dir)
9
9
return project_root and (project_root .. ' /node_modules' ) or ' '
10
10
end
11
11
12
+ local function get_angular_core_version (root_dir )
13
+ local project_root = vim .fs .dirname (vim .fs .find (' node_modules' , { path = root_dir , upward = true })[1 ])
14
+
15
+ local package_json = project_root .. ' /package.json'
16
+ if not vim .loop .fs_stat (package_json ) then
17
+ return ' '
18
+ end
19
+
20
+ local contents = io.open (package_json ):read ' *a'
21
+ local json = vim .json .decode (contents )
22
+ if not json .dependencies then
23
+ return ' '
24
+ end
25
+
26
+ local angular_core_version = json .dependencies [' @angular/core' ]
27
+
28
+ return angular_core_version
29
+ end
30
+
12
31
local default_probe_dir = get_probe_dir (vim .fn .getcwd ())
32
+ local default_angular_core_version = get_angular_core_version (vim .fn .getcwd ())
13
33
14
34
return {
15
35
default_config = {
@@ -20,6 +40,8 @@ return {
20
40
default_probe_dir ,
21
41
' --ngProbeLocations' ,
22
42
default_probe_dir ,
43
+ ' --angularCoreVersion' ,
44
+ default_angular_core_version ,
23
45
},
24
46
filetypes = { ' typescript' , ' html' , ' typescriptreact' , ' typescript.tsx' , ' htmlangular' },
25
47
-- Check for angular.json since that is the root of the project.
@@ -29,6 +51,7 @@ return {
29
51
},
30
52
on_new_config = function (new_config , new_root_dir )
31
53
local new_probe_dir = get_probe_dir (new_root_dir )
54
+ local angular_core_version = get_angular_core_version (new_root_dir )
32
55
33
56
-- We need to check our probe directories because they may have changed.
34
57
new_config .cmd = {
@@ -38,6 +61,8 @@ return {
38
61
new_probe_dir ,
39
62
' --ngProbeLocations' ,
40
63
new_probe_dir ,
64
+ ' --angularCoreVersion' ,
65
+ angular_core_version ,
41
66
}
42
67
end ,
43
68
docs = {
0 commit comments