disable formatter for php
This commit is contained in:
parent
4458a8755e
commit
158e492332
1 changed files with 112 additions and 112 deletions
|
|
@ -46,15 +46,13 @@ return {
|
||||||
"--indent",
|
"--indent",
|
||||||
"2",
|
"2",
|
||||||
"--preserve-blank-lines",
|
"--preserve-blank-lines",
|
||||||
"--quiet"
|
"--quiet",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
format_on_save = function(bufnr)
|
format_on_save = function(bufnr)
|
||||||
-- Disable with a global or buffer-local variable
|
-- Disable with a global or buffer-local variable
|
||||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
return { timeout_ms = 2000, lsp_fallback = true }
|
return { timeout_ms = 2000, lsp_fallback = true }
|
||||||
end,
|
end,
|
||||||
|
|
@ -62,6 +60,13 @@ return {
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
require("conform").setup(opts)
|
require("conform").setup(opts)
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = { "php" },
|
||||||
|
callback = function(bufnr)
|
||||||
|
vim.b[bufnr].disable_autoformat = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
local function toggleAutoFormat()
|
local function toggleAutoFormat()
|
||||||
-- to make this global, change b to g
|
-- to make this global, change b to g
|
||||||
if vim.b.disable_autoformat == nil then
|
if vim.b.disable_autoformat == nil then
|
||||||
|
|
@ -92,26 +97,21 @@ return {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if args.bang then
|
if args.bang then vim.cmd("w") end
|
||||||
vim.cmd("w")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require("conform").format(
|
require("conform").format({
|
||||||
{
|
|
||||||
async = true,
|
async = true,
|
||||||
lsp_format = "fallback",
|
lsp_format = "fallback",
|
||||||
range = range,
|
range = range,
|
||||||
formatters = args.fargs
|
formatters = args.fargs,
|
||||||
},
|
}, callback)
|
||||||
callback
|
|
||||||
)
|
|
||||||
end, {
|
end, {
|
||||||
range = true,
|
range = true,
|
||||||
bang = true,
|
bang = true,
|
||||||
force = true,
|
force = true,
|
||||||
desc = "Format the document",
|
desc = "Format the document",
|
||||||
nargs = '*',
|
nargs = "*",
|
||||||
-- complete = function()
|
-- complete = function()
|
||||||
-- local formatters = require('conform').formatters_by_ft
|
-- local formatters = require('conform').formatters_by_ft
|
||||||
--
|
--
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue