Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide API to add a new language to the LSP service #11326

Open
10 tasks done
hlouzada opened this issue Jan 15, 2020 · 6 comments
Open
10 tasks done

Provide API to add a new language to the LSP service #11326

hlouzada opened this issue Jan 15, 2020 · 6 comments

Comments

@hlouzada
Copy link
Contributor

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

I am trying to add a new language support in Spyder to connect via LSP in a user plugin. My plugin should modify the dictionary and lists containing the languages and show them in the setup a new server options on the LSP server editor preferences panel. If reseted preferences with spyder --reset it will work until Spyder is restarted

What steps reproduce the problem?

fIDE.zip

  1. Install the extension
  2. Open Spyder
  3. Open preferences: setup a new server in LSP server editor; command file to lunch the server is located in plugin_install_location/fIDE/spyder_fIDE/server/bin/br.ifsc.ciermag.flang.ide; the port is 5008; host is set to 127.0.0.1
  4. Close Spyder
  5. Open preferences

What is the expected output? What do you see instead?

It is expected that the spyder automatically lunches and connects to the F language server, but nothing happens and when the preferences is opend there is an error.

Paste Traceback/Error Below (if applicable)

Traceback (most recent call last):
File "/home/hendrik/anaconda3/envs/fIDE/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 3128, in show_preferences
widget = completion_plugin._create_configwidget(dlg, self)
File "/home/hendrik/anaconda3/envs/fIDE/lib/python3.7/site-packages/spyder/plugins/base.py", line 117, in _create_configwidget
configwidget.initialize()
File "/home/hendrik/anaconda3/envs/fIDE/lib/python3.7/site-packages/spyder/preferences/configdialog.py", line 71, in initialize
self.setup_page()
File "/home/hendrik/anaconda3/envs/fIDE/lib/python3.7/site-packages/spyder/plugins/completion/languageserver/confpage.py", line 1115, in setup_page
self.table = LSPServerTable(self, text_color=ima.MAIN_FG_COLOR)
File "/home/hendrik/anaconda3/envs/fIDE/lib/python3.7/site-packages/spyder/plugins/completion/languageserver/confpage.py", line 589, in init
self.load_servers()
File "/home/hendrik/anaconda3/envs/fIDE/lib/python3.7/site-packages/spyder/plugins/completion/languageserver/confpage.py", line 624, in load_servers
server.language = LSP_LANGUAGE_NAME[server.language.lower()]
KeyError: 'f'

Versions

  • Spyder version: 4.0.1
  • Python version: 3.7.5
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: Linux 5.0.0-38-generic

Dependencies

atomicwrites >=1.2.0 : 1.3.0 (OK)
chardet >=2.0.0 : 3.0.4 (OK)
cloudpickle >=0.5.0 : 1.2.2 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.11.1 (OK)
jedi =0.14.1 : 0.14.1 (OK)
keyring : None (OK)
nbconvert >=4.0 : 5.6.1 (OK)
numpydoc >=0.6.0 : 0.9.2 (OK)
pexpect >=4.4.0 : 4.7.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=0.3 : 5.6.7 (OK)
pygments >=2.0 : 2.5.2 (OK)
pylint >=0.25 : 2.4.4 (OK)
pyls >=0.31.2;<0.32.0 : 0.31.2 (OK)
xdg >=0.26 : 0.26 (OK)
zmq >=17 : 18.1.0 (OK)
qdarkstyle >=2.7 : 2.7 (OK)
qtawesome >=0.5.7 : 0.6.0 (OK)
qtconsole >=4.6.0 : 4.6.0 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.8.3 (OK)
sphinx >=0.6.6 : 2.3.1 (OK)
spyder_kernels >=1.8.1;<2.0.0: 1.8.1 (OK)
watchdog : None (OK)
cython >=0.21 : None (NOK)
matplotlib >=2.0.0 : None (NOK)
numpy >=1.7 : None (NOK)
pandas >=0.13.1 : None (NOK)
scipy >=0.17.0 : None (NOK)
sympy >=0.7.3 : None (NOK)

@ccordoba12
Copy link
Member

There's no entry for the F language server here:

Selección_087

so that's probably why you're having the error above.

So I think you need to add it in a PR for your plugin to work. The available LSP languages are available here:

https://github.com/spyder-ide/spyder/blob/68d75e00e95b95a3e1ef5a3136f0778ad3867fb5/spyder/plugins/completion/languageserver/__init__.py#L21_L26

@dpizetta
Copy link
Contributor

Hi @ccordoba12, yes, as you pointed that is the problem, but instead of adding that language to the Spyder main project, may Spyder can provide a function to add new languages as plugins using LSP, so when the plugin is installed, Spyder adds the new language configuration needed without hard-coded changes.

@ccordoba12 ccordoba12 changed the title Adding a new language to Spyder using LSP Provide API to add a new language to the LSP service Jan 16, 2020
@ccordoba12 ccordoba12 added this to the v4.1.0 milestone Jan 16, 2020
@ccordoba12
Copy link
Member

I agree: we should provide an API for external plugins to register a new LSP language along with its configuration. @andfoy, please take a look at that.

However, for that @jogufe would have to wait a couple of months because right now we're busy fixing some important bugs. So it's his call.

@hlouzada
Copy link
Contributor Author

Thank you for your reply. I will stick with modifying the code until the API is provided.

@dalthviz
Copy link
Member

Hi there, as part of the Improving external completion plugins development support in Spyder NumFOCUS Small Development Grant and the interest shown for AI code assistants integration with Spyder at #20632 (which checking seems like most of them rely on the LSP in some extend) some elements/ideas that could be important to take into account when creating/defining a public API to extend the LSP based functionality that has Spyder:

  • Make possible doing registration of custom/child LSPClient classes (custom class definition that inherits from LSPClient)
  • Make possible for a single server instance/config definition to handle multiple languages if required (depending on languages supported by the external service)
  • Maybe create a new category/language entry as another possible config value to cover the AI assistant language server case.
  • Enable programmatic registration of server configs (command to launch server, config options, etc)

And not completly related with the LSP support but related to its usage and the response handling from the Editor:

  • Need to support a new type of completions in the GUI/Editor/Completion widget. Usually the completions retrieved from Copilot and other AI based services use a ghost text format (similar to a snippet completion but without elements to fill-in and usually of a bigger size, for example a full class definition with multiple methods/functions and that is shown as a preview inside the file before actually selecting it to be part of the file contents in the form of faded text/content)

@ccordoba12 ccordoba12 modified the milestones: wishlist, v6.1.0 Feb 19, 2024
@ccordoba12
Copy link
Member

Thanks for the summary @dalthviz! I think we should start talking about this with @hlouzada after releasing Spyder 6 to make it a reality in 6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants