ts-fmt-lint.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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"},
  21. settings = {
  22. rootMarkers = {".git/", "package.json"},
  23. languages = {
  24. html = {prettier},
  25. css = {prettier},
  26. json = {prettier},
  27. yaml = {prettier}
  28. -- markdown = {markdownPandocFormat, markdownlint},
  29. }
  30. }
  31. }
  32. end
  33. return M