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

Newline indentation does not follow my tab size setting (in a svelte file) #6861

Open
1 task done
thelegendtubaguy opened this issue Jan 27, 2024 · 5 comments
Open
1 task done
Labels
bug [core label] language An umbrella label for all programming languages syntax behaviors setting Feedback for preferences, configuration, etc svelte Svelte framework support

Comments

@thelegendtubaguy
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

In a .svelte file with a typescript script block, Zed doesn't appear to be respecting my tab size setting. I have tab_size set at the root of my settings.json to 4.

Environment

Zed: v0.119.20 (Zed)
OS: macOS 13.6.1
Memory: 32 GiB
Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

In these two screenshots, I have a basic if block. I've hit enter to go to the first line inside the block and hit tab 1 time. Zed seems to indent 2 spaces instead of my setting of 4.
Screenshot 2024-01-27 at 7 30 01 AM
This is what it looks like if I hit enter and hit space 4 times:
Screenshot 2024-01-27 at 7 30 12 AM

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

@JosephTLyons JosephTLyons added language An umbrella label for all programming languages syntax behaviors setting Feedback for preferences, configuration, etc svelte Svelte framework support and removed triage labels Jan 29, 2024
@reandov
Copy link

reandov commented Mar 13, 2024

I'm also having this problem, really strange

@lthoerner
Copy link

lthoerner commented Sep 2, 2024

This is still a bug, but here is a workaround for now. Use .prettierrc to set "tabWidth": 4, or "useTabs": true, depending on whether you want to use tabs or spaces. Then manually set "tab_width": 4 in Zed's settings.json. This issue seems to arise from a conflict with Prettier's formatting.

@matubu
Copy link
Contributor

matubu commented Sep 3, 2024

It is possible to change this option inside of the svelte extension code by adding this inside the zed::Extension implementation

    fn language_server_workspace_configuration(
        &mut self,
        _language_server_id: &zed_extension_api::LanguageServerId,
        _worktree: &zed_extension_api::Worktree,
    ) -> Result<Option<serde_json::Value>> {
        Ok(Some(serde_json::json!({
            "prettier": {
                "useTabs": true,
                "tabWidth": 4,
            }
        })))
    }

But it seems like extensions can't currently access user preference for formatting options. I think it's something the extensions should have access to.

@bdkjones
Copy link

I have the same issue editing PHP files. The first tab is always 2 spaces, then subsequent tabs are 4. So I have to hit tab, tab, and then backspace twice to get my desired indentation.

I've already tried setting "tab_width" in my settings and I'm set to use spaces instead of tabs. Zed is unusable until this is fixed.

@shirshak55
Copy link

shirshak55 commented Sep 29, 2024

image

I am also facing similar issue. I think formatting isn't polished yet.

The intention line should be 4 space. I have set it up in prettierrc file also. Also, it would be nice to see if there are no logs of prettier, as some prettier settings aren't being applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] language An umbrella label for all programming languages syntax behaviors setting Feedback for preferences, configuration, etc svelte Svelte framework support
Projects
None yet
Development

No branches or pull requests

7 participants