12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- -- formart 格式化
- return {
- "stevearc/conform.nvim",
- event = { "BufWritePre" },
- cmd = { "ConformInfo" },
- keys = {
- {
- -- Customize or remove this keymap to your liking
- "<leader>f",
- function()
- require("conform").format({ async = true, lsp_fallback = true })
- end,
- mode = "",
- desc = "Format buffer",
- },
- },
- -- Everything in opts will be passed to setup()
- opts = {
- -- Define your formatters
- formatters_by_ft = {
- lua = { "stylua" },
- python = { "isort", "black" },
- html = { 'htmlbeautifier' },
- css = { 'stylelint' },
- yaml = { 'yamlfix' },
- shell = { 'shellcheck' },
- json = { "ixjson" },
- javascript = { { "prettierd", "prettier" } }
- },
- -- Set up format-on-save
- format_on_save = { timeout_ms = 100, lsp_fallback = true },
- -- Customize formatters
- formatters = {
- shfmt = {
- prepend_args = { "-i", "2" },
- },
- },
- },
- init = function()
- -- If you want the formatexpr, here is the place to set it
- vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
- end,
- }
|