Skip to content

[LFX] KPM & LSP Integrated #1847

@He1pa

Description

@He1pa
Contributor

Enhancement

Sometimes users will edit the kcl.mod file in the IDE to update project dependencies. The integration between LSP and KPM needs to be strengthened

  1. When users update kcl.mod in the IDE, the required dependencies are automatically downloaded
  2. When users use the kpm tool to update dependencies, the IDE can be updated (recompiled). For example
import k8s  # Error: Module not found

use kcl mod add k8s

kpm will download the k8s package and then the IDE errors will be eliminated

Pretest:
Research the implementation of similar features in other languages ​​(rust's cargo watch is recommended, but any other language is fine), provide research reports and design solutions (optional).
Any form of report is acceptable, but don't submit to this repository, use Google Doc or your own public repository

Activity

Siddhi-agg

Siddhi-agg commented on Feb 3, 2025

@Siddhi-agg
Contributor

Hi @He1pa !
I would like to contribute to this. From the description, I have determined the following objectives for the project:

  1. Automatic Dependency Download on kcl.mod Update: When a user edits the kcl.mod file in an IDE (e.g., adding a new package like k8s), the required dependencies should be automatically downloaded, eliminating manual intervention.
  2. IDE Update After KPM Command Execution: If a user manually uses kcl mod add to add a dependency, the IDE should recognize this change and update its state (e.g., resolving "Module not found" errors) without requiring a full rebuild or restart.

To have these features in the project, we can try the following approach:

  1. Implement file-watching logic using the LSP server
  2. Develop a logic which triggers the kpm commands to install the new dependencies when a change in the kcl.mod file is detected.
  3. Add logic to verify the download status and provide log of errors or warnings (if any) in the terminal.

This way, the change in the 'kcl.mod' will be detected in both the cases (on updating the file or on using kcl mod add) and the file watching would trigger the download of the newly added dependencies. If there are any problems in resolving the new dependencies, we can also add some diagnostic features along with the logs to help solve the problems in downloading.

added this to the v1.0 Release milestone on Feb 6, 2025
literalEval

literalEval commented on Feb 12, 2025

@literalEval

Hi @He1pa

I have worked with language servers (Dart and Js) during my GSoC project and find myself comfortable working with the protocols. So, I would love to contribute to this project.

Can you please mention the pretest for this ?

He1pa

He1pa commented on Feb 12, 2025

@He1pa
ContributorAuthor

@Gmin2 @Siddhi-agg @literalEval I have updated the pretest

literalEval

literalEval commented on Feb 12, 2025

@literalEval

@He1pa thanks.

I have prepared a report for Dart/Flutter since that's what I'm familiar with. Researching on Rust/Cargo ecosystem as it is preferred for the pretest.

He1pa

He1pa commented on Feb 14, 2025

@He1pa
ContributorAuthor

@literalEval Dart/Futter is also fine. The reason for choosing rust/cargo is that other modules refer to their design and we are more familiar with it

literalEval

literalEval commented on Feb 19, 2025

@literalEval

@He1pa somehow forgot to submit the report and my application on time. The applications seem to be closed now. Will be on time in the next session.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @He1pa@literalEval@zong-zhe@Siddhi-agg

        Issue actions

          [LFX] KPM & LSP Integrated · Issue #1847 · kcl-lang/kcl