diff --git a/vim/README b/vim/README new file mode 100644 index 0000000..0719b1f --- /dev/null +++ b/vim/README @@ -0,0 +1,18 @@ +This is vim support for kdesrc-build. To use, place ftdetect/kdesrc-buildrc.vim +in your $VIMRUNTIME/ftdetect folder (create the folder if necessary, +$VIMRUNTIME is normally ~/.vim). This detects kdesrc-buildrc files. + +Additionally place syntax/kdesrc-buildrc.vim in the $VIMRUNTIME/syntax folder +(again, create if necessary). This allows Vim to properly highlight your +kdesrc-buildrc when it's detected. + +Use ":set ft" to see what filetype is detected if it doesn't work. + +The highlighting is quite simplistic, many improvements could easily be made for +those with interest and some free time.... + +NOTE: Kate and kwrite support is included in the "kdesrc-buildrc.xml" file that has +been included and updated with kdesrc-build for years. Improvements to that are +encouraged as well. :) + + - Michael Pyne, mpyne@kde.org, 2014 Aug 08 diff --git a/vim/ftdetect/kdesrc-buildrc.vim b/vim/ftdetect/kdesrc-buildrc.vim new file mode 100644 index 0000000..911dc94 --- /dev/null +++ b/vim/ftdetect/kdesrc-buildrc.vim @@ -0,0 +1,5 @@ +" Sample code as taken from vim 7.4.273 syntax documentation. + +au BufRead,BufNewFile ~/.kdesrc-buildrc,kdesrc-buildrc* set filetype=kdesrc-buildrc + +" vim: set ft=vim: diff --git a/vim/syntax/kdesrc-buildrc.vim b/vim/syntax/kdesrc-buildrc.vim new file mode 100644 index 0000000..5f65467 --- /dev/null +++ b/vim/syntax/kdesrc-buildrc.vim @@ -0,0 +1,150 @@ +" Vim syntax file +" Language: kdesrc-build configuration file +" Maintainer: Michael Pyne +" Latest Revision: 8 August 2014 + +" Copyright (c) 2014 Michael Pyne +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions +" are met: +" +" 1. Redistributions of source code must retain the above copyright +" notice, this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +if exists("b:current_syntax") + finish +endif + +syn case match + +" We use Lisp-style keywords +setlocal iskeyword+=- + +" Keywords +syn keyword ksbrcOption contained skipwhite nextgroup=ksbrcStringValue + \ binpath branch build-dir checkout-only cmake-options configure-flags + \ custom-build-command cxxflags dest-dir do-not-compile kdedir + \ libpath log-dir make-install-prefix make-options module-base-path + \ override-build-system override-url prefix qtdir repository + \ revision source-dir svn-server tag remove-after-install + +syn keyword ksbrcGlobalOption contained skipwhite nextgroup=ksbrcStringValue + \ branch-group git-desired-protocol git-repository-base http-proxy + \ kde-languages niceness debug-level persistent-data-file set-env + +" MUST BE CONSISTENT WITH ABOVE. Used when a module-set option is used in the +" wrong spot to highlight the error. +syn keyword ksbrcErrorGlobalOption contained skipwhite nextgroup=ksbrcStringValue + \ branch-group git-desired-protocol git-repository-base http-proxy + \ kde-languages niceness debug-level persistent-data-file set-env + +syn keyword ksbrcModuleSetOption contained skipwhite nextgroup=ksbrcStringValue + \ use-modules ignore-modules + +" MUST BE CONSISTENT WITH ABOVE. Used when a module-set option is used in the +" wrong spot to highlight the error. +syn keyword ksbrcErrorModuleSetOption contained skipwhite nextgroup=ksbrcStringValue + \ use-modules ignore-modules + +syn keyword ksbrcBoolOption contained skipwhite nextgroup=ksbrcBoolValue + \ build-system-only build-when-unchanged ignore-kde-structure + \ install-after-build install-session-driver manual-build manual-update + \ no-src reconfigure recreate-configure refresh-build run-tests + \ use-clean-install + +syn keyword ksbrcGlobalBoolOption contained skipwhite nextgroup=ksbrcBoolValue + \ async colorful-output disable-agent-check disable-snapshot pretend + \ purge-old-logs stop-on-failure use-idle-io-priority + +" MUST BE CONSISTENT WITH ABOVE. Used when a global option is used in the +" wrong spot to highlight the error. +syn keyword ksbrcErrorBoolOption contained skipwhite nextgroup=ksbrcBoolValue + \ async colorful-output disable-agent-check disable-snapshot pretend + \ purge-old-logs stop-on-failure use-idle-io-priority + +" Matches +syn match ksbrcKeyword "\" +syn match ksbrcKeyword "\" +syn match ksbrcKeyword "\" +syn match ksbrcKeyword "\" + + +syn match ksbrcPath "\S*$" contained +syn match ksbrcKeyword "^\s*include\>" skipwhite nextgroup=ksbrcPath + +" This is a 'region' instead of a match to allow line continuations to work (a +" match will never break across lines). 100% accuracy would demand that all +" possible values/lines can be broken, but it makes no sense other than option +" values so that's where I'll leave it for now. +" +" Since we're using a region we need to stop before comments manually, or stop +" at EOL if there are no comments (which is why there's multiple end=). The +" me=s-1 part to the 'end before comment' clause ensures that the comment and +" any preceding whitespace isn't 'eaten up' by this match. +syn region ksbrcStringValue start="\S" end="$" end="\s*#"me=s-1 contained contains=ksbrcLineContinue + +syn match ksbrcBoolValue "\c\" contained + +syn match ksbrcComment "#.*$" + +" Regions +syn region ksbrcModuleSetRegion fold matchgroup=ksbrcKeyword + \ start="module-set\>" end="end module-set" + \ contains=ksbrcComment,ksbrcOption,ksbrcModuleSetOption,ksbrcBoolOption,ksbrcErrorBoolOption,ksbrcErrorGlobalOption +syn region ksbrcGlobalRegion fold matchgroup=ksbrcKeyword + \ start="global\>" end="end global" + \ contains=ksbrcComment,ksbrcOption,ksbrcGlobalOption,ksbrcGlobalBoolOption,ksbrcBoolOption,ksbrcErrorModuleSetOption + +" These two regions should be about equivalent. Probably could just duplicate +" the start= and end=, which vim supports, except that the end might not match +" the corresponding start= +syn region ksbrcModuleRegion fold matchgroup=ksbrcKeyword + \ start='module\>\(-set\)\@!' end='end module' + \ contains=ksbrcComment,ksbrcOption,ksbrcBoolOption,ksbrcErrorBoolOption,ksbrcErrorModuleSetOption,ksbrcErrorGlobalOption +syn region ksbrcOptionsRegion fold matchgroup=ksbrcKeyword + \ start="options\>" end="end options" + \ contains=ksbrcComment,ksbrcOption,ksbrcBoolOption,ksbrcErrorBoolOption,ksbrcErrorModuleSetOption,ksbrcErrorGlobalOption + +" Handle continuation lines +syn match ksbrcLineContinue "\\$" contained + +" Footer boilerplate +let b:current_syntax = "kdesrc-buildrc" + +" Help vim find where to start highlighting (I think...) +syn sync match SyncRegionEnd grouphere NONE "^\s*end\s\+\(module\|module-set\|options\)\s*$" + +" Link our styles to standard styles +hi def link ksbrcKeyword Keyword +hi def link ksbrcComment Comment +hi def link ksbrcPath Include +hi def link ksbrcStringValue String +hi def link ksbrcBoolValue Boolean + +hi def link ksbrcOption Identifier +hi def link ksbrcGlobalOption Identifier +hi def link ksbrcBoolOption Identifier +hi def link ksbrcGlobalBoolOption Identifier +hi def link ksbrcModuleSetOption Identifier + +hi def link ksbrcLineContinue Special + +hi def link ksbrcErrorBoolOption Error +hi def link ksbrcErrorModuleSetOption Error +hi def link ksbrcErrorGlobalOption Error + +" vim: set ft=vim: