1
Fork 0

feat: ts formatting

This commit is contained in:
Matei Adriel 2022-02-23 15:52:27 +02:00
parent 1e499dccba
commit c45475a62d
2 changed files with 9 additions and 3 deletions

View file

@ -103,12 +103,12 @@ function M.setup()
settings = {rootMarkers = {".git/"}, languages = efmLanguages} 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 -- Auto format
for extension, timeout in pairs(autoFormatOn) do for extension, timeout in pairs(autoFormatOn) do
-- I wonder if this could be done in a single glob pattern -- 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
end end

View file

@ -1,7 +1,13 @@
local M = {} local M = {}
function M.setup() 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 end
return M return M