[m-rev.] Added vim directory to distribution

Ralph Becket rafe at cs.mu.OZ.AU
Wed Mar 13 18:48:04 AEDT 2002


Estimated hours taken: 2
Branches: main

Files and instructions for adding Mercury syntax highlighting under Vim.

NEWS:
	Mention the new directory.

vim:
vim/README:
vim/mercury.vim:
vim/mercuryhdr.sh:
vim/myfiletypes.vim:
vim/mysyntax.vim:
	New directory added and populated.

bindist/Mmakefile:
	Added VIM_FILES variable and commands to create
	$(MERCURY_VERSION)/vim if necessary and populate it.

Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.250
diff -u -r1.250 NEWS
--- NEWS	12 Mar 2002 16:32:21 -0000	1.250
+++ NEWS	13 Mar 2002 07:45:25 -0000
@@ -255,6 +255,12 @@
 * The `--convert-to-goedel' option has been removed.
   It never really worked anyway.
 
+Changes to the Mercury distribution:
+
+* A new `vim' directory has been added to the distribution containing
+  the necessary files and information to support syntax highlighting
+  for Mercury under Vim.
+
 NEWS for Mercury release 0.10.1:
 --------------------------------
 
Index: README
===================================================================
RCS file: README
diff -N README
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ README	13 Mar 2002 06:56:57 -0000
@@ -0,0 +1,31 @@
+To use the Mercury syntax highlighting file presented here for Vim do
+the following (if you have a slightly different vim set-up you will
+have to change the directory and file names listed below as
+appropriate and possibly edit the `mercury.vim' file.)
+
+1. Create a directory `~/vim'.
+
+2. Copy `mercury.vim' into `~/vim' (you will need to edit the
+`au! Syntax mercury so $HOME/vim/mercury.vim' line in `mysyntax.vim'
+if you put this file elsewhere.)
+
+3. Copy `mercuryhdr.sh' into `~/vim' (you will need to edit the
+`nnoremap <C-X>h' line in `mercury.vim' if you put this elsewhere.)
+You can omit this step if you do not intend to use `<C-X>h'.
+
+4. Either copy `myfiletypes.vim' and `mysyntax.vim' into `~/vim' or
+include their contents in your own versions of these files.
+
+5. Include the following lines in your `.vimrc' file:
+
+  let myfiletypefile = "$HOME/vim/myfiletypes.vim"
+  let mysyntaxfile   = "$HOME/vim/mysyntax.vim"
+
+6. By default, only the opening comment characters and not the text of
+Mercury comments is highlighted.  If you prefer to have the comment
+text highlighted as well add the following line to your `.vimrc' file:
+
+  let mercury_highlight_full_comment = 1
+
+7. The `mercury.vim' file is worth a brief perusal.
+

Index: mercury.vim
===================================================================
RCS file: mercury.vim
diff -N mercury.vim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mercury.vim	13 Mar 2002 07:12:35 -0000
@@ -0,0 +1,137 @@
+" Vim syntax file
+" Language:     Mercury
+" Maintainer:   Ralph Becket <rafe at cs.mu.oz.au>
+" ts=2 sw=2 et
+
+  " I find it handy to run `mtags' over the Mercury library .m files
+  " and move the resulting tags file to `$HOME/mercury/tags.library'.
+  "
+set tags=./tags,$HOME/mercury/tags.library,$HOME/mercury/tags.compiler
+
+  " Handy if you use `:make'.
+  "
+set makeprg=mmake
+
+  " Don't wrap over-long lines.
+  "
+set wrapmargin=0
+set textwidth=0
+
+  " These settings allow for neater coding styles, but
+  " should not be imposed on existing files that use,
+  " say, the default `tabstop=8, shiftwidth=8, noexpandtab'.
+  "
+  " It is a good idea to have a modeline comment at the top
+  " of your Mercury source files containing
+  " ` vim: ft=mercury ff=unix ts=4 sw=4 et '
+  "
+" set tabstop=8
+" set shiftwidth=8
+" set expandtab   
+
+  " Controls how autoindenting works.  See the Vim help pages for details.
+  "
+set formatoptions=trcq
+
+  " <C-X>l inserts a comment line.
+  "
+nnoremap <C-X>l o0<C-D>%------------------------------------------------------------------------------%<CR><ESC>x
+inoremap <C-X>l --------------------------------------------------------------------------------<ESC>80<BAR>C%<CR>
+
+  " <F6> attempts to wrap a call up with { } braces for DCG escapes.
+  "
+nnoremap <F6> I{ <ESC>%a }<ESC>j
+
+  " <F7> and <F8> comment and uncomment lines out respectively.
+  "
+nnoremap <F7> 0i% <ESC>j
+nnoremap <F8> :s/% //e<CR>j
+
+  " <C-X>h runs `$HOME/vim/mercuryhdr.sh' which inserts all the
+  " usual boilerplate for a new Mercury module.
+  "
+nnoremap <C-X>h !!$HOME/vim/mercuryhdr.sh %<CR>:set filetype=mercury<CR>
+
+  " Go to the bottom window and rerun the last mmake command.
+  " Reload any .err buffers that have changed.
+  "
+nnoremap ,m <C-W>b:!mmake<UP><CR>
+autocmd! FileChangedShell *.err vi!
+
+  " Remove any old syntax stuff hanging around.
+  "
+syn clear
+
+  " Mercury is case sensitive.
+  "
+syn case match
+
+  " The default highlighting for Mercury comments is to only highlight the
+  " initial `%' and subsequent `line' punctuation characters.  To highlight
+  " everything including the comment text, add
+  "
+  "   let mercury_highlight_full_comment = 1
+  "
+  " somewhere in your `.vimrc' file.
+  "
+if exists("mercury_highlight_full_comment") && mercury_highlight_full_comment
+  syn region  mercuryComment      start=+%+ end=+.*$+                                           contains=mercuryToDo
+else
+  syn region  mercuryComment      start=+%[-=%*_]*+ end=+.*$+he=s-1                             contains=mercuryToDo
+endif
+syn keyword mercuryKeyword      module use_module import_module
+syn keyword mercuryKeyword      include_module end_module
+syn keyword mercuryKeyword      interface implementation
+syn keyword mercuryKeyword      pred mode func type inst 
+syn keyword mercuryKeyword      is semidet det nondet multi erroneous
+syn keyword mercuryKeyword      cc_nondet cc_multi
+syn keyword mercuryKeyword      typeclass instance where
+syn keyword mercuryKeyword      pragma promise
+syn keyword mercuryPragma       inline no_inline
+syn keyword mercuryPragma       type_spec source_file fact_table
+syn keyword mercuryPragma       memo loop_check minimal_model
+syn keyword mercuryPragma       terminates does_not_terminate check_termination
+syn keyword mercuryCInterface   c_header_code c_code
+syn keyword mercuryCInterface   foreign_proc foreign_header foreign_code
+syn keyword mercuryCInterface   may_call_mercury will_not_call_mercury
+syn keyword mercuryCInterface   thread_safe not_thread_safe
+syn keyword mercuryCInterface   promise_pure promise_semipure
+syn keyword mercuryImpure       impure semipure
+syn keyword mercuryToDo         XXX TODO NOTE         
+syn keyword mercuryLogical      some all not if then else true fail
+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,mercuryCComment
+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
+syn match   mercuryFirst80 +^.\{80}+                                                          contains=ALL
+syn match   mercuryTooLong +^.\{81,}+                                                         contains=mercuryFirst80
+
+syn sync fromstart
+
+if !exists("did_mercury_syntax_inits")
+
+  let did_mercury_syntax_inits = 1
+
+  hi link mercuryComment        Comment
+  hi link mercuryCComment       Comment
+  hi link mercuryNumCode        Special
+  hi link mercuryImpure         Special
+  hi link mercuryKeyword        Keyword
+  hi link mercuryPragma         PreProc
+  hi link mercuryCInterface     PreProc
+  hi link mercuryToDo           Todo
+  hi link mercuryLogical        Special
+  hi link mercuryImplication    Special
+  hi link mercuryClauseHead     Statement
+  hi link mercuryString         String
+  hi link mercuryStringFmt      Special
+  hi link mercuryAtom           Constant
+  hi link mercuryTooLong        ErrorMsg
+
+endif
+
+let b:current_syntax = "mercury"
+

Index: mercuryhdr.sh
===================================================================
RCS file: mercuryhdr.sh
diff -N mercuryhdr.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mercuryhdr.sh	13 Mar 2002 07:11:49 -0000
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+cat <<EOF
+%------------------------------------------------------------------------------%
+% $1
+% $([ -n "$USERNAME" ] && echo $USERNAME "")<$USER@$(hostname -d)>
+% $(date)
+% vim: ft=mercury ff=unix ts=4 sw=4 et wm=0 tw=0
+%
+%------------------------------------------------------------------------------%
+
+:- module $(echo $1 | sed 's/\./__/g;s/__m$//').
+
+:- interface.
+
+:- import_module io.
+
+
+
+:- pred main(io::di, io::uo) is det.
+
+%------------------------------------------------------------------------------%
+%------------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module .
+
+%------------------------------------------------------------------------------%
+
+main -->
+
+%------------------------------------------------------------------------------%
+%------------------------------------------------------------------------------%
+EOF

Index: myfiletypes.vim
===================================================================
RCS file: myfiletypes.vim
diff -N myfiletypes.vim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ myfiletypes.vim	13 Mar 2002 07:18:15 -0000
@@ -0,0 +1,10 @@
+" myfiletypes.vim
+"
+" Copy this file into your `~/vim' directory.  Alternatively, edit your
+" own myfiletypes.vim file to include the lines below.
+"
+" See also `mysyntax.vim'.
+
+augroup filetype
+  au! BufRead,BufNewFile	*.m,*.moo	set filetype=mercury
+augroup END

Index: mysyntax.vim
===================================================================
RCS file: mysyntax.vim
diff -N mysyntax.vim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mysyntax.vim	13 Mar 2002 07:17:44 -0000
@@ -0,0 +1,9 @@
+" mysyntax.vim
+"
+" Copy this file into your `~/vim' directory.  Edit this file appropriately
+" if you place `mercury.vim' in a different location.  Alternatively, edit
+" your own mysyntax.vim file to include the line below.
+"
+" See also `myfiletypes.vim'.
+
+au! Syntax mercury  so $HOME/vim/mercury.vim

Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/Mmakefile,v
retrieving revision 1.30
diff -u -r1.30 Mmakefile
--- Mmakefile	9 May 2001 17:32:45 -0000	1.30
+++ Mmakefile	13 Mar 2002 07:41:56 -0000
@@ -38,6 +38,8 @@
 		  ../scripts/canonical_grade \
 		  ../scripts/gud.el
 
+VIM_FILES	= ../vim/*
+
 CONFIG_FILES	= ../config.sub ../config.guess ../install-sh
 
 # These files have a local version bindist.$filename which will be
@@ -76,6 +78,8 @@
 	cp $(SCRIPT_FILES) $(MERCURY_VERSION)/scripts
 	test -d $(MERCURY_VERSION)/util || mkdir $(MERCURY_VERSION)/util
 	cp $(UTILS) $(MERCURY_VERSION)/util
+	test -d $(MERCURY_VERSION)/vim || mkdir $(MERCURY_VERSION)/vim
+	cp $(VIM_FILES) $(MERCURY_VERSION)/vim
 	cp $(CONFIG_FILES) $(MERCURY_VERSION)
 	cp $(README_ETC) $(MERCURY_VERSION)
 	-cd ../samples && mmake realclean
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list