css-variable-ls

0.6.38 • Public • Published

CSS Variable Langauage Server

I did no actual work on this language server. I just extracted the language server Vu Nguyen created for CSS Variables Autocomplete and adapted it for my use case. All credit goes to Vu Nguyen.

Installation

npm i -g css-variable-ls

Setup

    if not configs.cssvar then
        configs.cssvar = {
            default_config = {
                cmd = { "cssvar", "--stdio" },
                filetypes = { "css", "scss", "less" },
                root_dir = lsp.util.root_pattern("package.json", ".git"),
                single_file_support = true,
                settings = {
                    cssVariables = {
                        lookupFiles = {
                            "**/*.css",
                            "**/*.scss",
                            "**/*.sass",
                            "**/*.less",
                        },
                    },
                },
            },
            docs = {
                default_config = {
                    root_dir = [[root_pattern("", ".git") or bufdir]],
                },
            },
        }
    end
    lsp.cssvar.setup({
    ...
        on_new_config = function(_, root_dir)
            local client = vim.lsp.get_active_clients({ name = "cssvar" })[1]
            local path = util.path.join(root_dir, ".luarc.json")
            if util.path.exists(path) == false then
                return
            end
            local f = assert(io.open(path, "r")) -- assuming path is in the scope
            local content = f:read("*a")
            f:close()
            local config = vim.json.decode(content)
            if config == nil or config["cssVariables"] == nil then
                return
            end
            if client == nil then
                return
            end
            client.notify(
                "workspace/didChangeConfiguration",
                { settings = {
                    cssVariables = config["cssVariables"],
                } }
            )
        end,
        ...
    })

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.6.381latest

Version History

VersionDownloads (Last 7 Days)Published
0.6.381
0.6.371
0.6.360
0.6.350
0.6.340
0.6.330
0.6.320
0.6.310
0.6.300
0.6.290
0.6.280
0.6.270
0.6.260
0.6.250
0.6.240
0.6.230
0.6.220
0.6.210
0.6.200
0.6.190
0.6.180
0.6.170
0.6.160
0.6.150
0.6.140
0.6.130
0.6.120
0.6.110
0.6.100
0.6.90
0.6.80
0.6.70
0.6.60
0.6.50
0.6.40
0.6.30
0.6.20
0.6.10
0.6.00
0.5.290
0.5.280
0.5.270
0.5.260
0.5.250
0.5.240
0.5.230
0.5.220
0.5.210
0.5.200
0.5.190
0.5.180
0.5.100
0.5.80
0.5.60
0.5.50
0.5.40
0.5.20
0.5.10
0.5.00
0.4.00
0.1.20
0.1.00
2.6.20

Package Sidebar

Install

npm i css-variable-ls

Weekly Downloads

2

Version

0.6.38

License

MIT

Unpacked Size

527 kB

Total Files

173

Last publish

Collaborators

  • jose.morris-garay