scalameta / metals-vscode

Visual Studio Code extension for Metals
https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview
Apache License 2.0
301 stars 76 forks source link

Metals uses ~/.metals unconditionally; Conflicts with .metals detection for shell prompt scripts #1143

Closed Dessix closed 1 year ago

Dessix commented 2 years ago

Describe the bug

Starship and Oh-My-Zsh provide Scala support, and detecting a .metals directory causes it to assume that the user is in a Scala project.

Using the VSCode extension immediately creates this in the user's $HOME directory, which results in invocation of the Scala toolchain upon detection, for every command.

While this is desirable within a Metals workspace, this is both a performance and functionality hit for such shell script users.

To Reproduce Steps to reproduce the behavior:

  1. Install Metals-VSCode
  2. Generate a Scala project, e.g. sbt new scala/scala3.g8
  3. Open a .scala source file with VSCode
  4. Observe a .metals dotfile directory being created to hold versions-meta.json at $HOME/.metals.

Expected behavior

XDG standards are preferable where possible. As versions-meta.json appears to be a configuration file, it should go in an XDG Configuration directory for Metals.

A rough implementation would look like this:

This would comply with XDG's spec, reduce home-directory pollution, and ensure proper functionality of the various popular zsh, bash, and fish prompts.

Currently, this is handled in src/util.ts, wherein the only path searched is os.homedir.

Alternatively, using VSCode's mechanism for configuration storage may be sufficient for viability, though this relies on the .metals directory not being consumed by anything but the VSCode extension, which may not be an assumption that can be safely taken.

Installation:

Additional context

Starship Scala Configuration

Search terms

Home Directory, Dotfiles .metals XDG_HOME XDG_DATA

tanishiking commented 2 years ago

Thank you for reporting! I was working on the issue here https://github.com/scalameta/metals-vscode/pull/1076 I'll finish up

Dessix commented 2 years ago

Fantastic- thank you @tanishiking :)

tgodzik commented 1 year ago

The PR from @tanishiking is merged :1st_place_medal: