From b320075c5b5db05e5c2ce3fa5b81d20dc6378cb0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 13 Jan 2020 00:08:59 -0500 Subject: [PATCH] Add company-box scrollbar "fix" & refactor config --- modules/completion/company/config.el | 90 +++++++++++++++------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index a98bcca9c..1555d6d25 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -70,47 +70,42 @@ company-box-max-candidates 50 company-box-icons-alist 'company-box-icons-all-the-icons company-box-icons-functions - '(+company-box-icons--yasnippet-fn - company-box-icons--lsp - +company-box-icons--elisp-fn - company-box-icons--acphp) + (cons #'+company-box-icons--elisp-fn + (delq 'company-box-icons--elisp + company-box-icons-functions)) company-box-icons-all-the-icons - `((Unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :face 'all-the-icons-purple)) - (Text . ,(all-the-icons-material "text_fields" :height 0.8 :face 'all-the-icons-green)) - (Method . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red)) - (Function . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red)) - (Constructor . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red)) - (Field . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red)) - (Variable . ,(all-the-icons-material "adjust" :height 0.8 :face 'all-the-icons-blue)) - (Class . ,(all-the-icons-material "class" :height 0.8 :face 'all-the-icons-red)) - (Interface . ,(all-the-icons-material "settings_input_component" :height 0.8 :face 'all-the-icons-red)) - (Module . ,(all-the-icons-material "view_module" :height 0.8 :face 'all-the-icons-red)) - (Property . ,(all-the-icons-material "settings" :height 0.8 :face 'all-the-icons-red)) - (Unit . ,(all-the-icons-material "straighten" :height 0.8 :face 'all-the-icons-red)) - (Value . ,(all-the-icons-material "filter_1" :height 0.8 :face 'all-the-icons-red)) - (Enum . ,(all-the-icons-material "plus_one" :height 0.8 :face 'all-the-icons-red)) - (Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.8 :face 'all-the-icons-red)) - (Snippet . ,(all-the-icons-material "short_text" :height 0.8 :face 'all-the-icons-red)) - (Color . ,(all-the-icons-material "color_lens" :height 0.8 :face 'all-the-icons-red)) - (File . ,(all-the-icons-material "insert_drive_file" :height 0.8 :face 'all-the-icons-red)) - (Reference . ,(all-the-icons-material "collections_bookmark" :height 0.8 :face 'all-the-icons-red)) - (Folder . ,(all-the-icons-material "folder" :height 0.8 :face 'all-the-icons-red)) - (EnumMember . ,(all-the-icons-material "people" :height 0.8 :face 'all-the-icons-red)) - (Constant . ,(all-the-icons-material "pause_circle_filled" :height 0.8 :face 'all-the-icons-red)) - (Struct . ,(all-the-icons-material "streetview" :height 0.8 :face 'all-the-icons-red)) - (Event . ,(all-the-icons-material "event" :height 0.8 :face 'all-the-icons-red)) - (Operator . ,(all-the-icons-material "control_point" :height 0.8 :face 'all-the-icons-red)) - (TypeParameter . ,(all-the-icons-material "class" :height 0.8 :face 'all-the-icons-red)) - ;; (Template . ,(company-box-icons-image "Template.png")))) - (Yasnippet . ,(all-the-icons-material "short_text" :height 0.8 :face 'all-the-icons-green)) - (ElispFunction . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red)) - (ElispVariable . ,(all-the-icons-material "check_circle" :height 0.8 :face 'all-the-icons-blue)) - (ElispFeature . ,(all-the-icons-material "stars" :height 0.8 :face 'all-the-icons-orange)) - (ElispFace . ,(all-the-icons-material "format_paint" :height 0.8 :face 'all-the-icons-pink)))) - - (defun +company-box-icons--yasnippet-fn (candidate) - (when (get-text-property 0 'yas-annotation candidate) - 'Yasnippet)) + (let ((all-the-icons-scale-factor 0.8)) + `((Unknown . ,(all-the-icons-material "find_in_page" :face 'all-the-icons-purple)) + (Text . ,(all-the-icons-material "text_fields" :face 'all-the-icons-green)) + (Method . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) + (Function . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) + (Constructor . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) + (Field . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) + (Variable . ,(all-the-icons-material "adjust" :face 'all-the-icons-blue)) + (Class . ,(all-the-icons-material "class" :face 'all-the-icons-red)) + (Interface . ,(all-the-icons-material "settings_input_component" :face 'all-the-icons-red)) + (Module . ,(all-the-icons-material "view_module" :face 'all-the-icons-red)) + (Property . ,(all-the-icons-material "settings" :face 'all-the-icons-red)) + (Unit . ,(all-the-icons-material "straighten" :face 'all-the-icons-red)) + (Value . ,(all-the-icons-material "filter_1" :face 'all-the-icons-red)) + (Enum . ,(all-the-icons-material "plus_one" :face 'all-the-icons-red)) + (Keyword . ,(all-the-icons-material "filter_center_focus" :face 'all-the-icons-red)) + (Snippet . ,(all-the-icons-material "short_text" :face 'all-the-icons-red)) + (Color . ,(all-the-icons-material "color_lens" :face 'all-the-icons-red)) + (File . ,(all-the-icons-material "insert_drive_file" :face 'all-the-icons-red)) + (Reference . ,(all-the-icons-material "collections_bookmark" :face 'all-the-icons-red)) + (Folder . ,(all-the-icons-material "folder" :face 'all-the-icons-red)) + (EnumMember . ,(all-the-icons-material "people" :face 'all-the-icons-red)) + (Constant . ,(all-the-icons-material "pause_circle_filled" :face 'all-the-icons-red)) + (Struct . ,(all-the-icons-material "streetview" :face 'all-the-icons-red)) + (Event . ,(all-the-icons-material "event" :face 'all-the-icons-red)) + (Operator . ,(all-the-icons-material "control_point" :face 'all-the-icons-red)) + (TypeParameter . ,(all-the-icons-material "class" :face 'all-the-icons-red)) + (Template . ,(all-the-icons-material "short_text" :face 'all-the-icons-green)) + (ElispFunction . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) + (ElispVariable . ,(all-the-icons-material "check_circle" :face 'all-the-icons-blue)) + (ElispFeature . ,(all-the-icons-material "stars" :face 'all-the-icons-orange)) + (ElispFace . ,(all-the-icons-material "format_paint" :face 'all-the-icons-pink))))) (defun +company-box-icons--elisp-fn (candidate) (when (derived-mode-p 'emacs-lisp-mode) @@ -118,7 +113,20 @@ (cond ((fboundp sym) 'ElispFunction) ((boundp sym) 'ElispVariable) ((featurep sym) 'ElispFeature) - ((facep sym) 'ElispFace)))))) + ((facep sym) 'ElispFace))))) + + (defadvice! +company-remove-scrollbar-a (orig-fn &rest args) + "This restrains the scrollbar to a width of ~32px. See +https://github.com/sebastiencs/company-box/issues/44" + :around #'company-box--update-scrollbar + (cl-letf* ((old-display-buffer-in-side-window + (symbol-function #'display-buffer-in-side-window)) + ((symbol-function #'display-buffer-in-side-window) + (lambda (buffer alist) + (setf (alist-get 'window-width alist) 0.1) + (funcall old-display-buffer-in-side-window + buffer alist)))) + (apply orig-fn args)))) (use-package! company-dict