view runtime/syntax/cabal.vim @ 34536:ad6cd802579d v9.1.0170

patch 9.1.0170: Re-allow curwin == prevwin, but document it instead Commit: https://github.com/vim/vim/commit/d64801e913314d2e19dbb38f60e6d285238debff Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Tue Mar 12 20:46:12 2024 +0100 patch 9.1.0170: Re-allow curwin == prevwin, but document it instead Problem: more places exist where curwin == prevwin, and it may even be expected in some cases. Solution: revert v9.1.0001, but document that it's possible instead. (Sean Dewar) I've had a change of heart for the following reasons: - A quick 'n dirty [GitHub code search](https://github.com/search?q=%2F%28winnr%5C%28%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%7Cwinnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5C%29%29%2F&type=code) reveals some cases where it's expected in the wild. Particularly, it made me aware `winnr() == winnr('#')` is possible when curwin is changed temporarily during the evaluation of a &statusline expression item (`%{...}`), and is used to show something different on the statusline belonging to the previous window; that behaviour wasn't changed in v9.1.0001, but it means curwin == prevwin makes sense in some cases. - The definition and call sites of back_to_prevwin imply some expectation that prevwin == wp (== curwin) is possible, as it's used to skip entering the prevwin in that case. - Prior to v9.1.0001, `:wincmd p` would not beep in the case that was patched in v9.1.0001, but now does. That resulted in #14047 being opened, as it affected the CtrlP plugin. I find it odd that `:wincmd p` had cases where it wouldn't beep despite doing nothing, but it may be preferable to keep things that way (or instead also beep if curwin == prevwin, if that's preferred). - After more digging, I found cases in win_free_mem, enter_tabpage, aucmd_restbuf and qf_open_new_cwindow where curwin == prevwin is possible (many of them from autocommands). Others probably exist too, especially in places where curwin is changed temporarily. fixes: #14047 closes: #14186 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Mar 2024 21:00:11 +0100
parents 5acd6f02ea35
children
line wrap: on
line source

" Vim syntax file
" Language:     Haskell Cabal Build file
" Author:	Vincent Berthoux <twinside@gmail.com>
" Maintainer:   Marcin Szamotulski <profunctor@pm.me>
" Previous Maintainer:	Vincent Berthoux <twinside@gmail.com>
" File Types:   .cabal
" Last Change:  22 Oct 2022
" v1.6: Added support for foreign-libraries
"       Added highlighting for various fields 
" v1.5: Incorporated changes from
"       https://github.com/sdiehl/haskell-vim-proto/blob/master/vim/syntax/cabal.vim
"       Use `syn keyword` instead of `syn match`.
"       Added cabalStatementRegion to limit matches of keywords, which fixes
"       the highlighting of description's value.
"       Added cabalVersionRegion to limit the scope of cabalVersionOperator
"       and cabalVersion matches.
"       Added cabalLanguage keyword.
"       Added calbalTitle, cabalAuthor and cabalMaintainer syntax groups.
"       Added ! and ^>= operators (calbal 2.0)
"       Added build-type keywords
" v1.4: Add benchmark support, thanks to Simon Meier
" v1.3: Updated to the last version of cabal
"       Added more highlighting for cabal function, true/false
"       and version number. Also added missing comment highlighting.
"       Cabal known compiler are highlighted too.
"
" V1.2: Added cpp-options which was missing. Feature implemented
"       by GHC, found with a GHC warning, but undocumented. 
"       Whatever...
"
" v1.1: Fixed operator problems and added ftdetect file
"       (thanks to Sebastian Schwarz)
"
" v1.0: Cabal syntax in vimball format
"       (thanks to Magnus Therning)

" quit when a syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

" this file uses line continuation
let s:cpo_save = &cpo
set cpo&vim

" set iskeyword for this syntax script
syn iskeyword @,48-57,192-255,-

" Case sensitive matches
syn case match

syn keyword cabalConditional	if else
syn keyword cabalFunction	os arche impl flag
syn match cabalComment		/--.*$/

" Case insensitive matches
syn case ignore

syn keyword cabalCategory contained
	\ executable
	\ library
	\ benchmark
	\ test-suite
	\ source-repository
	\ flag
        \ foreign-library
	\ custom-setup
	\ common
syn match cabalCategoryTitle contained /[^{]*\ze{\?/
syn match cabalCategoryRegion
	\ contains=cabalCategory,cabalCategoryTitle
	\ nextgroup=cabalCategory skipwhite
	\ /^\c\s*\(contained\|executable\|library\|benchmark\|test-suite\|source-repository\|flag\|foreign-library\|custom-setup\|common\)\+\s*\%(.*$\|$\)/
syn keyword cabalTruth true false

" cabalStatementRegion which limits the scope of cabalStatement keywords, this
" way they are not highlighted in description.
syn region cabalStatementRegion start=+^\s*\(--\)\@<!\k\+\s*:+ end=+:+
syn keyword cabalStatement contained containedin=cabalStatementRegion
	\ default-language
	\ default-extensions
	\ author
        \ autogen-includes
        \ autogen-modules
        \ asm-sources
        \ asm-options
	\ branch
	\ bug-reports
	\ build-depends
	\ build-tools
        \ build-tool-depends
	\ build-type
	\ buildable
	\ c-sources
	\ cabal-version
	\ category
	\ cc-options
	\ copyright
        \ cmm-sources
        \ cmm-options
	\ cpp-options
        \ cxx-options
        \ cxx-sources
	\ data-dir
	\ data-files
	\ default
        \ default-extensions
	\ description
	\ executable
	\ exposed-modules
	\ exposed
	\ extensions
        \ extra-bundled-libraries
	\ extra-doc-files
	\ extra-dynamic-library-flavours
        \ extra-framework-dirs
        \ extra-ghci-libraries
	\ extra-lib-dirs
	\ extra-lib-dirs-static
	\ extra-libraries
	\ extra-libraries-static
	\ extra-library-flavours
	\ extra-source-files
	\ extra-tmp-files
	\ for example
	\ frameworks
	\ ghc-options
	\ ghc-prof-options
	\ ghc-shared-options
        \ ghcjs-options
        \ ghcjs-prof-options
        \ ghcjs-shared-options
	\ homepage
        \ hs-source-dir
	\ hs-source-dirs
	\ hugs-options
	\ import
	\ include-dirs
	\ includes
	\ install-includes
        \ js-sources
	\ ld-options
        \ lib-version-info
        \ lib-version-linux
	\ license
	\ license-file
	\ location
	\ main-is
	\ maintainer
	\ manual
        \ mixins
	\ module
        \ mod-def-file
	\ name
	\ nhc98-options
        \ options
	\ other-extensions
        \ other-language
        \ other-languages
	\ other-modules
	\ package-url
	\ pkgconfig-depends
        \ scope
	\ setup-depends
        \ signatures
	\ stability
	\ subdir
	\ synopsis
        \ reexported-modules
	\ tag
	\ tested-with
        \ test-module
	\ type
	\ version
	\ virtual-modules

" operators and version operators
syn match cabalOperator /&&\|||\|!/
syn match cabalVersionOperator contained
	\ /!\|==\|\^\?>=\|<=\|<\|>/
" match version: `[%]\@<!` is to exclude `%20` in http addresses.
syn match cabalVersion contained
	\ /[%$_-]\@<!\<\d\+\%(\.\d\+\)*\%(\.\*\)\?\>/
" cabalVersionRegion which limits the scope of cabalVersion pattern.
syn match cabalVersionRegionA
	\ contains=cabalVersionOperator,cabalVersion
	\ keepend
	\ /\%(==\|\^\?>=\|<=\|<\|>\)\s*\d\+\%(\.\d\+\)*\%(\.\*\)\?\>/
" version inside `version: ...` 
syn match cabalVersionRegionB
	\ contains=cabalStatementRegion,cabalVersionOperator,cabalVersion
	\ /^\s*\%(cabal-\)\?version\s*:.*$/

syn keyword cabalLanguage Haskell98 Haskell2010

" title region
syn match cabalName contained /:\@<=.*/
syn match cabalNameRegion
	\ contains=cabalStatementRegion,cabalName
	\ nextgroup=cabalStatementRegion
	\ oneline
	\ /^\c\s*name\s*:.*$/

" author region
syn match cabalAuthor contained /:\@<=.*/
syn match cabalAuthorRegion
	\ contains=cabalStatementRegion,cabalStatement,cabalAuthor
	\ nextgroup=cabalStatementRegion
	\ oneline
	\ /^\c\s*author\s*:.*$/

" maintainer region
syn match cabalMaintainer contained /:\@<=.*/
syn match cabalMaintainerRegion
	\ contains=cabalStatementRegion,cabalStatement,cabalMaintainer
	\ nextgroup=cabalStatementRegion
	\ oneline
	\ /^\c\s*maintainer\s*:.*$/

" license region
syn match cabalLicense contained /:\@<=.*/
syn match cabalLicenseRegion
	\ contains=cabalStatementRegion,cabalStatement,cabalLicense
	\ nextgroup=cabalStatementRegion
	\ oneline
	\ /^\c\s*license\s*:.*$/

" license-file region
syn match cabalLicenseFile contained /:\@<=.*/
syn match cabalLicenseFileRegion
	\ contains=cabalStatementRegion,cabalStatement,cabalLicenseFile
	\ nextgroup=cabalStatementRegion
	\ oneline
	\ /^\c\s*license-file\s*:.*$/

" tested-with region with compilers and versions
syn keyword cabalCompiler contained ghc nhc yhc hugs hbc helium jhc lhc
syn match cabalTestedWithRegion
	\ contains=cabalStatementRegion,cabalStatement,cabalCompiler,cabalVersionRegionA
	\ nextgroup=cabalStatementRegion
	\ oneline
	\ /^\c\s*tested-with\s*:.*$/

" build type keywords
syn keyword cabalBuildType contained
	\ simple custom configure
syn match cabalBuildTypeRegion
	\ contains=cabalStatementRegion,cabalStatement,cabalBuildType
	\ nextgroup=cabalStatementRegion
	\ /^\c\s*build-type\s*:.*$/

" Define the default highlighting.
" Only when an item doesn't have highlighting yet
hi def link cabalName	      Title
hi def link cabalAuthor	      Normal
hi def link cabalMaintainer   Normal
hi def link cabalCategoryTitle Title
hi def link cabalLicense      Normal
hi def link cabalLicenseFile  Normal
hi def link cabalBuildType    Keyword
hi def link cabalVersion      Number
hi def link cabalTruth        Boolean
hi def link cabalComment      Comment
hi def link cabalStatement    Statement
hi def link cabalLanguage     Type
hi def link cabalCategory     Type
hi def link cabalFunction     Function
hi def link cabalConditional  Conditional
hi def link cabalOperator     Operator
hi def link cabalVersionOperator Operator
hi def link cabalCompiler     Constant

let b:current_syntax = "cabal"

let &cpo = s:cpo_save
unlet! s:cpo_save

" vim: ts=8