save
This commit is contained in:
@@ -1,30 +1,42 @@
|
|||||||
return {
|
return {
|
||||||
"stevearc/conform.nvim",
|
"stevearc/conform.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"tpope/vim-sleuth",
|
"tpope/vim-sleuth",
|
||||||
},
|
},
|
||||||
event = { "BufWritePre" },
|
event = { "BufWritePre" },
|
||||||
cmd = { "ConformInfo" },
|
cmd = { "ConformInfo" },
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>f",
|
"<leader>f",
|
||||||
function()
|
function()
|
||||||
require("conform").format({ async = true, lsp_fallback = true })
|
require("conform").format { async = true, lsp_fallback = true }
|
||||||
end,
|
end,
|
||||||
mode = "",
|
mode = "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
notify_on_error = false,
|
notify_on_error = false,
|
||||||
format_on_save = function(bufnr)
|
format_on_save = function(bufnr)
|
||||||
local disable_filetypes = { c = true, cpp = true }
|
local disable_filetypes = { c = true, cpp = true }
|
||||||
return {
|
return {
|
||||||
timeout_ms = 500,
|
timeout_ms = 500,
|
||||||
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
|
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { "stylua" },
|
lua = { "stylua" },
|
||||||
},
|
},
|
||||||
},
|
hooks = {
|
||||||
|
pre_format = function(lines, _)
|
||||||
|
-- Strip comments
|
||||||
|
local no_comments = {}
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
if not line:match "%s*//" and not line:match "%s*/%*.*%*/" then
|
||||||
|
table.insert(no_comments, line)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return no_comments
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,5 +49,4 @@ function clip() {
|
|||||||
cat $1 | clip.exe
|
cat $1 | clip.exe
|
||||||
}
|
}
|
||||||
|
|
||||||
# Motd logic
|
fastfetch
|
||||||
clear; cal; cat ~/.motd
|
|
||||||
|
|||||||
Reference in New Issue
Block a user