File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 20
20
--- })
21
21
--- ```
22
22
23
- local util = require ' lspconfig.util'
24
-
25
- local root_file = {
23
+ local root_markers = {
26
24
' .stylelintrc' ,
27
25
' .stylelintrc.mjs' ,
28
26
' .stylelintrc.cjs' ,
@@ -35,8 +33,6 @@ local root_file = {
35
33
' stylelint.config.js' ,
36
34
}
37
35
38
- root_file = util .insert_package_json (root_file , ' stylelint' )
39
-
40
36
return {
41
37
cmd = { ' stylelint-lsp' , ' --stdio' },
42
38
filetypes = {
@@ -49,6 +45,21 @@ return {
49
45
' vue' ,
50
46
' wxss' ,
51
47
},
52
- root_markers = root_file ,
48
+ root_dir = function (bufnr , on_dir )
49
+ local iswin = vim .uv .os_uname ().version :match ' Windows'
50
+ local package_json_dir = vim .fs .root (bufnr , ' package.json' )
51
+
52
+ -- Append `package.json` only if contains 'stylelint'
53
+ if package_json_dir then
54
+ local path_sep = iswin and ' \\ ' or ' /'
55
+ for line in io.lines (package_json_dir .. path_sep .. ' package.json' ) do
56
+ if line :find (' stylelint' ) then
57
+ root_markers [# root_markers + 1 ] = ' package.json'
58
+ end
59
+ end
60
+ end
61
+
62
+ on_dir (vim .fs .root (bufnr , root_markers ))
63
+ end ,
53
64
settings = {},
54
65
}
You can’t perform that action at this time.
0 commit comments