From 696766cc8d9ab129274347a185951a474337ea77 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 5 Sep 2021 18:49:09 +0200 Subject: Add 'mpvim' plugin @ 513c455d5a902fff2b38edf86abc15c36688bf85 Provides syntax highlighting for MacPorts Portfiles. This code was copied from the 'macports-contrib' repository (https://github.com/macports/macports-contrib) at commit 513c455d5a902fff2b38edf86abc15c36688bf85 (https://github.com/macports/macports-contrib/tree/513c455d5a902fff2b38edf86abc15c36688bf85). The Vim plugin lives in a subdirectory of the 'macports-contrib' repository, so I'd have to include a whole mess of files that don't relate to Vim if I wanted to add the plugin as a submodule. I'd just as soon not have to copy the files into my repository tree like this, but it's better than adding a non-Vim submodule. Assuming it's okay to add these files to my repository, as the port file for this plugin describes it as being BSD licensed: https://github.com/macports/macports-ports/blob/12d7b1597bef875058758c9c587b7593f39a5af1/editors/mpvim/Portfile Unfortunately, there's no BSD license or copyright notice included in the plugin code. But I'm going to assume I'm allowed to redistribute it. --- bundle/mpvim/Makefile | 12 ++ bundle/mpvim/README | 26 +++ bundle/mpvim/compiler/portfile.vim | 13 ++ bundle/mpvim/ftdetect/macports.vim | 3 + bundle/mpvim/ftplugin/portfile.vim | 40 ++++ bundle/mpvim/indent/portfile.vim | 7 + bundle/mpvim/snippets/portfile.snippets | 53 ++++++ bundle/mpvim/syntax/portfile.vim | 317 ++++++++++++++++++++++++++++++++ 8 files changed, 471 insertions(+) create mode 100644 bundle/mpvim/Makefile create mode 100644 bundle/mpvim/README create mode 100644 bundle/mpvim/compiler/portfile.vim create mode 100644 bundle/mpvim/ftdetect/macports.vim create mode 100644 bundle/mpvim/ftplugin/portfile.vim create mode 100644 bundle/mpvim/indent/portfile.vim create mode 100644 bundle/mpvim/snippets/portfile.snippets create mode 100644 bundle/mpvim/syntax/portfile.vim (limited to 'bundle') diff --git a/bundle/mpvim/Makefile b/bundle/mpvim/Makefile new file mode 100644 index 0000000..3b96717 --- /dev/null +++ b/bundle/mpvim/Makefile @@ -0,0 +1,12 @@ +.PHONY: all install + +prefix := ~/.vim + +all: + +install: + @for dir in compiler ftdetect ftplugin indent snippets syntax; \ + do \ + mkdir -p $(DESTDIR)$(prefix)/$$dir/ ; \ + cp -rv $$dir/* $(DESTDIR)$(prefix)/$$dir/ ; \ + done diff --git a/bundle/mpvim/README b/bundle/mpvim/README new file mode 100644 index 0000000..da7f6ca --- /dev/null +++ b/bundle/mpvim/README @@ -0,0 +1,26 @@ +=== About mpvim +mpvim adds MacPorts support to vim. This currently includes syntax coloring for +Portfiles and running lint from vim. + +=== Manual installation +Run 'make install' or copy the files in this directory into ~/.vim. + +=== Installation via MacPorts +Run 'sudo port install mpvim'; the files will be placed into +share/vim/vimfiles under the MacPorts prefix (/opt/local by default). + +=== Usage +* :make runs 'port lint' on the Portfile in the current buffer + +* :MPpatch applies the patch located at to the Portfile + in the current buffer and shows the differences with vimdiff. Also + automatically fetches the patch format in case the diff is on trac. + +* add 'let g:portfile_highlight_space_errors=1' to your .vimrc to highlight mixed + spaces and tabs in Portfiles as errors + +* mpvim supports snipMate (http://www.vim.org/scripts/script.php?script_id=2540) + snippets. "new" in a new buffer named Portfile will create a new + Portfile skeleton. Subsequent 's will cycle through the variables. + More snippets are available for variants, build phases etc. Take a look + at snippets/portfile.vim for the complete list diff --git a/bundle/mpvim/compiler/portfile.vim b/bundle/mpvim/compiler/portfile.vim new file mode 100644 index 0000000..d5a05eb --- /dev/null +++ b/bundle/mpvim/compiler/portfile.vim @@ -0,0 +1,13 @@ +" vim:fenc=utf-8:et:sw=4:ts=4:sts=4 + +" Vim compiler file +" Author: Maximilian Nickel + +if exists("current_compiler") + finish +endif +let current_compiler = "portfile" + +setlocal makeef=/tmp/portfile##.err +setlocal makeprg=cd\ %:p:h\ &&\ port\ lint\ --nitpick\ 2>&1\ \\\|\ grep\ -v\ \"\\\-\\\->\" +setlocal errorformat=Warning\:\ Line\ %l\ %m,Error\:%m,Warn\:%m,%m diff --git a/bundle/mpvim/ftdetect/macports.vim b/bundle/mpvim/ftdetect/macports.vim new file mode 100644 index 0000000..836fc9e --- /dev/null +++ b/bundle/mpvim/ftdetect/macports.vim @@ -0,0 +1,3 @@ +" Portfile +au BufNewFile,BufRead Portfile set filetype=portfile +au FileType portfile compiler portfile diff --git a/bundle/mpvim/ftplugin/portfile.vim b/bundle/mpvim/ftplugin/portfile.vim new file mode 100644 index 0000000..116c249 --- /dev/null +++ b/bundle/mpvim/ftplugin/portfile.vim @@ -0,0 +1,40 @@ +" vim:fenc=utf-8:et:sw=4:ts=4:sts=4 +" ====================================================================== +" Vim filetype plugin for portfile +" Maintainer: Maximilian Nickel +" ====================================================================== + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +if !exists("g:did_mpftplugin") + function PortfileGetErrors() + if !empty(getqflist()) + exe "copen" + end + endfunction + + function TracPatch(url) + let patchfile="$TMPDIR/portfile.patch" + let url = substitute(a:url, "/attachment/", "/raw-attachment/", "") + let cmd = "!curl --progress-bar -o \"" . patchfile . "\" \"" . url . "\"" + exe cmd + exe "diffpatch " . patchfile + endfunction + + let g:did_mpftplugin = 1 +endif + +au QuickFixCmdPre make exe "cclose" +au QuickFixCmdPost make call PortfileGetErrors() +command! -nargs=1 MPpatch :call TracPatch("") + +" Ignore Portfile modeline +setlocal nomodeline +setlocal fileencoding=utf-8 +setlocal expandtab +setlocal shiftwidth=4 +setlocal tabstop=4 +setlocal softtabstop=4 diff --git a/bundle/mpvim/indent/portfile.vim b/bundle/mpvim/indent/portfile.vim new file mode 100644 index 0000000..c1c6b33 --- /dev/null +++ b/bundle/mpvim/indent/portfile.vim @@ -0,0 +1,7 @@ +" vim:fenc=utf-8:et:sw=4:ts=4:sts=4 + +" Vim indent file +" Language: MacPorts portfiles +" Maintainer: Lawrence Velázquez + +runtime! indent/tcl.vim diff --git a/bundle/mpvim/snippets/portfile.snippets b/bundle/mpvim/snippets/portfile.snippets new file mode 100644 index 0000000..2752a37 --- /dev/null +++ b/bundle/mpvim/snippets/portfile.snippets @@ -0,0 +1,53 @@ +snippet modeline + # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 +snippet new + # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 + # $Id$ + + PortSystem 1.0 + + name ${1:PortName} + version ${2:PortVersion} + maintainers ${3:MaintainerHandle} + + categories ${4:Categories} + description ${5:Description} + long_description ${6:LongDescription} + + platforms ${7:Platforms} + + homepage ${8:Homepage} +snippet cargs + configure.args${1:-append/-delete} ${2:args} +snippet cenv + configure.env${1:-append/-delete} ${2:args} +snippet dlib + depends_lib${1:-append/-delete} ${2:args} +snippet drun + depends_run${1:-append/-delete} ${2:args} +snippet dbuild + depends_build${1:-append/-delete} ${2:args} +snippet var + variant ${1:name} description {${2:text}} { + ${3} + } +snippet fetch + ${1:pre-/post-}fetch { + ${2} + } +snippet patch + ${1:pre-/post-}patch { + ${2} + } +snippet conf + ${1:pre-/post-}configure { + ${2} + } +snippet build + ${1:pre-/post-}build { + ${2} + } +snippet dest + ${1:pre-/post-}destroot { + ${2} + } diff --git a/bundle/mpvim/syntax/portfile.vim b/bundle/mpvim/syntax/portfile.vim new file mode 100644 index 0000000..480a876 --- /dev/null +++ b/bundle/mpvim/syntax/portfile.vim @@ -0,0 +1,317 @@ +" vim:fenc=utf-8:et:sw=4:ts=4:sts=4 + +" Vim syntax file +" Language: MacPorts Portfiles +" Maintainer: Maximilian Nickel +" + +if &compatible || v:version < 603 + finish +endif + +if exists("b:current_syntax") + finish +endif + +" Disable whitespace error highlight if variable is not set +if !exists("g:portfile_highlight_space_errors") + let g:portfile_highlight_space_errors=0 +endif + +let is_tcl=1 +runtime! syntax/tcl.vim + +unlet b:current_syntax + +" Some custom extensions contain a dash (for example, fs-traverse) +setlocal iskeyword+=- + +syn match PortfileGroup "{.\+}" contained +syn match PortfileYesNo "\<\%(yes\|no\)\>" contained + +syn keyword PortfileRequired PortSystem name version maintainers +syn keyword PortfileRequired homepage platforms +syn match PortfileRequired "\" +syn match PortfileRequired "\" +syn match PortfileRequired "\<\%(long_\)\?description\%(-append\)\?\>" nextgroup=PortfileDescription skipwhite +syn region PortfileDescription matchgroup=Normal start="" skip="\\$" end="$" contained + +syn keyword PortfileOptional PortGroup epoch revision patch_sites +syn keyword PortfileOptional license conflicts license_noconflict +syn keyword PortfileOptional replaced_by supported_archs + +syn match PortfileOptional "\" +syn keyword PortfileOptional distname dist_subdir worksrcdir + +syn keyword PortfileOptional installs_libs nextgroup=PortfileYesNo skipwhite +syn match PortfileOptional "\" + +syn keyword PortfileOptional use_xcode nextgroup=PortfileYesNo skipwhite + +syn match PortfileOptional "\" nextgroup=PortfileChecksums skipwhite +syn region PortfileChecksums matchgroup=Normal start="" skip="\\$" end="$" contained contains=PortfileChecksumsType +syn keyword PortfileChecksumsType md5 sha1 rmd160 sha256 size contained + +syn match PortfilePhases "\<\%(pre-\|post-\)\?\%(fetch\|checksum\|extract\|patch\|configure\|build\|test\|destroot\|archive\|install\|activate\|deactivate\)\>" contains=PortfilePrePost + +" Fetch phase options +syn match PortfilePhasesFetch "\" +syn match PortfilePhasesFetch "\" +syn match PortfilePhasesFetch "\" +syn match PortfilePhasesFetch "\" +syn match PortfilePhasesFetch "\" + +" Extract phase options +syn match PortfilePhasesExtract "\" +syn match PortfilePhasesExtract "\" nextgroup=PortfileYesNo skipwhite + +" Patch phase options +syn match PortfilePhasesPatch "\" +syn match PortfilePhasesPatch "\" + +" Configure phase options +syn keyword PortfilePhasesConf use_configure nextgroup=PortfileYesNo skipwhite +syn match PortfilePhasesConf "\" +syn match PortfilePhasesConf "\" +syn match PortfilePhasesConf "\" nextgroup=PortfileConfEntries skipwhite +syn region PortfileConfEntries matchgroup=Normal start="" skip="\\$" end="$" contained +syn match PortfilePhasesConf "\" +syn match PortfilePhasesConf "\" +syn match PortfilePhasesConf "\" +syn match PortfilePhasesConf "\" +syn match PortfilePhasesConf "\" + +" Automake and Autoconf +syn match PortfilePhasesAA "\" nextgroup=PortfileYesNo skipwhite +syn match PortfilePhasesAA "\" + +" Build phase options +syn match PortfilePhasesBuild "\" +syn match PortfilePhasesBuild "\" +syn match PortfilePhasesBuild "\" +syn keyword PortfilePhasesBuild use_parallel_build nextgroup=PortfileYesNo skipwhite + +" Test phase options +syn match PortfilePhasesTest "\" nextgroup=PortfileYesNo skipwhite +syn match PortfilePhasesTest "\" +syn match PortfilePhasesTest "\" +syn match PortfilePhasesTest "\" + +" Test destroot options +syn match PortfilePhasesDest "\" +syn match PortfilePhasesDest "\" nextgroup=PortfileYesNo skipwhite +syn match PortfilePhasesDest "\" +syn match PortfilePhasesDest "\" + +" Variants +syn region PortfileVariant matchgroup=Keyword start="^\s*\zsvariant" skip="\\$" end="$" contains=PortfileVariantName,PortfileVariantRequires,PortfileVariantDescription,PortfileVariantConflicts skipwhite +syn keyword PortfileVariantRequires requires nextgroup=PortfileVariantName contained +syn keyword PortfileVariantConflicts conflicts nextgroup=PortfileVariantName contained +syn keyword PortfileVariantDescription description nextgroup=PortfileGroup contained skipwhite +syn match PortfileVariantName "\<\w\+\>" contained +syn keyword PortfileOptional universal_variant nextgroup=PortfileYesNo skipwhite +syn match PortfileOptional "\" nextgroup=PortfileDefaultVariants skipwhite +syn match PortfileDefaultVariants "\<[+-]\w\+\%(\s\+[+-]\w\+\)*\>" contained + +" Platform +syn match PortfilePlatform "\" nextgroup=PortfilePlatformName skipwhite +syn match PortfilePlatformName "\<\l\w\+\>" nextgroup=PortfilePlatformVersion contained skipwhite +syn match PortfilePlatformVersion "\<\d\+\>" nextgroup=PortfilePlatformArch contained skipwhite +syn match PortfilePlatformArch "\<\l\w\+\>" contained + +" Subports +syn region PortfileSubport matchgroup=Keyword start="^\s*\zssubport\>" skip="\\$" end="$" contains=PortfileSubportName +syn match PortfileSubportName "\<[\w\.-]\+\>" contained + +" Dependencies +syn match PortfileDepends "\" nextgroup=PortfileDependsEntries skipwhite +syn region PortfileDependsEntries matchgroup=Normal start="" skip="\\$" end="$" contains=PortfileDependsEntry contained +syn match PortfileDependsEntry "\<\%(port\|bin\|path\|lib\):" contained + +" StartupItems +syn match PortfileStartupPid "\<\%(none\|auto\|clean\|manual\)\>" contained +syn match PortfileOptional "\" +syn match PortfileOptional "\" nextgroup=PortfileYesNo skipwhite +syn match PortfileOptional "\" nextgroup=PortfileStartupPid skipwhite + +" Livecheck / Distcheck +syn match PortfileOptional "\" +syn keyword PortfileOptional distcheck.check + +" Notes +syn keyword PortfilePhases notes + +" Port Groups + +" App +syn match PortfileGroups "\" + +" Archcheck +syn match PortfileGroups "\" + +" CMake +" has no keywords + +" crossbinutils +syn match PortfileGroups "\" + +" crossgcc +syn match PortfileGroups "\" + +" github +syn match PortfileGroups "\" + +" Gnustep +syn match PortfileGroups "\" +syn keyword PortfileGroups variant_with_docs gnustep_layout +syn match PortfileGroups "\" + +" Haskell +syn keyword PortfileGroups haskell.setup + +" hocbinding +syn match PortfileGroups "\" + +" hunspelldict +syn match PortfileGroups "\" + +" KDE 4, versions 1.0 and 1.1 +" have no keywords + +" muniversal +syn match PortfileGroups "\" +syn match PortfileGroups "\" +syn match PortfileGroups "\" +syn match PortfileGroups "\" + +" obsolete +" has no keywords (other than replaced_by, and that should be elsewhere in +" this file) + +" ocml +" has no keywords + +" octave +syn match PortfileGroups "\" + +" PEAR +syn match PortfileGroups "\" + +" Perl5 +syn match PortfileGroups "\" + +" PHP 1.0 +syn match PortfileGroups "\" +syn match PortfileGroups "\" +" PHP 1.1 (only adding those not already present in 1.0) +syn match PortfileGroups "\" +syn match PortfileGroups "\" + +" PHP5 extension +syn match PortfileGroups "\" + +" PHP5 PEAR +syn match PortfileGroups "\" + +" Pure +syn match PortfileGroups "\" + +" Python +syn match PortfileGroups "\" +" I'm not documenting the Python{24,25,26,27,31,32} groups. Don't use them. + +" Qt4 +syn match PortfileGroups "\" +syn match PortfileGroups "\" +syn match PortfileGroups "\" + +" Ruby +syn match PortfileGroups "\" + +" Select +syn match PortfileGroups "\" + +" TeX Live +syn match PortfileGroups "\" + +" X11 Font +syn match PortfileGroups "\" + +" Xcode +syn match PortfileGroups "\" +syn match PortfileGroups "\" +syn match PortfileGroups "\" + +" Xcode version +syn match PortfileGroups "\" + +" Zope +syn match PortfileGroups "\" + +" End of PortGroups + + +" Tcl extensions +syn keyword PortfileTcl xinstall fs-traverse readdir md5 vercmp +syn keyword PortfileTcl reinplace strsed +syn keyword PortfileTcl copy move delete touch ln system +syn match PortfileTcl "\" +syn match PortfileTcl "\<\%(add\|exists\)\%(user\|group\)\>" +syn keyword PortfileTcl nextuid nextgid +syn keyword PortfileTcl variant_isset variant_set +syn match PortfileTcl "\" +syn keyword PortfileTcl lpush lpop lunshift lshift ldindex +syn keyword PortfileTcl ui_debug ui_error ui_info ui_msg ui_warn + +" check whitespace, copied from python.vim +if g:portfile_highlight_space_errors == 1 + " trailing whitespace + syn match PortfileSpaceError display excludenl "\S\s\+$"ms=s+1 + " mixed tabs and spaces + syn match PortfileSpaceError display " \+\t" + syn match PortfileSpaceError display "\t\+ " +endif + +hi def link PortfileGroup String +hi def link PortfileYesNo Special +hi def link PortfileStartupPid Special + +hi def link PortfileRequired Keyword +hi def link PortfileOptional Keyword +hi def link PortfileDescription String +hi def link PortfileChecksumsType Special + +hi def link PortfilePhases Keyword +hi def link PortfilePhasesFetch Keyword +hi def link PortfilePhasesExtract Keyword +hi def link PortfilePhasesPatch Keyword +hi def link PortfilePhasesConf Keyword +hi def link PortfilePhasesAA Keyword +hi def link PortfilePhasesBuild Keyword +hi def link PortfilePhasesTest Keyword +hi def link PortfilePhasesDest Keyword + +hi def link PortfileVariantConflicts Statement +hi def link PortfileVariantDescription Statement +hi def link PortfileVariantRequires Statement +hi def link PortfileVariantName Identifier +hi def link PortfileDefaultVariants Identifier + +hi def link PortfilePlatform Keyword +hi def link PortfilePlatformName Identifier +hi def link PortfilePlatformVersion tclNumber +hi def link PortfilePlatformArch Identifier + +hi def link PortfileSubportName Identifier + +hi def link PortfileDepends Keyword +hi def link PortfileDependsEntry Special +hi def link PortfileGroups Keyword + +hi def link PortfileTcl Keyword + +if g:portfile_highlight_space_errors == 1 + hi def link PortFileSpaceError Error +endif + +let b:current_syntax = "Portfile" -- cgit v1.2.3