ts-fmt-lint.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. -- Example configuations here: https://github.com/mattn/efm-langserver
  2. -- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed.
  3. local M = {}
  4. M.setup = function()
  5. local tsserver_args = {}
  6. local prettier = {
  7. formatCommand = "prettier --stdin-filepath ${INPUT}",
  8. formatStdin = true
  9. }
  10. if vim.fn.glob("node_modules/.bin/prettier") ~= "" then
  11. prettier = {
  12. formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}",
  13. formatStdin = true
  14. }
  15. end
  16. require"lspconfig".efm.setup {
  17. -- init_options = {initializationOptions},
  18. cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"},
  19. init_options = {documentFormatting = true, codeAction = false},
  20. filetypes = {"html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact"},
  21. settings = {
  22. rootMarkers = {".git/", "package.json"},
  23. languages = {
  24. html = {prettier},
  25. css = {prettier},
  26. json = {prettier},
  27. yaml = {prettier}
  28. }
  29. }
  30. }
  31. end
  32. return M