diff options
Diffstat (limited to '')
-rw-r--r-- | runtime/indent/Make_mvc.mak | 21 | ||||
-rw-r--r-- | runtime/indent/Makefile | 3 | ||||
-rw-r--r-- | runtime/indent/odin.vim | 119 | ||||
-rw-r--r-- | runtime/indent/qml.vim | 6 | ||||
-rw-r--r-- | runtime/indent/r.vim | 8 | ||||
-rw-r--r-- | runtime/indent/racket.vim | 4 | ||||
-rw-r--r-- | runtime/indent/rhelp.vim | 8 | ||||
-rw-r--r-- | runtime/indent/rmd.vim | 8 | ||||
-rw-r--r-- | runtime/indent/rnoweb.vim | 8 | ||||
-rw-r--r-- | runtime/indent/rrst.vim | 8 | ||||
-rw-r--r-- | runtime/indent/testdir/runtest.vim | 38 | ||||
-rw-r--r-- | runtime/indent/testdir/vim.in | 5 | ||||
-rw-r--r-- | runtime/indent/testdir/vim.ok | 5 | ||||
-rw-r--r-- | runtime/indent/yaml.vim | 7 |
14 files changed, 207 insertions, 41 deletions
diff --git a/runtime/indent/Make_mvc.mak b/runtime/indent/Make_mvc.mak new file mode 100644 index 0000000..0f73d7f --- /dev/null +++ b/runtime/indent/Make_mvc.mak @@ -0,0 +1,21 @@ +# Makefile for running indent tests on OS Windows. +# Made on the base of a indent/Makefile. +# Restorer, 13.03.2024 + +.SUFFIXES: + +VIM = vim.exe +VIMRUNTIME = .. + +# Run the tests that didn't run yet or failed previously. +# If a test succeeds a testdir\*.out file will be written. +# If a test fails a testdir\*.fail file will be written. +test : + @ set "VIMRUNTIME=$(VIMRUNTIME)" + $(VIM) --clean --not-a-term -u testdir\runtest.vim + + +clean testclean : + @ if exist testdir\*.fail del /q testdir\*.fail + @ if exist testdir\*.out del /q testdir\*.out + diff --git a/runtime/indent/Makefile b/runtime/indent/Makefile index f6c4473..66ded80 100644 --- a/runtime/indent/Makefile +++ b/runtime/indent/Makefile @@ -1,5 +1,8 @@ # Portable Makefile for running indent tests. +.SUFFIXES: +.PHONY: test clean testclean + VIM = vim VIMRUNTIME = .. diff --git a/runtime/indent/odin.vim b/runtime/indent/odin.vim new file mode 100644 index 0000000..e3318c4 --- /dev/null +++ b/runtime/indent/odin.vim @@ -0,0 +1,119 @@ +vim9script + +# Vim indent plugin file +# Language: Odin +# Maintainer: Maxim Kim <habamax@gmail.com> +# Website: https://github.com/habamax/vim-odin +# Last Change: 2024-01-15 + +if exists("b:did_indent") + finish +endif +b:did_indent = 1 + +b:undo_indent = 'setlocal cindent< cinoptions< cinkeys< indentexpr<' + +setlocal cindent +setlocal cinoptions=L0,m1,(s,j1,J1,l1,+0,:0,#1 +setlocal cinkeys=0{,0},0),0],!^F,:,o,O + +setlocal indentexpr=GetOdinIndent(v:lnum) + +def PrevLine(lnum: number): number + var plnum = lnum - 1 + var pline: string + while plnum > 1 + plnum = prevnonblank(plnum) + pline = getline(plnum) + # XXX: take into account nested multiline /* /* */ */ comments + if pline =~ '\*/\s*$' + while getline(plnum) !~ '/\*' && plnum > 1 + plnum -= 1 + endwhile + if getline(plnum) =~ '^\s*/\*' + plnum -= 1 + else + break + endif + elseif pline =~ '^\s*//' + plnum -= 1 + else + break + endif + endwhile + return plnum +enddef + +def GetOdinIndent(lnum: number): number + var plnum = PrevLine(lnum) + var pline = getline(plnum) + var pindent = indent(plnum) + # workaround of cindent "hang" + # if the previous line looks like: + # : #{} + # : #whatever{whateverelse} + # and variations where : # { } are in the string + # cindent(lnum) hangs + if pline =~ ':\s\+#.*{.*}' + return pindent + endif + + var indent = cindent(lnum) + var line = getline(lnum) + + if line =~ '^\s*#\k\+' + if pline =~ '[{:]\s*$' + indent = pindent + shiftwidth() + else + indent = pindent + endif + elseif pline =~ 'switch\s.*{\s*$' + indent = pindent + elseif pline =~ 'case\s*.*,\s*\(//.*\)\?$' # https://github.com/habamax/vim-odin/issues/8 + indent = pindent + matchstr(pline, 'case\s*')->strcharlen() + elseif line =~ '^\s*case\s\+.*,\s*$' + indent = pindent - shiftwidth() + elseif pline =~ 'case\s*.*:\s*\(//.*\)\?$' + if line !~ '^\s*}\s*$' && line !~ '^\s*case[[:space:]:]' + indent = pindent + shiftwidth() + endif + elseif pline =~ '^\s*@.*' && line !~ '^\s*}' + indent = pindent + elseif pline =~ ':[:=].*}\s*$' + indent = pindent + elseif pline =~ '^\s*}\s*$' + if line !~ '^\s*}' && line !~ 'case\s*.*:\s*$' + indent = pindent + else + indent = pindent - shiftwidth() + endif + elseif pline =~ '\S:\s*$' + # looking up for a case something, + # whatever, + # anything: + # ... 20 lines before + for idx in range(plnum - 1, plnum - 21, -1) + if plnum < 1 + break + endif + if getline(idx) =~ '^\s*case\s.*,\s*$' + indent = indent(idx) + shiftwidth() + break + endif + endfor + elseif pline =~ '{[^{]*}\s*$' && line !~ '^\s*[})]\s*$' # https://github.com/habamax/vim-odin/issues/2 + indent = pindent + elseif pline =~ '^\s*}\s*$' # https://github.com/habamax/vim-odin/issues/3 + # Find line with opening { and check if there is a label: + # If there is, return indent of the closing } + cursor(plnum, 1) + silent normal! % + var brlnum = line('.') + var brline = getline('.') + if plnum != brlnum && (brline =~ '^\s*\k\+:\s\+for' || brline =~ '^\s*\k\+\s*:=') + indent = pindent + endif + endif + + return indent +enddef diff --git a/runtime/indent/qml.vim b/runtime/indent/qml.vim index 8c9fa91..cf0ba41 100644 --- a/runtime/indent/qml.vim +++ b/runtime/indent/qml.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: QML " Maintainer: Chase Knowlden <haroldknowlden@gmail.com> -" Last Change: 2023 Aug 16 +" Last Change: 2024 Jan 24 by Vim Project " " Improved JavaScript indent script. @@ -40,10 +40,10 @@ function! s:GetQmlIndent() " bracket/brace/paren blocks if pline =~ '[{[(]$' - let ind += &sw + let ind += shiftwidth() endif if line =~ '^[}\])]' - let ind -= &sw + let ind -= shiftwidth() endif " '/*' comments diff --git a/runtime/indent/r.vim b/runtime/indent/r.vim index f7956e4..339c46b 100644 --- a/runtime/indent/r.vim +++ b/runtime/indent/r.vim @@ -1,8 +1,10 @@ " Vim indent file " Language: R -" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> -" Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Sun Oct 08, 2023 10:45AM +" Maintainer: This runtime file is looking for a new maintainer. +" Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> +" Former Repository: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: 2023 Oct 08 10:45AM +" 2024 Feb 19 by Vim Project (announce adoption) " Only load this indent file when no other was loaded. diff --git a/runtime/indent/racket.vim b/runtime/indent/racket.vim index 2d45d89..d301cd6 100644 --- a/runtime/indent/racket.vim +++ b/runtime/indent/racket.vim @@ -3,7 +3,7 @@ " Maintainer: D. Ben Knoble <ben.knoble+github@gmail.com> " Previous Maintainer: Will Langstroth <will@langstroth.com> " URL: https://github.com/benknoble/vim-racket -" Last Change: 2023 Jul 17 +" Last Change: 2024 Jan 31 if exists("b:did_indent") finish @@ -66,4 +66,4 @@ setlocal lispwords+=if-view,case-view,cond-view,list-view,dyn-view setlocal lispwords+=case/dep setlocal lispwords+=define/obs -let b:undo_indent = "setlocal indentexpr< lisp< lispoptions< ai< si< lw<" +let b:undo_indent = "setlocal lisp< ai< si< lw<" .. (has('vim9script') ? ' indentexpr< lispoptions<' : '') diff --git a/runtime/indent/rhelp.vim b/runtime/indent/rhelp.vim index 334802a..97820ae 100644 --- a/runtime/indent/rhelp.vim +++ b/runtime/indent/rhelp.vim @@ -1,8 +1,10 @@ " Vim indent file " Language: R Documentation (Help), *.Rd -" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> -" Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Mon Feb 27, 2023 07:01PM +" Maintainer: This runtime file is looking for a new maintainer. +" Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> +" Former Repository: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: 2023 Feb 27 07:01PM +" 2024 Feb 19 by Vim Project (announce adoption) " Only load this indent file when no other was loaded. diff --git a/runtime/indent/rmd.vim b/runtime/indent/rmd.vim index a043b0c..f2d34a3 100644 --- a/runtime/indent/rmd.vim +++ b/runtime/indent/rmd.vim @@ -1,8 +1,10 @@ " Vim indent file " Language: Rmd -" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> -" Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Wed Nov 09, 2022 09:44PM +" Maintainer: This runtime file is looking for a new maintainer. +" Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> +" Former Repository: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: 2022 Nov 09 09:44PM +" 2024 Feb 19 by Vim Project (announce adoption) " Only load this indent file when no other was loaded. diff --git a/runtime/indent/rnoweb.vim b/runtime/indent/rnoweb.vim index 668cdb7..1bdf7f3 100644 --- a/runtime/indent/rnoweb.vim +++ b/runtime/indent/rnoweb.vim @@ -1,8 +1,10 @@ " Vim indent file " Language: Rnoweb -" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> -" Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Mon Feb 27, 2023 07:17PM +" Maintainer: This runtime file is looking for a new maintainer. +" Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> +" Former Repository: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: 2024 Feb 27 07:17PM +" 2024 Feb 19 by Vim Project (announce adoption) " Only load this indent file when no other was loaded. diff --git a/runtime/indent/rrst.vim b/runtime/indent/rrst.vim index 585c5e6..73c8b04 100644 --- a/runtime/indent/rrst.vim +++ b/runtime/indent/rrst.vim @@ -1,8 +1,10 @@ " Vim indent file " Language: Rrst -" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> -" Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Feb 25, 2023 +" Maintainer: This runtime file is looking for a new maintainer. +" Former Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> +" Former Repository: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: 2023 Feb 25 +" 2024 Feb 19 by Vim Project (announce adoption) " Only load this indent file when no other was loaded. diff --git a/runtime/indent/testdir/runtest.vim b/runtime/indent/testdir/runtest.vim index 882a140..dde8c5c 100644 --- a/runtime/indent/testdir/runtest.vim +++ b/runtime/indent/testdir/runtest.vim @@ -2,7 +2,7 @@ " " Current directory must be runtime/indent. -" Only do this with the +eval feature +" Only do this with the +eval feature. if 1 set nocp @@ -18,7 +18,7 @@ au! SwapExists * call HandleSwapExists() func HandleSwapExists() " Ignore finding a swap file for the test input and output, the user might be " editing them and that's OK. - if expand('<afile>') =~ '.*\.\(in\|out\|fail\|ok\)' + if expand('<afile>') =~ '.*\.\%(in\|out\|fail\|ok\)' let v:swapchoice = 'e' endif endfunc @@ -30,19 +30,19 @@ for fname in glob('testdir/*.in', 1, 1) " Execute the test if the .out file does not exist of when the .in file is " newer. let in_time = getftime(fname) - let out_time = getftime(root . '.out') + let out_time = getftime(root .. '.out') if out_time < 0 || in_time > out_time - call delete(root . '.fail') - call delete(root . '.out') + call delete(root .. '.fail') + call delete(root .. '.out') set sw& ts& filetype= - exe 'split ' . fname + exe 'split ' .. fname let did_some = 0 let failed = 0 let end = 1 while 1 - " Indent all the lines between "START_INDENT" and "END_INDENT" + " Indent all the lines between "START_INDENT" and "END_INDENT". exe end let start = search('\<START_INDENT\>') let end = search('\<END_INDENT\>') @@ -63,7 +63,7 @@ for fname in glob('testdir/*.in', 1, 1) exe lnum + 1 let lnum_exe = search('\<INDENT_EXE\>') exe lnum + 1 - let indent_at = search('\<INDENT_\(AT\|NEXT\|PREV\)\>') + let indent_at = search('\<INDENT_\%(AT\|NEXT\|PREV\)\>') if lnum_exe > 0 && lnum_exe < end && (indent_at <= 0 || lnum_exe < indent_at) exe substitute(getline(lnum_exe), '.*INDENT_EXE', '', '') let lnum = lnum_exe @@ -87,15 +87,15 @@ for fname in glob('testdir/*.in', 1, 1) exe start + 1 if pattern == '' try - exe 'normal =' . (end - 1) . 'G' + exe 'normal =' .. (end - 1) .. 'G' catch - call append(indent_at, 'ERROR: ' . v:exception) + call append(indent_at, 'ERROR: ' .. v:exception) let failed = 1 endtry else let lnum = search(pattern) if lnum <= 0 - call append(indent_at, 'ERROR: pattern not found: ' . pattern) + call append(indent_at, 'ERROR: pattern not found: ' .. pattern) let failed = 1 break endif @@ -109,7 +109,7 @@ for fname in glob('testdir/*.in', 1, 1) try normal == catch - call append(indent_at, 'ERROR: ' . v:exception) + call append(indent_at, 'ERROR: ' .. v:exception) let failed = 1 endtry endif @@ -118,21 +118,21 @@ for fname in glob('testdir/*.in', 1, 1) if !failed " Check the resulting text equals the .ok file. - if getline(1, '$') != readfile(root . '.ok') + if getline(1, '$') != readfile(root .. '.ok') let failed = 1 endif endif if failed let failed_count += 1 - exe 'write ' . root . '.fail' - echoerr 'Test ' . fname . ' FAILED!' + exe 'write ' .. root .. '.fail' + echoerr 'Test ' .. fname .. ' FAILED!' else - exe 'write ' . root . '.out' - echo "Test " . fname . " OK\n" + exe 'write ' .. root .. '.out' + echo "Test " .. fname .. " OK\n" endif - quit! " close the indented file + quit! " Close the indented file. endif endfor @@ -140,7 +140,7 @@ endfor endif if failed_count > 0 - " have make report an error + " Have make report an error. cquit endif qall! diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in index c2e149a..1ff2d0d 100644 --- a/runtime/indent/testdir/vim.in +++ b/runtime/indent/testdir/vim.in @@ -946,3 +946,8 @@ Blue Black endenum " END_INDENT + +" START_INDENT +call prop_type_add('indent_after_literal_dict', #{ foo: 'bar' }) +call prop_type_delete('indent_after_literal_dict') +" END_INDENT diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok index b10e081..fa8869b 100644 --- a/runtime/indent/testdir/vim.ok +++ b/runtime/indent/testdir/vim.ok @@ -946,3 +946,8 @@ enum Color Black endenum " END_INDENT + +" START_INDENT +call prop_type_add('indent_after_literal_dict', #{ foo: 'bar' }) +call prop_type_delete('indent_after_literal_dict') +" END_INDENT diff --git a/runtime/indent/yaml.vim b/runtime/indent/yaml.vim index 93fd8ea..e5daf9f 100644 --- a/runtime/indent/yaml.vim +++ b/runtime/indent/yaml.vim @@ -3,6 +3,7 @@ " Maintainer: Nikolai Pavlov <zyx.vim@gmail.com> " Last Updates: Lukas Reineke, "lacygoill" " Last Change: 2022 Jun 17 +" 2024 Feb 29 disable mulitline indent by default (The Vim project) " Only load this indent file when no other was loaded. if exists('b:did_indent') @@ -138,11 +139,13 @@ function GetYAMLIndent(lnum) else return indent(prevmapline) endif - elseif prevline =~# '^\s*- ' + elseif get(g:, 'yaml_indent_multiline_scalar', 0) && + \ prevline =~# '^\s*- ' " - List with " multiline scalar return previndent+2 - elseif prevline =~# s:mapkeyregex .. '\v\s*%(%(' .. s:c_ns_tag_property .. + elseif get(g:, 'yaml_indent_multiline_scalar', 0) && + \ prevline =~# s:mapkeyregex .. '\v\s*%(%(' .. s:c_ns_tag_property .. \ '\v|' .. s:c_ns_anchor_property .. \ '\v|' .. s:block_scalar_header .. \ '\v)%(\s+|\s*%(\#.*)?$))*' |