|
@@ -272,63 +272,5 @@ 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")
|
|
|
-
|
|
|
--- only format with LSP if there are clients attached
|
|
|
-local lsp_formatter = formatters.custom({
|
|
|
- format = function()
|
|
|
- local bufnr = vim.api.nvim_get_current_buf()
|
|
|
- local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
|
|
|
- if #clients > 0 then
|
|
|
- vim.lsp.buf.format({ timeout_ms = 4000, bufnr = bufnr })
|
|
|
- end
|
|
|
- end
|
|
|
-})
|
|
|
-
|
|
|
--- the built-in formatter was not playing well with folds
|
|
|
-local whitespace_formatter = formatters.custom({
|
|
|
- format = function()
|
|
|
- vim.cmd('%s/\\s\\+$//e')
|
|
|
- end
|
|
|
-})
|
|
|
-
|
|
|
-local js = {
|
|
|
- lsp_formatter,
|
|
|
- formatters.if_file_exists({
|
|
|
- pattern = {
|
|
|
- "dprint.json",
|
|
|
- "dprint.jsonc",
|
|
|
- ".dprint.json",
|
|
|
- ".dprint.jsonc",
|
|
|
- },
|
|
|
- formatter = formatters.shell({ cmd = { "dprint", "fmt", "--stdin", "%:p" }}),
|
|
|
- }),
|
|
|
-}
|
|
|
-
|
|
|
-format_on_save.setup({
|
|
|
- error_notifier = vim_notify,
|
|
|
-
|
|
|
- exclude_path_patterns = {
|
|
|
- "/node_modules/",
|
|
|
- },
|
|
|
-
|
|
|
- formatter_by_ft = {
|
|
|
- javascript = js,
|
|
|
- typescript = js,
|
|
|
- typescriptreact = js,
|
|
|
-
|
|
|
- -- don't format diffs
|
|
|
- diff = {},
|
|
|
- },
|
|
|
-
|
|
|
- fallback_formatter = {
|
|
|
- whitespace_formatter,
|
|
|
- lsp_formatter,
|
|
|
- },
|
|
|
-})
|
|
|
-
|
|
|
-- typescript-vim compiler options
|
|
|
vim.g.typescript_compiler_options = '--incremental --noEmit'
|