[m-rev.] for review: rewrite of vim syntax file

Peter Wang novalazy at gmail.com
Wed Apr 22 15:07:33 AEST 2015


On Thu, 16 Apr 2015 16:57:49 +0800, Sebastian Godelet <sebastian.godelet at outlook.com> wrote:

> diff --git a/vim/ftplugin/mercury.vim b/vim/ftplugin/mercury.vim
> index 1087274..c996e49 100644
> --- a/vim/ftplugin/mercury.vim
> +++ b/vim/ftplugin/mercury.vim
> @@ -1,9 +1,11 @@
>   " Vim syntax file
>   " Language:     Mercury
>   " Maintainer:   Sebastian Godelet <sebastian.godelet at outlook.com>
> -" Last Change:  2015-04-15
> +" Last Change:  2015-04-16
>   " vim: ts=2 sw=2 et
> 
> +" for documentation, please use :help mercury-ftplugin
> +
>   if exists("b:did_mercury_ftplugin")
>     finish
>   endif
> @@ -18,7 +20,7 @@ setlocal 
> tags+=$HOME/mercury/tags.library,$HOME/mercury/tags.compiler
> 
>     " Handy if you use `:make'.
>     "
> -setlocal makeprg="mmc -m"
> +setlocal makeprg=mmc\ --make

Actually, the projects I work with use a makefile or a shell script to
drive mmc --make, so this turns out to be counter-productive.  It might
be the case for a lot of projects.  I have commented it out for myself.

> @@ -90,18 +92,29 @@ nnoremap ,P <ESC>O:- pragma 
> foreign_proc("C",<CR><TAB>(_IO0::di, _IO::uo),<CR>[w
>   nnoremap ,M <ESC>O:- mutable(VAR, TYPE, VALUE, ground, [untrailed, 
> attach_to_io_state]).<ESC>2FVcw
>   nnoremap ,T <ESC>Otrace [io(!IO)] (<CR>),<ESC>^O<TAB>
> 
> -  " sg - this is now the default
> -" nnoremap ,m :set makeprg=mmc\ --make\
> -nnoremap gi m':1/^:- interface<CR>jj
> -nnoremap gI m':1/^:- implementation<CR>jj
> -nnoremap gE m':/^:- end_module<CR>
> +nnoremap <C-X>i m':1/^:- interface<CR>jj
> +nnoremap <C-X>I m':1/^:- implementation<CR>jj
> 
>   inoremap <F3> ::in,
>   inoremap <F4> ::out,
>   inoremap <F5> io::di, io::uo)
>   inoremap <F6> is det.

I found out that Vim supports buffer-local mappings.  ftplugin/mercury.vim
can introduce mappings like this so they only apply to Mercury files.

    inoremap <buffer> ...
    nnoremap <buffer> ...

A minor improvement is to add <silent> for these:

    nnoremap <buffer> <silent> <C-X>i m':1/^:- interface<CR>jj
    nnoremap <buffer> <silent> <C-X>I m':1/^:- implementation<CR>jj

There haven't been any objections, so can you send a pull request or
patch and I'll commit it for you.

Peter



More information about the reviews mailing list