2021-11-30 19:22:51 +00:00
|
|
|
local vim = require("vim")
|
|
|
|
local cmd = vim.cmd
|
|
|
|
local fn = vim.fn
|
|
|
|
|
2021-12-06 12:15:32 +00:00
|
|
|
local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim)
|
|
|
|
local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim
|
|
|
|
local plugin_files_dir = config_dir .. "/lua/pluginconf" -- Dir with plugin config files including Plug call(s)
|
2021-11-30 19:22:51 +00:00
|
|
|
|
|
|
|
-- Automatically download vimplug and run PlugInstall
|
|
|
|
local autoload_dir = config_dir .. "/autoload"
|
|
|
|
local plug_install_path = autoload_dir .. "/plug.vim"
|
|
|
|
local plug_download_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
|
|
|
|
|
|
|
if fn.empty(fn.glob(plug_install_path)) > 0 then
|
|
|
|
print("Downloading vim-plug, there may be initial errors...")
|
|
|
|
fn.system({"mkdir", "-p", autoload_dir})
|
|
|
|
fn.system("curl " .. plug_download_url .. " > " .. plug_install_path)
|
|
|
|
cmd[[autocmd VimEnter * PlugInstall]]
|
2021-12-03 13:41:16 +00:00
|
|
|
cmd[[autocmd VimEnter * UpdateRemotePlugins]]
|
2021-11-30 19:22:51 +00:00
|
|
|
end
|
|
|
|
|
2021-12-03 13:40:29 +00:00
|
|
|
-- Load a file containing Plug call(s) and plugin settings
|
|
|
|
local function load_plugin_file(plugin_file)
|
|
|
|
local plugin_path = plugin_files_dir .. "/" .. plugin_file
|
2021-12-05 21:33:23 +00:00
|
|
|
LoadFile(plugin_path)
|
2021-11-30 19:22:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Load a single given plugin using a Plug call
|
|
|
|
local function load_plugin(plugin)
|
|
|
|
cmd("Plug '" .. plugin .. "'")
|
|
|
|
end
|
|
|
|
|
2021-12-03 18:00:47 +00:00
|
|
|
|
2021-11-30 19:22:51 +00:00
|
|
|
-- Begin Plug.vim loading process
|
|
|
|
cmd("call plug#begin('" .. plugvim_plugins_dir .. "')")
|
|
|
|
|
|
|
|
load_plugin('airblade/vim-gitgutter')
|
|
|
|
load_plugin('dhruvasagar/vim-table-mode')
|
|
|
|
load_plugin('tmhedberg/SimpylFold')
|
|
|
|
load_plugin('wakatime/vim-wakatime')
|
|
|
|
load_plugin('mhinz/vim-startify')
|
|
|
|
load_plugin('ryanoasis/vim-devicons')
|
2021-12-03 16:33:49 +00:00
|
|
|
load_plugin_file("polyglot.lua")
|
2021-11-30 19:22:51 +00:00
|
|
|
load_plugin_file("vim-code-dark.lua")
|
|
|
|
load_plugin_file("commentary.lua")
|
|
|
|
load_plugin_file("coc.vim")
|
|
|
|
load_plugin_file("vimwiki.lua")
|
|
|
|
load_plugin_file("nerdtree.lua")
|
|
|
|
load_plugin_file("airline.lua")
|
2021-12-06 11:44:42 +00:00
|
|
|
load_plugin_file("fzf.lua")
|
2021-11-30 19:22:51 +00:00
|
|
|
|
|
|
|
-- End Plug.vim loading process
|
|
|
|
cmd[[call plug#end()]]
|
|
|
|
|
|
|
|
-- Run autocmds defined in the plugin files after plugin loading has finished
|
|
|
|
cmd[[doautocmd User PlugLoaded]]
|