init.lua 2.3 KB

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