[groovy] Replace defvar with spacemacs|defc

And extend spacemacs|defc to allow setting
a :safe directive.
This commit is contained in:
Maximilian Wolff 2021-04-17 22:06:12 +02:00
parent c83a9e76b3
commit 8814329a11
No known key found for this signature in database
GPG key ID: 2DD07025BFDBD89A
2 changed files with 10 additions and 6 deletions

View file

@ -53,7 +53,7 @@
spacemacs-dotspacemacs-layers)
"List of variable groups that can't be customized.")
(defmacro spacemacs|defc (symbol standard doc type &optional group-override)
(defmacro spacemacs|defc (symbol standard doc type &optional group-override safe)
"Spacemacs flavored `defcustom' for .spacemacs configurations.
SYMBOL is the variable name; it should not be quoted.
STANDARD is an expression specifying the variable's standard value.
@ -63,6 +63,8 @@ TYPE should be a widget type for editing the symbol's value.
base types and useful composite types.
GROUP-OVERRIDE should be provided if you don't want Spacemacs to infer the
configuration group from the currently configured layer name.
SAFE should be filled with a function to be set to
safe-local-variable property.
NOTE: Use interactive function `spacemacs/customization-valid-p' to test if a
variable has a proper type. In interactive mode it will also `message'
@ -88,6 +90,7 @@ NOTE: Variables defined with a group listed in
`',standard)
,(format "%s\n\nTYPE: %s\n" doc type)
:type ,type
:safe ,safe
:group group)
(when (memq group spacemacs-customization-uncustomizable-groups)
;; HACK: This will make `custom-variable-p' return nil

View file

@ -23,11 +23,12 @@
;; Variables
(defvar groovy-backend (if (configuration-layer/layer-used-p 'lsp) 'lsp 'company-groovy)
(spacemacs|defc groovy-backend (if (configuration-layer/layer-used-p 'lsp) 'lsp 'company-groovy)
"The backend to use for IDE features.
Possible values are `lsp' and `company-groovy'.
If `nil' then 'company-groovy` is the default backend unless `lsp' layer is used")
(put 'groovy-backend 'safe-local-variable #'symbolp)
If not set then 'company-groovy` is the default backend unless `lsp' layer is used"
'(choice (const lsp) (const company-groovy)) nil #'symbolp)
(defvar groovy-lsp-jar-path "~/groovy-lsp-all.jar"
"The path to the lsp jar file")
(spacemacs|defc groovy-lsp-jar-path "~/groovy-lsp-all.jar"
"The path to the lsp jar file"
'(file) nil #'stringp)