diff --git a/sources_non_forked/guile.vim/COPYING.txt b/sources_non_forked/guile.vim/COPYING.txt new file mode 100644 index 00000000..5a4460a2 --- /dev/null +++ b/sources_non_forked/guile.vim/COPYING.txt @@ -0,0 +1,19 @@ +Copyright (c) 2019 HiPhish + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sources_non_forked/guile.vim/README.rst b/sources_non_forked/guile.vim/README.rst new file mode 100644 index 00000000..ba7e91a9 --- /dev/null +++ b/sources_non_forked/guile.vim/README.rst @@ -0,0 +1,42 @@ +.. default-role:: code + +########################### + GNU Guile support for Vim +########################### + +This plugin extends Vim's Scheme support to include the additions to the +language provided by the `GNU Guile`_ implementation. The plugin automatically +detects whether a Scheme file is a Guile file and adds syntax highlighting for +Guile's special forms. + + +Installation +############ + +Install this like any other Vim plugin. + + +Using the plugin +################ + +When a Guile buffer has been detected its `filetype` option will be set to the +value `scheme.guile`. This uses Vim's dotted file type (see `:h 'filetype'`) in +order to allow users to keep using their setting any plugins for Scheme in +addition to this. + +Guile is detected by either looking for a shebang in the first line (see +`4.3.1 The Top of a Script File`_ in the Guile manual), or by scanning the file +for an occurrence of `define-module` or `use-modules`. This is not absolutely +reliable, but it should work for the vast majority of cases. + + +License +####### + +Released under the MIT (Expat) license, see the COPYING_ file for details. + + +.. ---------------------------------------------------------------------------- +.. _GNU Guile: http://www.gnu.org/software/guile/ +.. _COPYING: COPYING.txt +.. _4.3.1 The Top of a Script File: info:guile.info#The%20Top%20of%20a%20Script%20File diff --git a/sources_non_forked/guile.vim/autoload/guile.vim b/sources_non_forked/guile.vim/autoload/guile.vim new file mode 100644 index 00000000..9739e3bf --- /dev/null +++ b/sources_non_forked/guile.vim/autoload/guile.vim @@ -0,0 +1,43 @@ +" License: The MIT License (MIT) {{{ +" Copyright (c) 2019 HiPhish +" +" Permission is hereby granted, free of charge, to any person obtaining a +" copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to permit +" persons to whom the Software is furnished to do so, subject to the +" following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +" NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +" USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} + +" ----------------------------------------------------------------------------- +" Detect whether the file is a Guile file. +" +" Try to find Guile-specific forms, e.g. the Guile shebang or a define-module +" expression. +" ----------------------------------------------------------------------------- +function! guile#detect() + " Guile uses the shebang in the first line + if getline(1) =~? '\v^#!.*[Gg]uile' + return 1 + endif + " Search for a module definition + let l:save_cursor = getcurpos() + call cursor(1, 1) + if search('\v\(\s*(define-module|use-modules)\s*\(', 'c', 0, 1000) + return 1 + endif + call setpos('.', l:save_cursor) + return 0 +endfunction diff --git a/sources_non_forked/guile.vim/ftdetect/scheme.vim b/sources_non_forked/guile.vim/ftdetect/scheme.vim new file mode 100644 index 00000000..ff2aa644 --- /dev/null +++ b/sources_non_forked/guile.vim/ftdetect/scheme.vim @@ -0,0 +1,36 @@ +" License: The MIT License (MIT) {{{ +" Copyright (c) 2019 HiPhish +" +" Permission is hereby granted, free of charge, to any person obtaining a +" copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to permit +" persons to whom the Software is furnished to do so, subject to the +" following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +" NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +" USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} + +" Safely adjust to file type to not include `guile` more than once +function! s:adjust_ft() + for l:ft in split(&filetype, '\v\.') + if l:ft == 'guile' + return + endif + endfor + let &ft.='.guile' +endfunction + +augroup filetypedetect + autocmd BufRead,BufNewFile *scm if guile#detect() | call s:adjust_ft() | endif +augroup end diff --git a/sources_non_forked/guile.vim/logo.svg b/sources_non_forked/guile.vim/logo.svg new file mode 100644 index 00000000..17265b1f --- /dev/null +++ b/sources_non_forked/guile.vim/logo.svg @@ -0,0 +1,184 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources_non_forked/guile.vim/makefile b/sources_non_forked/guile.vim/makefile new file mode 100644 index 00000000..9b2c45d3 --- /dev/null +++ b/sources_non_forked/guile.vim/makefile @@ -0,0 +1,6 @@ +VIM = nvim + +.PHONY: check + +check: + @VADER_OUTPUT_FILE=/dev/stdout $(VIM) --headless -c 'Vader! test/*.vader' diff --git a/sources_non_forked/guile.vim/syntax/guile.vim b/sources_non_forked/guile.vim/syntax/guile.vim new file mode 100644 index 00000000..d498af9e --- /dev/null +++ b/sources_non_forked/guile.vim/syntax/guile.vim @@ -0,0 +1,106 @@ +" License: The MIT License (MIT) {{{ +" Copyright (c) 2019 HiPhish +" +" Permission is hereby granted, free of charge, to any person obtaining a +" copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to permit +" persons to whom the Software is furnished to do so, subject to the +" following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +" NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +" USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} + +" GNU Guile syntax highlighting for extensions to Scheme +scriptencoding utf-8 + + +" ============================================================================= +" Multi-line comments, used for the shebang +syntax region guileComment start='\v<#!' end='\v!#' + +" Keywords +syntax match guileKeyword '\v<#:[^ ()]+>' + + +" ===[ Special keywords ]====================================================== +" Special keywords +syntax keyword guileSyntax define* +syntax keyword guileSyntax define-public +syntax keyword guileSyntax define-module +syntax keyword guileSyntax define-accessor +syntax keyword guileSyntax define-class +syntax keyword guileSyntax define-enumeration +syntax keyword guileSyntax define-inlinable +syntax keyword guileSyntax define-syntax-parameter + +syntax keyword guileSyntax λ +syntax keyword guileSyntax lambda* + +syntax keyword guileSyntax use-modules + +syntax keyword guileSyntax call-with-input-file +syntax keyword guileSyntax call-with-input-string +syntax keyword guileSyntax call-with-output-file +syntax keyword guileSyntax call-with-output-string +syntax keyword guileSyntax call-with-prompt +syntax keyword guileSyntax call-with-trace + +syntax keyword guileSyntax eval-when + +syntax keyword guileSyntax syntax-parameterize + +syntax keyword guileSyntax with-error-to-file +syntax keyword guileSyntax with-error-to-port +syntax keyword guileSyntax with-error-to-string +syntax keyword guileSyntax with-fluid* +syntax keyword guileSyntax with-fluids +syntax keyword guileSyntax with-fluids* +syntax keyword guileSyntax with-input-from-port +syntax keyword guileSyntax with-input-from-string +syntax keyword guileSyntax with-output-to-port +syntax keyword guileSyntax with-output-to-string + +" Macros +syntax keyword guileSyntaxSyntax define-syntax-rule + + +" ===[ Literals ]============================================================== +" Boolean literals +syntax keyword guileBoolean #true +syntax keyword guileBoolean #false + +" Unspecified literal (e.g. the return value of '(if #f #f)') +syntax match guileConstant '\v<#\>' + +" Byte vector literal +syntax match guileQuote '\v<\zs#vu8\ze\(' + +" Number literals +syntax match guileNumber '\v<#[bB][+-]?[0-1]+>' +syntax match guileNumber '\v<#[oO][+-]?[0-7]+>' +syntax match guileNumber '\v<#[dD][+-]?\d+>' +syntax match guileNumber '\v<#[xX][+-]?[0-9a-fA-F]+>' +syntax match guileNumber '\v<#[eE][+-]?(\d+\.\d*|\d*\.\d+|\d+)>' " Exact +syntax match guileNumber '\v<(\+|-)(inf|nan)\.0>' " NaN and infinity + + +" ============================================================================= +highlight link guileComment schemeComment +highlight link guileQuote schemeQuote +highlight link guileSyntax schemeSyntax +highlight link guileSyntaxSyntax schemeSyntaxSyntax +highlight link guileBoolean schemeBoolean +highlight link guileConstant schemeConstant +highlight link guileNumber schemeNumber +highlight link guileKeyword Type diff --git a/sources_non_forked/guile.vim/test/detect.vader b/sources_non_forked/guile.vim/test/detect.vader new file mode 100644 index 00000000..9771ba55 --- /dev/null +++ b/sources_non_forked/guile.vim/test/detect.vader @@ -0,0 +1,25 @@ +# Test whether Guile is being detected +Given (Detect by shebang): + #!/usr/local/bin/guile -s + !# +Execute: + Assert guile#detect() + +Given (Detect by define-module): + (define-module (foo bar)) +Execute: + Assert guile#detect() + +Given (Detect by use-modules): + (use-modules (foo bar)) +Execute: + Assert guile#detect() + + +----------------------------------------------------------------------------- +# Test whether the file type is adjusted when a Guile file is edited +Execute (File type adjustment): + edit test/nonsense.scm +Then: + AssertEqual 'scheme.guile', &ft + bwipeout! diff --git a/sources_non_forked/guile.vim/test/nonsense.scm b/sources_non_forked/guile.vim/test/nonsense.scm new file mode 100644 index 00000000..449b1b04 --- /dev/null +++ b/sources_non_forked/guile.vim/test/nonsense.scm @@ -0,0 +1,7 @@ +#!/usr/local/bin/guile -s +!# + +;;; This is a nonsense file, meant to test whether the file type is adjusted +;;; properly. The Guile detection itself is tested separately. +(display "Hello from Guile!") +(newline) diff --git a/sources_non_forked/guile.vim/test/syntax.vader b/sources_non_forked/guile.vim/test/syntax.vader new file mode 100644 index 00000000..738eabfa --- /dev/null +++ b/sources_non_forked/guile.vim/test/syntax.vader @@ -0,0 +1,119 @@ +# Note: For simplicity we will not check the syntax highlighting of fixed +# keywords like 'define-public', only the highlighting of patterns + + +Given scheme.guile (Multi-line comment): + #!/usr/local/bin/guile -s + !# + #! This is a + multi-line comment !# + +Execute: + for i in range(1, 25) + AssertEqual 'guileComment', SyntaxAt(1, i) + endfor + AssertEqual 'guileComment', SyntaxAt(2, 1) + AssertEqual 'guileComment', SyntaxAt(2, 2) + for i in range(1, 12) + AssertEqual 'guileComment', SyntaxAt(3, i) + endfor + for i in range(1, 21) + AssertEqual 'guileComment', SyntaxAt(4, i) + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (keywords): + #:keyword + #:key-word + +Execute: + for i in range(1, 9) + AssertEqual 'guileKeyword', SyntaxAt(1, i) + endfor + for i in range(1, 10) + AssertEqual 'guileKeyword', SyntaxAt(2, i) + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Boolean literals): + #true + #false + +Execute: + for i in range(1, 5) + AssertEqual 'guileBoolean', SyntaxAt(1, i) + endfor + for i in range(1, 6) + AssertEqual 'guileBoolean', SyntaxAt(2, i) + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Unspecified object representation): + # + +Execute: + for i in range(1, 14) + AssertEqual 'guileConstant', SyntaxAt(1, i) + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Bytevector literal): + #vu8(1 2 3 4) + +Execute: + for i in range(1, 4) + AssertEqual 'guileQuote', SyntaxAt(1, i) + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Integer number literals): + #b0101 #b+0101 #b-0101 #B0101 #B+0101 #B-0101 + #o0237 #o+0237 #o-0237 #O0237 #O+0237 #O-0237 + #d0239 #d+0239 #d-0239 #D0239 #D+0239 #D-0239 + #x03AF #x+03AF #x-03AF #X03AF #X+03AF #X-03AF + #x03af #x+03af #x-03af #X03af #X+03af #X-03af + +Execute: + for i in range(1, 5) + for j in range(1, 6) + for k in [0, 7, 15, 23, 30, 38] + AssertEqual 'guileNumber', SyntaxAt(i, k + j) + endfor + endfor + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Exact decimal number literls): + #e012345 #e+01234 #e-01234 #E012345 #E+01234 #E-01234 + #e.12345 #e+.1234 #e-.1234 #E.12345 #E+.1234 #E-.1234 + #e0.1234 #e+0.123 #e-0.123 #E0.1234 #E+0.123 #E-0.123 + +Execute: + for line in [1, 2] + for offset in range(0, 5) + for column in range(1, 8) + AssertEqual 'guileNumber', SyntaxAt(line, offset * 9 + column) + endfor + endfor + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Infinity and NaN literals): + +inf.0 -inf.0 +nan.0 -nan.0 + +Execute: + for offset in range(0, 3) + for i in range(1, 6) + AssertEqual 'guileNumber', SyntaxAt(1, offset * 7 + i) + endfor + endfor + +----------------------------------------------------------------------------- +Given scheme.guile (Syntax-rule macro): + (define-syntax-rule (first-of expr expr* ...) + expr) + +Execute: + for i in range(2, 19) + AssertEqual 'guileSyntaxSyntax', SyntaxAt(1, i) + endfor