efm-general-ls.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 prettier_global = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true}
  18. local eslint = {
  19. lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
  20. lintIgnoreExitCode = true,
  21. lintStdin = true,
  22. lintFormats = {"%f:%l:%c: %m"},
  23. formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
  24. formatStdin = true
  25. }
  26. local shellcheck = {
  27. LintCommand = 'shellcheck -f gcc -x',
  28. lintFormats = {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'}
  29. }
  30. local shfmt = {formatCommand = 'shfmt -ci -s -bn', formatStdin = true}
  31. local markdownlint = {
  32. -- TODO default to global lintrc
  33. -- lintcommand = 'markdownlint -s -c ./markdownlintrc',
  34. lintCommand = 'markdownlint -s',
  35. lintStdin = true,
  36. lintFormats = {'%f:%l %m', '%f:%l:%c %m', '%f: %l: %m'}
  37. }
  38. local markdownPandocFormat = {formatCommand = 'pandoc -f markdown -t gfm -sp --tab-stop=2', formatStdin = true}
  39. require"lspconfig".efm.setup {
  40. -- init_options = {initializationOptions},
  41. cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
  42. init_options = {documentFormatting = true, codeAction = false},
  43. filetypes = {"lua", "python", "javascriptreact", "javascript", "sh", "html", "css", "json", "yaml", "markdown"},
  44. settings = {
  45. rootMarkers = {".git/"},
  46. languages = {
  47. lua = {luaFormat},
  48. python = {isort, yapf},
  49. -- javascriptreact = {prettier, eslint},
  50. -- javascript = {prettier, eslint},
  51. javascriptreact = {prettier},
  52. javascript = {prettier_global},
  53. sh = {shellcheck, shfmt},
  54. html = {prettier_global},
  55. css = {prettier_global},
  56. json = {prettier_global},
  57. yaml = {prettier_global},
  58. -- markdown = {markdownPandocFormat, markdownlint},
  59. markdown = {markdownPandocFormat}
  60. }
  61. }
  62. }
  63. -- Also find way to toggle format on save
  64. -- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim