Skip to content

Godot GDScript problems #2127

Open
Open
@mnewt

Description

@mnewt

lsp with GDScript mostly works fine but has two visible issues:

Problem 1

It repeatedly logs warnings and pops open the *Warnings* buffer. If I close the *Warnings* buffer, it just opens it up again. I presume there is a capability mismatch between Godot and lsp. Example *Warnings* entries:

Warning (lsp-mode): Unknown notification: gdscript/capabilities
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil
Warning (lsp-mode): Unknown notification: nil

lsp-log: https://gist.github.com/mnewt/20339c243dba4a5138c1354e3a0c78fa

The first warning will pop up when lsp is started and the subsequent warnings will pop up from time to time while editing.

Problem 2

company completion doesn't work when company-box-mode is enabled. I think I've narrowed down the problem to what happens in lsp-completion--exit-fn. It goes something like this:

  1. The lsp-completion-item plist entry has inside it :label and :insert-text?
  2. When company-mode is enabled but company-box-mode is not, :insert-text? is nil.
  3. When company-mode and company-box-mode are enabled, :insert-text? is "", so lsp-completion--exit-fn inserts that blank string.

I've confirmed that inserting this in lsp-completion--exit-fn does indeed cause the candidate to be inserted as expected:

(when (string-empty-p insert-text?) (setq insert-text? nil))

Questions

  1. What can we do to fix the warnings?
  2. If it's a lot of work to fix them, is there a way to silence them for now, or at least cause the *Warnings*buffer to not pop up every time one occurs?
  3. Is the completion bug a problem in lsp or company-box? Can you clarify what is going on there?

Reproduction Steps:

emacs -Q

(custom-set-variables
 '(straight-use-package-by-default t)
 '(straight-vc-git-default-clone-depth 1))

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)

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

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

(use-package lsp-mode)

(use-package gdscript-mode
  :straight ( :type git :host github :repo "godotengine/emacs-gdscript-mode")
  :hook
  (gdscript-mode . lsp))

Now, open a GDScript file and try to insert a completion using company, e.g.:

func _re

And do M-x company-complete, then M-x company-complete-selection

Versions

lsp: 7.0.1 (commit 1185a48)

GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.6 (Build 19G2021)) of 2020-08-29

Godot 3.2.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions