sponsor Vim development Vim logo Vim Book Ad

vim-chip8 : Syntax highlighting and indentation rules for Chip8 assembly.

 script karma  Rating 6/3, Downloaded by 1109  Comments, bugs, improvements  Vim wiki

created by
jackie kircher
 
script type
syntax
 
description
Syntax highlighting and indentation rules for Chip8 assembly. These rules will apply to any *.8o file.
Full support for the SuperChip and XO-Chip instruction sets is available, but not enabled out-of-the-box. Read below for directions.

Supported keywords:
  conditionals:  begin, else, end, if, then, while
      constants:  buzzer, const, delay, key
       functions:  bcd, jump, jump0, load, save, sprite
          repeats:  again, loop
    statements:  :alias`, :breakpoint, :next, :unpack, clear, return

There is also syntax highlighting for named subroutines, integer/hex/binary values, and comments.


Auto-indentation will trigger for the following cases
  * indent one shiftwidth on lines following `loop`
  * indent one shiftwidth on lines following `while`
  * unindent to matching `loop` when ending it with `again`
  * indent one shiftwidth on lines following `if ... begin` and `else`
  * unindent to matching `if ... begin` when ending it with `end`
  * indent to zero for new labels
  * indent one shiftwidth on lines following new labels
  * indent to zero when ending a subroutine with `;`


SuperChip

An expanded set of keywords are supported for the SuperChip instruction set. To enable these uncomment out the following line in syntax/8o.vim:
  "let b:superChip = 1

Supported keywords:
    constants:  bighex
     functions:  hires, loadflags, lores, saveflags, scroll-down, scroll-left, scroll-right
  statements:  exit


XO-Chip

Another set of keywords are available to support the XO-Chip instructions. These are also disabled by default but can be turned on by uncommenting out the following line in syntax/8o.vim:
  "let b:superChip = 1

Supported keywords:
    constants:  long
     functions:  plane, scroll-up
  statements:  audio


Contribute!

I really haven't done a whole lot of Chip8 programming so if something feels weird or is missing, please feel free to leave an issue of submit a pull request at https://github.com/jackiekircher/vim-chip8
 
install details
Copy the corresponding files to your vim directory (~/.vim/ or ~/vimfiles/):

  ftdetect/8o.vim to ~/.vim/ftdetect/8o.vim
  syntax/8o.vim to ~/.vim/syntax/8o.vim
  indent/8o.vim to ~/.vim/indent/8o.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-chip8-1.0.zip 1.0 2015-10-01 7.0 jackie kircher * add support for the XO-Chip
* increase hex number length to 4 digits
* add highlighting and indentation support for 'if ... begin' blocks
* support nesting auto-indentation with loops and if statements
* fix highlighting rules for 'scroll-down', 'scroll-left', and 'scroll-right'
* include function highlighting for main chip8 functions by default
* don't auto-indent labels until typing a space after ':'
vim-chip8-0.1.zip 0.1 2014-10-13 7.0 jackie kircher Initial upload
ip used for rating: 216.73.216.46

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github