Skip to content

Commit

Permalink
feat: improve SQL file handling and dbt syntax integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PedramNavid committed Sep 2, 2024
1 parent e913648 commit e031b58
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lua/dbtpal/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@

local projects = require "dbtpal.projects"
local config = require "dbtpal.config"

vim.api.nvim_create_augroup("dbtPal", {})


if config.options.custom_dbt_syntax_enabled then
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
group = "dbtPal",
pattern = { "*.sql" },
command = "set filetype=dbt syntax=dbt",
desc = "Enable custom dbt syntax",
callback = function()
vim.bo.filetype = "sql"
vim.cmd("runtime syntax/dbt.vim")
end,
desc = "Enable custom dbt syntax on top of SQL",
})
else
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
group = "dbtPal",
pattern = { "*.sql" },
callback = function()
vim.bo.filetype = "sql"
end,
desc = "Set filetype to SQL without custom dbt syntax",
})
end

Expand Down

0 comments on commit e031b58

Please sign in to comment.