Closed nic-avant closed 1 year ago
I use LazyVim and I have this configured in ~/.config/nvim/lua/plugins/dbt.lua
return {
{
"PedramNavid/dbtpal",
opts = function()
local dbt = require("dbtpal")
dbt.setup({
-- Path to the dbt executable
path_to_dbt = "dbt",
-- Path to the dbt project, if blank, will auto-detect
-- using currently open buffer for all sql,yml, and md files
-- tried hard coding to my dbt-fundamentals project but it didn't work either
path_to_dbt_project = "",
-- Path to dbt profiles directory
path_to_dbt_profiles_dir = vim.fn.expand("~/.dbt"),
-- Search for ref/source files in macros and models folders
extended_path_search = true,
-- Prevent modifying sql files in target/(compiled|run) folders
protect_compiled_files = true,
})
-- Setup key mappings
vim.keymap.set("n", "<leader>drf", dbt.run)
vim.keymap.set("n", "<leader>drp", dbt.run_all)
vim.keymap.set("n", "<leader>dtf", dbt.test)
vim.keymap.set("n", "<leader>dm", require("dbtpal.telescope").dbt_picker)
-- Enable Telescope Extension
require("telescope").load_extension("dbtpal")
end,
dependencies = { { "nvim-lua/plenary.nvim" }, { "nvim-telescope/telescope.nvim" } },
},
}
Hey! Thanks for finding a bug, I think I narrowed it down to an issue with grep, hopefully the update I just pushed solves that.
This is my first time trying it with Lazy.nvim but I think you might have to slightly update the code as follows:
return {
{
"PedramNavid/dbtpal",
init = function()
require("dbtpal").setup({
-- Path to the dbt executable
path_to_dbt = "dbt",
path_to_dbt_project = "",
-- NOTE: You may need to change this if your course has a custom profiles.yml in the project directory.
path_to_dbt_profiles_dir = vim.fn.expand("~/.dbt"),
extended_path_search = true,
protect_compiled_files = true,
})
vim.keymap.set("n", "<leader>drf", require('dbtpal').run)
vim.keymap.set("n", "<leader>drp", require('dbtpal').run_all)
vim.keymap.set("n", "<leader>dtf", require('dbtpal').test)
vim.keymap.set("n", "<leader>dm", require("dbtpal.telescope").dbt_picker)
require("telescope").load_extension("dbtpal")
end,
},
}
Let me know if that works or if you're still having trouble.
It's attempting now! The new thing is that it's not auto-detecting my dbt project... I don't know if this would be related to the grep
problem so if it isn't then we could open a new issue, but basically I have a repo with project structure like this:
❯ tree . -L 2
.
├── README.md
├── data
│ ├── jaffle_shop_customers.csv
│ ├── jaffle_shop_orders.csv
│ ├── main.db
│ └── stripe_payments.csv
├── doom
│ ├── README.md
│ ├── analyses
│ ├── dbt_packages
│ ├── dbt_project.yml
│ ├── logs
│ ├── macros
│ ├── models
│ ├── seeds
│ ├── snapshots
│ ├── target
│ └── tests
├── init_db.py
├── logs
│ └── dbt.log
└── requirements.txt
13 directories, 10 files
And if I open nvim in .
or in ./doom
then DbtRun
I get this error:
dbt command failed: dbt --printer-width=10 run --select --profiles-dir v:null --project-dir v:null
Encountered an error:
Runtime Error
fatal: Invalid --project-dir flag. Not a dbt project. Missing dbt_project.yml file
But I had assumed the plugin would detect the dbt_project.yml
file in ./doom
This is the same dbt-fundamentals
project in your repo?
I opened nvim in ./doom
like this
DBTPAL_LOG_LEVEL=trace nvim models/staging/jaffle_shop/stg_customers.sql
then ran :DbtBuild It ran the command correctly (failed because I don't have the doom dbt profile but thats not the main issue)
Failed to run dbt command. Exit Code: 2
------------
dbt command failed: dbt --printer-width=10 --log-level=INFO build --profiles-dir /Users/pedram/.dbt --project-dir /Users/pedram/repos/dbt-fundamentals/doom
Can you try running using the trace log level and pasting everythign from messages after running :DbtBuild ?
Just to confirm, you did update :Lazy
and pressing U
?
So based on your error message I see that mine is different with --profiles-dir v:null
but in my lazy config I have:
path_to_dbt_profiles_dir = vim.fn.expand("~/.dbt"),
Lazy is updated - I do not think that is the problem
Opening nvim with the trace
didn't actually give me anymore of a message - looks like the profiles-dir is not being set right in the config or something?
Just set the path_to_dbt_profiles_dir
to the explicit full path to /Users/me/.dbt
and got the same issue - so looks to be definitely that that variable isn't getting bubbled around to where it needs to be... Is this another Mac-related issue?
Can you share the full config? Trace should’ve given you many more messages.
Make sure you’re using init, not opts, in your Lazy config too please
Well I changed opts
to init
and now we're in business!
I need to review LazyVim config I guess, I haven't used init
in any of my additional plugins
Thank you for responding to this so fast!
Thanks for reporting the bug! Feel free to keep the feature requests and issues coming.
Hello,
I'm starting to work with
dbt
and I'm exicted to see some plugins for neovim - I went to try this out with the jaffle_shop tutorial through the dbt-fundamentals course but none of the commands are working. I'm not a super savvy neovim user - so lua error messages are not second-nature for me to read but here's what I can copy out of:messages
Relevant Info:
dbt run
and all that works from the terminalgf
worksThanks for working on this extension - looking forward to using it heavily!