A Vim plugin for syntax highlighting of OpenQASM files.
Add the line
Plugin 'Qiskit/openqasm', {'rtp': 'plugins/vim/'}
into your .vimrc
between the call vundle#begin()
and call vundle#end()
lines, reload, and run :PluginInstall
.
Add the line
Plug 'Qiskit/openqasm', {'rtp': 'plugins/vim/'}
into your .vimrc
between the call plug#begin()
and call plug#end()
lines, reload, and run :PlugInstall
.
Clone this repository somewhere locally with
$ cd <plugins path>
$ git clone https://github.com/Qiskit/openqasm
This does not need to be in the .vim
directory.
Now add the plugin's subdirectory to Vim's runtime path, by adding the following to your .vimrc
:
set rtp+='<plugins path>/openqasm/plugins/vim'
Reload .vimrc
to load the plugin.
At present, this only provides syntax highlighting file for OpenQASM files, which automatically registers itself for all files with the name *.qasm
.
To turn on syntax highlighting for another file (for example stdgates.inc
), call
:set filetype=openqasm
either as a command, or as part of an autocommand.
The default highlighting groups are defined at the bottom of the file syntax/openqasm.vim
.
You can override these in your own configuration files (.vimrc
, etc) if you prefer different groupings.
The plugin attempts to determine the OpenQASM version from the required OPENQASM <version>;
statement at the top of the file, and falls back to OpenQASM 3.0 if this is unparseable (perhaps on multiple lines) or not present.
You can control the fallback value by setting
let g:openqasm_version_fallback = 2.0
in your .vimrc
file.
You can override all version checking with
let g:openqasm_version_override = 2.0
For full help, call
:help openqasm
No attempt is made to highlight the arbitrary grammars present inside defcal
blocks of OpenQASM 3.
This would be strongly dependent on the grammar file loaded by the defcalgrammar
statement.
openqasm.vim is licensed under the Apache 2.0 open-source license, along with the rest of the OpenQASM source.
See the LICENSE
file in the root of this repository for more information.