diff --git a/home/.config/nvim/lua/pluginconf/airline.lua b/home/.config/nvim/lua/pluginconf/airline.lua
index 8c3ef46..7184da5 100644
--- a/home/.config/nvim/lua/pluginconf/airline.lua
+++ b/home/.config/nvim/lua/pluginconf/airline.lua
@@ -2,15 +2,9 @@ local vim = require("vim")
local g = vim.g
local cmd = vim.cmd
-cmd[[
-Plug 'vim-airline/vim-airline'
-Plug 'vim-airline/vim-airline-themes'
-]]
-
--- Airline specific theming settings
-g.airline_theme = 'codedark' -- Use codedark theme from vim-airline-themes
-g.airline_right_sep = "" -- Don't use special separators (<)
-g.airline_left_sep = "" -- Don't use special separators (>)
+-- Don't use special separators
+g.airline_right_sep = "" -- (default: <)
+g.airline_left_sep = "" -- (default: >)
-- Tabline setup
-- TODO: Figure out how to set # separated variables in lua (open for PRs)
diff --git a/home/.config/nvim/lua/pluginconf/coc.vim b/home/.config/nvim/lua/pluginconf/coc.vim
index d8171ce..11be2ae 100644
--- a/home/.config/nvim/lua/pluginconf/coc.vim
+++ b/home/.config/nvim/lua/pluginconf/coc.vim
@@ -6,9 +6,6 @@
" however if anyone knows how to completely reproduce everything here in lua,
" this is open to pull requests
-Plug 'neoclide/coc.nvim', {'branch': 'release'}
-Plug 'antoinemadec/coc-fzf'
-
let g:coc_global_extensions = [
\ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css',
\ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml',
diff --git a/home/.config/nvim/lua/pluginconf/commentary.lua b/home/.config/nvim/lua/pluginconf/commentary.lua
index 804de99..69e80f8 100644
--- a/home/.config/nvim/lua/pluginconf/commentary.lua
+++ b/home/.config/nvim/lua/pluginconf/commentary.lua
@@ -1,9 +1,9 @@
local vim = require("vim")
local cmd = vim.cmd
-cmd[[Plug 'tpope/vim-commentary']]
-
+-- Set up shortcuts to quickly comment some code
Keymap("n", "", ":Commentary")
Keymap("v", "", ":Commentary")
+-- Set up comments for unhandled file types
cmd[[autocmd FileType apache setlocal commentstring=#\ %s]]
diff --git a/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua b/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua
index e37aea8..a2479e6 100644
--- a/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua
+++ b/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua
@@ -11,7 +11,7 @@ local fn = vim.fn
-- when I access something as an attribute, but it would be neat to see what that
-- attribute actually holds, is it a class or a fucntion. But from my searching,
-- I wasn't able to find anything like this. This is open to pull requests.
-cmd[[Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }]]
+-- Plugin: numirias/semshi
if (fn.has("python3")) then
fn.system({"pip", "install", "nvim", "--upgrade"})
diff --git a/home/.config/nvim/lua/pluginconf/fzf.lua b/home/.config/nvim/lua/pluginconf/fzf.lua
index 9fb1452..e520c6e 100644
--- a/home/.config/nvim/lua/pluginconf/fzf.lua
+++ b/home/.config/nvim/lua/pluginconf/fzf.lua
@@ -2,10 +2,6 @@ local vim = require("vim")
local cmd = vim.cmd
local g = vim.g
-cmd[[Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }]]
-cmd[[Plug 'junegunn/fzf.vim']]
-cmd[[Plug 'stsewd/fzf-checkout.vim']]
-
g.fzf_layout = {
up = '~90%',
window = {
diff --git a/home/.config/nvim/lua/pluginconf/nerdtree.lua b/home/.config/nvim/lua/pluginconf/nerdtree.lua
index a4fbca2..47e7183 100644
--- a/home/.config/nvim/lua/pluginconf/nerdtree.lua
+++ b/home/.config/nvim/lua/pluginconf/nerdtree.lua
@@ -3,12 +3,6 @@ local g = vim.g
local fn = vim.fn
local cmd = vim.cmd
-cmd[[
-Plug 'preservim/nerdtree'
-Plug 'Xuyuanp/nerdtree-git-plugin'
-Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
-]]
-
-- Implement manual NERDTreeToggle, but use NERDTreeFind for openning.
-- This makes NERDTree open with the current file pre-selected
Keymap("n", "", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true})
diff --git a/home/.config/nvim/lua/pluginconf/polyglot.lua b/home/.config/nvim/lua/pluginconf/polyglot.lua
index 91d3eff..b9b9187 100644
--- a/home/.config/nvim/lua/pluginconf/polyglot.lua
+++ b/home/.config/nvim/lua/pluginconf/polyglot.lua
@@ -2,8 +2,6 @@ local vim = require("vim")
local cmd = vim.cmd
local g = vim.g
-cmd[[Plug 'sheerun/vim-polyglot']]
-
-- Disable polyglot's "sensible" settings, while there are some nice things it
-- does, I set these manually in my default config and I don't like depending
-- on single plugin for so many things, doing it manually doing it manually is
diff --git a/home/.config/nvim/lua/pluginconf/vim-code-dark.lua b/home/.config/nvim/lua/pluginconf/vim-code-dark.lua
index de7fc35..6690b7f 100644
--- a/home/.config/nvim/lua/pluginconf/vim-code-dark.lua
+++ b/home/.config/nvim/lua/pluginconf/vim-code-dark.lua
@@ -1,12 +1,4 @@
local vim = require("vim")
local cmd = vim.cmd
-cmd[[Plug 'tomasiser/vim-code-dark']]
-
--- Set vim-code-dark as colortheme after plugin loading was finished
-cmd[[
-augroup VimCodeDark
- autocmd!
- autocmd User PlugLoaded ++nested colorscheme codedark
-augroup end
-]]
+cmd[[colorscheme codedark]]
diff --git a/home/.config/nvim/lua/pluginconf/vimwiki.lua b/home/.config/nvim/lua/pluginconf/vimwiki.lua
index 8f266e5..80a10cc 100644
--- a/home/.config/nvim/lua/pluginconf/vimwiki.lua
+++ b/home/.config/nvim/lua/pluginconf/vimwiki.lua
@@ -2,8 +2,6 @@ local vim = require("vim")
local cmd = vim.cmd
local g = vim.g
-cmd[[Plug 'vimwiki/vimwiki']]
-
local wiki_conf = {}
wiki_conf["path"] = "~/Personal/vimwiki"
wiki_conf["path_html"] = "~/Personal/vimwiki-html"
diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua
index 3584fb0..06e0e06 100644
--- a/home/.config/nvim/lua/plugins.lua
+++ b/home/.config/nvim/lua/plugins.lua
@@ -1,56 +1,119 @@
local vim = require("vim")
local cmd = vim.cmd
+local api = vim.api
local fn = vim.fn
-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)
-
--- 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]]
- cmd[[autocmd VimEnter * UpdateRemotePlugins]]
+-- Automatically download (bootstrap) packer plugin manager
+-- if it's not already installed
+local packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
+local packer_bootstrap
+if fn.empty(fn.glob(packer_install_path)) > 0 then
+ print("Installing packer plugin manager, please wait...")
+ packer_bootstrap = fn.system({
+ 'git', 'clone', '--depth', '1',
+ 'https://github.com/wbthomason/packer.nvim',
+ packer_install_path
+ })
+ print("Packer installed, reload vim to install plugins")
end
--- 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
- LoadFile(plugin_path)
+-- Automatically run :PackerCompile if plugins.lua is updated
+cmd[[
+augroup packer_user_config
+ autocmd!
+ autocmd BufWritePost ~/.config/nvim/lua/plugins.lua source | PackerCompile
+augroup end
+]]
+
+-- Returns the line to be executed after plugin is loaded, this
+-- is useful for the `config` parameter of packer's use to
+-- source `.vim` files or require `.lua` files
+-- Expects a file path from pluginconf/ folder
+local function get_plugin_file(pluginconf_file)
+ local filename, extension = pluginconf_file:match("^(.+)(%..+)$")
+ if (extension == ".vim") then
+ -- Source wants absolute path
+ local pluginconf_path = fn.stdpath("config") .. "lua/pluginconf"
+ local source_line = string.format('source "%s/%s"', pluginconf_path, pluginconf_file)
+ return string.format("vim.fn.execute('%s')", source_line)
+ else
+ -- Require wants relative path from lua/
+ local pluginconf_path = "pluginconf"
+ return string.format('require("%s/%s")', pluginconf_path, filename)
+ end
end
--- Load a single given plugin using a Plug call
-local function load_plugin(plugin)
- cmd("Plug '" .. plugin .. "'")
-end
+-- Make sure to add packer here, even if it's opt
+api.nvim_command("packadd packer.nvim")
+-- Define packer plugins
+return require("packer").startup({
+ function(use)
+ use("wbthomason/packer.nvim")
+ use('airblade/vim-gitgutter')
+ use('dhruvasagar/vim-table-mode')
+ use('tmhedberg/SimpylFold')
+ use('wakatime/vim-wakatime')
+ use('mhinz/vim-startify')
+ use('ryanoasis/vim-devicons')
+ use({
+ "tomasiser/vim-code-dark",
+ config = get_plugin_file("vim-code-dark.lua"),
+ })
+ use({
+ "vim-airline/vim-airline",
+ config = get_plugin_file("airline.lua"),
+ requires = { "vim-airline/vim-airline-themes", opt = true },
+ })
+ use({
+ "preservim/nerdtree",
+ config = get_plugin_file("nerdtree.lua"),
+ requires = {
+ { "Xuyuanp/nerdtree-git-plugin", opt = true },
+ { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true },
+ },
+ })
+ use({
+ "vimwiki/vimwiki",
+ config = get_plugin_file("vimwiki.lua")
+ })
+ use({
+ "sheerun/vim-polyglot",
+ setup = get_plugin_file("polyglot.lua")
+ })
+ use({
+ "tpope/vim-commentary",
+ config = get_plugin_file("commentary.lua")
+ })
+ use({
+ "junegunn/fzf",
+ run = function() fn['fzf#install']() end,
+ })
+ use({
+ "junegunn/fzf.vim",
+ config = get_plugin_file("fzf.lua"),
+ after = "fzf",
+ requires = { "stsewd/fzf-checkout.vim", opt = true },
+ })
+ use({
+ "neoclide/coc.nvim",
+ branch = "release",
+ config = get_plugin_file("coc.vim"),
+ requires = { "antoinemadec/coc-fzf", opt = true },
+ })
--- 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')
-load_plugin_file("polyglot.lua")
-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")
-load_plugin_file("fzf.lua")
-
--- 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]]
+ -- Run sync if we've just bootstrapped packer
+ if packer_bootstrap then
+ require("packer").sync()
+ end
+ end,
+ config = {
+ display = {
+ open_fn = require('packer.util').float,
+ },
+ profile = {
+ enable = true,
+ threshold = 1, -- the amount in ms that a plugins load time must be over for it to be included in the profile
+ },
+ }
+})