A vim plugin for the ca65 assembler providing syntax highlighting, convenience functions and help pages.
Go to file
2024-01-06 11:10:57 +01:00
doc fix missing spaces 2023-12-30 20:28:31 +01:00
ftdetect rename to ca65 2023-12-14 01:41:14 +01:00
ftplugin Add commentstring 2023-12-27 13:58:56 +01:00
syntax add missing jvs 2024-01-06 11:10:57 +01:00
LICENSE Initial commit 2023-12-14 01:40:48 +01:00
README.md move proc option to vimrc 2023-12-14 08:16:05 +01:00

vim-ca65: Vim support for the ca65 assembler

This plugin provides syntax highlighting, convenience functions and help pages for the ca65 assembler.

I currently only work with the 65C02 processor. However, I tried to include everything for the 65816 as well. If you find anything that is missing or mistakes, please open an issue or a pull request.

Features

Syntax Highlighting

The syntax highlighting currently supports the (undocumented) 6502, 65C02 and 65816 opcodes, the ca65 assembler functions and the macro packs generic and longbranch.

Convenience

This plugin provides the b:match_words variable for jumping between words (requires matchit.vim) Supported are the assembler commands like .if .endif, .macro .endmacro as well as stack instructions. This allows for easier checking of stack push/pull order.

There is also a function that opens a header/source file with the same name in a vsplit. For example if ~/project/main.s65 is opened, the function would open ~/project/main.h65 to the right of it.

Help

I compiled parts of the W65C02 datasheet and parts of the "Programming the 658126" book into a vim help page. Type :help <opcode> (or help ca65-<opcode> if the first one gives the wrong page) to see information about a opcode (how it works, updated flags...).

Installation

Install using your favorite plugin manager, for example with vim-plug:

" in vimrc
call plug#begin()
Plug 'matthiasquintern/vim-ca65'
call plug#end()

Configuration

Select processor

By default, the syntax highlighting only highlights the original 6502 instructions. To enable the illegal/undocumented instructions, the 65C02 instructions or the 65816 instructions, write this into your vimrc:

" in ~/.vimrc
let g:ca65_illegal = 1  " enable the illegal 6502 opcodes
let g:ca65_65C02 = 1    " enable 65C02 instructions
let g:ca65_65816 = 1    " enable 65816 instructions

Select filetype

By default, the plugin loads for files having a .s65 or .h65 extension. To load it for your preferred extension, write this into ~/.vim/ftdetect/ca65.vim:

" in ~/.vim/ftdetect/ca65.vim
au BufRead,BufNewFile *.myExtension setfiletype ca65

Customize syntax highlighting

If the labels and instructions have the same color in your colorscheme, link ca65Label (or ca65Opcode) to another class, eg:

" in ~/.vim/ftplugin/ca65.vim
hi link ca65Label Typedef

You can add syntax highlighting for your own assembler like this:

" in ~/.vim/ftplugin/ca65.vim
syn keyword ca65customMacros Macro1 Macro2 mul div macro3

Header/Source split function

To use the source-header split function, map it and set your preferred assembly filetypes:

" in ~/.vim/ftplugin/ca65.vim
nnoremap <buffer> <leader>h :call SplitHeader("h65", "s65")<Cr>