如何在spacemacs里用自定义的theme?

大家好!

我在spacemacs里用的theme是基于spacemacs-dark的修改版,就是通过(custom-set-variables '(spacemacs-theme-custom-colors '(...)))改基础配色和通过custom-theme-set-faces来直接修改face。不过这样修改太麻烦了而且也挤占.spacemacs文件的空间,所以我想直接把spacemacs-theme这个包直接修改成自己想要的配色版本然后重命名成一个新的package。

不过spacemacs的themes是通过dotspacemacs-themes来加载的,这些主题要么是自带的要么是theme-megapack里的,或者是elpa/melpa上的packages,我自己写的package不管放在哪里spacemacs都会以为这是一个需要从melpa上安装的package然后报错。

请问大家有没有这方面的经验,我自己写的theme怎么样才能被spacemacs加载呢?

我看主题的readme里都会说用load-theme,刚看了下,在spacemacs的core/core-themes-support.el里也是用的load-themC-h f load-theme一下,按它的说明在config里load你的theme吧。

谢谢楼上!

我看了spacemacs/load-theme (theme)里如果参数theme是存在于(custom-available-themes)里的就不会触发从melpa安装。所以只要在dotspacemacs/user-init里把theme的路径添加到载入路径里:

(add-to-list 'load-path "path/to/my-theme/")
(add-to-list 'custom-theme-load-path "path/to/my-theme/")

这样就可以在dotspacemacs-themes里加入自定义的my-theme了。\[T]/

1 个赞