olrtg / emmet-language-server Goto Github PK
View Code? Open in Web Editor NEWA language server for emmet.io
Home Page: https://www.npmjs.com/package/@olrtg/emmet-language-server
License: MIT License
A language server for emmet.io
Home Page: https://www.npmjs.com/package/@olrtg/emmet-language-server
License: MIT License
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}"
}
}
}
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.
As the title said, add support for emmet.extensionsPath
when setting up LSP with init_options
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.
Reference plan
"emmet.triggerExpansionOnTab": true, option in vscode
For example
enter
view press tab ->
Does anyone know how to set up nvim-lsp so that I can expand emmet with ctrl + h?
First I wanted to thank you for your LS. It's been very useful.
Is there a way in which I can configure the LS is to autocomplete for React or Vue component syntax.
For example, if I type AppCard>div
it should be completed to this:
<AppCard>
<div></div>
</AppCard>
Is this possible?
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.
currently if i the do following in a JSX file in helix, I get a self closing tag, as expected:
however if i do the same thing in a .vue file i get the following result
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?
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
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 = {},
},
})
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.
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.
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.
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.
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 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.
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:
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?
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?
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):
works
works
works
but don't need the extra <x>
I checked the options on your README, perhaps I am missing something?
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
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.
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.
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"]
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
.
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
the css shortcuts here dont work
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.