AndreaCrotti / yasnippet-snippets

a collection of yasnippet snippets for many languages
GNU General Public License v3.0
1.15k stars 461 forks source link

Error in condition evaluation: Symbol’s function definition is void: js2-node-type #486

Open Daut opened 5 months ago

Daut commented 5 months ago

Initially reported here: https://github.com/joaotavora/yasnippet/issues/1186


When working with <style> blocks of the .vue files I get the following errors when trying to expand lsp-mode suggestions.

[yas] Error in condition evaluation: Symbol’s function definition is void: js2-node-type [8 times]
[yas] Error running #[128 \302\301\303\300""\207 [(yas-after-exit-snippet-hook) run-hooks apply append] 6 

Additionally Emacs freezes for couple of seconds before completing the selection.

I get similar errors when editing <script> tags too, but without freeze.

When I turn off yas-minor-mode Emacs stops freezing.

Below are parts of my .emacs file related to yas, lsp-mode and company-mode

(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :config
  (lsp-enable-which-key-integration t)
  (setq lsp-completion-provider :none)
  (setq lsp-headerline-breadcrumb-enable nil)
  (add-to-list 'lsp-disabled-clients '(typescript-mode . vue-semantic-server))
  (add-to-list 'lsp-disabled-clients '(js-mode . vue-semantic-server)))

(use-package company
  :hook (after-init . global-company-mode)
  :bind
  (:map company-active-map
        ("<tab>" . company-complete-selection))
  ;; (:map lsp-mode-map
  ;;       ("<tab>" . company-indent-or-complete-column))
  :config
  (setq company-minimum-prefix-length 1)
  (setq company-idle-delay 0.15)
  (setq company-dabbrev-code-ignore-case t)
  (setq company-keywords-ignore-case t)
  (setq company-dabbrev-downcase t)
  (setq completion-ignore-case t)
  (setq company-transformers '(delete-consecutive-dups
                             company-sort-by-occurrence
                             company-sort-by-backend-importance))
  :init
  (setq company-backends '((company-capf :with company-yasnippet company-dabbrev-code)
                           (company-dabbrev-code company-keywords company-files)
                           company-dabbrev)))

(use-package company-box
  :hook (company-mode . company-box-mode))

;; yasnippet
(use-package yasnippet
  :diminish yas-minor-mode
  :hook (after-init . yas-global-mode))

(use-package yasnippet-snippets
  :after yasnippet
  :config (yasnippet-snippets-initialize))
ghosty141 commented 4 months ago

Some snippets for js-mode depend on things from js2-mode which is an external package, it should be checked if that package is installed before the functions are used.

Current offenders after a quick search:

snippets/js-mode/type-inline-comment:4:#condition: (not (= (js2-node-type (js2-node-at-point)) js2-COMMENT))
snippets/js-mode/return-comment:4:#condition: (= (js2-node-type (js2-node-at-point)) js2-COMMENT)
snippets/js-mode/type-multiline-comment:4:#condition: (= (js2-node-type (js2-node-at-point)) js2-COMMENT)
snippets/js-mode/param-comment:4:#condition: (= (js2-node-type (js2-node-at-point)) js2-COMMENT)