Coder Social home page Coder Social logo

vim-spirv's Introduction

vim-spirv

A vim plugin for the Khronos Group's SPIR-V standard providing rich syntax highlighting for disassembled SPIR-V assembly (.spvasm files) and automatically disassembled binary SPIR-V modules (.spv files) with interactive visualisation of the ID under the cursor to show, at a glance, the source of opcode operands.

vim-spirv

This plugin does not target the older LLVM IR based SPIR 1.2 and 2.0 specifications.

Install

Using vim-plug.

Plug 'kbenzie/vim-spirv'

Using Vundle.

Plugin 'kbenzie/vim-spirv'

Using vim-pathogen.

git clone https://github.com/kbenzie/vim-spirv.git ~/.vim/bundle/vim-spirv

Options

g:spirv_enable_current_id

Enable automatic highlighting of all occurrences of the ID under the cursor. This is useful for highlighting where an opcode ID is defined and used at a glance. See g:spirv_current_id_highlight. To disable this option.

let g:spirv_enable_current_id = 0

g:spirv_current_id_highlight

Specify the value of the SpirvCurrentID highlight group, this is only set when the g:spirv_enable_current_id option is enabled. To Customize the highlight group to, for example, make the current ID bold.

let g:spirv_current_id_highlight = 'term=bold cterm=bold gui=bold'

g:spirv_enable_extinst_error

Enable highlighting extended instruction error highlighting, enabling this option will parse the file looking for an OpExtInstImport instruction, determine the imported instruction set and set the value of that instruction sets highlight group, E.G. SpirvGlslStd450, to linked to the SpirvInstruction highlight group. If no OpExtInstImport instruction is found, or it is commented out, the extended instruction set highlight group will be linked to SpirvError. When this option is disabled the extended instruction set highlight group is set to SpirvInstruction. To disable this option.

let g:spirv_enable_extinst_error = 0

g:spirv_enable_autodisassemble

Enable automatic disassembly of SPIR-V binary files on :edit and automatic assembly on :write enabling ease of editing. This option depends on spirv-as and spirv-dis being available on the system PATH, to override this behavior see g:spirv_as_path and g:spirv_dis_path. To disable this option.

let g:spirv_enable_autoassemble = 1

g:spirv_as_path

Path to the spirv-as tool used automatically assemble SPIR-V assembly into a binary when g:spirv_enable_autodisassemble is enabled. If spirv-as is on the system PATH this option need not be set. Default setting.

let g:spirv_as_path = 'spirv-as'

g:spirv_dis_path

Path to the spirv-dis tool used automatically disassemble SPIR-V assembly into a binary when g:spirv_enable_autodisassemble is enabled. If spirv-dis is on the system PATH this option need not be set. Default setting.

let g:spirv_dis_path = 'spirv-dis'

License (MIT)

See license file.

vim-spirv's People

Contributors

kbenzie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vim-spirv's Issues

Add formatting support

SPIR-V indentation is a pain to handle manually but is very regular, add support for automatically formatting SPIR-V with the gq<motion> command.

Official SPIR-V syntax

I just found out about both this project, and the official SPIR-V vim syntax generated by SPIR-V Tools: https://github.com/KhronosGroup/SPIRV-Tools#extras

Are you aware of the other project? If so, how do these compare? If not, may I suggest collaborating with SPIR-V Tools and bringing the features in the project there for the greater benefit of the community?

Automatic disassembly/assembly of SPIR-V binary files can't be disabled

Hi,

There is an option g:spirv_enable_autodisassemble, but it is only used to enable/disable highlighting of IDs and OpExtImport errors when opening a binary SPIR-V files. Autocommands for assembly/disassembly binary SPIR-V files are added uncoditionally:

augroup spirv
" Remove all autocmds from the spirv group
autocmd!
" Set autocommands to disassemble SPIR-V binaries on load
autocmd BufReadPre,FileReadPre *.spv,*.spv32,*.spv64 setlocal bin
autocmd BufReadPost,FileReadPost *.spv,*.spv32,*.spv64 call spirv#disassemble()
" Set autocommands to assemble SPIR-V binaries on write
autocmd BufWriteCmd,FileWriteCmd *.spv,*.spv32,*.spv64 call spirv#assemble()
augroup END

This means that even if I set g:spirv_enable_autodisassemble = 0 I will still see the following error when opening a binary SPIR-V file:

spirv-dis failed
Error detected while processing BufRead Autocommands for "*.spv"..function spirv#disassemble:
line   13:
E484: Can't open file /tmp/vzQKVBI/1

I guess this is not an important issue, because with autodisassemble disabled I wouldn't open binary files anyway

Add OpCode snippet support

Aid hand writing SPIR-V by supporting OpCode snippets in the UltiSnips format. Generate the snippets from the JSON schema.

Add folding support

For large SPIR-V modules which have multiple pair blocks, such as OpFunction/OpFunctionEnd it would be helpful to be able to fold sections which are not currently relevant away allowing the reader to focus on the point of interest.

Errors when moving around a .spv file

I'm having the following errors when moving around a .spv file. This is making the plugin unusable.

On Vim:

Error detected while processing function spirv#highlight_extinst:
line   23:
Traceback (most recent call last):
Press ENTER or type command to continue
Error detected while processing function spirv#highlight_extinst:
line   23:
  File "<string>", line 1, in <module>
Press ENTER or type command to continue
Error detected while processing function spirv#highlight_extinst:
line   23:
  File "<string>", line 3, in find_group_names
Press ENTER or type command to continue
Error detected while processing function spirv#highlight_extinst:
line   23:
NameError: global name 'vim' is not defined
Press ENTER or type command to continue
Error detected while processing function spirv#highlight_extinst:
line   23:
E858: Eval did not return a valid python object
Press ENTER or type command to continue
Error detected while processing function spirv#highlight_extinst:
line   33:
E714: List required
Press ENTER or type command to continue
Error detected while processing function spirv#highlight_extinst:
line   45:
E714: List required
Press ENTER or type command to continue

On NeoVim:

Error detected while processing function spirv#highlight_extinst[23]..provider#python#Call:              
line   18:                                                                                               
error caught in request handler 'python_eval ('find_group_names()',)':                                   
Traceback (most recent call last):                                                                       
  File "/usr/lib/python2.7/site-packages/neovim/plugin/script_host.py", line 150, in python_eval         
    return eval(expr, self.module.__dict__)                                                              
  File "<string>", line 1, in <module>                                                                   
  File "<string>", line 3, in find_group_names                                                           
Press ENTER or type command to continue                                                                  
Error detected while processing function spirv#highlight_extinst[23]..provider#python#Call:              
line   18:                                                                                               
NameError: global name 'vim' is not defined                                                              
Press ENTER or type command to continue                                                                  
Error detected while processing function spirv#highlight_extinst:                                        
line   33:                                                                                               
E714: List required                                                                                      
Press ENTER or type command to continue                                                                  
Error detected while processing function spirv#highlight_extinst:                                        
line   45:                                                                                               
E714: List required                                                                                      
Press ENTER or type command to continue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.