-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lsp: Make vim support more explicit, add code completions (#5917)
* Make vim support more explicit, add code completions * cleanup
- Loading branch information
Showing
10 changed files
with
16,272 additions
and
6,820 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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()), | ||
} | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2019 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e # Fail on any error. | ||
|
||
ROOT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
pushd ${ROOT_PATH} | ||
go run ./src/tools/gen-grammar.go --cache ./cache --template ./spirv.json.tmpl --out ./spirv.json | ||
go run ./src/tools/gen-grammar.go --cache ./cache --template ./src/schema/schema.go.tmpl --out ./src/schema/schema.go | ||
|
||
mkdir -p ./spirvls | ||
cp ./spirv.json ./spirvls | ||
|
||
go build -o ./spirvls/spirvls ./src/langsvr.go | ||
popd |
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.