init.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. local utils = require "utils"
  2. local service = require "lsp.service"
  3. local null_ls = require "lsp.null-ls"
  4. local M = {}
  5. function M.config()
  6. require("lsp.kind").setup()
  7. require("lsp.handlers").setup()
  8. require("lsp.signs").setup()
  9. require("lsp.keybinds").setup()
  10. end
  11. function M.setup(lang)
  12. local lang_server = lvim.lang[lang].lsp
  13. local provider = lang_server.provider
  14. if utils.check_lsp_client_active(provider) then
  15. return
  16. end
  17. local overrides = lvim.lsp.override
  18. if utils.is_table(overrides) then
  19. if utils.has_value(overrides, lang) then
  20. return
  21. end
  22. end
  23. if utils.is_string(overrides) then
  24. if overrides == lang then
  25. return
  26. end
  27. end
  28. local sources = null_ls.setup(lang)
  29. for _, source in pairs(sources) do
  30. local method = source.method
  31. local format_method = "NULL_LS_FORMATTING"
  32. if utils.is_table(method) then
  33. if utils.has_value(method, format_method) then
  34. lang_server.setup.on_attach = service.no_formatter_on_attach
  35. end
  36. end
  37. if utils.is_string(method) then
  38. if method == format_method then
  39. lang_server.setup.on_attach = service.no_formatter_on_attach
  40. end
  41. end
  42. end
  43. if provider == "" or provider == nil then
  44. return
  45. end
  46. require("lspconfig")[provider].setup(lang_server.setup)
  47. end
  48. return M