Skip to content

Commit e20b0eb

Browse files
committed
fix: more generic handling of actions
1 parent 36d0592 commit e20b0eb

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lsp-ltex.el

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,12 @@ Return the deserialized object, or nil if the SYM.el file dont exist."
334334

335335
(defun lsp-ltex--add-rule (lang rule rules-plist)
336336
"Add RULE of language LANG to the plist named RULES-PLIST (symbol)."
337-
(let ((lang-key (intern (concat ":" lang))))
338-
(when (null (eval rules-plist))
339-
(set rules-plist (list lang-key [])))
340-
(plist-put (eval rules-plist) lang-key
341-
(vconcat (list rule) (plist-get (eval rules-plist) lang-key)))
342-
(when-let (out-file (lsp-ltex--serialize-symbol rules-plist lsp-ltex-user-rules-path))
343-
(lsp-message "[INFO] Rule for language %s saved to file \"%s\"" lang out-file))))
337+
(when (null (eval rules-plist))
338+
(set rules-plist (list lang [])))
339+
(plist-put (eval rules-plist) lang
340+
(vconcat (list rule) (plist-get (eval rules-plist) lang)))
341+
(when-let (out-file (lsp-ltex--serialize-symbol rules-plist lsp-ltex-user-rules-path))
342+
(lsp-message "[INFO] Rule for language %s saved to file \"%s\"" (symbol-name lang) out-file)))
344343

345344
(defun lsp-ltex-combine-plists (&rest plists)
346345
"Create a single property list from all plists in PLISTS.
@@ -537,13 +536,14 @@ This file is use to activate the language server."
537536
"Execute action ACTION-HT by getting KEY and storing it in the RULES-PLIST.
538537
When STORE is non-nil, this will also store the new plist in the directory
539538
`lsp-ltex-user-rules-path'."
540-
(let ((args-ht (lsp-get (if lsp-use-plists action-ht (elt action-ht 0)) key)))
539+
(let ((args-ht (lsp-get (if (vectorp action-ht) (elt action-ht 0) action-ht) key)))
541540
(dolist (lang (lsp-ltex--lsp-keys args-ht))
542-
(mapc (lambda (rule)
543-
(lsp-ltex--add-rule lang rule rules-plist)
544-
(when store
545-
(lsp-ltex--serialize-symbol rules-plist lsp-ltex-user-rules-path)))
546-
(lsp-get args-ht (intern (concat ":" lang)))))))
541+
(let ((lang-key (if (stringp lang) (intern (concat ":" lang)) lang)))
542+
(mapc (lambda (rule)
543+
(lsp-ltex--add-rule lang-key rule rules-plist)
544+
(when store
545+
(lsp-ltex--serialize-symbol rules-plist lsp-ltex-user-rules-path)))
546+
(lsp-get args-ht lang-key))))))
547547

548548
(lsp-defun lsp-ltex--code-action-add-to-dictionary ((&Command :arguments?))
549549
"Handle action for \"_ltex.addToDictionary\"."

0 commit comments

Comments
 (0)