aca / emmet-ls

Emmet support based on LSP.
MIT License
363 stars 31 forks source link

SolidJS JSX support #43

Open 33KK opened 2 years ago

33KK commented 2 years ago

SolidJS uses class instead of className.

petergoes commented 1 year ago

Preact can also be configured to use class instead of className. It would be nice if this could be configured.

aca commented 1 year ago

I'll check this week

olrtg commented 1 year ago

Doesn't this fix the issue?

require("lvim.lsp.manager").setup("emmet_ls", {
  filetypes = {
    "astro",
    "css",
    "eruby",
    "html",
    "javascriptreact",
    "less",
    "sass",
    "scss",
    "svelte",
    "typescriptreact",
    "vue",
  },
  init_options = {
    jsx = {
      options = {
        ["markup.attributes"] = { className = "class" },
      },
    },
  },
})

This should convert className attributes to class and it should work with jsx/tsx files.

aca commented 1 year ago

Forgot to note on this. As @olrtg commented, it is possible with init_options.

Here's another example with mason

require("mason-lspconfig").setup_handlers({
    function(server_name) -- default handler (optional)
        lspconfig[server_name].setup()
    end,

    ["emmet_ls"] = function()
        lspconfig.emmet_ls.setup {
            init_options = {
              jsx = {
                options = {
                  ["markup.attributes"] = { className = "class" },
                },
              },
            }
        }
    end,
})

Problem is that as solidjs file extension is just 'tsx', 'jsx'. It requires some custom additional logics that can detect that it is solidjs project.

I'm not sure how it should be implemented.

I'm not professional frontend developer. Is there any good example to follow?

Thanks for the comment by the way @olrtg .

olrtg commented 1 year ago

@aca I like the first option far better. I think that maybe we can check in the package.json for a solidjs dependency. Is kind of hard anyway to ensure that's always the case because you can have an Astro project using react and solidjs a the same time and now solidjs takes precedence (but it's kind of a edge case).

AFAIK vscode doesn't handle this for you.. so I wonder if we should just let this up to the user.