npm.io
1.0.2 • Published 3 years agoCLI

@olrtg/emmet-ls

Licence
MIT
Version
1.0.2
Deps
3
Size
8 kB
Vulns
0
Weekly
0
Stars
456
DeprecatedThis package is deprecated

emmet-ls

A language server for emmet.io


Why another language server?

While aca/emmet-ls works for what I need, there were a couple of things that annoyed me from time to time and while trying to fix one of those things (aca/emmet-ls#55) I've discovered that we can leverage microsoft/vscode-emmet-helper and make a simple language server that wraps the library to provide completions.

So I decided to do that and it worked!

The most important thing is that microsoft/vscode has an excelent integration with emmet and we can have that, in all editors that implement the Language Server Protocol.

Setup

First install:

npm i -g @olrtg/emmet-ls
Neovim (withouth nvim-lspconfig)
vim.api.nvim_create_autocmd({ "FileType" }, {
  pattern = "astro,css,eruby,html,htmldjango,javascriptreact,less,pug,sass,scss,svelte,typescriptreact,vue",
  callback = function()
    vim.lsp.start({
      cmd = { "emmet-ls", "--stdio" },
      root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1]),
      init_options = {
        --- @type table<string, any> https://docs.emmet.io/customization/preferences/
        preferences = {},
        --- @type "always" | "never" Defaults to `"always"`
        showExpandedAbbreviation = "always",
        --- @type boolean Defaults to `false`
        showAbbreviationSuggestions = false,
        --- @type boolean Defaults to `false`
        showSuggestionsAsSnippets = false,
        --- @type table<string, any> https://docs.emmet.io/customization/syntax-profiles/
        syntaxProfiles = {},
        --- @type table<string, string> https://docs.emmet.io/customization/snippets/#variables
        variables = {},
        --- @type string[]
        excludeLanguages = {},
      },
    })
  end,
})
Credits