Switch package manager to packer

This commit is contained in:
ItsDrike 2021-12-06 13:18:36 +01:00
parent c5baadf07f
commit dce7dd58d0
No known key found for this signature in database
GPG key ID: FB8CA11A2CF3A843
10 changed files with 116 additions and 84 deletions

View file

@ -2,15 +2,9 @@ local vim = require("vim")
local g = vim.g local g = vim.g
local cmd = vim.cmd local cmd = vim.cmd
cmd[[ -- Don't use special separators
Plug 'vim-airline/vim-airline' g.airline_right_sep = "" -- (default: <)
Plug 'vim-airline/vim-airline-themes' g.airline_left_sep = "" -- (default: >)
]]
-- 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 (>)
-- Tabline setup -- Tabline setup
-- TODO: Figure out how to set # separated variables in lua (open for PRs) -- TODO: Figure out how to set # separated variables in lua (open for PRs)

View file

@ -6,9 +6,6 @@
" however if anyone knows how to completely reproduce everything here in lua, " however if anyone knows how to completely reproduce everything here in lua,
" this is open to pull requests " this is open to pull requests
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'antoinemadec/coc-fzf'
let g:coc_global_extensions = [ let g:coc_global_extensions = [
\ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css', \ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css',
\ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', \ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml',

View file

@ -1,9 +1,9 @@
local vim = require("vim") local vim = require("vim")
local cmd = vim.cmd local cmd = vim.cmd
cmd[[Plug 'tpope/vim-commentary']] -- Set up shortcuts to quickly comment some code
Keymap("n", "<A-/>", ":Commentary<CR>") Keymap("n", "<A-/>", ":Commentary<CR>")
Keymap("v", "<A-/>", ":Commentary<CR>") Keymap("v", "<A-/>", ":Commentary<CR>")
-- Set up comments for unhandled file types
cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] cmd[[autocmd FileType apache setlocal commentstring=#\ %s]]

View file

@ -11,7 +11,7 @@ local fn = vim.fn
-- when I access something as an attribute, but it would be neat to see what that -- 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, -- 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. -- 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 if (fn.has("python3")) then
fn.system({"pip", "install", "nvim", "--upgrade"}) fn.system({"pip", "install", "nvim", "--upgrade"})

View file

@ -2,10 +2,6 @@ local vim = require("vim")
local cmd = vim.cmd local cmd = vim.cmd
local g = vim.g 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 = { g.fzf_layout = {
up = '~90%', up = '~90%',
window = { window = {

View file

@ -3,12 +3,6 @@ local g = vim.g
local fn = vim.fn local fn = vim.fn
local cmd = vim.cmd 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. -- Implement manual NERDTreeToggle, but use NERDTreeFind for openning.
-- This makes NERDTree open with the current file pre-selected -- This makes NERDTree open with the current file pre-selected
Keymap("n", "<C-n>", "g:NERDTree.IsOpen() ? ':NERDTreeClose<CR>' : @% == '' ? ':NERDTree<CR>' : ':NERDTreeFind<CR>'", {expr=true}) Keymap("n", "<C-n>", "g:NERDTree.IsOpen() ? ':NERDTreeClose<CR>' : @% == '' ? ':NERDTree<CR>' : ':NERDTreeFind<CR>'", {expr=true})

View file

@ -2,8 +2,6 @@ local vim = require("vim")
local cmd = vim.cmd local cmd = vim.cmd
local g = vim.g local g = vim.g
cmd[[Plug 'sheerun/vim-polyglot']]
-- Disable polyglot's "sensible" settings, while there are some nice things it -- 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 -- 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 -- on single plugin for so many things, doing it manually doing it manually is

View file

@ -1,12 +1,4 @@
local vim = require("vim") local vim = require("vim")
local cmd = vim.cmd local cmd = vim.cmd
cmd[[Plug 'tomasiser/vim-code-dark']] cmd[[colorscheme codedark]]
-- Set vim-code-dark as colortheme after plugin loading was finished
cmd[[
augroup VimCodeDark
autocmd!
autocmd User PlugLoaded ++nested colorscheme codedark
augroup end
]]

View file

@ -2,8 +2,6 @@ local vim = require("vim")
local cmd = vim.cmd local cmd = vim.cmd
local g = vim.g local g = vim.g
cmd[[Plug 'vimwiki/vimwiki']]
local wiki_conf = {} local wiki_conf = {}
wiki_conf["path"] = "~/Personal/vimwiki" wiki_conf["path"] = "~/Personal/vimwiki"
wiki_conf["path_html"] = "~/Personal/vimwiki-html" wiki_conf["path_html"] = "~/Personal/vimwiki-html"

View file

@ -1,56 +1,119 @@
local vim = require("vim") local vim = require("vim")
local cmd = vim.cmd local cmd = vim.cmd
local api = vim.api
local fn = vim.fn local fn = vim.fn
local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim) -- Automatically download (bootstrap) packer plugin manager
local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim -- if it's not already installed
local plugin_files_dir = config_dir .. "/lua/pluginconf" -- Dir with plugin config files including Plug call(s) local packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
local packer_bootstrap
-- Automatically download vimplug and run PlugInstall if fn.empty(fn.glob(packer_install_path)) > 0 then
local autoload_dir = config_dir .. "/autoload" print("Installing packer plugin manager, please wait...")
local plug_install_path = autoload_dir .. "/plug.vim" packer_bootstrap = fn.system({
local plug_download_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" 'git', 'clone', '--depth', '1',
'https://github.com/wbthomason/packer.nvim',
if fn.empty(fn.glob(plug_install_path)) > 0 then packer_install_path
print("Downloading vim-plug, there may be initial errors...") })
fn.system({"mkdir", "-p", autoload_dir}) print("Packer installed, reload vim to install plugins")
fn.system("curl " .. plug_download_url .. " > " .. plug_install_path)
cmd[[autocmd VimEnter * PlugInstall]]
cmd[[autocmd VimEnter * UpdateRemotePlugins]]
end end
-- Load a file containing Plug call(s) and plugin settings -- Automatically run :PackerCompile if plugins.lua is updated
local function load_plugin_file(plugin_file) cmd[[
local plugin_path = plugin_files_dir .. "/" .. plugin_file augroup packer_user_config
LoadFile(plugin_path) autocmd!
autocmd BufWritePost ~/.config/nvim/lua/plugins.lua source <afile> | 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 end
-- Load a single given plugin using a Plug call -- Make sure to add packer here, even if it's opt
local function load_plugin(plugin) api.nvim_command("packadd packer.nvim")
cmd("Plug '" .. plugin .. "'")
-- 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 },
})
-- Run sync if we've just bootstrapped packer
if packer_bootstrap then
require("packer").sync()
end end
end,
config = {
-- Begin Plug.vim loading process display = {
cmd("call plug#begin('" .. plugvim_plugins_dir .. "')") open_fn = require('packer.util').float,
},
load_plugin('airblade/vim-gitgutter') profile = {
load_plugin('dhruvasagar/vim-table-mode') enable = true,
load_plugin('tmhedberg/SimpylFold') threshold = 1, -- the amount in ms that a plugins load time must be over for it to be included in the profile
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]]