Add simple formatter with par.

main
Joshua Potter 2024-01-23 09:39:44 -07:00
parent e8ae478148
commit 12584e10fa
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,13 @@
local M = {}
function M.set_fmt_map()
vim.keymap.set('v', 'g|', function()
local width = vim.bo.textwidth
if width == 0 and vim.w.colorcolumn then
width = tonumber(vim.w.colorcolumn:match("[^,]+"))
end
return string.format("!par w%d<cr>", width ~= 0 and width or 80)
end, { expr = true })
end
return M

View File

@ -119,6 +119,7 @@ in
config = { config = {
home.packages = with pkgs; [ home.packages = with pkgs; [
par
ripgrep ripgrep
]; ];
@ -156,6 +157,7 @@ in
# Lua loader to search for our /nix/store/.../?.lua files. # Lua loader to search for our /nix/store/.../?.lua files.
(lib.mkBefore '' (lib.mkBefore ''
package.path = '${config}/?.lua;' .. package.path package.path = '${config}/?.lua;' .. package.path
require('utils.fmt').set_fmt_map()
'') '')
# Extra Lua configuration to be appended to `init.lua`. # Extra Lua configuration to be appended to `init.lua`.
(lib.mkAfter '' (lib.mkAfter ''