Problem:    scdoc files are not recognized
Solution:   Recognize .scd files
---
I am the author and maintainer of the vim-scdoc plugin. [scdoc] is a 
lightweight manpage generator and is stable: the syntax file should not 
need to be updated frequently. I'd like to upstream these files for 
inclusion in Vim.

This is my first contribution to Vim, so please provide feedback if I 
need to do anything differently.

 runtime/filetype.vim          |  3 ++
 runtime/ftplugin/scdoc.vim    | 26 ++++++++++++++++++
 runtime/syntax/scdoc.vim      | 52 +++++++++++++++++++++++++++++++++++
 src/testdir/test_filetype.vim |  1 +
 src/version.c                 |  2 ++
 5 files changed, 84 insertions(+)
 create mode 100644 runtime/ftplugin/scdoc.vim
 create mode 100644 runtime/syntax/scdoc.vim

diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index e14d80fd8..648a19d9e 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1526,6 +1526,9 @@ au BufNewFile,BufRead *.sbt                       setf sbt
 " Scilab
 au BufNewFile,BufRead *.sci,*.sce              setf scilab
 
+" scdoc
+au BufNewFile,BufRead *.scd                    setf scdoc
+
 " SCSS
 au BufNewFile,BufRead *.scss                   setf scss
 
diff --git a/runtime/ftplugin/scdoc.vim b/runtime/ftplugin/scdoc.vim
new file mode 100644
index 000000000..2e98e647f
--- /dev/null
+++ b/runtime/ftplugin/scdoc.vim
@@ -0,0 +1,26 @@
+" scdoc filetype plugin
+" Maintainer: Gregory Anders <g...@gpanders.com>
+" Last Updated: 2021-08-04
+
+" Only do this when not done yet for this buffer
+if exists('b:did_ftplugin')
+    finish
+endif
+
+" Don't load another plugin for this buffer
+let b:did_ftplugin = 1
+
+setlocal comments=b:;
+setlocal commentstring=;%s
+setlocal formatoptions+=t
+setlocal noexpandtab
+setlocal shiftwidth=0
+setlocal softtabstop=0
+setlocal textwidth=80
+
+let b:undo_ftplugin = 'setl com< cms< fo< et< sw< sts< tw<'
+
+if has('conceal')
+    setlocal conceallevel=2
+    let b:undo_ftplugin .= ' cole<'
+endif
diff --git a/runtime/syntax/scdoc.vim b/runtime/syntax/scdoc.vim
new file mode 100644
index 000000000..25c9c5433
--- /dev/null
+++ b/runtime/syntax/scdoc.vim
@@ -0,0 +1,52 @@
+" Syntax file for scdoc files
+" Maintainer: Gregory Anders <g...@gpanders.com>
+" Last Updated: 2021-08-04
+
+if exists('b:current_syntax')
+    finish
+endif
+let b:current_syntax = 'scdoc'
+
+syntax match scdocFirstLineError "\%^.*$"
+syntax match scdocFirstLineValid 
"\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$"
+
+syntax region scdocCommentError start="^;\S" end="$" keepend
+syntax region scdocComment start="^; " end="$" keepend
+
+syntax region scdocHeaderError start="^#\{3,}" end="$" keepend
+syntax region scdocHeader start="^#\{1,2}" end="$" keepend
+
+syntax match scdocIndentError "^[ ]\+"
+
+syntax match scdocLineBreak "++$"
+
+syntax match scdocOrderedListMarker "^\s*\.\%(\s\+\S\)\@="
+syntax match scdocListMarker "^\s*-\%(\s\+\S\)\@="
+
+syntax match scdocTableStartMarker "^[\[|\]][\[\-\]]"
+syntax match scdocTableMarker "^[|:][\[\-\] ]"
+
+syntax region scdocBold concealends matchgroup=scdocBoldDelimiter 
start="\\\@<!\*" end="\\\@<!\*"
+syntax region scdocUnderline concealends matchgroup=scdocUnderlineDelimiter 
start="\<\\\@<!_" end="\\\@<!_\>"
+syntax region scdocPre matchgroup=scdocPreDelimiter start="^\t*```" 
end="^\t*```"
+
+hi link scdocFirstLineValid     Comment
+hi link scdocComment            Comment
+hi link scdocHeader             Title
+hi link scdocOrderedListMarker  Statement
+hi link scdocListMarker         scdocOrderedListMarker
+hi link scdocLineBreak          Special
+hi link scdocTableMarker        Statement
+hi link scdocTableStartMarker   scdocTableMarker
+
+hi link scdocFirstLineError     Error
+hi link scdocCommentError       Error
+hi link scdocHeaderError        Error
+hi link scdocIndentError        Error
+
+hi link scdocPreDelimiter       Delimiter
+
+hi scdocBold term=bold cterm=bold gui=bold
+hi scdocUnderline term=underline cterm=underline gui=underline
+hi link scdocBoldDelimiter scdocBold
+hi link scdocUnderlineDelimiter scdocUnderline
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 4f94b96e7..cd40b6d3c 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -433,6 +433,7 @@ let s:filename_checks = {
     \ 'scilab': ['file.sci', 'file.sce'],
     \ 'screen': ['.screenrc', 'screenrc'],
     \ 'sexplib': ['file.sexp'],
+    \ 'scdoc': ['file.scd'],
     \ 'scss': ['file.scss'],
     \ 'sd': ['file.sd'],
     \ 'sdc': ['file.sdc'],
diff --git a/src/version.c b/src/version.c
index 35bb3910a..1b1f7a605 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3284,
 /**/
     3283,
 /**/
-- 
2.32.0

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20210804171333.88508-1-greg%40gpanders.com.

Reply via email to