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 2020--- })
2121--- ```
2222
23- local util = require ' lspconfig.util'
24-
25- local root_file = {
23+ local root_markers = {
2624 ' .stylelintrc' ,
2725 ' .stylelintrc.mjs' ,
2826 ' .stylelintrc.cjs' ,
@@ -35,8 +33,6 @@ local root_file = {
3533 ' stylelint.config.js' ,
3634}
3735
38- root_file = util .insert_package_json (root_file , ' stylelint' )
39-
4036return {
4137 cmd = { ' stylelint-lsp' , ' --stdio' },
4238 filetypes = {
@@ -49,6 +45,21 @@ return {
4945 ' vue' ,
5046 ' wxss' ,
5147 },
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 ,
5364 settings = {},
5465}
You can’t perform that action at this time.
0 commit comments