From d9a0e4f05eb439e112ffca0db71c32e2c93d0cda Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 10 Dec 2023 00:40:17 -0600 Subject: [PATCH] feat(nvim): add (p)sql formatting --- dots/.config/nvim/lua/core/filetypes.lua | 2 ++ .../nvim/lua/plugins/configs/formatter.lua | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/dots/.config/nvim/lua/core/filetypes.lua b/dots/.config/nvim/lua/core/filetypes.lua index 3f940d63..6076d23d 100644 --- a/dots/.config/nvim/lua/core/filetypes.lua +++ b/dots/.config/nvim/lua/core/filetypes.lua @@ -11,12 +11,14 @@ M.setup = function() [".*/Azure%-Pipelines/.*%.yaml"] = "azure-pipelines", [".*/waybar/config"] = "jsonc", [".*/etc/systemd/.*"] = "systemd", + [".*%.psql"] = "sql" }, }) vim.treesitter.language.register("yaml", "azure-pipelines") vim.treesitter.language.register("gitignore", "dockerignore") vim.treesitter.language.register("html", "xml") + vim.treesitter.language.register("sql", "psql") end return M diff --git a/dots/.config/nvim/lua/plugins/configs/formatter.lua b/dots/.config/nvim/lua/plugins/configs/formatter.lua index 5d369816..a3673fef 100644 --- a/dots/.config/nvim/lua/plugins/configs/formatter.lua +++ b/dots/.config/nvim/lua/plugins/configs/formatter.lua @@ -25,6 +25,24 @@ return { markdown = filetypes.markdown.prettierd, css = filetypes.css.prettierd, lua = filetypes.lua.stylua, + psql = function () + return { + exe = "sql-formatter", + args = { + "-l", + "postgresql", + "--fix", + }, + } + end, + sql = function () + return { + exe = "sql-formatter", + args = { + "--fix", + }, + } + end, asm = function() return { exe = "asmfmt",