diff --git a/lua/custom/plugins/formatting.lua b/lua/custom/plugins/formatting.lua index 4fda24a1..d58b9d14 100644 --- a/lua/custom/plugins/formatting.lua +++ b/lua/custom/plugins/formatting.lua @@ -1,6 +1,16 @@ return { 'stevearc/conform.nvim', event = { 'BufReadPre', 'BufNewFile' }, + keys = { + { + 'tf', + function() + vim.g.disable_autoformat = not vim.g.disable_autoformat + end, + mode = '', + desc = 'Toggle Format On Save', + }, + }, config = function() local conform = require 'conform' @@ -20,11 +30,12 @@ return { liquid = { 'prettier' }, lua = { 'stylua' }, }, - format_on_save = { - lsp_fallback = true, - async = false, - timeout_ms = 1000, - }, + format_on_save = function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 1000, lsp_format = 'fallback' } + end, } end, } diff --git a/lua/custom/plugins/tstools.lua b/lua/custom/plugins/tstools.lua new file mode 100644 index 00000000..216c7929 --- /dev/null +++ b/lua/custom/plugins/tstools.lua @@ -0,0 +1,14 @@ +return { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + config = function() + require('typescript-tools').setup { + settings = { + jsx_close_tag = { + enable = true, + filetypes = { 'javascriptreact', 'typescriptreact', 'javascript' }, + }, + }, + } + end, +}