|
@@ -268,5 +268,42 @@ cmp.setup({
|
|
|
},
|
|
|
})
|
|
|
|
|
|
+-- format on save
|
|
|
+local format_on_save = require("format-on-save")
|
|
|
+local formatters = require("format-on-save.formatters")
|
|
|
+local vim_notify = require("format-on-save.error-notifiers.vim-notify")
|
|
|
+
|
|
|
+local js = {
|
|
|
+ formatters.lsp,
|
|
|
+ formatters.if_file_exists({
|
|
|
+ pattern = {
|
|
|
+ "dprint.json",
|
|
|
+ "dprint.jsonc",
|
|
|
+ ".dprint.json",
|
|
|
+ ".dprint.jsonc",
|
|
|
+ },
|
|
|
+ formatter = formatters.shell({ cmd = { "dprint", "fmt", "--stdin", "%" }}),
|
|
|
+ }),
|
|
|
+}
|
|
|
+
|
|
|
+format_on_save.setup({
|
|
|
+ error_notifier = vim_notify,
|
|
|
+
|
|
|
+ exclude_path_patterns = {
|
|
|
+ "/node_modules/",
|
|
|
+ },
|
|
|
+
|
|
|
+ formatter_by_ft = {
|
|
|
+ javascript = js,
|
|
|
+ typescript = js,
|
|
|
+ typescriptreact = js,
|
|
|
+ },
|
|
|
+
|
|
|
+ fallback_formatter = {
|
|
|
+ formatters.remove_trailing_whitespace,
|
|
|
+ formatters.lsp,
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
-- typescript-vim compiler options
|
|
|
vim.g.typescript_compiler_options = '--incremental --noEmit'
|