Repository: spyder-ide/spyder

Issue:
TypeError in go-to-definition
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

I started Spyder 4b6, import numpy as np, when I ctrl-clicked on np, I got this error message. Plus, the code highligting doesn't work as expected: import (purpule) numpy (white) as(purple) np (purple), np should have been colored white too.

### Traceback
```python-traceback
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1219, in handle_go_to_definition
    def_range = position['range']
TypeError: string indices must be integers

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\logging\__init__.py", line 1034, in emit
    msg = self.format(record)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\logging\__init__.py", line 880, in format
    return fmt.format(record)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\logging\__init__.py", line 619, in format
    record.message = record.getMessage()
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\logging\__init__.py", line 380, in getMessage
    msg = msg % self.args
ValueError: incomplete format
Call stack:
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\Scripts\spyder-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\app\start.py", line 196, in main
    mainwindow.main()
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\app\mainwindow.py", line 3646, in main
    mainwindow = run_spyder(app, options, args)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\app\mainwindow.py", line 3529, in run_spyder
    app.exec_()
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\completion\languageserver\client.py", line 343, in on_msg_received
    handler(resp['result'], req_id)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\completion\languageserver\providers\document.py", line 195, in process_go_to_definition
    {'params': result})
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\completion\languageserver\plugin.py", line 279, in receive_response
    self.COMPLETION_CLIENT_NAME, req_id, response)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\completion\plugin.py", line 138, in receive_response
    self.gather_and_send(request_responses)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\completion\plugin.py", line 189, in gather_and_send
    response_instance.handle_response(req_type, responses)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 915, in handle_response
    handler(params)
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1236, in handle_go_to_definition
    "Error when processing go to definition")
  File "C:\Users\Amin\Anaconda3\envs\spyder-beta\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 946, in log_lsp_handle_errors
    logger.error('%', 1, stack_info=True)
Message: '%'
Arguments: (1,)
```

## Versions

* Spyder version: 4.0.0b6 
* Python version: 3.7.3
* Qt version: 5.12.5
* PyQt5 version: 5.12.3
* Operating System: Windows 10

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.2 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.6.0 (OK)
sphinx >=0.6.6               :  2.2.0 (OK)
pylint >=0.25                :  2.4.2 (OK)
psutil >=0.3                 :  5.6.3 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.1.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.5.0;<2.0.0:  1.5.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  None (NOK)
cython >=0.21                :  None (NOK)
IPython >=4.0                :  7.8.0 (OK)
matplotlib >=2.0.0           :  None (NOK)
pandas >=0.13.1              :  None (NOK)
numpy >=1.7                  :  None (NOK)
scipy >=0.17.0               :  None (NOK)
pyls >=0.28.2;<0.29.0        :  0.28.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:

Resolving patch:
diff --git a/spyder/plugins/completion/plugin.py b/spyder/plugins/completion/plugin.py
--- a/spyder/plugins/completion/plugin.py
+++ b/spyder/plugins/completion/plugin.py
@@ -81,7 +81,7 @@ def __init__(self, parent, plugins=['lsp', 'kite', 'fallback']):
         self.language_status = {}
         self.started = False
         self.req_id = 0
-        self.collection_mutex = QMutex()
+        self.collection_mutex = QMutex(QMutex.Recursive)
 
         for plugin in plugins:
             if plugin in self.BASE_PLUGINS:


Test patch: