nvim.git

nvim

~
git clone https://github.com/debuman/nvim.git

lua/josean/plugins/formatting.lua (1053B)

      1 return {
      2   "stevearc/conform.nvim",
      3   lazy = true,
      4   event = { "BufReadPre", "BufNewFile" }, -- to disable, comment this out
      5   config = function()
      6     local conform = require("conform")
      7 
      8     conform.setup({
      9       formatters_by_ft = {
     10         javascript = { "prettier" },
     11         typescript = { "prettier" },
     12         javascriptreact = { "prettier" },
     13         typescriptreact = { "prettier" },
     14         svelte = { "prettier" },
     15         css = { "prettier" },
     16         html = { "prettier" },
     17         json = { "prettier" },
     18         yaml = { "prettier" },
     19         markdown = { "prettier" },
     20         graphql = { "prettier" },
     21         lua = { "stylua" },
     22         python = { "isort", "black" },
     23       },
     24       format_on_save = {
     25         lsp_fallback = true,
     26         async = false,
     27         timeout_ms = 1000,
     28       },
     29     })
     30 
     31     vim.keymap.set({ "n", "v" }, "<leader>mp", function()
     32       conform.format({
     33         lsp_fallback = true,
     34         async = false,
     35         timeout_ms = 1000,
     36       })
     37     end, { desc = "Format file or range (in visual mode)" })
     38   end,
     39 }