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

Support for different js-mode offset variables #63

Open
notetiene opened this issue May 18, 2022 · 5 comments
Open

Support for different js-mode offset variables #63

notetiene opened this issue May 18, 2022 · 5 comments

Comments

@notetiene
Copy link

notetiene commented May 18, 2022

Since js-mode has different offset variables, I was wondering if we could support those also.

Currently, if I use this file:

function test(arg) {
    switch(arg) {
      case 'foo':
          return 'bar'
      default:
          return 'baz'
    }
}

the guessed indentation is 2.

The problem is that js-switch-indent-offset was set to 2.

@rrthomas
Copy link
Collaborator

Sure, we can support multiple variables (see the sgml-mode settings for an example). Feel free to submit a patch.

@notetiene
Copy link
Author

Sorry, I'm not sure where to look for that. Do you mean web-mode offsets? The example I showed used an js-indent-level of 4 while having js-switch-indent-offset of 2.

@rrthomas
Copy link
Collaborator

Sorry, I mean web-mode, yes. You can set multiple variables to the same value. Is that not enough for you?

@notetiene
Copy link
Author

notetiene commented May 18, 2022

You can set multiple variables to the same value.

That makes sense. I was wondering if dtrt-indent could support multiple indentation values to multiple variables or at least guess the main indentation (js-indent-level) by excluding some contexts (like the switch block). That's currently not the case.

In order to do so, we would have to implement some parsing mechanism.

The issue isn't just related to js-mode (or derived modes), but also to web-mode and even c-mode as well. I'm not sure if you're open for language specific parser to fix heuristics.

@rrthomas
Copy link
Collaborator

This sort of guessing seems to me better left to more specialised modes like smie-mode with smie-config-guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants