switch sql formatter to sql-formatter, filter obsidian workspaces by existence

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-02-19 11:43:19 -05:00
parent 8bd885a06a
commit 62b7744614
2 changed files with 21 additions and 28 deletions

View File

@ -1,7 +1,7 @@
local options = {
formatters_by_ft = {
lua = { "stylua" },
sql = { "pg_format", "sqlfluff" }, -- pg_format first, fallback to sqlfluff
sql = { "sql-formatter" },
json = { "jq" },
markdown = { "mdformat" },
-- css = { "prettier" },
@ -9,15 +9,10 @@ local options = {
},
-- no format_on_save (manual-only)
formatters = {
pg_format = {
prepend_args = {
"--keyword-case", "2", -- 1 = UPPER, 2 = lower
"--function-case", "2", -- 2 = lower
"--spaces", "4",
},
},
sqlfluff = {
args = { "fix", "--force", "--dialect", "postgres", "-" },
["sql-formatter"] = {
command = vim.fn.stdpath("data") .. "/mason/bin/sql-formatter",
args = { "-l", "postgresql" },
stdin = true,
},
},
}

View File

@ -1,5 +1,20 @@
local home = os.getenv("HOME") or "~"
local function dir_exists(path)
return vim.fn.isdirectory(vim.fn.expand(path)) == 1
end
local all_workspaces = {
{ name = "journal", path = home .. "/journal" },
{ name = "work", path = home .. "/hc_notes" },
{ name = "SQL", path = "/mnt/c/Users/ptrowbridge/SQL" },
{ name = "pl", path = "/mnt/c/Users/ptrowbridge/plbuild" },
}
local workspaces = vim.tbl_filter(function(w)
return dir_exists(w.path)
end, all_workspaces)
return {
"epwalsh/obsidian.nvim",
version = "*",
@ -9,24 +24,7 @@ return {
"nvim-lua/plenary.nvim",
},
opts = {
workspaces = {
{
name = "journal",
path = home .. "/journal",
},
{
name = "work",
path = home .. "/hc_notes",
},
{
name = "SQL",
path = "/mnt/c/Users/ptrowbridge/SQL",
},
{
name = "pl",
path = "/mnt/c/Users/ptrowbridge/plbuild",
},
},
workspaces = workspaces,
},
}