mirror of
https://github.com/CompeyDev/my-nvim-setup.git
synced 2024-12-12 12:50:37 +00:00
fix not using current file's path
This commit is contained in:
parent
14ef6759be
commit
e0d3950f50
1 changed files with 62 additions and 62 deletions
|
@ -5,27 +5,27 @@ local autocmd = vim.api.nvim_create_autocmd
|
||||||
-- This must be used for plugins that need to be loaded just after a file
|
-- This must be used for plugins that need to be loaded just after a file
|
||||||
-- ex : treesitter, lspconfig etc
|
-- ex : treesitter, lspconfig etc
|
||||||
M.lazy_load = function(tb)
|
M.lazy_load = function(tb)
|
||||||
autocmd(tb.events, {
|
autocmd(tb.events, {
|
||||||
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
|
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
|
||||||
callback = function()
|
callback = function()
|
||||||
if tb.condition() then
|
if tb.condition() then
|
||||||
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
|
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
|
||||||
|
|
||||||
-- dont defer for treesitter as it will show slow highlighting
|
-- dont defer for treesitter as it will show slow highlighting
|
||||||
-- This deferring only happens only when we do "nvim filename"
|
-- This deferring only happens only when we do "nvim filename"
|
||||||
if tb.plugin ~= "nvim-treesitter" then
|
if tb.plugin ~= "nvim-treesitter" then
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
require("packer").loader(tb.plugin)
|
require("packer").loader(tb.plugin)
|
||||||
if tb.plugin == "nvim-lspconfig" then
|
if tb.plugin == "nvim-lspconfig" then
|
||||||
vim.cmd "silent! do FileType"
|
vim.cmd("silent! do FileType")
|
||||||
end
|
end
|
||||||
end, 0)
|
end, 0)
|
||||||
else
|
else
|
||||||
require("packer").loader(tb.plugin)
|
require("packer").loader(tb.plugin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- load certain plugins only when there's a file opened in the buffer
|
-- load certain plugins only when there's a file opened in the buffer
|
||||||
|
@ -33,60 +33,60 @@ end
|
||||||
-- This gives an instant preview of nvim with the file opened
|
-- This gives an instant preview of nvim with the file opened
|
||||||
|
|
||||||
M.on_file_open = function(plugin_name)
|
M.on_file_open = function(plugin_name)
|
||||||
M.lazy_load {
|
M.lazy_load({
|
||||||
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||||
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
|
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
|
||||||
plugin = plugin_name,
|
plugin = plugin_name,
|
||||||
condition = function()
|
condition = function()
|
||||||
local file = vim.fn.expand "%"
|
local file = vim.fn.expand("%")
|
||||||
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||||
end,
|
end,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
M.packer_cmds = {
|
M.packer_cmds = {
|
||||||
"PackerSnapshot",
|
"PackerSnapshot",
|
||||||
"PackerSnapshotRollback",
|
"PackerSnapshotRollback",
|
||||||
"PackerSnapshotDelete",
|
"PackerSnapshotDelete",
|
||||||
"PackerInstall",
|
"PackerInstall",
|
||||||
"PackerUpdate",
|
"PackerUpdate",
|
||||||
"PackerSync",
|
"PackerSync",
|
||||||
"PackerClean",
|
"PackerClean",
|
||||||
"PackerCompile",
|
"PackerCompile",
|
||||||
"PackerStatus",
|
"PackerStatus",
|
||||||
"PackerProfile",
|
"PackerProfile",
|
||||||
"PackerLoad",
|
"PackerLoad",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.treesitter_cmds = {
|
M.treesitter_cmds = {
|
||||||
"TSInstall",
|
"TSInstall",
|
||||||
"TSBufEnable",
|
"TSBufEnable",
|
||||||
"TSBufDisable",
|
"TSBufDisable",
|
||||||
"TSEnable",
|
"TSEnable",
|
||||||
"TSDisable",
|
"TSDisable",
|
||||||
"TSModuleInfo",
|
"TSModuleInfo",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.mason_cmds = {
|
M.mason_cmds = {
|
||||||
"Mason",
|
"Mason",
|
||||||
"MasonInstall",
|
"MasonInstall",
|
||||||
"MasonInstallAll",
|
"MasonInstallAll",
|
||||||
"MasonUninstall",
|
"MasonUninstall",
|
||||||
"MasonUninstallAll",
|
"MasonUninstallAll",
|
||||||
"MasonLog",
|
"MasonLog",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.gitsigns = function()
|
M.gitsigns = function()
|
||||||
autocmd({ "BufRead" }, {
|
autocmd({ "BufRead" }, {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.fn.system [[git rev-parse 2>/dev/null]]
|
vim.fn.system("git rev-parse 2>/dev/null " .. vim.fn.expand("%:p:h"))
|
||||||
if vim.v.shell_error == 0 then
|
if vim.v.shell_error == 0 then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
require("packer").loader "gitsigns.nvim"
|
require("packer").loader("gitsigns.nvim")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in a new issue