An open API service indexing awesome lists of open source software.

https://github.com/russmatney/company-css-classes

Company-completion for classes in a css file
https://github.com/russmatney/company-css-classes

company css emacs

Last synced: 7 months ago
JSON representation

Company-completion for classes in a css file

Awesome Lists containing this project

README

          

#+TITLE: company-css-classes

Autocompletion for classnames in a css file.

Created to support tailwindCSS class autocompletion in clojurescript
hiccup-style components.

Currently only supports completion in ~:class~ lists, as in:

#+BEGIN_SRC clojurescript
(defn my-component []
[:div
{:class ["text-"]}
"some content"])
#+END_SRC

Utilizes a local cache to prevent extraneous parsing of the css file. The cache
can be cleared with ~M-x company-css-classes-clear-cache~.

* Configuration
This lib parses css class-names from a css file specified via
`company-css-classes-filepath`. This can be set per project using
~.dir-locals.el~.

#+begin_src elisp
;; /.dir-locals.el
((clojurec-mode
(company-css-classes-filepath . "./public/css/main-built.css"))
(clojurescript-mode
(company-css-classes-filepath . "./public/css/main-built.css")))
#+end_src

The value is passed to `file-truename`, so relative and expandable filepaths should
work fine.

* Roadmap
** [ ] Support completion following ~:div.text-~ syntax
This should be reasonable, and I believe company provides helpers to support
this.
** [ ] Support fetching the class definition for display in ~company-box~
* Installation
** Doom Emacs
#+BEGIN_SRC emacs-lisp
;; packages.el
(package! company-css-classes :recipe
(:host github :repo "russmatney/company-css-classes" :files ("*")))

;; config.el
(use-package! company-css-classes)

(use-package! clojure-mode
:mode "\\.clj$"
:mode ("\\.cljs$" . clojurescript-mode)
:mode ("\\.cljc$" . clojurec-mode)

:config
(set-company-backend!
'clojurescript-mode
'(company-capf company-yasnippet company-flow company-css-classes-backend)))
(set-company-backend!
'clojurec-mode
'(company-capf company-yasnippet company-flow company-css-classes-backend)))
#+END_SRC