Align the Vim syntax file to match the Mercury language more closely

vim/README:
    Removed warning about ~/.vim/after/filetype.vim,

    Add utf-8 encoding detection.

    Added more details to the Vim README and

vim/after/filetype.vim:
vim/ftdetect/mercury.vim.
    Renamed file type detection for Mercury to ftdetect/mercury.vim.  This
    allows one to install the vim configuration files with a single command:
    $ cp -r vim/ ~/.vim

vim/syntax/mercury.vim:
    Fixed escaping of the escape character in strings,
This commit is contained in:
Sebastian Godelet
2014-10-27 14:10:44 +08:00
committed by Paul Bone
parent fe785c668b
commit 3f9ec5c79d
4 changed files with 23 additions and 14 deletions

View File

@@ -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. If you wish to change the colour scheme used by Vim's syntax highlighting,
4. It is advisable to have the following file encoding detection lines
in your ~/.vimrc:
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.

View File

@@ -1,6 +0,0 @@
" filetype.vim
" vim: ts=2 sw=2 et
augroup filetypedetect
au! BufRead,BufNewFile *.m,*.moo setfiletype mercury
augroup END

4
vim/ftdetect/mercury.vim Normal file
View File

@@ -0,0 +1,4 @@
" mercury.vim
" vim: ts=2 sw=2 et
au! BufRead,BufNewFile *.m,*.moo setfiletype mercury

View File

@@ -79,6 +79,7 @@ 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