orzechowskid / tsi.el

treesitter-based indendentation for emacs 28 and 27
GNU General Public License v3.0
47 stars 5 forks source link

Indent region uses standard-indent instead of tsi-typescript-indent-offset #40

Open ColemanGariety opened 2 years ago

ColemanGariety commented 2 years ago

Hello and thank you for work on this excellent package. It is the only viable solution for TSX in Emacs. And it works almost perfectly, except for a small problem.

Steps to reproduce

Start with some unindented typescript code like this:

const foo = {
a: {
b: 'foo'
},
c: 'bar'
}

Highlight this code and call indent-for-tab-command. Notice that it indents with an offset of 4:

const foo = {
    a: {
        b: 'foo'
    },
    c: 'bar'
}

Now place your cursor one line at a time, calling indent-for-tab-command on each line. Notice that it indents with an offset of 2:

const foo = {
  a: {
    b: 'foo'
  },
  c: 'bar'
}
ColemanGariety commented 2 years ago

I solved this by adding (setq standard-indent 2) to my emacs config.

EDIT: Reopened because it appears to be a design flaw that standard-indent is used only for regional indents.