json.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. local M = {}
  2. M.config = function()
  3. O.lang.json = {
  4. diagnostics = {
  5. virtual_text = { spacing = 0, prefix = "" },
  6. signs = true,
  7. underline = true,
  8. },
  9. formatter = {
  10. exe = "python",
  11. args = { "-m", "json.tool" },
  12. stdin = true,
  13. },
  14. lsp = {
  15. path = DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
  16. },
  17. }
  18. end
  19. M.format = function()
  20. O.formatters.filetype["json"] = {
  21. function()
  22. return {
  23. exe = O.lang.json.formatter.exe,
  24. args = O.lang.json.formatter.args,
  25. stdin = O.lang.json.formatter.stdin,
  26. }
  27. end,
  28. }
  29. require("formatter.config").set_defaults {
  30. logging = false,
  31. filetype = O.formatters.filetype,
  32. }
  33. end
  34. M.lint = function()
  35. -- TODO: implement linters (if applicable)
  36. return "No linters configured!"
  37. end
  38. M.lsp = function()
  39. if require("lv-utils").check_lsp_client_active "jsonls" then
  40. return
  41. end
  42. -- npm install -g vscode-json-languageserver
  43. require("lspconfig").jsonls.setup {
  44. cmd = {
  45. "node",
  46. O.lang.json.lsp.path,
  47. "--stdio",
  48. },
  49. on_attach = require("lsp").common_on_attach,
  50. commands = {
  51. Format = {
  52. function()
  53. vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
  54. end,
  55. },
  56. },
  57. }
  58. end
  59. M.dap = function()
  60. -- TODO: implement dap
  61. return "No DAP configured!"
  62. end
  63. return M