efm-general-ls.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. -- Example configuations here: https://github.com/mattn/efm-langserver
  2. -- python
  3. local flake8 = {
  4. LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -",
  5. lintStdin = true,
  6. lintFormats = {"%f:%l:%c: %m"}
  7. }
  8. local isort = {formatCommand = "isort --quiet -", formatStdin = true}
  9. local yapf = {formatCommand = "yapf --quiet", formatStdin = true}
  10. -- lua
  11. local luaFormat = {
  12. formatCommand = "lua-format -i --no-keep-simple-function-one-line --column-limit=120",
  13. formatStdin = true
  14. }
  15. -- JavaScript/React/TypeScript
  16. local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true}
  17. local eslint = {
  18. lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
  19. lintIgnoreExitCode = true,
  20. lintStdin = true,
  21. lintFormats = {"%f:%l:%c: %m"},
  22. formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
  23. formatStdin = true
  24. }
  25. require"lspconfig".efm.setup {
  26. -- init_options = {initializationOptions},
  27. init_options = {documentFormatting = true, codeAction = false},
  28. filetypes = {"lua", "python", "javascriptreact", "javascript"},
  29. settings = {
  30. rootMarkers = {".git/"},
  31. languages = {
  32. lua = {luaFormat},
  33. python = {isort, yapf},
  34. javascriptreact = {prettier, eslint},
  35. javascript = {prettier, eslint}
  36. }
  37. }
  38. }
  39. -- TODO turn these eslint and prettier examples into something good
  40. -- TODO also shellcheck and shell formatting
  41. -- Also find way to toggle format on save
  42. -- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim