Permalink
Browse files

[perl #30943] Syntax highlighting work v2

Further improvements under editor/

* Added POD highlighting to pasm.vim
* Fixed POD highlighting in pmc.vim
* Added an indent-script for .imc files
* Fixed the filetype-detect plugin to override previous choices; vim was
mistaking imc and pasm files for ini-files.
* Fixed up MAKEFILE to install the new files
* Updated the documentation
* Manifest update

Courtesy of Andrew Rodland <arodland@entermail.net>


git-svn-id: https://svn.parrot.org/parrot/trunk@6495 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 3f2968e commit b623b65b222e059b83e4449002252722990ee1c3 Leopold Toetsch committed Aug 7, 2004
Showing with 105 additions and 17 deletions.
  1. +1 −0 MANIFEST
  2. +10 −1 editor/Makefile
  3. +10 −10 editor/README.pod
  4. +3 −3 editor/filetype_parrot.vim
  5. +75 −0 editor/indent_imc.vim
  6. +3 −0 editor/pasm.vim
  7. +3 −3 editor/pmc.vim
View
@@ -351,6 +351,7 @@ editor/pasm.el [devel]
editor/pasm.vim [devel]
editor/pmc.vim [devel]
editor/filetype_parrot.vim [devel]
+editor/indent_imc.vim [devel]
encodings/utf8.c []
examples/assembly/99beer.pasm [main]doc
examples/assembly/Makefile [main]doc
View
@@ -1,9 +1,18 @@
-all: imc.vim
+all: imc.vim vim-install
imc.vim: imc.vim.in ../ops/*.ops
cp -f imc.vim.in imc.vim
perl ops2vim.pl ../ops/*.ops >> imc.vim
+
+vim-install:
+ mkdir -p $(HOME)/.vim/syntax/
cp imc.vim $(HOME)/.vim/syntax/
+ cp pasm.vim $(HOME)/.vim/syntax/
+ cp pmc.vim $(HOME)/.vim/syntax/
+ mkdir -p $(HOME)/.vim/ftdetect/
+ cp filetype_parrot.vim $(HOME)/.vim/ftdetect/parrot.vim
+ mkdir -p $(HOME)/.vim/indent
+ cp indent_imc.vim $(HOME)/.vim/indent/imc.vim
imc.kate:
perl kate_syntax.pl '../' > imcc.xml
View
@@ -2,7 +2,7 @@
editor/README.pod - Productivity Comes in Pretty Colors
-=head1 Syntax Highlighting
+=head1 Syntax Highlighting and Other Editor Assistance
Included in this directory are some add-ins for making working on parrot (or in
parrot) easier, for various popular editors. Mostly that means
@@ -11,15 +11,15 @@ your favorite editor
=head2 Vim
-There are four files here: C<imc.vim> (generated from C<imc.vim.in>),
-C<pasm.vim>, C<pmc.vim>, and C<filetype_parrot.vim>. The first three are syntax
-files, and the last is a filetype script that tells vim to associate the
-extensions .imc, .imcc, .pasm, and .pmc with the right syntax. Copy C<imc.vim>,
-C<pasm.vim>, and C<pmc.vim> into C<~/.vim/syntax> or C<$VIMRUNTIME/syntax>,
-creating the directory if it doesn't exist. Copy C<filetype_parrot.vim> into
-C<~/.vim/ftdetect> or C<$VIMRUNTIME/ftdetect>, creating the directory if it
-doesn't exist. C<pmc.vim> requires C<pod.vim>, which is standard in the Vim
-distribution.
+There are several files here, all with the C<.vim> extension. C<imc.vim>
+(generated from C<imc.vim.in>), C<pasm.vim>, and C<pmc.vim> are syntax
+files; C<indent_imc.vim> is an indent plugin; and C<filetype_parrot.vim> is a
+filetype script that tells vim to associate the extensions .imc, .imcc, .pasm,
+and .pmc with the right syntax. The syntax files should be installed to
+C<~/.vim/syntax/>; C<filetype_parrot.vim> should be installed to
+C<~/.vim/ftdetect>; C<indent_imc.vim> should be called C<~/.vim/indent/imc.vim>.
+C<make> in the C<editor/> dir will do this automatically. If you want indenting,
+you should also place C<filetype indent on> somewhere in your vimrc.
=head2 Kate
@@ -1,3 +1,3 @@
-au BufNewFile,BufRead *.pmc setf pmc
-au BufNewFile,BufRead *.pasm setf pasm
-au BufNewFile,BufRead *.imc,*.imcc setf imc
+au BufNewFile,BufRead *.pmc set ft=pmc
+au BufNewFile,BufRead *.pasm set ft=pasm
+au BufNewFile,BufRead *.imc,*.imcc set ft=imc
View
@@ -0,0 +1,75 @@
+" Description: imcc indenter
+" Author: Andrew Rodland <arodland@entermail.net>
+" Last Change: 2004 Aug 3
+
+" As usual, we want to be alone
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent=1
+
+setlocal indentexpr=IMCIndent()
+setlocal indentkeys=o,O,*<Return>,<bs>,:,=.end,0#
+
+fun! InPOD(lnum)
+ return synIDattr(synID(a:lnum, 1, 1), "name") =~? '^myPod$\|^pod[A-Z]'
+endfun
+
+fun! IMCIndent()
+ let thisline = getline(v:lnum)
+
+ let POD_START = '^=[a-z]'
+
+ if thisline =~? POD_START
+ return 0
+ endif
+
+
+ if InPOD(v:lnum)
+ return -1
+ endif
+
+ let LABEL_OR_COMMENT = '^\s*\k\+:\s*$\|^#'
+ if thisline =~? LABEL_OR_COMMENT
+ return 0
+ endif
+
+ let lnum=v:lnum
+ while lnum > 0
+ let lnum = prevnonblank(lnum-1)
+ let prevline = getline(lnum)
+
+ if prevline !~? LABEL_OR_COMMENT
+ if !InPOD(lnum)
+ break
+ endif
+ endif
+ endwhile
+
+ if lnum < 1
+ return 0
+ endif
+
+ let ind = indent(lnum)
+
+ let SUB = '^\s*\.pcc_sub\s\+\|^\s*\.sub\s\+'
+ let RETURNBLOCK = '\s*\.pcc_begin_return\s*$'
+ let END = '^\s*\.end\s*$\|^\s*\.pcc_end_return\s*$'
+
+ if prevline =~? SUB
+ let ind = ind + &sw
+ endif
+
+ if prevline =~? RETURNBLOCK
+ let ind = ind + &sw
+ endif
+
+ if thisline =~? END
+ let ind = ind - &sw
+ endif
+
+ return ind
+
+endfun
+
+
View
@@ -11,6 +11,9 @@ elseif exists("b:current_syntax")
finish
endif
+syn include @Pod syntax/pod.vim
+syn region myPod start="^=pod" start="^=item" start="^=head" end="^=cut" keepend contains=@Pod
+
syn match pasmIdentifier "[A-Za-z0-9_]\+"
syn match pasmLabel "[A-Za-z0-9_]\+:"he=e-1
syn match pasmComment "#.*"
View
@@ -11,8 +11,8 @@ elseif exists("b:current_syntax")
finish
endif
-syn include @Pod <sfile>:p:h/pod.vim
-syn region pmcPod start="^=[a-z]" end="^=cut" contains=@Pod keepend contained
+syn include @Pod syntax/pod.vim
+syn region pmcPod start="^=[a-z]" end="^=cut" keepend contained contains=@Pod
" A bunch of useful C keywords
syn keyword cStatement goto break return continue asm
@@ -129,7 +129,7 @@ if exists("c_comment_strings")
syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,pmcPOD
else
syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError
- syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError
+ syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,pmcPOD
endif
" keep a // comment separately, it terminates a preproc. conditional
syntax match cCommentError display "\*/"

0 comments on commit b623b65

Please sign in to comment.