RPC implementation in Vim

I didn’t understand the purpose of the new RPC server until I watched the very helpful Youtube video. Of course, seeing that made me want the same functionality in my favorite editor, Vim. My first fairly crude stab at it is here: https://github.com/jgillies/vim-dbt/blob/master/dbtrpc.vim. This currently does nothing to deal with exceptions, and right now it’s really only meant to show the compiled SQL. Updates may or may not come.

Here’s a clip of it in action (those letters popping up are keystrokes):


@jesse this is unreal!!

It would be killer if the rpc server auto-reloaded when the dbt project files are updated. This is definitely coming, but in its current state, you’ll probably need to restart the server whenever the files change. One cool option could be to use fswatch (or similar) to restart the server when local files are updated?

Super slick, nice work!

Hey, you guys made it super easy to implement, even for a Python dummy like me. Which are the file changes that require a server restart?

I think any new files + modifications in models/, seeds/, macros/, dbt_modules, and dbt_project.yml should probably trigger a restart! Folders like tests/ and analysis are probably less important here, and you’d almost certainly want to ignore the target/ dir!

OK, got it. I actually never bothered testing it with dependencies, and now that I’m doing that, I’m seeing some issues. I don’t think they’ll be too hard to sort out, but the code probably isn’t useable in the real world at the moment.

Turned out the issues I was having were mostly related to me having stuff in the wrong spots in my project (this was my first time setting up a new project in a while…should have read the getting started docs). But yeah, I see what you mean about restarting the server. fswatch looks like it might work well. I’ll play around with it a bit later.

1 Like

So I finally got some time to goof around with this some more. I was able to replicate the dbt Cloud functionality of compiling, running the SQL, and returning the results, but the entire process is slow enough to make it kind of impractical (and to make this painful to watch; the suspense is killing me!).

Anyway, here it is in action:

Here are the tools I’m using to make it happen: