init.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. local M = {}
  2. --- Initialize lvim default configuration
  3. -- Define lvim global variable
  4. function M:init(opts)
  5. opts = opts or {}
  6. self.path = opts.path
  7. local utils = require "utils"
  8. require "config.defaults"
  9. -- Fallback config.lua to lv-config.lua
  10. if not utils.is_file(self.path) then
  11. local lv_config = self.path:gsub("config.lua$", "lv-config.lua")
  12. print(self.path, "not found, falling back to", lv_config)
  13. self.path = lv_config
  14. end
  15. local builtins = require "core.builtins"
  16. builtins.config(self)
  17. local settings = require "config.settings"
  18. settings.load_options()
  19. local lvim_lsp_config = require "lsp.config"
  20. lvim.lsp = vim.deepcopy(lvim_lsp_config)
  21. local supported_languages = {
  22. "asm",
  23. "bash",
  24. "beancount",
  25. "bibtex",
  26. "bicep",
  27. "c",
  28. "c_sharp",
  29. "clojure",
  30. "cmake",
  31. "comment",
  32. "commonlisp",
  33. "cpp",
  34. "crystal",
  35. "cs",
  36. "css",
  37. "cuda",
  38. "d",
  39. "dart",
  40. "dockerfile",
  41. "dot",
  42. "elixir",
  43. "elm",
  44. "emmet",
  45. "erlang",
  46. "fennel",
  47. "fish",
  48. "fortran",
  49. "gdscript",
  50. "glimmer",
  51. "go",
  52. "gomod",
  53. "graphql",
  54. "haskell",
  55. "hcl",
  56. "heex",
  57. "html",
  58. "java",
  59. "javascript",
  60. "javascriptreact",
  61. "jsdoc",
  62. "json",
  63. "json5",
  64. "jsonc",
  65. "julia",
  66. "kotlin",
  67. "latex",
  68. "ledger",
  69. "less",
  70. "lua",
  71. "markdown",
  72. "nginx",
  73. "nix",
  74. "ocaml",
  75. "ocaml_interface",
  76. "perl",
  77. "php",
  78. "pioasm",
  79. "ps1",
  80. "puppet",
  81. "python",
  82. "ql",
  83. "query",
  84. "r",
  85. "regex",
  86. "rst",
  87. "ruby",
  88. "rust",
  89. "scala",
  90. "scss",
  91. "sh",
  92. "solidity",
  93. "sparql",
  94. "sql",
  95. "supercollider",
  96. "surface",
  97. "svelte",
  98. "swift",
  99. "tailwindcss",
  100. "terraform",
  101. "tex",
  102. "tlaplus",
  103. "toml",
  104. "tsx",
  105. "turtle",
  106. "typescript",
  107. "typescriptreact",
  108. "verilog",
  109. "vim",
  110. "vue",
  111. "yaml",
  112. "yang",
  113. "zig",
  114. }
  115. require("lsp.manager").init_defaults(supported_languages)
  116. end
  117. local function deprecation_notice()
  118. local in_headless = #vim.api.nvim_list_uis() == 0
  119. if in_headless then
  120. return
  121. end
  122. for lang, entry in pairs(lvim.lang) do
  123. local deprecated_config = entry["lsp"] or {}
  124. if not vim.tbl_isempty(deprecated_config) then
  125. local msg = string.format(
  126. "Deprecation notice: [lvim.lang.%s.lsp] setting is no longer supported. See https://github.com/LunarVim/LunarVim#breaking-changes",
  127. lang
  128. )
  129. vim.schedule(function()
  130. vim.notify(msg, vim.log.levels.WARN)
  131. end)
  132. end
  133. end
  134. end
  135. --- Override the configuration with a user provided one
  136. -- @param config_path The path to the configuration overrides
  137. function M:load(config_path)
  138. local autocmds = require "core.autocmds"
  139. config_path = config_path or self.path
  140. local ok, err = pcall(vim.cmd, "luafile " .. config_path)
  141. if not ok then
  142. print("Invalid configuration", config_path)
  143. print(err)
  144. return
  145. end
  146. deprecation_notice()
  147. self.path = config_path
  148. autocmds.define_augroups(lvim.autocommands)
  149. local settings = require "config.settings"
  150. settings.load_commands()
  151. end
  152. return M