GithubHelp home page GithubHelp logo

olrtg / emmet-language-server Goto Github PK

View Code? Open in Web Editor NEW
251.0 5.0 6.0 2.63 MB

A language server for emmet.io

Home Page: https://www.npmjs.com/package/@olrtg/emmet-language-server

License: MIT License

JavaScript 100.00%
emmet lsp-server neovim

emmet-language-server's People

Contributors

gonstoll avatar olrtg avatar pswsm avatar tsuzat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

emmet-language-server's Issues

Multiple nested tags appear at once

Just like this
Video_20230905_114816_718

here is the lsp used
2023-09-05-12-44-19-541

here is my configuration
Screenshot_2023-09-05-12-52-26-462_com termux

hope to solve this problem

input: html
expect: <html></html>
but: <html><html></html></html>

Missing or malfunctioned completion with emmet-language-server

Here is my lsp config, and I did't really know if it is lsp or emmet-language-eserver causing the problem.

call LspAddServer([#{name: 'emmet',
                 \   filetype: ['html', 'htm'],
                 \   path: '/home/mellash/.npm-global/bin/emmet-language-server',
                 \   args: ['--stdio'],
                 \ }])

Here is a screenshot of the completion

lsp

lspconfig setup not working

I installed emmet-language-server with Mason, I'm getting this error after enabling the server in my lspconfig.lua file: [lspconfig] Cannot access configuration for emmet_language_server. Ensure this server is listed in 'server_configuration.md' or added as custom server

Setup with nvim-lspconfig doesn't work

Using the provided nvim-lspconfig setup, I encoutered an error: [lspconfig] Cannot access configuration for emmet_language_server. Ensure this server is listed in 'server_configuration.md' or added as custom server.

Setup with autocmd does work though. However, I'd like the lsp stuffs being in a single place, so I prefer setting up with nvim-lspconfig.

I then came up with this config.

local lspconfig = require "lspconfig"
local configs = require "lspconfig.configs"

if not configs.emmet_language_server then
  configs.emmet_language_server = {
    default_config = {
      filetypes = {
        "html",
        "css",
        "scss",
        "javascript",
        "javascriptreact",
        "typescriptreact",
        "svelte",
      },
      cmd = { "emmet-language-server", "--stdio" },
      root_dir = lspconfig.util.root_pattern ".git",
      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 `true`
        showabbreviationsuggestions = true,
        --- @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

lspconfig.emmet_language_server.setup {
  on_attach = on_attach,
  capabilities = capabilities,
}

Anyway, it's still a lot nicer if I could set this up without having to manually add and explicitly pass default options.

Lsp is not working in Helix

After doing according to this repos readme. Every config is fine from my end also done the installation of the emmet-language-server but still it didn't work. Is it because of the path declaration of that npm module which isn't getting activated or what? Because I saw this behavior after installing any npm package globally and done a hx --health [language] to check and there I saw that package by default wasn't showing for that particular. So, to solve that I only installed lsps that are providing homebrew command.

I'm using helix --head and below is my configs->
[language-server.emmet-ls]
args = ["--stdio"]
command = "emmet-language-server"

language-servers = [ "typescript-language-server", "tailwindcss-react", "eslint", "emmet-ls" ]

For HTML ->
[[language]]
name = "html"
formatter = { command = 'prettier', args = ["--parser", "html"] }
language-servers = [ "vscode-html-language-server", "tailwindcss-react", "emmet-ls"]

Context aware completion

Hey I've been using your emmet language server from a long time I would like to thank you for creating such a great language server for neovim community
I'm a frontend developer and when I am on a react project and writing react code in a js file
I get a little bit annoyed how the language server shows emmet suggestions outside the jsx context
For example this is a navbar.js file

import "../stylesheets/navbar.css";

function navbar() {
  return (
    <>
      <nav>
        <ul>Thing one</ul>
        <ul>Thing Two</ul>
        <ul>Thing Three</ul>
      </nav>
    </>
  );
}
export default navbar;

When my cursor is inside the jsx fragment <> It shows emmet suggestions that is fine
But it also shows emmet suggestions when I'm on the next line after import statement
Isn't there any settings available to achieve context aware completion for emmet?

Emmet suggestions don't appear in cmp on 2.0.2

Hi there - when I update from 2.0.1 to 2.0.2, I no longer receive Emmet suggestions in cmp. Downgrading to 2.0.1 again fixes the problem.

Please let me know if I can provide any additional information or help test anything.

Change `className` to `class` when expanding div class names

Hi! I'm using SolidJS on my project, but the default behavior of emmet is to expand .text-center to <div className="text-center"></div>. The problem is that SolidJS does not use className, only class.

I've search how to change this behavior, and found this: How to change emmet expanding "className" to "class" in VSCode for JSX/TSX?.

So i tried putting this configuration on Helix:

[language-server.emmet-ls]
command = "emmet-language-server"
config = { includeLanguages = { typescriptreact = "html" } }
args = ["--stdio"]

But nothing changed, even if a use:

[language-server.emmet-ls]
command = "emmet-language-server"
config = { emmet = { includeLanguages = { typescriptreact = "html" } } }
args = ["--stdio"]

The config field is sent to initializationOptions of onInitialize.

Idk if the problem is with this lsp, emmet-helper or emmet itself.

Arbitrary element expansion (vs. emmet-ls)

Hi!

I've tried emmet-language-server instead of emmet-ls, because I don't like that every word I write gets expanded into a tag, even though I have a close auto complete entry that would make more sense.

I've read here aca/emmet-ls#55 that this language server fixes that problem, but it seems to have the same behavior: I'm editing a .tsx file, write "asdf" and it gets expanded to "". Is there an option I didn't see?

Is there a way to use a `snippets.json` file?

Pretty much just the title.

I am using Neovim with lsp-config.

I have tried this:

lsp_conf.emmet_language_server.setup({
    extensionsPath = {
        init_options = {
            os.getenv("HOME") .. "/emmet-extensions"
        }
    }
})

And this is $HOME/emmet-extensions/snippets.json:

{
    "html": {
        "snippets": {
            "test": "div{test}"
        }
    }
}

Emmet no longer does anything

Emmet completions don't work for me anymore. I installed it with Mason, and it was working great, until one day it stopped working. The completions still show up, so if I type ht I see a completion that says html~ Text, which I don't get if I uninstall it. But if I select the completion it autocompletes to nothing.

I have nothing whatsoever related to emmet-language-server in my config. I would assume that was the problem, except that it was working before, so I don't get what changed.

Possibility to add language filters

I wasn't able to add the "bem" filter as the default filter and I have to use .item>.-child|bem all time
In emmet documentation, they provide to use the snippets.json file, but in the plugin, docs provided only variables if I understand well it's part of a snippets config

abbr for <style> tag in HTML

not sure how to resolve it without vscode parser, but I managed to resolve it via a stupid way.

I started 2 emmet-language-server instances for html file, one doComplete with html, one do css. you can easily config this via autocmd.
ref:microsoft/vscode#28039

One flaw is that you will get 2 abbr suggestions messed your comp.

Question about adding filetypes

i am using LazyVim in neovim and i have created a lsp-config.lua in the plugins directory for changing the filetypes as i needed to add vue to the filetype
return { { "neovim/nvim-lspconfig", opts = { servers = { emmet_language_server = { filetypes = { "css", "eruby", "html", "javascript", "javascriptreact", "less", "sass", "scss", "pug", "typescriptreact", "vue", }, }, }, }, }, }
The reason i have all the types mentioned is because only adding vue made it stop working on other formats and wanted to ask if setting it up like this will also cause issue with other default configurations that are provided by emmet-language-server and if i should add those here as well.
Thank you in advance and love yours over emmet_ls.

Usage via `omnifunc`

Hey!
Thank you for writing this plugin. I would like to use it with Neovim without any additional autocomplete plugins.

I've copied the configuration from the readme but I can't this plugin work with built-in autocomplete. I have a following on_attach function that connects omnifunc with lsp.omnifunc for the buffer:

local on_attach = function(client, bufnr)
    local map = vim.api.nvim_buf_set_keymap
    local ion = vim.api.nvim_buf_set_option
    local opts = { noremap = true }

    ion(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
    ion(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')

    -- Configure keybindings for LSP
    map(bufnr, 'n', 'C-y', '<Cmd>lua vim.lsp.buf.code_action()<CR>', opts)
    map(bufnr, 'n', 'g0', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
    map(bufnr, 'n', 'gf', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
    map(bufnr, 'n', 'gi', '<Cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    map(bufnr, 'n', 'gt', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
    map(bufnr, 'n', 'gr', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
    map(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
end

Now, if I type valid emmet syntax in the HTML file (e.g. h1.center), and hit CTRL+x, CTRL+o, I see a following message in status line:

^X mode (^]^D^E^F^O^K^L^N^O^Ps^U^V^Y) Pattern not found

How can I force emmet to convert snippet to a proper HTML structure?

Can't prompt CSS in vue files

Reproduction method

  1. Create a vue file
<template>
  <div></div>
</template>

<script>
export default {
  name: "a",
};
</script>

<style lang="scss" scoped>
div {
}
</style>
  1. No prompt will appear when entering the css abbreviation in the scss section.
    image

Unable to use self-closing tags in vue files in Helix Editor

currently if i the do following in a JSX file in helix, I get a self closing tag, as expected:

jsx

however if i do the same thing in a .vue file i get the following result

vue

My Helix languages.toml includes the following

[language-server.emmet-lsp]
command = "emmet-language-server"
args = ["--stdio"]

[[language]]
name = "vue"
language-servers = [ "vue-language-server", "emmet-lsp"]
formatter = { command = 'prettier', args = ["--parser", "vue"] }
auto-format = true

Can you tell me if I need to do anything to the Helix config to get the LSP to respond in the right way please?

Not run on xml file.

I install the plugin from mason on lazyvim, but the plugin do not work on xml file. It works fine as expected on html file, but because most of the time i work with xml data, this kinda bother me have to use vscode only to works with xml file.

Astro support?

First of all, I want to thank you for this excellent plugin! I don't know if this is the right place to ask for this but your emmet wrap plugin seems to not work on .astro files, the popup is created but nothing happens after you press enter and I wanted to know if there is something I'm missing or if there is an incompatibility issue, everything else about emmet works with my lsp, like snippets and all of emmet goodness, just this specific thing doesn't work. Thanks again, and sorry if this is a dumb issue.

syntaxProfile not working with jsx files

With html and js files the settings work, but with jsx they don't

require("lspconfig").emmet_language_server.setup({
  filetypes = { "css", "eruby", "html", "javascript", "javascriptreact", "less", "sass", "scss", "svelte", "pug", "typescriptreact", "vue" },
  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 `true`
    showabbreviationsuggestions = true,
    --- @type boolean defaults to `false`
    showsuggestionsassnippets = false,
    --- @type table<string, any> https://docs.emmet.io/customization/syntax-profiles/
    syntaxProfiles = {
      html = {
        tag_nl = "decide",
        tag_nl_leaf = true,
        inline_break = 1
      },
    },
    --- @type table<string, string> https://docs.emmet.io/customization/snippets/#variables
    variables = {
    },
    --- @type string[]
    excludelanguages = {},
  },
})

Does it work in nvim 0.10.0 ?

Hello,
with the following versions:

Nvim 0.10.0
LazyVim latest version
Mason
emmet-language-server 2.6.0

I successfully installed emmet-language-server using mason, it also attaches to buffers, but nothing happens when I try the html functionalities.
For example typing div.mb-3 does not yield any results

Here's my lsp-config:

return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0
      -- Be aware that you also will need to properly configure your LSP server to
      -- provide the inlay hints.
      inlay_hints = {
        enabled = true,
        exclude = { "vue" }, -- filetypes for which you don't want to enable inlay hints
      },
      -- make sure mason installs the server
      servers = {
        emmet_language_server = {
          filetypes = {
            "vue",
            "html",
            "css",
          },
        },
        vtsls = {
          settings = {
            typescript = {
              updateImportsOnFileMove = { enabled = "always" },
              suggest = {
                completeFunctionCalls = true,
              },
              inlayHints = {
                enumMemberValues = { enabled = false },
                functionLikeReturnTypes = { enabled = false },
                parameterNames = { enabled = "literals" },
                parameterTypes = { enabled = false },
                propertyDeclarationTypes = { enabled = false },
                variableTypes = { enabled = false },
              },
            },
          },
        },
      },
    },
  },
}

Am I missing a configuration step?
LazyVim uses nvim-cmp and cmp-nvim-lsp for completion.

Self-closing tag weird behaviour

It's not necessarily an emmet_language_server problem, but I don't know where to ask this, so I'm asking here.
Setting filetype to javascript in neovim, emmet_language_server doesn't self-close it.
But with filetype set to javascriptreact, it closes it as advertised.
Here's the gif to illustrate this:

Peek 2023-11-15 21-41

Server crashes on startup neovim

Hello, I don't know if I am doing something wrong, but I can't figure out how to start this LSP server without it crashing.

Everything works perfectly with emmet-ls but when I start emmet-language-server I instantly get the error message Client 1 quit with exit code 1 and signal 0.

Expand emmet snippets

Does anyone know how to set up nvim-lsp so that I can expand emmet with ctrl + h?

Multiplication not working properly on Helix

Hello, I found this here: helix-editor/helix#1896 (comment), and decided to give it a go (currently using emmet-ls). I'm using helix editor and my config is quite simple (defaults) and works fine. As I was using emmet-ls, I simply changed the command and kept the language-server name as it was.

[language-server.emmet-ls]
args = ["--stdio"]
command="emmet-language-server"

Here is a quick example of what happens (works = shows auto-complete, generates markup):

  • div - works
  • div>heading - works
  • div>heading* - No autocomplete (good)
  • div> heading*2 - Does not work, no auto-complete
  • div> heading*2x - works but don't need the extra <x>

I checked the options on your README, perhaps I am missing something?

how to add a new language?

Hi,

I'm using LazyVim; I'd like to know how to add Svelte.

I saw this PR (it seems like Svelte is removed)
neovim/nvim-lspconfig#2914

But it seems that svelte language server is not implementing emmet for me?

I tried this config:
#2 (comment)

and added it in autocommands.lua

And I'm getting an error no global object on_attach and capabilities.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.