sh.lua 1004 B

12345678910111213141516171819202122232425262728293031323334353637
  1. -- npm i -g bash-language-server
  2. require("lspconfig").bashls.setup {
  3. cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
  4. on_attach = require("lsp").common_on_attach,
  5. filetypes = { "sh", "zsh" },
  6. }
  7. -- sh
  8. local sh_arguments = {}
  9. local shfmt = { formatCommand = "shfmt -ci -s -bn", formatStdin = true }
  10. local shellcheck = {
  11. LintCommand = "shellcheck -f gcc -x",
  12. lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m" },
  13. }
  14. if O.lang.sh.formatter == "shfmt" then
  15. table.insert(sh_arguments, shfmt)
  16. end
  17. if O.lang.sh.linter == "shellcheck" then
  18. table.insert(sh_arguments, shellcheck)
  19. end
  20. require("lspconfig").efm.setup {
  21. -- init_options = {initializationOptions},
  22. cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
  23. init_options = { documentFormatting = true, codeAction = false },
  24. filetypes = { "sh" },
  25. settings = {
  26. rootMarkers = { ".git/" },
  27. languages = {
  28. sh = sh_arguments,
  29. },
  30. },
  31. }