diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index 35ba6cf..88ad60f 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -1,15 +1,25 @@ local options = { formatters_by_ft = { lua = { "stylua" }, + sql = { "pg_format", "sqlfluff" }, -- pg_format first, fallback to sqlfluff + json = { "jq" }, + markdown = { "mdformat" }, -- css = { "prettier" }, -- html = { "prettier" }, }, - - -- format_on_save = { - -- -- These options will be passed to conform.format() - -- timeout_ms = 500, - -- lsp_fallback = true, - -- }, + -- 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", "-" }, + }, + }, } return options diff --git a/lua/mappings.lua b/lua/mappings.lua index fd1f41f..11c1bac 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -57,3 +57,6 @@ vim.keymap.set('x', '"', function() local text = vim.fn.getreg('"') -- Get the visually selected text vim.cmd('normal! c"' .. text .. '"') end, { desc = "Wrap selected text in double quotes" }) + +-- Gitsigns blame current line +vim.keymap.set("n", "gb", ":Gitsigns blame_line", { noremap = true, silent = true, desc = "Git blame line" }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 90ef158..91e60f9 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,10 +1,25 @@ return { + -- Conform (formatter) { "stevearc/conform.nvim", - -- event = 'BufWritePre', -- uncomment for format on save - opts = require "configs.conform", + lazy = false, + cmd = { "ConformInfo", "ConformFormat" }, -- enables :ConformInfo before load + keys = { + { + "g+w", + function() + require("conform").format({ async = false, lsp_fallback = true }) + end, + mode = "n", + desc = "Format file (Conform)", + }, + }, + config = function() + require("conform").setup(require "configs.conform") + end, }, + -- LSP { "neovim/nvim-lspconfig", config = function() @@ -12,11 +27,13 @@ return { end, }, + -- File explorer { "nvim-tree/nvim-tree.lua", opts = require "configs.nvimtree", }, + -- Telescope { 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, @@ -24,14 +41,14 @@ return { require "configs.telescope" end }, + + -- Treesitter { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', config = function() require'nvim-treesitter.configs'.setup { - -- Enable Treesitter syntax highlighting - ensure_installed = { "markdown", "sql","vim", - "lua", "vimdoc", "html", "css" }, -- add other languages if needed + ensure_installed = { "markdown", "sql", "vim", "lua", "vimdoc", "html", "css" }, highlight = { enable = true, additional_vim_regex_highlighting = { "markdown" }, @@ -39,10 +56,21 @@ return { } end, }, + + -- Transparent { - 'xiyaowong/transparent.nvim', - lazy = false - } + 'xiyaowong/transparent.nvim', + lazy = false + }, + + -- Mason (to install formatters like pgformatter/sqlfluff) + { + "williamboman/mason.nvim", + cmd = { "Mason", "MasonInstall", "MasonUpdate" }, + config = function() + require("mason").setup() + end, + }, -- { -- "nvim-treesitter/nvim-treesitter", -- opts = {