[m-rev.] for review: Aligning the Vim syntax file to match the Mercury language more closely
Sebastian Godelet
sebastian.godelet+github at gmail.com
Mon Oct 27 17:10:44 AEDT 2014
Fixed escaping of the escape character in strings,
added more details to the Vim README and
moved file type detection to vim/ftdetect,
such that one can use
$ cp -r vim/ ~/.vim
to copy the Vim syntax files without conflicts.
vim/README:
Removed warning about ~/.vim/after/filetype.vim,
add utf-8 encoding detection.
vim/after/filetype.vim:
moved to vim/ftdetect/mercury.vim.
vim/syntax/mercury.vim:
see above.
diff --git a/vim/README b/vim/README
index fc24187..30e0650 100644
--- a/vim/README
+++ b/vim/README
@@ -1,4 +1,4 @@
-Mercury Syntax Highlighting Under Vim 6.0
+Mercury Syntax Highlighting Under Vim 6.0+
1. Create a diretory `~/.vim':
@@ -8,24 +8,31 @@ Mercury Syntax Highlighting Under Vim 6.0
$ cp -r . ~/.vim
-IMPORTANT: If you already have a file `~/.vim/after/filetype.vim' then you
-should copy the files from this directory one by one, except for
-`after/filetype.vim' which you should append to your own
-`~/.vim/after/filetype.vim'.
-
3. Ensure you have the following lines in your `~/.vimrc' file:
filetype on
filetype plugin on
syntax enable
+ set modeline
+
+4. It is advisable to have the following file encoding detection lines
+in your ~/.vimrc:
-4. If you wish to change the colour scheme used by Vim's syntax highlighting,
+ if has("multi_byte")
+ set encoding=utf-8
+ setglobal fileencoding=utf-8
+ if &termencoding == ""
+ let &termencoding = &encoding
+ endif
+ endif
+
+5. If you wish to change the colour scheme used by Vim's syntax highlighting,
we suggest you put the necessary commands in `~/.vim/colors/mycolours.vim'
and append the following to the above list of commands in your `~/.vimrc':
colors mycolours
-4. Vim will load `~/.vim/syntax/mercury.vim' and `~/.vim/ftplugin/mercury.vim'
+6. Vim will load `~/.vim/syntax/mercury.vim' and `~/.vim/ftplugin/mercury.vim'
automatically when opening a .m or .moo file.
The syntax file describes two options you may wish to alter from your
@@ -33,3 +40,6 @@ The syntax file describes two options you may wish
to alter from your
The ftplugin file defines a number of useful keyboard mappings you may wish to
consider.
+
+If you want to add a custom extension for Mercury source files, then modify the
+ftdetect/mercury.vim file. Currently .m and .moo are recognised.
diff --git a/vim/after/filetype.vim b/vim/after/filetype.vim
deleted file mode 100644
index 97f9076..0000000
--- a/vim/after/filetype.vim
+++ /dev/null
@@ -1,6 +0,0 @@
-" filetype.vim
-" vim: ts=2 sw=2 et
-
-augroup filetypedetect
- au! BufRead,BufNewFile *.m,*.moo setfiletype mercury
-augroup END
diff --git a/vim/ftdetect/mercury.vim b/vim/ftdetect/mercury.vim
new file mode 100644
index 0000000..b535dcf
--- /dev/null
+++ b/vim/ftdetect/mercury.vim
@@ -0,0 +1,4 @@
+" mercury.vim
+" vim: ts=2 sw=2 et
+
+au! BufRead,BufNewFile *.m,*.moo setfiletype mercury
diff --git a/vim/syntax/mercury.vim b/vim/syntax/mercury.vim
index 9d37f94..03ddf7a 100644
--- a/vim/syntax/mercury.vim
+++ b/vim/syntax/mercury.vim
@@ -78,7 +78,7 @@ syn match mercuryImplication +<=>\|<=\|=>\|/\\\|\\/+
syn match mercuryNumCode +0'.\|0[box][0-9a-fA-F]*+
syn region mercuryAtom start=+'+ skip=+\\.+ end=+'+
syn region mercuryString start=+"+ skip=+\\.+ end=+"+
contains=mercuryStringFmt
-syn match mercuryStringFmt
+\\[abfnrtv]\|\\x[0-9a-fA-F]*\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]+
contained
+syn match mercuryStringFmt
/\\[abfnrtv\\"]\|\\x[0-9a-fA-F]\+\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]/
contained
syn region mercuryClauseHead start=+^[a-zA-Z]+
end=+=\|:-\|\.\s*$\|-->+
contains=mercuryComment,mercuryCComment,mercuryAtom,mercuryString
syn region mercuryCComment start=+/\*+ end=+\*/+
contains=mercuryToDo
if !exists("mercury_no_highlight_overlong") || !mercury_no_highlight_overlong
More information about the reviews
mailing list