Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

[WIP] Complete CSS selectors inside of attributes #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sadovnychyi
Copy link

This is work in progress and still requires some modifications, but I would love to hear some feedback before I will continue.

Lookup all .css, .scss and .less files in project on package activation. Look for entity.other.attribute-name.class.css or entity.other.attribute-name.id.css scopes inside of each file. This makes it work with any stylesheets supported by Atom. No need to use external CSS parser.

  • Lookup for CSS scopes inside of current file as well.
  • Update completions registry when new stylesheets created or updated.
  • Make global parsing asynchronous for each file
  • Allow to configure what to ignore – right now all VCS and Core ignored files are ignored. But sometimes we want to get autocompletions from, for example, bower_components directory
  • Should we make this completions optional under an experimental setting?
  • Handle events when files updated outside of Atom
  • Handle file removal event

sample
#13


getStylesheetsAtPath: (dir) ->
stylesheets = []
for file in fs.readdirSync(dir)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scanning a whole project on each autocomplete call is too expensive IMO

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more like proof of concept. Look on my to-do list about caching.

On Wed, Dec 30, 2015, 23:50 Steel Brain notifications@github.com wrote:

In lib/provider.coffee
#21 (comment):

@@ -168,7 +170,42 @@ module.exports =

 attributePattern.exec(line)?[1]
  • getAttributeValues: (attribute) ->
  • getLocalStylesheets: (editor) ->
  • source = editor.getText()
  • while match = stylePattern.exec(source)
  •  match[1]
    
  • getStylesheetsAtPath: (dir) ->
  • stylesheets = []
  • for file in fs.readdirSync(dir)

Scanning a whole project on each autocomplete call is too expensive IMO


Reply to this email directly or view it on GitHub
https://github.com/atom/autocomplete-html/pull/21/files#r48611158.

@sadovnychyi
Copy link
Author

@mnquintana @50Wliu could you guys take a look on updated implementation?

I've basically copy pasted load-paths-handler.coffee from fuzzy-finder package since looks like there are no other way to browse all project files.

It does lookup all files on package activation and updates completions index on each save event.
But it will not update completions from files created outside of atom. Also I didn't found a way to subscribe on file removal event.

Any advices?

@PixelT
Copy link

PixelT commented Oct 28, 2016

Hi,
how the progress about plugin looks like?

@florianbouvot
Copy link

@sadovnychyi is it working when styles.scss is closed (gif demo) ?

@sadovnychyi
Copy link
Author

@florianbouvot it does. https://github.com/atom/autocomplete-html/pull/21/files#diff-43f9c4cec188d77db17033d59fb3944dR202

It scans all of ['.css', '.scss', '.less', '.html'] in your project.

I been using this branch for a long time, there's just issues that I don't have time to resolve and it's unsafe to merge without fixing them. But basically this is very usable as is.

@florianbouvot
Copy link

@sadovnychyi cool and how can we use it now ?

@sadovnychyi
Copy link
Author

Just clone, switch the branch and apm link it, or just manually replace the package.

@florianbouvot
Copy link

@sadovnychyi thank you, I think you should consider to create a dedicated plugin 😉

@sadovnychyi
Copy link
Author

atom/atom#14853 -- I think after this is merged it would be much easier to solve some issues here.

@florianbouvot
Copy link

@sadovnychyi I clone sadovnychyi:master and apm link it but it doesn't seem to work. I didn't know which branch to choose, can you help me ?

atom/atom#14853 -- I think after this is merged it would be much easier to solve some issues here.

I understand 😉

@a7madgamal
Copy link

need this BADLY :(

@vinkla
Copy link

vinkla commented Nov 12, 2018

Is this pull request still alive? What can one do to help? I'm guessing this pull request needs to be decaffeinated before it can be merged?

@sadovnychyi
Copy link
Author

@vinkla I think there's language servers available for this now, would make sense to use one of those.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants