khorser committed 3116bee

Initial checkin

Comments (0)

Files changed (5)

+*Mercury.txt*               Mercury Compiler Support Plugins
+                            $HGLastChangedDate$
+                            Author: Sergey Khorev <>
+1. Overview                                         |mercury-overview|
+2. Installation                                     |mercury-installation|
+3. Filetype plugin                                  |mercury-ftplugin|
+4. Mercury commands plugin                          |mercury-commands|
+5. Syntax highlighting                              |mercury-syntax|
+6. Customisation                                    |mercury-customisation|
+1. Overview                                            *mercury-overview*
+This is a set of Vim plugins to simplify work with Mercury language compiler
+Native Mercury installer for Windows can be found here: 
+2. Installation                                         *mercury-install*
+The plugins com as a vimball; to install it, simply >
+       vim Mercury.vba
+       :so %
+       :q
+Your .vimrc needs to have: >
+   	set nocp
+	filetype plugin on
+3. Filetype plugin                                      *mercury-ftplugin*
+It is a modified version of |ftplugin| from officical Mercury distribution
+It allows using |:make| to invoke mmake and sets some formatting options.
+If you like keeping *.err files open in Vim, the plugin also removes "file
+changed" prompt for them.
+4. Mercury commands plugin              *mercury-commands* *mercury_commands*
+mercury_commands |plugin| provides additional functionality via Vim commands:
+                                                                    *:Mmc*
+:Mmc [arg1]...      Invoke compiler (mmc), using current file when no
+                    arguments passed.
+                                                                    *:Mmake*
+:Mmake [arg1]...    Invoke mmake (mmake.bat on Windows).
+                                                                    *:Mmerr*
+:Mmerr              Show last output from :Mmc or :Mmake.
+                                                                    *:Mmod*
+:Mmod name [interface_imports]
+:Mmod name {interfaceimports} [implementation_imports]
+                    Insert module template, interface_imports and
+                    implementation_imports are comma-separated lists
+                    of modules. E.g., >
+        :Mmod mymodule char,list io,store
+                                                                    *:Mmain*
+:Mmain name [interface_imports]
+:Mmain name {interfaceimports} [implementation_imports]
+                    Insert module template containing the `main' predicate
+5. Syntax highlighting                                      *mercury-syntax*
+That is |syntax-highlighting| plugin from official Mercury distribution.
+6. Customisation                                      *mercury-customisation*
+If you have several compilers installed, you can set g:mercury_home or 
+b:mercury_home variable to point to specific installation directory
+ vim:tw=78:ts=8:ft=help:norl:


+" Filetype detection plugin
+" Language: Mercury
+" Last Change: $HGLastChangedDate$
+" Maintainer:	Sergey Khorev <>
+au BufRead,BufNewFile  *.m,*.moo         set filetype=mercury


+" Vim filetype plugin
+" Language:    Mercury
+" Last Change: $HGLastChangedDate$
+" Maintainer:  Sergey Khorev <>
+" Based on work of Ralph Becket <>
+" vim: ts=2 sw=2 et
+if exists("b:did_ftplugin")
+  finish
+let b:did_ftplugin = 1
+" 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'.
+if has('win32')
+  if exists('b:mercury_home')
+    let s:mercury_home = b:mercury_home
+  elseif exists('g:mercury_home')
+    let s:mercury_home = g:mercury_home
+  else
+    " @ MERCURY_HOME @ will be substituted with a real path during installation
+    let s:mercury_home = "@MERCURY_HOME@"
+    if s:mercury_home[0] == "@"
+      echoerr "Mercury home is not set"
+    endif
+  endif
+  let &l:makeprg = s:mercury_home . '/bin/mmake.bat'
+  unlet s:mercury_home
+  setlocal makeprg=mmake
+setlocal errorformat&
+" Reload any .err buffers silently
+autocmd! FileChangedShell *.err vi!
+" Formatting options
+setlocal formatoptions=trcq
+setlocal wrapmargin=0 textwidth=0
+setlocal fileformat=unix


+" Commands for Mercury compiler (
+" Native Mercury installer for Windows:
+" Last Change: $HGLastChangedDate$
+" URL:
+" Maintainer:  Sergey Khorev <>
+" :Mmc arg1...	
+"     - invoke compiler (mmc), use current file when no arguments passed
+" :Mmake arg1...
+"     - invoke mmake (mmake.bat on Windows)
+" :Mmerr 
+"     - show last output from :Mmc or :Mmake
+" :Mmod name [interface_imports [implementation_imports]]
+"     - insert module template, *imports are comma-separated lists of modules
+" :Mmain name [interface_imports [implementation_imports]]
+"     - insert module template with the `main' predicate
+" g:mercury_home or b:mercury_home - Mercury installation directory
+let s:save_cpo = &cpo
+set cpo&vim
+if exists("loaded_mercury_commands")
+  finish
+let loaded_mercury_commands = 1
+if v:version < 700
+  finish
+command! -nargs=* Mmc call mercury_commands#CallMmc(<q-args>)
+command! -nargs=* Mmake call mercury_commands#CallMmake(mercury_commands#PasteArgs(<f-args>))
+command! Mmerr echo mercury_commands#GetLastOutput()
+command! -nargs=+ Mmod call mercury_commands#Module(0, <f-args>)
+command! -nargs=+ Mmain call mercury_commands#Module(1, <f-args>)
+let &cpo = s:save_cpo
+List of files for Vimball:
+" vim: set ts=8 sw=2 sts=2:


+" Vim syntax file
+" Language:     Mercury
+" Maintainer:   Ralph Becket <>
+" vim: ts=2 sw=2 et
+if exists("b:current_syntax")
+  finish
+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
+  syn region  mercuryComment      start=+%[-=%*_]*+ end=+.*$+he=s-1                             contains=mercuryToDo
+syn keyword mercuryKeyword      module use_module import_module
+syn keyword mercuryKeyword      include_module end_module
+syn keyword mercuryKeyword      initialise mutable
+syn keyword mercuryKeyword      initialize finalize finalise
+syn keyword mercuryKeyword      interface implementation
+syn keyword mercuryKeyword      pred mode func type inst solver any_pred any_func
+syn keyword mercuryKeyword      is semidet det nondet multi erroneous failure
+syn keyword mercuryKeyword      cc_nondet cc_multi
+syn keyword mercuryKeyword      typeclass instance where
+syn keyword mercuryKeyword      pragma promise external
+syn keyword mercuryKeyword      trace atomic or_else
+syn keyword mercuryPragma       inline no_inline
+syn keyword mercuryPragma       type_spec source_file fact_table obsolete
+syn keyword mercuryPragma       memo loop_check minimal_model
+syn keyword mercuryPragma       terminates does_not_terminate check_termination
+syn keyword mercuryPragma       promise_equivalent_clauses
+syn keyword mercuryCInterface   c_header_code c_code
+syn keyword mercuryCInterface   foreign_proc foreign_decl foreign_code
+syn keyword mercuryCInterface   foreign_type foreign_import_module
+syn keyword mercuryCInterface   foreign_export_enum foreign_export
+syn keyword mercuryCInterface   foreign_enum
+syn keyword mercuryCInterface   may_call_mercury will_not_call_mercury
+syn keyword mercuryCInterface   thread_safe not_thread_safe maybe_thread_safe
+syn keyword mercuryCInterface   promise_pure promise_semipure
+syn keyword mercuryCInterface   tabled_for_io local untrailed trailed 
+syn keyword mercuryCInterface   attach_to_io_state 
+syn keyword mercuryCInterface   can_pass_as_mercury_type stable
+syn keyword mercuryCInterface   will_not_throw_exception
+syn keyword mercuryCInterface   may_modify_trail will_not_modify_trail
+syn keyword mercuryCInterface   may_duplicate may_not_duplicate
+syn keyword mercuryCInterface   affects_liveness
+syn keyword mercuryCInterface   does_not_affect_liveness doesnt_affect_liveness
+syn keyword mercuryCInterface   no_sharing unknown_sharing sharing
+syn keyword mercuryCInterface   export import
+syn keyword mercuryImpure       impure semipure
+syn keyword mercuryToDo         XXX TODO NOTE         
+syn keyword mercuryLogical      some all not if then else true fail false
+syn keyword mercuryLogical      try catch catch_any
+syn keyword mercuryLogical      semidet_true semidet_false semidet_fail
+syn keyword mercuryLogical      impure_true 
+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 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
+  " The complicated regexp here matches an 80-column string,
+  " with proper treatment of tabs (assuming the tab size is 8):
+  " each row consists of 10 columns, and each column consists of either 8
+  " non-tab characters, or 0-7 non-tab characters followed by a tab.
+  syn match   mercuryFirst80 +^\([^	]\{8}\|[^	]\{0,7}	\)\{10}+                                contains=ALL
+  syn match   mercuryTooLong +^\([^	]\{8}\|[^	]\{0,7}	\)\{10}..*+                             contains=mercuryFirst80
+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