init.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. -- {{{ Bootstrap
  2. local home_dir = vim.loop.os_homedir()
  3. vim.opt.rtp:append(home_dir .. "/.local/share/lunarvim/lvim")
  4. vim.opt.rtp:remove(home_dir .. "/.config/nvim")
  5. vim.opt.rtp:remove(home_dir .. "/.config/nvim/after")
  6. vim.opt.rtp:append(home_dir .. "/.config/lvim")
  7. vim.opt.rtp:append(home_dir .. "/.config/lvim/after")
  8. vim.opt.rtp:remove(home_dir .. "/.local/share/nvim/site")
  9. vim.opt.rtp:remove(home_dir .. "/.local/share/nvim/site/after")
  10. vim.opt.rtp:append(home_dir .. "/.local/share/lunarvim/site")
  11. vim.opt.rtp:append(home_dir .. "/.local/share/lunarvim/site/after")
  12. -- TODO: we need something like this: vim.opt.packpath = vim.opt.rtp
  13. vim.cmd [[let &packpath = &runtimepath]]
  14. -- }}}
  15. local function file_exists(name)
  16. local f = io.open(name, "r")
  17. if f ~= nil then
  18. io.close(f)
  19. return true
  20. else
  21. return false
  22. end
  23. end
  24. local lvim_path = os.getenv "HOME" .. "/.config/lvim/"
  25. USER_CONFIG_PATH = lvim_path .. "config.lua"
  26. local config_exist = file_exists(USER_CONFIG_PATH)
  27. if not config_exist then
  28. USER_CONFIG_PATH = lvim_path .. "lv-config.lua"
  29. print "Rename ~/.config/lvim/lv-config.lua to config.lua"
  30. end
  31. require "default-config"
  32. local autocmds = require "core.autocmds"
  33. require("settings").load_options()
  34. local status_ok, error = pcall(vim.cmd, "luafile " .. USER_CONFIG_PATH)
  35. if not status_ok then
  36. print("something is wrong with your " .. USER_CONFIG_PATH)
  37. print(error)
  38. end
  39. require("settings").load_commands()
  40. autocmds.define_augroups(lvim.autocommands)
  41. local plugins = require "plugins"
  42. local plugin_loader = require("plugin-loader").init()
  43. plugin_loader:load { plugins, lvim.plugins }
  44. vim.g.colors_name = lvim.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs.
  45. vim.cmd("colorscheme " .. lvim.colorscheme)
  46. local utils = require "utils"
  47. utils.toggle_autoformat()
  48. local commands = require "core.commands"
  49. commands.load(commands.defaults)
  50. require("lsp").config()
  51. local null_status_ok, null_ls = pcall(require, "null-ls")
  52. if null_status_ok then
  53. null_ls.config {}
  54. require("lspconfig")["null-ls"].setup(lvim.lsp.null_ls.setup)
  55. end
  56. local lsp_settings_status_ok, lsp_settings = pcall(require, "nlspsettings")
  57. if lsp_settings_status_ok then
  58. lsp_settings.setup {
  59. config_home = os.getenv "HOME" .. "/.config/lvim/lsp-settings",
  60. }
  61. end
  62. require("keymappings").setup()
  63. -- TODO: these guys need to be in language files
  64. -- if lvim.lang.emmet.active then
  65. -- require "lsp.emmet-ls"
  66. -- end
  67. -- if lvim.lang.tailwindcss.active then
  68. -- require "lsp.tailwind