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

Update automatically settings.json with ansys-mechanical-autocomplete #932

Open
klmcadams opened this issue Oct 7, 2024 · 0 comments
Open
Assignees
Labels
enhancement New features or code improvements

Comments

@klmcadams
Copy link
Collaborator

📝 Description of the feature

Find the user or workspace settings.json folder, read settings.json, and append the stubs autocomplete settings to it

💡 Steps for implementing the feature

For updating the user settings.json:

@click.option(
    "--settings_location",
    default="user",
    type=str,
    help="Whether to update the settings.json file on the workspace or user level.",
)

if settings_location == "user":
    if "win" in sys.platform:
            settings_json = Path(os.environ.get("APPDATA")) / "Code" / "User" / "settings.json"
    elif "lin" in sys.platform:
        settings_json = (
            Path(os.environ.get("HOME")) / ".config" / "Code" / "User" / "settings.json"
        )

    ### settings_json_data code 

    # Combine the existing JSON with the autocomplete paths
    combined_dict = {**data, **settings_json_data}

    # Write the updated data back to the file
    with open(settings_json, "w") as file:
        json.dump(combined_dict, file, indent=4)

Unsure how to update workspace settings.json

  • Look for root pymechanical folder and search for .vscode/settings.json
  • Or, use javascript and the VSCode API to retrieve the workspace folder(s) - command line input may require the user to include the name of the workspace folder they want to update the settings in if there are multiple

🔗 Useful links and references

Find the location of settings.json for workspace folder

VSCode API workspace folder

json5 - allows trailing commas

@klmcadams klmcadams added the enhancement New features or code improvements label Oct 7, 2024
@klmcadams klmcadams self-assigned this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

No branches or pull requests

1 participant