[Pacemaker] Syntax highlighting in vim for crm configure edit

Dejan Muhamedagic dejanmm at fastmail.fm
Mon Dec 5 13:54:50 UTC 2011


Hi,

On Tue, Nov 22, 2011 at 07:14:24PM +0200, Dan Frincu wrote:
> Hi,
> 
> On Tue, Nov 15, 2011 at 11:47 AM, Raoul Bhatia [IPAX] <r.bhatia at ipax.at> wrote:
> > hi!
> >
> > On 2011-08-19 16:28, Dan Frincu wrote:
> >>
> >> Hi,
> >>
> >> On Thu, Aug 18, 2011 at 5:53 PM, Digimer<linux at alteeve.com>  wrote:
> >>>
> >>> On 08/18/2011 10:39 AM, Trevor Hemsley wrote:
> >>>>
> >>>> Hi all
> >>>>
> >>>> I have attached a first stab at a vim syntax highlighting file for 'crm
> >>>> configure edit'
> >>>>
> >>>> To activate this, I have added 'filetype plugin on' to my /root/.vimrc
> >>>> then created /root/.vim/{ftdetect,ftplugin}/pcmk.vim
> >>>>
> >>>> In /root/.vim/ftdetect/pcmk.vim I have the following content
> >>>>
> >>>> au BufNewFile,BufRead /tmp/tmp* set filetype=pcmk
> >>>>
> >>>> but there may be a better way to make this happen. /root/.vim/pcmk.vim
> >>>> is the attached file.
> >>>>
> >>>> Comments (not too nasty please!) welcome.
> >>
> >> I've added a couple of extra keywords to the file, to cover a couple
> >> more use cases. Other than that, great job.
> >
> > will this addition make it into some package(s)?
> > would it be right to ship this vim syntax file with crm?
> 
> In the hope it will be a part of crm, I've written a patch for this.
> Applying the patch over cibconfig.py and utils.py on Pacemaker 1.1.5
> and adding the pcmk.vim file to the vim syntax folder (for Debian
> Squeeze it's /usr/share/vim/vim72/syntax) gives access to syntax
> highlighting in crm configure edit, if using vi/vim as editor.
> 
> Original work on pcmk.vim by Trevor Hemsley <themsley at voiceflex.com>,
> a couple of additions by me.
> 
> Please review it and and add a Signed-Off line if it's ok.

Just tried it out, and when I do :set filetype=pcmk, vim spews at
me this:

Error detected while processing /usr/share/vim/vim72/syntax/synload.vim:
line   58:
E127: Cannot redefine function <SNR>3_SynSet: It is in use
E127: Cannot redefine function <SNR>3_SynSet: It is in use
E127: Cannot redefine function <SNR>3_SynSet: It is in use
E127: Cannot redefine function <SNR>3_SynSet: It is in use
Error detected while processing /usr/share/vim/vim72/syntax/nosyntax.vim:
line   21:
E218: autocommand nesting too deep
Error detected while processing /usr/share/vim/vim72/syntax/synload.vim:
line   58:
E127: Cannot redefine function <SNR>3_SynSet: It is in use
Error detected while processing /usr/share/vim/vim72/syntax/syntax.vim:
line   40:
E218: autocommand nesting too deep

BTW, I just copied the pcmk.vim file to ~/.vim/syntax.

Otherwise, the output looks fine. There are a few differences to
the configure show output:

- quotes are red along with the value
- ids are green whereas in configure show they are normal
- id references are light blue and in configure show they are green
- scores are red and in configure show violet
- roles/actions in constraints red and in configure show normal

There are probably a few more differences.

Cheers,

Dejan


> Regards,
> Dan
> 
> p.s.: many thanks to everyone for the input received on IRC.
> 
> >
> > thanks,
> > raoul
> > --
> > ____________________________________________________________________
> > DI (FH) Raoul Bhatia M.Sc.          email.          r.bhatia at ipax.at
> > Technischer Leiter
> >
> > IPAX - Aloy Bhatia Hava OG          web.          http://www.ipax.at
> > Barawitzkagasse 10/2/2/11           email.            office at ipax.at
> > 1190 Wien                           tel.               +43 1 3670030
> > FN 277995t HG Wien                  fax.            +43 1 3670030 15
> > ____________________________________________________________________
> >
> 
> 
> 
> -- 
> Dan Frincu
> CCNA, RHCE

> From d3ab2ab159137b271382db8d0edeef6d69325894 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Dan=20Fr=C3=AEncu?= <df.cluster at gmail.com>
> Date: Tue, 22 Nov 2011 18:50:10 +0200
> Subject: [PATCH][BUILD] Low: extra: Add syntax highlighting for crm configure edit
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> 
> Signed-off-by: Dan Frîncu <df.cluster at gmail.com>
> ---
>  shell/modules/cibconfig.py |    1 +
>  shell/modules/utils.py     |    7 +++++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/shell/modules/cibconfig.py b/shell/modules/cibconfig.py
> index 9cc9751..49b4b51 100644
> --- a/shell/modules/cibconfig.py
> +++ b/shell/modules/cibconfig.py
> @@ -128,6 +128,7 @@ class CibObjectSet(object):
>              except IOError, msg:
>                  common_err(msg)
>                  break
> +            s += "\n# vim: set filetype=.pcmk :\n"
>              s = ''.join(f)
>              f.close()
>              if hash(s) == filehash: # file unchanged
> diff --git a/shell/modules/utils.py b/shell/modules/utils.py
> index b57aa54..00013c6 100644
> --- a/shell/modules/utils.py
> +++ b/shell/modules/utils.py
> @@ -158,7 +158,7 @@ def str2tmp(s):
>      Write the given string to a temporary file. Return the name
>      of the file.
>      '''
> -    fd,tmp = mkstemp()
> +    fd,tmp = mkstemp(suffix=".pcmk")
>      try: f = os.fdopen(fd,"w")
>      except IOError, msg:
>          common_err(msg)
> @@ -317,7 +317,10 @@ def edit_file(fname):
>          return
>      if not user_prefs.editor:
>          return
> -    return ext_cmd("%s %s" % (user_prefs.editor,fname))
> +    if user_prefs.editor == "vim" or user_prefs.editor == "vi":
> +        return ext_cmd("%s %s -u /usr/share/vim/vim72/syntax/pcmk.vim" % (user_prefs.editor,fname))
> +    else:
> +        return ext_cmd("%s %s" % (user_prefs.editor,fname))
>  
>  def page_string(s):
>      'Write string through a pager.'
> -- 
> 1.7.0.4
> 


> _______________________________________________
> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org





More information about the Pacemaker mailing list