Skip to content

Instantly share code, notes, and snippets.

@erickgnavar
Last active June 28, 2020 16:45
Show Gist options
  • Save erickgnavar/c6d8ca76b6b10bf66847e6448b03551a to your computer and use it in GitHub Desktop.
Save erickgnavar/c6d8ca76b6b10bf66847e6448b03551a to your computer and use it in GitHub Desktop.

Extrae solo los nombres de las clases del archivo css

cat bootstrap.css| grep "^\." | awk '{print $1}' | sed  's/\.//g' | sed 's/\,//g' > bootstrap.txt

El archivo resultante debe ser similar a:

h1
lead
display-1
display-2
display-3
display-4
small
mark
list-unstyled
list-inline
list-inline-item
(setq css-path "path-to-bootstrap.txt")

(defun load-css-company-data (path)
  "Read data from PATH and return its lines."
  (with-temp-buffer
    (insert-file-contents path)
    (split-string (buffer-string) "\n" t)))

(setq sample-completions (load-css-company-data css-path))

(require 'cl-lib)

(require 'company)

(defun company-sample-backend (command &optional arg &rest ignored)
  (interactive (list 'interactive))
  (cl-case command
    (interactive (company-begin-backend 'company-sample-backend))
    (prefix (and (eq major-mode 'web-mode)
                 (company-grab-symbol)))
    (candidates
     (cl-remove-if-not
      (lambda (c) (string-prefix-p arg c))
      sample-completions))))

(add-to-list 'company-backends 'company-sample-backend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment