https://github.com/openqasm/openqasm.vim
Vim plugin for OpenQASM 3
https://github.com/openqasm/openqasm.vim
Last synced: 3 months ago
JSON representation
Vim plugin for OpenQASM 3
- Host: GitHub
- URL: https://github.com/openqasm/openqasm.vim
- Owner: openqasm
- License: apache-2.0
- Created: 2022-05-26T16:23:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-22T11:24:17.000Z (over 2 years ago)
- Last Synced: 2025-01-18T08:44:57.057Z (over 1 year ago)
- Language: Vim Script
- Size: 23.4 KB
- Stars: 7
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openqasm.vim
A Vim plugin for syntax highlighting of OpenQASM files.

## Installation
### [Vundle](https://github.com/VundleVim/Vundle.vim)
Add the line
```vim
Plugin 'openqasm/openqasm.vim'
```
into your `.vimrc` between the `call vundle#begin()` and `call vundle#end()` lines, reload, and run `:PluginInstall`.
### [vim-plug](https://github.com/junegunn/vim-plug)
Add the line
```vim
Plug 'openqasm/openqasm.vim'
```
into your `.vimrc` between the `call plug#begin()` and `call plug#end()` lines, reload, and run `:PlugInstall`.
### Bare Vim
Clone this repository somewhere locally with
```bash
$ cd
$ git clone https://github.com/openqasm/openqasm.vim
```
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`:
```vim
set rtp+='/openqasm.vim'
```
Reload `.vimrc` to load the plugin.
## Usage
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
```vim
: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 ;` 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
```vim
let g:openqasm_version_fallback = 2.0
```
in your `.vimrc` file.
You can override all version checking with
```vim
let g:openqasm_version_override = 2.0
```
For full help, call
```vim
:help openqasm
```
## Limitations
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.
## License
`openqasm.vim` is licensed under the Apache 2.0 open-source license.
See the [`LICENSE` file in the root of this repository](LICENSE) for more information.