Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
subratappt committed Jul 25, 2024
1 parent 0b17eb6 commit 7e904f4
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 372 deletions.
139 changes: 66 additions & 73 deletions lua/plugins/conform.lua
Original file line number Diff line number Diff line change
@@ -1,76 +1,69 @@
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable autoformat-on-save",
bang = true
})

vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save"
})

local options = {
lsp_fallback = true,

formatters_by_ft = {
lua = {
"stylua"
},

sh = {
"shfmt"
},

cpp = {
"clang-format"
},

c = {
"clang-format"
},

python = {
"black"
}
},

format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return {
timeout_ms = 3000,
lsp_fallback = true
}
end
}

return {
"stevearc/conform.nvim",
-- for users those who want auto-save conform + lazyloading!
event = "BufWritePre",
cmd = {
"ConformInfo"
},
config = function()
require("conform").setup(options)
end,
"stevearc/conform.nvim",
event = {
"BufWritePre",
},
cmd = {
"ConformInfo",
},
keys = {
{
-- Customize or remove this keymap to your liking
"<leader>fm",
function()
require("conform").format({
async = true,
})
end,
mode = "",
desc = "Format buffer",
},
},
-- This will provide type hinting with LuaLS
---@module "conform"
---@type conform.setupOpts
opts = {
-- Define your formatters
formatters_by_ft = {
lua = {
"stylua",
config = "~/.config/nvim/lua/stylua.toml",
},
python = {
-- "isort",
"black",
},
-- javascript = { "prettierd", "prettier", stop_after_first = true },
sh = {
"shfmt",
},

cpp = {
"clang-format",
},

-- Keymap
vim.keymap.set("n", "<leader>fm", function()
vim.lsp.buf.format {
async = true
}
end, {
desc = "Formating",
silent = true
})
c = {
"clang-format",
},
},
-- Set default options
default_format_opts = {
lsp_format = "fallback",
},
-- Set up format-on-save
format_on_save = {
timeout_ms = 500,
},
-- 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,
}
14 changes: 0 additions & 14 deletions lua/plugins/lsp_signature.lua

This file was deleted.

Loading

0 comments on commit 7e904f4

Please sign in to comment.