emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.79k stars 889 forks source link

args-out-of-range errors while browsing python code #711

Closed jumper047 closed 5 years ago

jumper047 commented 5 years ago

Describe the bug Error messages appear in minibuffer when i put cursor on function/method.

To Reproduce Put cursor at the end of second string. ''' from collections import namedtuple IndexEntry = namedtuple("indexEntry", ["time", "offset"]) '''

Expected behavior No errors in minibuffer.

Which Language Server did you use Microsoft python language server with package ms-python from Melpa.

OS Windows 7 x64

Error callstack

Backtrace

Debugger entered--Lisp error: (args-out-of-range [] -1)
  lsp-elt([] -1)
  lsp--signature->eldoc-message(#<hash-table equal 3/65 0x2a7d325>)
  #f(compiled-function (signature) #<bytecode 0x1ee510d>)(#<hash-table equal 3/65 0x2a7d325>)
  #f(compiled-function () #<bytecode 0x1b11011>)()
  #f(compiled-function (result) #<bytecode 0x2a1c59d>)(#<hash-table equal 3/65 0x2a7d325>)
  lsp--parser-on-message(#s(lsp--parser :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "" :workspace #s(lsp--workspace :parser #1 :server-capabilities #<hash-table equal 14/65 0x2b4b79d> :registered-server-capabilities nil :root "d:/psh/projects/MGViewer/" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1c9dcf5>) :test\? #f(compiled-function () #<bytecode 0x1c9dd09>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 4/65 0x1c9dd15> :request-handlers #<hash-table equal 0/65 0x1c9dd35> :response-handlers #<hash-table eql 6/65 0x1c9e135> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1c9e539> :action-handlers #<hash-table equal 0/65 0x1c9e8dd> :major-modes (python-mode) :activation-fn nil :priority 0 :server-id ms-python :multi-root nil :initialization-options ms-python--initialization-options :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :message-trace nil) :host-root nil :proc #<process ms-python> :cmd-proc #<process ms-python> :buffers (#<buffer QuickParamsCaching.py>) :highlight-overlays #<hash-table eq 0/65 0x2a1d201> :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x2a1d221> :watches #<hash-table equal 0/65 0x2a1d615> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x2a1da19>)) "{\"jsonrpc\":\"2.0\",\"result\":{\"signatures\":[],\"activeSignature\":-1,\"activeParameter\":-1},\"id\":50}")
  #f(compiled-function (proc output) #<bytecode 0x2a1da39>)(#<process ms-python> "Content-Length: 329\015\n\015\n{\"jsonrpc\":\"2.0\",\"result\":{\"contents\":{\"kind\":\"plaintext\",\"value\":\"enum.Enum('Methods', 'compress skip'):\\r\\nEnum\\r\\nGeneric enumeration.\\r\\n\\r\\n    Derive from this class to define new enumerations.\"},\"range\":{\"start\":{\"line\":29,\"character\":10},\"end\":{\"line\":29,\"character\":47}},\"_version\":0,\"_typeNames\":[\"enum.Enum\"]},\"id\":49}Content-Length: 94\015\n\015\n{\"jsonrpc\":\"2.0\",\"result\":{\"signatures\":[],\"activeSignature\":-1,\"activeParameter\":-1},\"id\":50}")

Messages

lsp--signature->eldoc-message: Args out of range: [], -1

My config:

(setq lsp-print-io t)
(use-package lsp-mode
       :config
       (require 'lsp-clients)
       (add-hook 'lsp-after-open-hook 'lsp-enable-imenu)
       (add-hook 'python-mode-hook 'lsp)
       (setq lsp-prefer-flymake nil)
       (setq lsp-imenu-sort-methods '(position kind))
       (setq lsp-auto-configure 'nil)

       (defun my-set-projectile-root ()
     (when lsp--cur-workspace
       (setq projectile-project-root (lsp--workspace-root lsp--cur-workspace))))
       (add-hook 'lsp-before-open-hook #'my-set-projectile-root)
       (defun my-python-mode-before-save-hook ()
     (when (eq major-mode 'python-mode)
       (lsp-format-buffer)
       ))
;;       (add-hook 'before-save-hook #'my-python-mode-before-save-hook)
       )

(use-package ms-python
        :after lsp-mode
        :config
        (add-hook 'python-mode-hook #'lsp)

        (setq ms-python-server-install-dir "d:/software/python-language-server-2019.1/output/bin/Release/")
      (add-hook 'lsp-ui-mode-hook #'(lambda() (setq-local flycheck-checker 'python-flake8)))
      (add-hook 'lsp-mode-hook #'(lambda () (progn (company-mode 1) (add-to-list 'company-backends 'company-lsp))))
    (add-hook 'lsp-mode-hook 'yas-minor-mode)
    (setq  flycheck-check-syntax-automatically '(save idle-change mode-
    enabled))
    (setq flycheck-idle-change-delay 4) 
        (use-package py-autopep8
          :hook (python-mode . py-autopep8-enable-on-save))
        (use-package py-isort
          :hook (before-save . py-isort-before-save))
        )

(use-package lsp-ui
  :after lsp-mode
  :init
  (add-hook 'lsp-mode-hook 'lsp-ui-mode)
  (add-hook 'python-mode-hook 'flycheck-mode)
  (add-hook 'lsp-ui-mode-hook 'hl-line-mode)
  :config
  (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
  (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)
  :bind (
     ("C-c j" . lsp-ui-imenu)
     )
  )
yyoncho commented 5 years ago

Temporary workaround until the issue is fixed:

(setq lsp-json-use-lists t)