ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Settings cannot be applied per folder

Open ldeveber opened this issue 1 year ago • 6 comments

Operating System

MacOS Sonoma

Ruby version

3.2

Project has a bundle

  • [ ] Has bundle

Ruby version manager being used

asdf

Description

Every time I open/reload VS Code, I get a bunch of warnings that our project is not set up correctly. We are using a monorepo setup with a ruby api and a nextjs web app.

my_project/
  client-web/   <-- nextjs app
  server-api/   <-- ruby app

Screenshot 2024-01-08 at 2 57 26 PM

Screenshot 2024-01-08 at 2 52 48 PM Screenshot 2024-01-08 at 2 52 56 PM

ldeveber avatar Jan 08 '24 20:01 ldeveber

Thank you for the bug report! Did you already configure your multi-root workspace? And does the issue persist on v0.5.5?

vinistock avatar Jan 15 '24 18:01 vinistock

Thank you for the bug report! Did you already configure your multi-root workspace? And does the issue persist on v0.5.5?

Sorry for the delay! Yes, we have the multi-root workspace configured already. Other extensions seem to work fine? And its still happening in 0.5.8 :(

ldeveber avatar Jan 24 '24 19:01 ldeveber

Can you share the contents of your .code-workspace please.

andyw8 avatar Jan 24 '24 22:01 andyw8

Sorry for the delay.

You can still configure settings per root folder and the Settings editor will present a third setting scope called Folder Settings: https://code.visualstudio.com/docs/editor/workspaces#_multiroot-workspace-settings

Following this example .vscode/project.code-workspace:

{
  "folders": [
    {
      "path": "../server-api"
    },
    {
      "path": "../client-web"
    },
    {
      "path": ".."
    }
  ],
  "settings": {
    // @see https://code.visualstudio.com/docs/getstarted/settings#_default-settings
    // @see https://code.visualstudio.com/docs/getstarted/settings#_workspace-settings/
    "editor.tabSize": 2,
    "editor.insertSpaces": true,
    "jest.disabledWorkspaceFolders": ["project", "server-api"],
    "[jsonc]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[markdown]": {
      "editor.formatOnSave": true,
      "editor.defaultFormatter": "yzhang.markdown-all-in-one"
    },
    "[html]": {
      "editor.defaultFormatter": "vscode.html-language-features"
    },
    // vvv THIS SHOULD BE IN server-api !!! vvv //
    "[ruby]": {
      "editor.formatOnSave": true,
      "editor.semanticHighlighting.enabled": true,
      "editor.defaultFormatter": "Shopify.ruby-lsp"
    },
    "rubyLsp.yjit": true,
    "rubyLsp.formatter": "rubocop",
    "rubyLsp.rubyVersionManager": "asdf",
    // ^^^ THIS SHOULD BE IN server-api !!! ^^^ //

    "files.associations": {
      ".env.*": "properties"
    },
    "typescript.tsdk": "client-web/node_modules/typescript/lib",
    // if these formattings get annoying we can move them to specific language settings:
    // @see https://stackoverflow.com/a/16224292/56713
    "files.insertFinalNewline": true,
    "files.trimTrailingWhitespace": true,
    "files.trimFinalNewlines": true,

    // @see https://github.com/relayjs/relay-examples/blob/main/.vscode/settings.json
    "relay.projects": [
      {
        "name": "client-web",
        "rootDirectory": "./client-web"
      }
    ]
  }
}

server-api/.vscode/settings.json:

{
  // TODO FIXME: ruby LSP settings go here
  "prettier.enable": false,
  "jest.enable": false,
  "eslint.enable": false,
}

ldeveber avatar Feb 22 '24 15:02 ldeveber

Your configuration looks fine to be honest. This might be a silly question, but did you open the configured workspace in VS Code (as opposed to just opening the directory)?

When you open the project.code-workspace file, there should be a button in the bottom right corner offering to open that workspace in VS Code.

vinistock avatar Feb 28 '24 17:02 vinistock

Your configuration looks fine to be honest. This might be a silly question, but did you open the configured workspace in VS Code (as opposed to just opening the directory)?

When you open the project.code-workspace file, there should be a button in the bottom right corner offering to open that workspace in VS Code.

I did open it that way, yeah. I found that if I opened the server-api directly and copied the ruby settings in the workspace file to server-api/.vscode/settings.json that the whole project works MUCH better. But it's a monorepo....so I need all the other folders too, so that defeats the purpose of having the workspace :/

Being able to jump into source code does NOT work from the workspace, but it does with the individual folder

ldeveber avatar Mar 29 '24 16:03 ldeveber