neovim: add Format command
This commit is contained in:
@@ -8,3 +8,14 @@ vim.api.nvim_create_user_command("FormattingEnable", formatting.enable, {})
|
||||
vim.api.nvim_create_user_command("FormattingDisable", formatting.disable, {})
|
||||
vim.api.nvim_create_user_command("FormattingToggle", formatting.toggle, {})
|
||||
vim.api.nvim_create_user_command("FormattingStatus", formatting.status, {})
|
||||
|
||||
vim.api.nvim_create_user_command("Format", function()
|
||||
local bf = vim.bo.filetype
|
||||
|
||||
if bf == "typescript" or bf == "typescriptreact" then
|
||||
vim.cmd(":!npx prettier --loglevel silent -w %")
|
||||
return
|
||||
end
|
||||
|
||||
vim.lsp.buf.format()
|
||||
end, {})
|
||||
|
||||
Reference in New Issue
Block a user