How do folks set up neovim / vim for
# spicedb
s
How do folks set up neovim / vim for SpiceDB? I saw TreeSitter SpiceDB, but no not sure about LSP
v
Yep, there is a neovim treesitter grammar supported by a external contributor: https://github.com/authzed/awesome-spicedb?tab=readme-ov-file#third-party-tools SpiceDB also now exposes an LSP with the
spicebd lsp
command. Finally, we've built an official VSCode extension, powered by the LSP: https://marketplace.visualstudio.com/items?itemName=authzed.spicedb-vscode
s
I wired up the lsp in neovim, but its tossing errors
Copy code
[ERROR][2024-08-22 08:36:52] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/local/bin/spicedb"        "stderr"        '{"level":"info","diagnostics":0,"uri":"file:///home/smith/git/dns-poc/test.zed","time":"2024-08-22T08:36:52-04:00","message":"computed diagnostics"}\n{"level":"info","id":"0","method":"textDocument/didChange","params":"{\\"contentChanges\\":[{\\"text\\":\\"\\\\ndefinition user{}\\\\n\\\\n\\\\n\\\\ndefinition organization {}\\\\n\\\\ncaveat someCaveat(someParam int) {\\\\n\\\\tsomeParam \\\\u003e 2\\\\n}\\\\n\\"}],\\"textDocument\\":{\\"uri\\":\\"file:///home/smith/git/dns-poc/test.zed\\",\\"version\\":47}}","response":null,"time":"2024-08-22T08:36:52-04:00","message":"responded to LSP request"}\n'
[ERROR][2024-08-22 08:36:52] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/local/bin/spicedb"        "stderr"        '{"level":"info","method":"textDocument/diagnostic","uri":"file:///home/smith/git/dns-poc/test.zed","time":"2024-08-22T08:36:52-04:00","message":"textDocDiagnostic"}\n'
[ERROR][2024-08-22 08:36:52] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/local/bin/spicedb"        "stderr"        '{"level":"info","diagnostics":0,"uri":"file:///home/smith/git/dns-poc/test.zed","time":"2024-08-22T08:36:52-04:00","message":"computed diagnostics"}\n{"level":"info","uri":"file:///home/smith/git/dns-poc/test.zed","diagnostics":0,"time":"2024-08-22T08:36:52-04:00","message":"diagnostics complete"}\n{"level":"info","id":"45","method":"textDocument/diagnostic","params":"{\\"range\\":{\\"end\\":{\\"character\\":0,\\"line\\":10},\\"start\\":{\\"character\\":0,\\"line\\":0}},\\"textDocument\\":{\\"uri\\":\\"file:///home/smith/git/dns-poc/test.zed\\"}}","response":{"kind":"full","items":[]},"time":"2024-08-22T08:36:52-04:00","message":"responded to LSP request"}\n'
and format on save, cool!
Added this to my nvim-lspconfig server_configurations, and then required it in init.lua authzed.lua
Copy code
local util = require 'lspconfig.util'

return {
  default_config = {
    cmd = { 'spicedb', 'lsp'},
    filetypes = { 'authzed' },
    root_dir = util.root_pattern('.zed'),
    single_file_support = true,
  },
}
init.lua
Copy code
require('lspconfig').authzed.setup {
    capabilities = capabilities,
    on_attach = on_attach,
}
Filed an issue in NerdFonts to add SpiceDB Icon ;P
v
@Joey ☝️maybe you can look into those LPS errors? But it sounds likeit working @smithp4ntz ?
j
I don't think there are errors
I think its just logs on stderr
s
everything appearsto be wroking fine, I think @Joey might be right that its just logging to stderr
v
nice! @smithp4ntz would you be willing to contribute how to use the LSP with neovim to our docs? the modeling section would be a good place to perhaps add a new "IDE integration" section: https://authzed.com/docs/spicedb/modeling
s
@vroldanbet, yeah I'll see if I can get it to work with normal vim too and put in a PR. One thing that might be nice is to get it added to "Mason"
v
oh that's a nice idea, can you open an issue in the spicedb repo for this?
24 Views