So I've installed the clang-format on my ubuntu machine and I want to make a keymap that everytime I to format my current working file. I had this for other languages, using null-ls and mason-lspconfig:
vim.keymap.set('n', '<Esc>', ':Format<CR>', { noremap = true, silent = true })
vim.keymap.set('i', '<Esc>', '<Esc>:w<CR>:Format<CR>', { noremap = true, silent = true })
This works with clang LSP, but is not formatting the way I want, that's why I want to use clang-format ( witch shows in :Mason but idk how to set it up from there ). So I wanted to remap the previous keymaps using this:
if check_cpp(curr_file) then
local command = string.format('clang-format --style=file -i %s', vim.fn.shellescape(curr_file))
vim.fn.system(command)
end
How should I do it?