sh.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. if not require("lv-utils").check_lsp_client_active "bashls" then
  2. -- npm i -g bash-language-server
  3. require("lspconfig").bashls.setup {
  4. cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
  5. on_attach = require("lsp").common_on_attach,
  6. filetypes = { "sh", "zsh" },
  7. }
  8. end
  9. -- sh
  10. local sh_arguments = {}
  11. local shfmt = { formatCommand = "shfmt -ci -s -bn", formatStdin = true }
  12. local shellcheck = {
  13. LintCommand = "shellcheck -f gcc -x",
  14. lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m" },
  15. }
  16. if O.lang.sh.linter == "shellcheck" then
  17. table.insert(sh_arguments, shellcheck)
  18. end
  19. if not require("lv-utils").check_lsp_client_active "efm" then
  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. }
  32. end