File: README.md

package info (click to toggle)
spirv-tools 2025.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,588 kB
  • sloc: cpp: 470,407; javascript: 5,893; python: 3,326; ansic: 488; sh: 450; ruby: 88; makefile: 18; lisp: 9
file content (87 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Neovim configuration guide for SPIR-V disassembly files

This directory holds instructions to configure Neovim for SPIR-V assembly files (`.spvasm`)

At the end, Neovim should support:
* Syntax highlighting
* Jump to definition
* Find all references
* Symbol renaming
* Operand hover information
* Formatting
* Completion suggestions for all Opcodes and Ids

While the instructions here are specifically for Neovim, they should translate easily to vim.

## Dependencies

In order to build and install the Visual Studio Code language server extension, you will need to install and have on your `PATH` the following dependencies:
* [`golang 1.16+`](https://golang.org/)

## File type detection

Neovim's default config location is typically `~/.config/nvim` so the rest of the instructions assume that but it will need to be changed if your system is different.

Tell neovim that `*.spvasm` files should be treated as `spvasm` filetype
```bash
echo "au BufRead,BufNewFile *.spvasm                set filetype=spvasm" > ~/.config/nvim/ftdetect/spvasm.vim
```

## Syntax Highlighting

### Generate the syntax highlighting file
```bash
cd <spirv-tools dir>
mkdir -p build && cd build
# Any platform is fine, ninja is used an as example
cmake -G Ninja ..
ninja spirv-tools-vimsyntax
```

### Copy the syntax file 
```bash
cp spvasm.vim ~/.config/nvim/syntax/spvasm.vim
```

## Language Server

### Building the LSP (masOS / Linux)

Run `build_lsp.sh`
Copy `spirvls` and `spirv.json` to a location in `$PATH`

```bash
cd <spirv-tools dir>/utils/vscode
./build_lsp.sh
sudo cp spirvls/* /usr/local/bin/
```

### Building the LSP (Windows)

TODO

### Configuring Neovim

Configuration will depend a lot on your installed plugins but assuming you are using [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) the following should be sufficient.

```lua
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'

if not configs.spvasm then
  configs.spvasm = {
    default_config = {
      cmd = { 'spirvls' },
      filetypes = { 'spvasm' },
      root_dir = function(fname)
        return '.'
      end,
      settings = {},
    },
  }
end

lspconfig.spvasm.setup {
  capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
}
```