vscode-elixir-ls icon indicating copy to clipboard operation
vscode-elixir-ls copied to clipboard

Better indentation in `.html.eex` autocompletion

Open clmay opened this issue 3 years ago • 6 comments

Phew,

"emmet.includeLanguages": {
  "html-eex": "html"
}

was exactly what I needed to get HTML completion working... but I have one more small, niggling problem with it still.

When the language is set to html instead of html-eex, creating a new node in the DOM and hitting return automatically adds a level of indentation, and moves the closing tag behind an extra newline, as well.

But when the language is set to html-eex, this behavior is disabled, so using a completion for e.g. <ul> will add the closing tag, but a return will add a newline and leave the cursor in front of the closing tag on the next line... no extra newline or indentation fanciness.

What would it take to make the behavior match the html autocompletion behavior in this final respect?

clmay avatar Sep 18 '20 17:09 clmay

I've added emmet instructions to the README in https://github.com/elixir-lsp/vscode-elixir-ls/pull/141

But when the language is set to html-eex, this behavior is disabled, so using a completion for e.g. <ul> will add the closing tag, but a return will add a newline and leave the cursor in front of the closing tag on the next line... no extra newline or indentation fanciness.

What would it take to make the behavior match the html autocompletion behavior in this final respect?

I'm not sure what this would involve so more research is needed.

axelson avatar Sep 19 '20 18:09 axelson

Let me know, I'm not sure I'm familiar enough with VS Code extensions to know how to accomplish this, or even where to look. But if you're able to suggest a starting place I'd be happy to do what I can.

clmay avatar Sep 20 '20 05:09 clmay

Unfortunately I'm not either which is why I've marked it as help wanted.

axelson avatar Sep 21 '20 06:09 axelson

Makes sense—no problem. :) Maybe someone will chime in.

clmay avatar Sep 21 '20 23:09 clmay

Hey gang. I'm here thanks to the Thinking Elixir interview with @axelson. Aloha!

I've been annoyed by this issue, too. I started poking around the docs to see if I could help. After a little bit of digging, it seems eex-language-configuration.json might need indentation rules:

...
  "indentationRules": {
    "increaseIndentPattern": "^((?!\\/\\/).)*(\\{[^}\"'`]*|\\([^)\"'`]*|\\[[^\\]\"'`]*)$",
    "decreaseIndentPattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]].*$"
  }
...

I don't know how to test this locally. Is it possible those additional rules would fix this issue?

type1fool avatar Jan 01 '21 21:01 type1fool

@type1fool hi :wave:! Hope you enjoyed the podcast :)

You can test locally by following the installation instructions: https://github.com/elixir-lsp/vscode-elixir-ls#installation

Those rules would definitely change the indentation support but I think you'd probably want more than just those.

axelson avatar Jan 08 '21 19:01 axelson