Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to show emmet suggestions in languages that are not pure mark up or stylesheet like #29532

Closed
tklepzig opened this issue Jun 27, 2017 · 31 comments
Assignees
Labels
emmet Emmet related issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@tklepzig
Copy link

tklepzig commented Jun 27, 2017

  • VSCode Version: Code - Insiders 1.14.0-insider (15b579d, 2017-06-27T05:16:51.982Z)
  • OS Version: Windows_NT ia32 10.0.10586
  • Extensions: All disabled

Steps to Reproduce:

  1. Create a new file with the following content:
import React from "react";

class MyComponent extends React.Component {
  
  render() {
   return div
  }
}

export default MyComponent;
  1. Set language mode of the file to javascriptreact.
  2. Place cursor after the div and trigger suggestion list.

Expected: The suggestion list contains the "expand emmet abbreviation" for the div tag.
Actual: The suggestion list contains no emmet entry at all.

@vscodebot vscodebot bot added the insiders label Jun 27, 2017
@vscodebot vscodebot bot added the emmet Emmet related issues label Jun 27, 2017
@geirsagberg
Copy link
Contributor

Also affects .tsx / Typescript React.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 27, 2017

We decided to disable the emmet abbreviations in the suggestion list in languages that are not pure mark up or stylesheet like. The reason was that there was no easy way for the emmet extension to understand the underlying language and identify the areas of the code where it should suggest emmet.

For example, in case of javascriptreact/typescriptreact, the emmet suggestions would show up no matter where (js vs html) you were typing. This got very noisy because in a jsx file you are most of the time writing js.

The solution we are aiming for is this:

So, now this issue becomes an extension candidate.

Note that the command Emmet: Expand Abbreviation and Emmet: Wrap with Abbreviation will continue to work in jsx/tsx files. Bind a keyboard shortcut for Emmet: Expand Abbreviation (other than tab) and you will be able to expand emmet abbreviations anywhere in jsx file

@ramya-rao-a ramya-rao-a added *extension-candidate Issue identified as good extension implementation feature-request Request for new features or functionality and removed insiders labels Jun 27, 2017
@ramya-rao-a ramya-rao-a added this to the Backlog milestone Jun 27, 2017
@ramya-rao-a ramya-rao-a changed the title emmet expansion not working in jsx files (javascriptreact) emmet expansion suggestions should show up in jsx files (javascriptreact) Jun 27, 2017
@tklepzig
Copy link
Author

Ok, I understand your point. Is there maybe a chance to add an entry in the settings to change this, so to enable the emmet abbreviations in certain languages?

@ramya-rao-a
Copy link
Contributor

@tklepzig If there would be such a setting, are you saying you wouldnt mind the emmet suggestions showing up when you are writing javascript code in javascriptreact file?

@geirsagberg
Copy link
Contributor

Can't speak for @tklepzig, but I would certainly love the choice to press Tab to expand an Emmet snippet. That is more important than showing the suggestions, for me.

@tklepzig
Copy link
Author

Yeah, I wouldn't mind if the emmet suggestions would show up in the whole jsx file.

@ramya-rao-a
Copy link
Contributor

@geirsagberg We are definitely moving away from binding Tab to Emmet. See https://code.visualstudio.com/updates/v1_13#_emmet-abbreviation-expansion-in-suggestion-list for more on this.

You can still bind any other keyboard shortcut to Emmet: Expand Abbreviation command to get emmet expansions anywhere in the jsx file

@tklepzig I'll keep that in mind and look into options

@ramya-rao-a ramya-rao-a changed the title emmet expansion suggestions should show up in jsx files (javascriptreact) Option to show emmet suggestions in languages that are not pure mark up or stylesheet like Jun 28, 2017
@ramya-rao-a
Copy link
Contributor

I have updated this issue title to track the option to allow suggestions to show up in non markup like languages like jsx

@nanaasumadu
Copy link

@ramya-rao-a
I have tested the new setting

"emmet.includeLanguages": { "php": "html" },
but emmet suggestion does not work.

html file
image

php file
image

"Emmet: Expand Abbrevation", however works.

@nanaasumadu
Copy link

@ramya-rao-a I can see that you have made a new commit to address this issue. I will test when the new build of insiders comes out this evening my time.

@ramya-rao-a
Copy link
Contributor

The setting emmet.showExpandedAbbreviation now supports the below three values

  • never: You will never see emmet abbreviations in the suggestion list for any language
  • inDefaultEmmetModesOnly: This is the default. You will see emmet abbreviations in the suggestion list for languages that are supported by default by emmet (other than jsx). ['html','pug','slim','haml','xml','xsl','css','scss','sass','less','stylus']
  • always: You will see emmet abbreviations in the suggestion list EVERYWHERE in your file as long as the language is either javascriptreact or typescriptreact or you have used the new setting emmet.includeLanguages to map any other language to one of the emmet supported languages

This change will be out in the next Insiders build (29th June, 2017)

Give it a try and let me know how it works out

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 28, 2017

@nanaasumadu Yes, please wait for the next Insider's build.
cc @jens1o You have been doing quite some emmet testing, so including you here

:)

@ramya-rao-a ramya-rao-a added the verification-needed Verification of issue is requested label Jun 28, 2017
@tklepzig
Copy link
Author

Thanks @ramya-rao-a! I will try this today with the new insiders (it's currently morning for me ;) )

@jens1o
Copy link
Contributor

jens1o commented Jun 29, 2017

I'm going to try it out too. :)

@nanaasumadu
Copy link

@ramya-rao-a Thanks. With the setting below, emmet suggestions are working in PHP

"emmet.showExpandedAbbreviation": "always",
"emmet.includeLanguages": { "php": "html" }

@nanaasumadu
Copy link

emmet_suggest_php

@jens1o
Copy link
Contributor

jens1o commented Jun 29, 2017

Yep, also working for me.

@nanaasumadu
Copy link

nanaasumadu commented Jun 29, 2017

I think I have discovered a bug. Emmet suggestions fails when there is * for multiplication in the code.

Try this in both PHP and HTML
div.test>ul>li>a*3

"Emmet: Expand Abbreviation" command, however, works.

@tklepzig
Copy link
Author

tklepzig commented Jun 29, 2017

@ramya-rao-a Yeah, it's working as expected, with always every time the emmet expansion is available in jsx.

I would only suggest to change the always to something more specific to make clear that it's targeting the javascriptreact and typescriptreact languages if no other one is added to the emmet.includeLanguages setting.

@jens1o
Copy link
Contributor

jens1o commented Jun 29, 2017

@nanaasumadu No, you didn't. It's already reported: #27784

@ramya-rao-a
Copy link
Contributor

@tklepzig I agree, but can't come up with a nice name for that. Trust me I have tried 😭 If you have any ideas, am open to suggestions.

@jens1o #27784 is about expansion not working at all when there is a grouping followed by multiplication. What @nanaasumadu is saying is that the suggestions stop showing when you hit *.
That is related to #29758

@nanaasumadu Until #29758 is completely fixed, as a work around you can still press Ctrl+Space and manually trigger the suggestion

@ramya-rao-a
Copy link
Contributor

Thanks for testing everyone!

@tklepzig
Copy link
Author

tklepzig commented Jun 29, 2017

@ramya-rao-a Hm, what do think about something like defaultAndIncludedLanguages (could be improved, only an idea ;) ) and add javascriptreact and typescriptreact as default to includeLanguages?

@ramya-rao-a
Copy link
Contributor

Adding add javascriptreact and typescriptreact as default to includeLanguages doesn't make sense

includeLanguages is to map a non supported language to a supported language

like javascript: javascriptreact

@tklepzig
Copy link
Author

Yeah, you are right, I forgot that it's a map, not just a list.
So maybe just leave it to the user? In the way, that defaultAndIncludedLanguages doesn't add anything unless includeLanguages is modified (including javascriptreact and typescriptreact)?

@ramya-rao-a
Copy link
Contributor

I didnt want to include any references to the "includeLanguages" setting. Not many people would be aware of what that means.

One option I was toying around was "never", "always" and "inHtmlAndCssOnly"

@tklepzig
Copy link
Author

Ok, I see your point.
Yeah, that sounds good, so all "combined" languages are excluded. Definitely a better name then the current one.

@ramya-rao-a
Copy link
Contributor

ya but the problem is languages like jade, haml, xml also should be included

so more like "never", "always" and "inMarkupAndCssOnly"?

@tklepzig
Copy link
Author

Yep, "Markup" sounds good. Should be clear enough which languages are included.

@ramya-rao-a
Copy link
Contributor

Done.

See 158270d

@tklepzig
Copy link
Author

Thx :)

@chrmarti chrmarti added the verified Verification succeeded label Jun 30, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
emmet Emmet related issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants