Skip to content

fix(indent): fix several indentation issues, conform to released version - #302

Merged
HerringtonDarkholme merged 13 commits into
HerringtonDarkholme:masterfrom
ronen:indent
Sep 10, 2026
Merged

HerringtonDarkholme merged 13 commits into
HerringtonDarkholme:masterfrom
ronen:indent

Conversation

@ronen

@ronen ronen commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

Hi,

This PR updates indent/typescript.vim with fixes for #271 and a handful of other indentation problems that have been nagging me. I added test cases for them in test/indent.vader

I started with the version released in the latest /Applications/MacVim.app/Contents/Resources/vim/runtime/indent/typescript.vim, but coming to this repo I saw that the version here had a few differences:

  • The local indent/typescript.vim uses some yats# helpers instead of including them inline
  • The definitions of regex's s:continuation_regex, s:ternary, and s:ternary_q differ
  • The released version includes change log comments that aren't in the local version

Since my version is based on the release, this PR conforms indent/typescript.vim to the release, plus adds the fixes. I hope that's OK!

PS. I came to this with little knowledge of vim scripting nor how vim indent scripts work; had AI do the coding for me 🙄

ronen added 11 commits January 18, 2026 08:52
Test cases for:
* Leading pipes and ampersands in type union/inersections
* Functions in object types
* Function type with object paramer
* Switch statement (issue HerringtonDarkholme#271)
The current release of [`indent/typescript.vim](https://github.com/vim/vim/blob/v9.1.2090/runtime/indent/typescript.vim) in the github.com/vim/vim repo includes some changes not in this repo.

This version of `indent/typescript.vim` in this commit:
* Is based on the release version
* Fixes the test cases in the previous commit
test cases for single-line if, without a trailing semicolon.
fixes the test case in the previous commit
* make sure indentation doesn't waterfall in function type with object parameter
* arrow function with multi-line args
multiline generic types should indent
    added comments #------------------ between each test case to make it easier to visually parse the file
fixes the test of the previous commit

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes several TypeScript indentation issues and conforms the local indent/typescript.vim to match the version released in Vim 9.1.2090. The PR replaces external yats# helper functions with inline implementations and adds comprehensive test coverage for the fixed indentation scenarios.

Changes:

  • Added indentation fixes for TypeScript union/intersection types with leading pipes and ampersands
  • Fixed indentation for switch/case statements, one-line if statements, arrow functions with multi-line arguments, and multiline generic types
  • Replaced yats# helper function calls with local s: implementations to align with the released Vim version
  • Added comprehensive test cases covering all the fixed indentation scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
test/indent.vader Added 8 new test cases covering union types, object types with functions, function types with object parameters, switch statements, one-line if statements, arrow functions, and multiline generics
indent/typescript.vim Synced with Vim 9.1.2090 release; replaced yats# helpers with local implementations; added new regex patterns and helper functions for TypeScript-specific features; implemented fixes for switch/case, one-line scope, union/intersection types, and generic type indentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread indent/typescript.vim
if getline(a:lnum) =~ '^\s*[])}]\s*\%([;,:]\s*\)\=$'
return a:ind
endif

Copilot AI Jan 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace found. This line should not end with whitespace.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment thread indent/typescript.vim
if msl_txt =~ s:obj_prop_line && msl_txt =~ s:comma_last
return msl_ind
endif

Copilot AI Jan 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace found. This line should not end with whitespace.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment thread indent/typescript.vim Resolved
Comment thread indent/typescript.vim Resolved
Comment thread indent/typescript.vim Resolved
Comment thread indent/typescript.vim Resolved
HerringtonDarkholme and others added 2 commits January 18, 2026 17:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@HerringtonDarkholme
HerringtonDarkholme merged commit d1a00ce into HerringtonDarkholme:master Sep 10, 2026
2 checks passed
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 this pull request may close these issues.

3 participants