From 956bb2d423f18fbbd1857b3e4b241db49b080918 Mon Sep 17 00:00:00 2001 From: Colton Padden Date: Fri, 23 Feb 2024 15:19:42 -0500 Subject: [PATCH 1/2] add example configuration using lazy.nvim --- README.md | 83 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 697e8fa..48ec3fd 100644 --- a/README.md +++ b/README.md @@ -30,43 +30,76 @@ Install using your favorite plugin manager: **Using Packer** ```lua - -use {'PedramNavid/dbtpal', +use { + "PedramNavid/dbtpal", config = 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 - path_to_dbt_project = "", + local dbt = require("dbtpal") + dbt.setup({ + -- Path to the dbt executable + path_to_dbt = "dbt", - -- Path to dbt profiles directory - path_to_dbt_profiles_dir = vim.fn.expand "~/.dbt", + -- Path to the dbt project, if blank, will auto-detect + -- using currently open buffer for all sql,yml, and md files + path_to_dbt_project = "", - -- Search for ref/source files in macros and models folders - extended_path_search = true, + -- Path to dbt profiles directory + path_to_dbt_profiles_dir = vim.fn.expand("~/.dbt"), - -- Prevent modifying sql files in target/(compiled|run) folders - protect_compiled_files = true + -- 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', 'drf', dbt.run) - vim.keymap.set('n', 'drp', dbt.run_all) - vim.keymap.set('n', 'dtf', dbt.test) - vim.keymap.set('n', 'dm', require('dbtpal.telescope').dbt_picker) + vim.keymap.set("n", "drf", dbt.run) + vim.keymap.set("n", "drp", dbt.run_all) + vim.keymap.set("n", "dtf", dbt.test) + vim.keymap.set("n", "dm", require("dbtpal.telescope").dbt_picker) -- Enable Telescope Extension - require'telescope'.load_extension('dbtpal') - end, - requires = { { 'nvim-lua/plenary.nvim' }, {'nvim-telescope/telescope.nvim'} } - } + require("telescope").load_extension("dbtpal") + end, + requires = { { "nvim-lua/plenary.nvim" }, { "nvim-telescope/telescope.nvim" } }, +} +``` + +**Using lazy.nvim** +
+Show configuration... + +```lua +{ + "PedramNavid/dbtpal", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + }, + config = function() + local dbt = require("dbtpal") + + dbt.setup({ + path_to_dbt = "dbt", + path_to_dbt_project = "", + path_to_dbt_profiles_dir = vim.fn.expand("~/.dbt"), + extended_path_search = true, + protect_compiled_files = true, + }) + + vim.keymap.set("n", "drf", dbt.run) + vim.keymap.set("n", "drp", dbt.run_all) + vim.keymap.set("n", "dtf", dbt.test) + vim.keymap.set("n", "dm", require("dbtpal.telescope").dbt_picker) + + require("telescope").load_extension("dbtpal") + end, +} ``` +
+ ## 🙈 Commands dbtpal has sensible defaults and can auto-detect project directories based From 70ae092b0f82d7c6f88b7ebe654912a6d2c197cf Mon Sep 17 00:00:00 2001 From: Colton Padden Date: Sat, 24 Feb 2024 23:38:07 -0500 Subject: [PATCH 2/2] lazy.nvim add ft, keys --- README.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 48ec3fd..fcc21f2 100644 --- a/README.md +++ b/README.md @@ -78,22 +78,25 @@ use { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim", }, + ft = { + "sql", + "md", + "yaml", + }, + keys = { + { "drf", "DbtRun" }, + { "drp", "DbtRunAll" }, + { "dtf", "DbtTest" }, + { "dm", "lua require('dbtpal.telescope').dbt_picker()" }, + }, config = function() - local dbt = require("dbtpal") - - dbt.setup({ + require("dbtpal").setup({ path_to_dbt = "dbt", path_to_dbt_project = "", path_to_dbt_profiles_dir = vim.fn.expand("~/.dbt"), extended_path_search = true, protect_compiled_files = true, }) - - vim.keymap.set("n", "drf", dbt.run) - vim.keymap.set("n", "drp", dbt.run_all) - vim.keymap.set("n", "dtf", dbt.test) - vim.keymap.set("n", "dm", require("dbtpal.telescope").dbt_picker) - require("telescope").load_extension("dbtpal") end, }