nvim/lua/config/prettier.lua

13 lines
484 B
Lua
Raw Normal View History

2024-06-08 01:06:17 +02:00
vim.api.nvim_create_autocmd( { "BufWritePre" }, {
2024-05-23 08:33:22 +02:00
pattern = { "*.vue", "*.js", "*.ts" },
2024-06-08 01:06:17 +02:00
callback = function(ev)
2024-06-13 10:52:43 +02:00
local old_cursor = vim.api.nvim_win_get_cursor(0)
2024-06-08 01:06:17 +02:00
vim.api.nvim_command([[ :silent! %!/usr/bin/env prettier --stdin-filepath % ]])
2024-06-13 10:52:43 +02:00
local new_cursor = vim.api.nvim_win_get_cursor(0)
if old_cursor[1] ~= new_cursor[1] or old_cursor[2] ~= new_cursor[2] then
vim.cmd.normal(vim.api.nvim_replace_termcodes('<C-o>', true, true, true))
end
2024-06-08 01:06:17 +02:00
end
2024-05-23 08:33:22 +02:00
})