[m-rev.] Added vim directory to distribution

Ralph Becket rafe at cs.mu.OZ.AU
Thu Mar 14 17:33:10 AEDT 2002


Following various suggestions, I've reorganised the Vim files for Vim 6.0.
New diffs follow (it's much the same as before, except that the original
mercury.vim file has now been split into vim/ftplugin/mercury.vim and
vim/syntax/mercury.vim, the README has been rewritten, and the
myfiletypes.vim file has been edited and moved to
vim/after/filetype.vim.)

Etimated hours taken: 2
Branches: main

Files and instructions for adding Mercury syntax highlighting under Vim 6.0.

NEWS:
      Mention the new directory.

vim:
vim/after:
vim/after/filetype.vim:
vim/ftplugin:
vim/ftplugin/mercury.vim:
vim/ftplugin/mercuryhdr.vim:
vim/syntax:
vim/syntax/mercury.vim:
vim/README:
      New directory structure added and populated.

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


Index: README
===================================================================
RCS file: README
diff -N README
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ README	14 Mar 2002 06:13:18 -0000
@@ -0,0 +1,30 @@
+Mercury Syntax Highlighting Under Vim 6.0
+
+1. Create a diretory `~/.vim':
+$ mkdir ~/.vim
+
+2. Copy everything recursively from this directory into `~/.vim':
+$ cp -r . ~/.vim
+
+3. Ensure you have the following lines in your `~/.vimrc' file:
+
+filetype on
+filetype plugin on
+filetype indent off
+runtime after/filetype.vim
+syntax enable
+
+4. If you wish to change the colour scheme used by Vim's syntax highlighting,
+we suggest you put the necessary commands in `~/.vim/after/syntax/syntax.vim'
+and append the following to the above list of commands in your `~/.vimrc':
+
+runtime after/syntax/syntax.vim
+
+4. 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
+`~/.vimrc' file.
+
+The ftplugin file defines a number of useful keyboard mappings you may wish to
+look at.


Index: filetype.vim
===================================================================
RCS file: filetype.vim
diff -N filetype.vim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ filetype.vim	14 Mar 2002 05:44:04 -0000
@@ -0,0 +1,7 @@
+" filetype.vim
+" vim: ts=2 sw=2 et
+
+augroup filetype
+  au! BufRead,BufNewFile  *.m,*.moo         setfiletype mercury
+  au! BufRead,BufNewFile  Mmake*            setfiletype make
+augroup END

Index: mercury.vim
===================================================================
RCS file: mercury.vim
diff -N mercury.vim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mercury.vim	14 Mar 2002 05:34:17 -0000
@@ -0,0 +1,66 @@
+" Vim syntax file
+" Language:     Mercury
+" Maintainer:   Ralph Becket <rafe at cs.mu.oz.au>
+" vim: ts=2 sw=2 et
+
+if exists("b:did_mercury_ftplugin")
+  finish
+endif
+let b:did_mercury_ftplugin = 1
+
+  " Miscellaneous settings.
+
+  " I find it handy to run `mtags' over the Mercury library .m files
+  " and move the resulting tags file to `$HOME/mercury/tags.library'.
+  "
+setlocal tags+=$HOME/mercury/tags.library,$HOME/mercury/tags.compiler
+
+  " Handy if you use `:make'.
+  "
+setlocal makeprg=mmake
+
+  " Don't wrap over-long lines.
+  "
+setlocal wrapmargin=0
+setlocal 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 '
+  "
+" setlocal tabstop=8
+" setlocal shiftwidth=8
+" setlocal expandtab   
+
+  " Controls how autoindenting works.  See the Vim help pages for details.
+  "
+setlocal 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/ftplugin/mercuryhdr.sh' which inserts all the
+  " usual boilerplate for a new Mercury module.
+  "
+nnoremap <C-X>h !!$HOME/.vim/ftplugin/mercuryhdr.sh %<CR>:set ft=mercury ff=unix ts=4 sw=4 et<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!


Index: mercuryhdr.sh
===================================================================
RCS file: mercuryhdr.sh
diff -N mercuryhdr.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mercuryhdr.sh	14 Mar 2002 06:26:00 -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
+%
+%------------------------------------------------------------------------------%
+
+:- 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: mercury.vim
===================================================================
RCS file: mercury.vim
diff -N mercury.vim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mercury.vim	14 Mar 2002 05:31:19 -0000
@@ -0,0 +1,83 @@
+" Vim syntax file
+" Language:     Mercury
+" Maintainer:   Ralph Becket <rafe at cs.mu.oz.au>
+" vim: ts=2 sw=2 et
+
+if exists("b:current_syntax")
+  finish
+endif
+let b:current_syntax = "mercury"
+
+  " 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.
+  "
+  " By default, parts of lines that extend over 80 characters will be
+  " highlighted.  To avoid this behaviour, add
+  "
+  "   let mercury_no_highlight_overlong = 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
+if exists("mercury_no_highlight_overlong") && !mercury_no_highlight_overlong
+  syn match   mercuryFirst80 +^.\{80}+                                                          contains=ALL
+  syn match   mercuryTooLong +^.\{81,}+                                                         contains=mercuryFirst80
+endif
+
+syn sync fromstart
+
+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

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 -R $(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