Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Code completion? #2

Closed
oscar-b opened this issue Nov 14, 2016 · 23 comments
Closed

Code completion? #2

oscar-b opened this issue Nov 14, 2016 · 23 comments

Comments

@oscar-b
Copy link

oscar-b commented Nov 14, 2016

Excellent work on the syntax highlighting, it looks a lot better now :)

Is it possible to also get CSS code completion, or is that not possible in VSCode?

@wmertens
Copy link
Contributor

I came here with that same question, and also with a link to something that may be related: microsoft/vscode#8928

@julienp
Copy link
Collaborator

julienp commented Nov 14, 2016

Thanks for the link, I'll look into this in the near future.

@wmertens
Copy link
Contributor

See also microsoft/vscode#2793 (comment), it seems that it is already possible if you manage to match the template strings with a TM grammar

@chuckhendo
Copy link

To add on to this - Emmet support would be great. Emmet/Code has an option for syntaxProfiles, so you can specify that you want to use CSS Emmet instead of HTML Emmet.... but it doesn't seem to detect that I'm inside of a CSS block and just does the HTML completion. Not sure if this can be fixed here or if it's a VSCode issue.

@YarivGilad
Copy link

@wmertens You have me confused... is it possible to autocomplete?
I read the comment you referenced. Is it possible to do or is it a suggestion?
Thank you!

@wmertens
Copy link
Contributor

Hmm you are right, not sure if autocomplete works with the injection grammars, maybe those are two different things

@mattiaerre
Copy link

+1 on this, autocomplete would be splendid; the last missing bit I guess 👍 and also linting but that's another story 😅

@YarivGilad
Copy link

Is there anything we can do to help this feature besides waiting or +1 ?
Can you reference a resource of how to create such an extension? is there anyone working on such an extension that can use some help? How can we go about contributing for this to materialize?

@julienp
Copy link
Collaborator

julienp commented Mar 24, 2017

Currently I have done no work toward this, and I'm not quite sure where to start. I'll of course happily merge any merge request implementing this :)

As @Ajar-Ajar said, any references or examples on how to go about this would be very helpful

@iFwu
Copy link

iFwu commented Apr 3, 2017

I think built-in css code completion is done by css language server, which you can refer to the offical css extension.

By the way, first I thought it's easy, just add "embeddedLanguages": { "source.css": "css" } to the "grammars" attribute, but Styled Components syntax differs from original css, which doesn't has css-legal brackets, and it causes the literal template blocks can't be highlighted by built-in css colorizer.

@wmertens
Copy link
Contributor

wmertens commented Apr 3, 2017 via email

@iFwu
Copy link

iFwu commented Apr 3, 2017 via email

@svipas
Copy link

svipas commented May 22, 2017

Check this: https://marketplace.visualstudio.com/items?itemName=plievone.vscode-template-literal-editor, it have only 1 problem I write about that in issues.

@ghost
Copy link

ghost commented Jul 14, 2017

I use the template literal editor as well. Works great. Thanks for the suggestion @svipben

@muhajirdev
Copy link

muhajirdev commented Jul 28, 2017

looking for the same thing. And recently found out that glamorous support autocomplete, it's nice. But it doesn't use css syntax, it use JS Object. The API is pretty similiar as it's inspired by styled-components

@auchenberg
Copy link

This functionality seems to be depend on landing microsoft/vscode#5961 in Code.

@lXSPandora
Copy link

Hey guys test it out

https://marketplace.visualstudio.com/items?itemName=lXSPandora.vscode-styled-components-snippets

@mjbvz
Copy link
Contributor

mjbvz commented Sep 28, 2017

I've created a TypeScript server plugin that adds suggestions, error reporting, and hovers for styled component strings in JS and TS: https://github.com/Microsoft/typescript-styled-plugin

This plugin works well in VS Code alongside the vscode-styled-components extension, and it also should work in any other editor that uses the TypeScript language service. Eventually we plan to let VS Code extensions contribute TS server plugins as well, which would eliminate the need for any extra npm installs or configuration.

Please give the plugin a try and let me know if you run into any issues

@SidKwok
Copy link

SidKwok commented Sep 30, 2017

@mjbvz Thanks! Great job!

@comerc
Copy link

comerc commented Nov 29, 2017

@mjbvz how to use it with styled-jsx?

@aczekajski
Copy link

@mjbvz Thanky you for the plugin! However, it is possible in styled-components to nest the selectors, just like in SCSS, so you can write &:hover { ... } or .wrapper & { ... } or even ${OtherComponent} { ... } and the autocompletion breaks inside the curly brackets.

@mjbvz
Copy link
Contributor

mjbvz commented Dec 14, 2017

Please post issues about the plugin here: https://github.com/Microsoft/typescript-styled-plugin/issues

@jeremytenjo
Copy link

Is there a better solution?

How can Atom make it work seamlessly, but VScode can't. This is the only reason I don't switch completely to VScode.

mjbvz added a commit to mjbvz/vscode-styled-components that referenced this issue Jan 12, 2018
Fixes styled-components#2
Fixes styled-components#38

Uses the `typescript-styled-plugin` to add intellisense, error reporting, and other language features for styled strings.

This requires VS Code 1.20+ (current insiders builds). Users on 1.19 will only get the intellisense if they are working in a jsconfig or tsconfig project
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests