victorteokw / ac-html

Emacs auto complete source for html.
22 stars 9 forks source link

Auto complete class name #6

Open victorteokw opened 9 years ago

victorteokw commented 9 years ago

class name and id are separated to two parts.

  1. User project defined.
  2. External framework defined.

I haven't find the tool to use for extracting class names and ids from source code. If you find it, please point here. Maybe we need to implement by ourselves just using regular expression.

osv commented 9 years ago

https://www.npmjs.org/package/extract-from-css this is only lib, script need that fill cache files

I think about Perl script that check every N sec., does css file modified or not, and update cache. Same think may be done with javascript and lib "extract-from-css". I'm not good with node, so can say how easy to do this, want to try after multiple stuff dir done.

victorteokw commented 9 years ago

I have this idea.

Index user's project and get lists of html files, and css files. (If user open the file with html-mode, web-mode, haml-mode, jade-mode, and slim-mode, then this file is html file.) (If user open the file with css-mode, sass-mode, scss-mode, less-mode, then this file is css file.) Parse every file and get list of classes and ids. Store into cache folder. (Currently according to id_and_class branch implementation, it will be "~/.emacs.d/.ac-html/md5_hash_of_project_dir_name")

After user create a file in project dir, add the parsed content to corresponding file in cache dir. After user edit a file, reparse the file and generate new ids and classes into corresponding cache file.

Only the first time indexing, it will be lag.

Since this lib just parse through regular expression and only recognizes css, we may parse files locally with pure elisp.

When using elisp batch mode, it will behaves like command line utility.

osv commented 9 years ago

I think this too complex, user must by hand open files css to make index? I think better to create local project dir ".ac-html/" this dir may contain just 2 files html-attributes-complete/global-class and global-id, use projectile, etc to append this directory ".ac-html" search.

Yes, pure lisp indexator better :) no dependencies

victorteokw commented 9 years ago

No, it just works. User don't need to do anything. Since the project will be large, so separating the cache files will be nice. And it can provide documentation like this:

Appeared in app/assets/stylesheets/application.css.scss
Appeared in app/views/welcome/index.html.erb

cache dir inside ~/.emacs.d is just like in local project dir. Since it uses md5 hash of project dir name. It just doesn't require use to append .ac-html to .gitignore file.

osv commented 9 years ago

Hello, I wrote https://github.com/osv/ac-html-csswatcher for class and id completion, it use external script csswatcher that monitor for changes files and parse files. Currently only .css supported.

It require multydir branch with pull https://github.com/cheunghy/ac-html/pull/22 I hope you merge it :)

Btw, why tests (https://github.com/cheunghy/ac-html/pull/20 ) not merged it pretty cover most situation for several different html-stuff sources?