Cleanup nvim config
This commit is contained in:
parent
33cce48101
commit
d9e2c81e42
16 changed files with 174 additions and 488 deletions
|
|
@ -1,6 +1,9 @@
|
|||
return {
|
||||
"stevearc/conform.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
-- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters
|
||||
-- Formatters can be installed by mason
|
||||
formatters_by_ft = {
|
||||
-- Conform will run multiple formatters sequentially
|
||||
lua = { "stylua" },
|
||||
|
|
@ -14,9 +17,27 @@ return {
|
|||
-- have other formatters configured.
|
||||
["_"] = { "trim_whitespace" },
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = true,
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
-- Disable with a global or buffer-local variable
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return { timeout_ms = 500, lsp_fallback = true }
|
||||
end,
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("conform").setup(opts)
|
||||
|
||||
local function toggleAutoFormat()
|
||||
-- to make this global, change b to g
|
||||
if vim.b.disable_autoformat == nil then
|
||||
vim.b.disable_autoformat = true
|
||||
return
|
||||
end
|
||||
|
||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||
end
|
||||
|
||||
MAP("n", "<leader>uf", toggleAutoFormat, "Toggle auto format")
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue