json.lua 1.2 KB

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