-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
116 lines (105 loc) · 3.07 KB
/
init.lua
File metadata and controls
116 lines (105 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
local function safe_require(module)
local ok, mod = pcall(require, module)
if ok then
return mod
else
vim.notify("Error loading " .. module .. "\n\n" .. mod, vim.log.levels.ERROR)
return nil
end
end
local function runPlugins()
require("lazy").setup({
require("plugins.neotree"),
require("plugins.theme"),
require("plugins.lualine"),
require("plugins.syntax"),
require("plugins.telescope"),
require("plugins.lazydev"),
require("plugins.lsp"),
require("plugins.autoformat"),
require("plugins.autocomplete"),
require("plugins.neostart"),
-- [[ Stuff in other_stuff ]]
-- vim-tmux-vavigator, vim-sleuth
-- vim-fugitive, vime-rhubarb
-- which-key.nvim, nvim-autopairs
-- todo-comments.nvim, nvim-colorizer.lua
-- undotree, Comment.nvim
-- gitsigns.nvim, live-server.nvim
require("plugins.other_stuff"),
require("plugins.tablines"),
require("plugins.peek"),
require("plugins.fugitive"),
-- require("plugins.ufo"), --comment out if you want fold
})
end
local function openCloseTree()
vim.keymap.set({ "n", "v", "o" }, "<Space>", "<Nop>", { silent = true })
vim.keymap.set("n", "<Space>", function()
if vim.bo.filetype == "neo-tree" then
vim.cmd("Neotree close")
else
vim.cmd("Neotree reveal")
end
end, { desc = "Toggle Neo-tree reveal or close", noremap = true, silent = true })
end
local function setTabToDefault()
vim.keymap.set("i", "<Tab>", "<Tab>", { expr = false }) -- cancel built-in snippet jump
vim.keymap.set("i", "<S-Tab>", "<S-Tab>", { expr = false }) -- cancel built-in snippet jump
vim.keymap.del("i", "<Tab>")
vim.keymap.del("i", "<S-Tab>")
end
local function cleanOldUndoFiles()
-- cleans up the old undotree files
local undo = require("core.cleanupUndo")
undo.setup() -- setup undo dir and options
undo.cleanup(120) -- delete undo files older than 60 days
end
local function loadKeymaps()
-- Safely load core config
local keymaps = safe_require("core.keymaps")
if keymaps and type(keymaps.setup) == "function" then
keymaps.setup()
end
end
local function tempManager()
local ok, tempmanager = pcall(require, "core.tempmanager")
if ok then
tempmanager.setup()
end
end
local function setupLazy()
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
error("Error cloning lazy.nvim:\n" .. out)
end
end
local rtp = vim.opt.rtp
rtp:prepend(lazypath)
end
local function loadTheme()
vim.cmd([[colorscheme tokyonight]])
vim.api.nvim_set_hl(0, "Folded", { bg = "NONE", fg = "#d6a849", italic = true })
end
local function runCodes()
setTabToDefault()
tempManager()
safe_require("core.options")
setupLazy()
cleanOldUndoFiles()
runPlugins()
loadTheme()
loadKeymaps()
vim.api.nvim_create_autocmd("FileType", {
pattern = "fugitive",
callback = function()
vim.cmd("setlocal syntax=git")
end,
})
vim.cmd("cabbrev git Git")
openCloseTree()
end
runCodes()