]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(cabal): Update compiler, ftplugin, syntax, add indent script
authorMateo Gjika <104777599+mateoxh@users.noreply.github.com>
Fri, 26 Jun 2026 20:29:50 +0000 (20:29 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 26 Jun 2026 20:29:50 +0000 (20:29 +0000)
closes: #20623

Signed-off-by: Mateo Gjika <104777599+mateoxh@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
.github/MAINTAINERS
runtime/compiler/cabal.vim
runtime/ftplugin/cabal.vim
runtime/indent/cabal.vim [new file with mode: 0644]
runtime/syntax/cabal.vim

index 10f8ecbac3f6874d59498c2a457d663089ce7936..f2200c4ac663256ea9f6148da532a249aa9156f7 100644 (file)
@@ -370,6 +370,7 @@ runtime/indent/basic.vim                            @dkearns
 runtime/indent/beancount.vim                           @nathangrigg
 runtime/indent/bpftrace.vim                            @sgruszka
 runtime/indent/bst.vim                                 @tpope
+runtime/indent/cabal.vim                               @mateoxh
 runtime/indent/cdl.vim                                 @dkearns
 runtime/indent/chatito.vim                             @ObserverOfTime
 runtime/indent/clojure.vim                             @axvr
index 02d4d9b8e1ac589f81a6167d556b6b4cb3388a99..3590e93e31b078e952d2e8561178280a32c71f7e 100644 (file)
@@ -33,7 +33,8 @@ CompilerSet errorformat=
       \%E%f:%l:%c:\ %trror:%m,
       \%E%f:%l:%c:\ %trror:,
       \%Z\ %\\+\|%.%#,
-      \%C%m
+      \%C%m,
+      \%-G%.%#
 
 let &cpo = s:save_cpo
 unlet s:save_cpo
index e7e4ab18a9ee272db7237414372d64725627f9a2..91b9298930321a9bcc365a95c583651bfee23f39 100644 (file)
@@ -3,16 +3,16 @@
 " Maintainer:  Riley Bruins <ribru17@gmail.com>
 " Last Change: 2024 Jul 06
 " 2026 Jan 13 by Vim project: set compiler #19152
+" 2026 Jun 26 by Vim project: set expandtab #20623
 
 if exists('b:did_ftplugin')
   finish
 endif
 let b:did_ftplugin = 1
 
-compiler cabal
-
-let b:undo_ftplugin = 'compiler make'
+setlocal expandtab
+setlocal comments=:-- commentstring=--\ %s
 
-setl comments=:-- commentstring=--\ %s
+compiler cabal
 
-let b:undo_ftplugin .= '| setl com< cms<'
+let b:undo_ftplugin = 'compiler make | setlocal com< cms< et<'
diff --git a/runtime/indent/cabal.vim b/runtime/indent/cabal.vim
new file mode 100644 (file)
index 0000000..3faaa6d
--- /dev/null
@@ -0,0 +1,100 @@
+" Vim indent file
+" Language: Haskell Cabal Build file
+" Maintainer: Mateo Gjika <@mateoxh>
+
+if exists('b:did_indent')
+  finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetCabalIndent()
+setlocal indentkeys=!^F,o,O,e,0=elif,<:>
+
+let b:undo_indent = 'setlocal inde< indk<'
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+function! GetCabalIndent() abort
+  let categories = '\v\c^<(executable|(foreign-)?library|flag|source-repository|test-suite|benchmark|common|custom-setup)>'
+  let line = getline(v:lnum)
+  let prevline = getline(v:lnum - 1)
+
+  if line =~# categories
+    return 0
+  endif
+
+  if line =~# '^\s*--'
+    return -1
+  endif
+
+  if line =~# '^\s*}'
+    let [lnum, col] = s:searchpairpos('{','','}','bnW')
+    if [lnum, col] == [0, 0]
+      return -1
+    else
+      return indent(lnum)
+    endif
+  endif
+
+  if line =~# '^\s*||'
+    if prevline =~# '^\s*||'
+      return indent(v:lnum - 1)
+    else
+      return indent(v:lnum - 1) + 1
+    endif
+  endif
+
+  if line =~# '\v^\s*<elif>'
+    let [lnum, col] = s:searchpairpos('\v<if>', '', '\v<elif>\zs', 'bnW')
+    return col - 1
+  elseif line =~# '\v^\s*<else>'
+    let [lnum, col] = s:searchpairpos('\v<if>', '\v<elif>', '\v<else>\zs', 'bnW')
+    return col - 1
+  endif
+
+  if prevline =~# '\v^\s*<(if|elif|else)>'
+    return indent(v:lnum - 1) + shiftwidth()
+  endif
+
+  if prevline =~# categories
+    return indent(v:lnum - 1) + shiftwidth()
+  endif
+
+  if empty(prevline) || line =~# '\v^\s*\S+:'
+    call cursor(v:lnum, 1)
+    let prevCond = search('\v^\s*<(if|elif|else)>', 'bnW', 0, 0,
+          \ "synIDattr(synID(line('.'),col('.'),1),'name') =~? 'comment'")
+    let prevCat = search(categories, 'bnW', 0, 0,
+          \ "synIDattr(synID(line('.'),col('.'),1),'name') =~? 'comment'")
+    if prevCond > prevCat
+      return indent(v:lnum) > indent(prevCond)
+            \ ? indent(prevCond) + shiftwidth()
+            \ : indent(prevCond)
+    elseif prevCat > 0
+      return indent(prevCat) + shiftwidth()
+    else
+      return 0
+    endif
+  endif
+
+  if line !~# '\v^\s*(<if>|--)'
+    if prevline =~# '\v^\s*\S+:$'
+      return indent(v:lnum - 1) + shiftwidth()
+    endif
+    if prevline =~# '\v^\s*\S+:\s*\S'
+      return match(prevline, '\v^\s*\S+:\s*\zs')
+    endif
+  endif
+
+  return indent(prevnonblank(v:lnum - 1))
+endfunction
+
+function! s:searchpairpos(start, middle, end, flags) abort
+  return searchpairpos(a:start, a:middle, a:end, a:flags,
+        \ "synIDattr(synID(line('.'),col('.'),1),'name') =~? 'comment'")
+endfunction
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
index ddc905615b4e5402d77123fd281eeb29496c8ff0..fffc0c7752f584d3a2841223b6dfceb6809facdd 100644 (file)
@@ -8,6 +8,7 @@
 "
 " 2026 Apr 29 by LĂ©ana: add missing haskell language editions
 " 2026 Apr 20 by Vim project: remove wrong oneline keyword #20018
+" 2026 Jun 26 by Vim project: add elif keyword #20623
 "
 " v1.6: Added support for foreign-libraries
 "       Added highlighting for various fields
@@ -53,7 +54,7 @@ syn iskeyword @,48-57,192-255,-
 " Case sensitive matches
 syn case match
 
-syn keyword cabalConditional   if else
+syn keyword cabalConditional   if elif else
 syn keyword cabalFunction      os arche impl flag
 syn match cabalComment         /--.*$/