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