spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

Register completion server capabilities bug with textDocumentSync #15045

Open hlouzada opened 3 years ago

hlouzada commented 3 years ago

Description

The LSP Protocol 4.16 now supports two types of save notifications boolean or SaveOptions:

export interface TextDocumentSyncOptions {
    /**
     * Open and close notifications are sent to the server. If omitted open
     * close notification should not be sent.
     */
    openClose?: boolean;
    /**
     * Change notifications are sent to the server. See
     * TextDocumentSyncKind.None, TextDocumentSyncKind.Full and
     * TextDocumentSyncKind.Incremental. If omitted it defaults to
     * TextDocumentSyncKind.None.
     */
    change?: TextDocumentSyncKind;
    /**
     * If present will save notifications are sent to the server. If omitted
     * the notification should not be sent.
     */
    willSave?: boolean;
    /**
     * If present will save wait until requests are sent to the server. If
     * omitted the request should not be sent.
     */
    willSaveWaitUntil?: boolean;
    /**
     * If present save notifications are sent to the server. If omitted the
     * notification should not be sent.
     */
    save?: boolean | SaveOptions;
}

See LSP Reference for more details.

Currently spyder only supports SaveOptions with:

self.save_include_text = sync_options['save']['includeText']

in spyder/plugins/editor/widgets/codeeditor.py.

What steps will reproduce the problem?

  1. Use a language server implemented with LSP Protocol 4.16, such as pygls;
  2. Initialize the server so spyder can request serve capabilities.

Traceback

  File "c:\users\hendr\anaconda3\envs\ciermag-develop\lib\site-packages\spyder\plugins\editor\plugin.py", line 318, in register_completion_capabilities
    editorstack.register_completion_capabilities(
  File "c:\users\hendr\anaconda3\envs\ciermag-develop\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 1845, in register_completion_capabilities
    editor.register_completion_capabilities(capabilities)
  File "c:\users\hendr\anaconda3\envs\ciermag-develop\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1176, in register_completion_capabilities
    self.save_include_text = sync_options['save']['includeText']
TypeError: 'bool' object is not subscriptable

Versions

Dependencies


# Mandatory:
atomicwrites >=1.2.0            :  1.4.0 (OK)
chardet >=2.0.0                 :  4.0.0 (OK)
cloudpickle >=0.5.0             :  1.6.0 (OK)
diff_match_patch >=20181111     :  20200713 (OK)
intervaltree >=3.0.2            :  3.1.0 (OK)
IPython >=7.6.0                 :  7.19.0 (OK)
jedi =0.17.2                    :  0.17.2 (OK)
jsonschema >=3.2.0              :  3.2.0 (OK)
keyring >=17.0.0                :  21.8.0 (OK)
nbconvert >=4.0                 :  6.0.7 (OK)
numpydoc >=0.6.0                :  1.1.0 (OK)
paramiko >=2.4.0                :  2.7.2 (OK)
parso =0.7.0                    :  0.7.0 (OK)
pexpect >=4.4.0                 :  4.8.0 (OK)
pickleshare >=0.4               :  0.7.5 (OK)
psutil >=5.3                    :  5.8.0 (OK)
pygments >=2.0                  :  2.7.4 (OK)
pylint >=1.0                    :  2.6.0 (OK)
pyls >=0.36.2;<1.0.0            :  0.36.2 (OK)
pyls_black >=0.4.6              :  0.4.6 (OK)
pyls_spyder >=0.3.2             :  0.3.2 (OK)
qdarkstyle >=2.8;<3.0           :  2.8.1 (OK)
qtawesome >=0.5.7               :  1.0.2 (OK)
qtconsole >=5.0.3               :  5.0.3 (OK)
qtpy >=1.5.0                    :  1.9.0 (OK)
rtree >=0.8.3                   :  0.9.7 (OK)
setuptools >=39.0.0             :  51.3.3.post20210118 (OK)
sphinx >=0.6.6                  :  3.4.3 (OK)
spyder_kernels >=1.10.2;<1.11.0 :  1.10.2 (OK)
textdistance >=4.2.0            :  4.2.0 (OK)
three_merge >=0.1.1             :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0        :  1.0.2 (OK)
zmq >=17                        :  21.0.1 (OK)

# Optional:
cython >=0.21                   :  None (NOK)
matplotlib >=2.0.0              :  3.3.3 (OK)
numpy >=1.7                     :  1.19.5 (OK)
pandas >=1.1.1                  :  1.2.1 (OK)
scipy >=0.17.0                  :  1.6.0 (OK)
sympy >=0.7.3                   :  1.7.1 (OK)

# Spyder plugins:
spyder_f_language               :  1.3.dev (OK)
steff456 commented 3 years ago

Hi @hlouzanda,

This will be a great addition for the PyLS, we can add this once Spyder 5 is out.

@andfoy can you please take a look at this one?