From c45475a62d24463c36353885ca44ee554e9b7af8 Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Wed, 23 Feb 2022 15:52:27 +0200
Subject: [PATCH] feat: ts formatting

---
 dotfiles/neovim/lua/my/plugins/lspconfig.lua | 4 ++--
 dotfiles/neovim/lua/my/plugins/null-ls.lua   | 8 +++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/dotfiles/neovim/lua/my/plugins/lspconfig.lua b/dotfiles/neovim/lua/my/plugins/lspconfig.lua
index 5b387e7..ed858d4 100644
--- a/dotfiles/neovim/lua/my/plugins/lspconfig.lua
+++ b/dotfiles/neovim/lua/my/plugins/lspconfig.lua
@@ -103,12 +103,12 @@ function M.setup()
         settings = {rootMarkers = {".git/"}, languages = efmLanguages}
     }
 
-    local autoFormatOn = {lua = 200, purs = 1000, nix = 200, js = 300, ts = 300, tsx = 300, jsx = 300}
+    local autoFormatOn = {lua = 200, purs = 1000, nix = 200, ts = 200, js = 200, json = 200, scss = 200, tsx = 200, jsx = 200}
 
     -- Auto format
     for extension, timeout in pairs(autoFormatOn) do
         -- I wonder if this could be done in a single glob pattern
-        cmd("autocmd BufWritePre *." .. extension .. " lua vim.lsp.buf.formatting_sync(nil, " .. timeout .. ")")
+        cmd("autocmd BufWritePre *." .. extension .. " lua vim.lsp.buf.formatting_sync()")
     end
 end
 
diff --git a/dotfiles/neovim/lua/my/plugins/null-ls.lua b/dotfiles/neovim/lua/my/plugins/null-ls.lua
index 3aba241..ff41600 100644
--- a/dotfiles/neovim/lua/my/plugins/null-ls.lua
+++ b/dotfiles/neovim/lua/my/plugins/null-ls.lua
@@ -1,7 +1,13 @@
 local M = {}
 
 function M.setup()
-    -- Setup goes here
+    local null_ls = require("null-ls")
+
+    local sources = {
+        null_ls.builtins.formatting.prettierd -- format ts files
+    }
+
+    null_ls.setup({sources = sources})
 end
 
 return M