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

Tab width from EditorConfig #840

Open
ffes opened this issue Jun 13, 2018 · 0 comments · May be fixed by #1239
Open

Tab width from EditorConfig #840

ffes opened this issue Jun 13, 2018 · 0 comments · May be fixed by #1239

Comments

@ffes
Copy link
Contributor

ffes commented Jun 13, 2018

I know I can add a line in .git/config or in ~/.tigrc to set the tab-size to (in most of my cases) 4 spaces.

In a perfect world tig would look in the repo for an EditorConfig file .editorconfig and take the indent_size from that for the current file.

They provide a C library https://github.com/editorconfig/editorconfig-core-c

krobelus added a commit to krobelus/tig that referenced this issue Oct 15, 2022
For projects that use tab width of 8, we need to set the "tab-size"
config option.  Many projects these days state their preference in a
".editorconfig" file.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that, so
I'd wait until someone complains. If we want that we could implement a
"tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
@krobelus krobelus linked a pull request Oct 15, 2022 that will close this issue
krobelus added a commit to krobelus/tig that referenced this issue Oct 15, 2022
For projects that use tab width != 8, we need to set the "tab-size"
config option.  Many projects these days state their preference in a
".editorconfig" file.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that, so
I'd wait until someone complains. If we want that we could implement a
"tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
krobelus added a commit to krobelus/tig that referenced this issue Oct 15, 2022
For projects that use tab width != 8, we need to set the "tab-size"
config option.  Many projects these days state their preference in a
".editorconfig" file. GitHub honors that file when rendering diffs
and blobs.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that, so
I'd wait until someone complains. If we want that we could implement a
"tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
krobelus added a commit to krobelus/tig that referenced this issue Oct 16, 2022
For projects that use tab width != 8, we need to set the "tab-size"
config option.  Many projects these days state their preference in a
".editorconfig" file. GitHub honors that file when rendering diffs
and blobs.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that, so
I'd wait until someone complains. If we want that we could implement a
"tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
krobelus added a commit to krobelus/tig that referenced this issue Oct 20, 2022
For projects that use tab width != 8, we need to set the "tab-size"
config option.  Many projects these days state their preference in a
".editorconfig" file. GitHub honors that file when rendering diffs
and blobs.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that, so
I'd wait until someone complains. If we want that we could implement a
"tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
krobelus added a commit to krobelus/tig that referenced this issue Jan 6, 2023
For projects that use tab width != 8, users want to set the "tab-size"
config option.  Many projects these days already state their preference
in a ".editorconfig" file. GitHub honors that file when rendering
diffs and blobs.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that,
so I'd mayb ewait until someone complains. If we want that we could
implement a "tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
krobelus added a commit to krobelus/tig that referenced this issue Mar 5, 2023
For projects that use tab width != 8, users want to set the "tab-size"
config option.  Many projects these days already state their preference
in a ".editorconfig" file. GitHub honors that file when rendering
diffs and blobs.

Add an optional dependency to the EditorConfig library to read such
files. Prefer the tab-size from EditorConfig, over the "tab-size"
config option. Not being able to override the EditorConfig tab-size
seems counterintuitive but I don't see why someone would want that,
so I'd mayb ewait until someone complains. If we want that we could
implement a "tab-size-from-editorconfig" option that defaults to true.

Implementation hiccups:

Unfortunately, we currently don't always fill "repo.worktree" - only
in the special cases where either of $GIT_WORK_TREE or core.worktree is
defined. Hence we need to run an extra "git rev-parse --show-toplevel".
We do run "git rev-parse --is-inside-worktree [...]" elsewhere but
we can't add "--show-toplevel" to that call or else we'd fail when
run in bare repos.

The use of diff_get_pathname() is a bit wasteful, we should probably
refactor this to just remember the last line of type LINE_DIFF_ADD_FILE
or LINE_DIFF_HEADER.

Closes jonas#840
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

Successfully merging a pull request may close this issue.

1 participant