sh.lua 924 B

123456789101112131415161718192021222324252627282930313233
  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.linter == "shellcheck" then
  15. table.insert(sh_arguments, shellcheck)
  16. end
  17. require("lspconfig").efm.setup {
  18. -- init_options = {initializationOptions},
  19. cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
  20. init_options = { documentFormatting = true, codeAction = false },
  21. filetypes = { "sh" },
  22. settings = {
  23. rootMarkers = { ".git/" },
  24. languages = {
  25. sh = sh_arguments,
  26. },
  27. },
  28. }