runtime(typescript): remove Fixedgq() function from indent script Commit: https://github.com/vim/vim/commit/eb59129d2c06fd6627f537fce4fb8660cc8d0cda Author: Phạm Bình An <phambinhanctb2...@gmail.com> Date: Thu Jun 5 21:21:35 2025 +0200
runtime(typescript): remove Fixedgq() function from indent script Problem: 1. The `Fixedgq()` function is broken (see https://github.com/vim/vim/issues/17412) 2. The `'formatexpr'` for Typescript is not documented, which causes confusion to users when they try to set `'formatprg'`, since `'formatexpr'` always takes precedence over `'formatprg'`. See also https://github.com/HerringtonDarkholme/yats.vim/issues/209 3. Typescript already has a very good and popular formatter called `prettier`, that can be easily integrated to Vim via `'formatprg'` (see #16989). I don't think there are any good reasons to reinvent a half-baked version in Vim. Solution: Remove the Fixedgq() 'formatexpr' function. fixes: #17412 closes: #17452 Signed-off-by: Phạm Bình An <phambinhanctb2...@gmail.com> Signed-off-by: Doug Kearns <dougkea...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/indent/typescript.vim b/runtime/indent/typescript.vim index e26750b8a..7eaa9b464 100644 --- a/runtime/indent/typescript.vim +++ b/runtime/indent/typescript.vim @@ -3,6 +3,7 @@ " Maintainer: See https://github.com/HerringtonDarkholme/yats.vim " Last Change: 2019 Oct 18 " 2023 Aug 28 by Vim Project (undo_indent) +" 2025 Jun 05 by Vim Project (remove Fixedgq() formatexp, #17452) " Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org " 0. Initialization {{{1 @@ -18,10 +19,9 @@ setlocal nosmartindent " Now, set up our indentation expression and keys that trigger it. setlocal indentexpr=GetTypescriptIndent() -setlocal formatexpr=Fixedgq(v:lnum,v:count) setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e -let b:undo_indent = "setlocal formatexpr< indentexpr< indentkeys< smartindent<" +let b:undo_indent = "setlocal indentexpr< indentkeys< smartindent<" " Only define the function once. if exists("*GetTypescriptIndent") @@ -443,64 +443,3 @@ endfunction let &cpo = s:cpo_save unlet s:cpo_save - -function! Fixedgq(lnum, count) - let l:tw = &tw ? &tw : 80 - - let l:count = a:count - let l:first_char = indent(a:lnum) + 1 - - if mode() == 'i' " gq was not pressed, but tw was set - return 1 - endif - - " This gq is only meant to do code with strings, not comments - if s:IsLineComment(a:lnum, l:first_char) || s:IsInMultilineComment(a:lnum, l:first_char) - return 1 - endif - - if len(getline(a:lnum)) < l:tw && l:count == 1 " No need for gq - return 1 - endif - - " Put all the lines on one line and do normal splitting after that - if l:count > 1 - while l:count > 1 - let l:count -= 1 - normal J - endwhile - endif - - let l:winview = winsaveview() - - call cursor(a:lnum, l:tw + 1) - let orig_breakpoint = searchpairpos(' ', '', '\.', 'bcW', '', a:lnum) - call cursor(a:lnum, l:tw + 1) - let breakpoint = searchpairpos(' ', '', '\.', 'bcW', s:skip_expr, a:lnum) - - " No need for special treatment, normal gq handles edgecases better - if breakpoint[1] == orig_breakpoint[1] - call winrestview(l:winview) - return 1 - endif - - " Try breaking after string - if breakpoint[1] <= indent(a:lnum) - call cursor(a:lnum, l:tw + 1) - let breakpoint = searchpairpos('\.', '', ' ', 'cW', s:skip_expr, a:lnum) - endif - - - if breakpoint[1] != 0 - call feedkeys("r\<CR>") - else - let l:count = l:count - 1 - endif - - " run gq on new lines - if l:count == 1 - call feedkeys("gqq") - endif - - return 0 -endfunction -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1uNGHs-0022GV-MU%40256bit.org.