Skip to content

How to correctly use WidgetLSPAdapter to enable code completion in the code editor of custom extension #1109

Open
@boogie-ben

Description

@boogie-ben

I have written a custom extension which supports files with the .cpw suffix. After opening a .cpw file, there will be 0 to N code editors (created by newInlineEditor of the CodeMirrorEditorFactory instance).

I expect to get the code completion feature in these code editors.

I wrote a CPWAdapter by imitating NotebookAdapter and FileEditorAdapter. It can successfully start the LSP connection and communicate for .cpw files, but I haven't found the correct implementation to enable the code completion feature for the code editors. I'm asking for help.

I have created a minimum reproducible code repository. Please evaluate my code and let me know if there are any problems with my implementation process.

minimum reproducible

Current progress:

  1. In the activate function in index.ts, I use WidgetTracker and new CPWAdapter in widgetAdded.
  2. In CPWWidget, code editors are created in the content area. (In the actual business process, code editors are generated dynamically and there may be 0 or more of them.)
  3. After a certain code editor gets focused, it is designated as the activeEditor.
  4. In CPWAdapter, when the activeEditor is switched or its content changes, the VirtualDocument is updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions