From 8643dd3b6bde9964e96ebc2cb72c2bd50c6e55c7 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 22 Aug 2022 14:57:24 +0300 Subject: [PATCH] Refactor nvim packer configuration --- home/.config/nvim/init.lua | 13 +----- .../{pluginconf => plugins}/bufferline.lua | 0 .../{pluginconf => plugins}/colorscheme.lua | 0 .../{pluginconf => plugins}/completion.lua | 0 .../indent-blankline.lua | 0 .../{pluginmanager.lua => plugins/init.lua} | 41 +++++++++++++------ .../nvim/lua/{pluginconf => plugins}/lsp.lua | 1 + .../lua/{pluginconf => plugins}/lualine.lua | 0 .../lua/{pluginconf => plugins}/nvim-tree.lua | 0 .../lua/{pluginconf => plugins}/telescope.lua | 0 .../{pluginconf => plugins}/treesitter.lua | 0 11 files changed, 31 insertions(+), 24 deletions(-) rename home/.config/nvim/lua/{pluginconf => plugins}/bufferline.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins}/colorscheme.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins}/completion.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins}/indent-blankline.lua (100%) rename home/.config/nvim/lua/{pluginmanager.lua => plugins/init.lua} (76%) rename home/.config/nvim/lua/{pluginconf => plugins}/lsp.lua (99%) rename home/.config/nvim/lua/{pluginconf => plugins}/lualine.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins}/nvim-tree.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins}/telescope.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins}/treesitter.lua (100%) diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 107c41e..fee008a 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -1,16 +1,5 @@ -require 'pluginmanager' +require 'plugins/init' require 'autocmd' require 'keybinds' require 'settings' require 'common' - --- Plugin configurations -require 'pluginconf.lualine' -require 'pluginconf.bufferline' -require 'pluginconf.lsp' -require 'pluginconf.completion' -require 'pluginconf.treesitter' -require 'pluginconf.indent-blankline' -require 'pluginconf.nvim-tree' -require 'pluginconf.colorscheme' -require 'pluginconf.telescope' diff --git a/home/.config/nvim/lua/pluginconf/bufferline.lua b/home/.config/nvim/lua/plugins/bufferline.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/bufferline.lua rename to home/.config/nvim/lua/plugins/bufferline.lua diff --git a/home/.config/nvim/lua/pluginconf/colorscheme.lua b/home/.config/nvim/lua/plugins/colorscheme.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/colorscheme.lua rename to home/.config/nvim/lua/plugins/colorscheme.lua diff --git a/home/.config/nvim/lua/pluginconf/completion.lua b/home/.config/nvim/lua/plugins/completion.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/completion.lua rename to home/.config/nvim/lua/plugins/completion.lua diff --git a/home/.config/nvim/lua/pluginconf/indent-blankline.lua b/home/.config/nvim/lua/plugins/indent-blankline.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/indent-blankline.lua rename to home/.config/nvim/lua/plugins/indent-blankline.lua diff --git a/home/.config/nvim/lua/pluginmanager.lua b/home/.config/nvim/lua/plugins/init.lua similarity index 76% rename from home/.config/nvim/lua/pluginmanager.lua rename to home/.config/nvim/lua/plugins/init.lua index a806328..d01452e 100644 --- a/home/.config/nvim/lua/pluginmanager.lua +++ b/home/.config/nvim/lua/plugins/init.lua @@ -1,23 +1,25 @@ local fn = vim.fn -local cmd = vim.cmd -- Install packer if it's not yet installed local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' -local packer_not_installed = fn.empty(fn.glob(install_path)) - -if packer_not_installed > 0 then - print('Packer is not installed, cloning it now...') - cmd('silent !git clone https://github.com/wbthomason/packer.nvim ' .. - install_path) +if fn.empty(fn.glob(install_path)) > 0 then + print('installing packer') + Packer_bootstrap = fn.system({ + 'git', 'clone', '--depth', '1', + 'https://github.com/wbthomason/packer.nvim', install_path + }) + vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' .. + vim.o.runtimepath + print('installed packer') end -- Configure packer -cmd 'packadd packer.nvim' -local use = require('packer').use +vim.cmd [[packadd packer.nvim]] require('packer').startup(function() +local use = require('packer').use -- The plugin manager itself - use {'wbthomason/packer.nvim', opt = true} + use {'wbthomason/packer.nvim', opt=true} -- Colorscheme use({'catppuccin/nvim', as = 'catppuccin'}) @@ -120,7 +122,22 @@ require('packer').startup(function() -- Vim <3 Asciidoctor use 'habamax/vim-asciidoctor' + -- Sync plugins if Packer was just + -- installed + if Packer_bootstrap then + print('syncing') + require('packer').sync() + print('synced') + end end) --- Install plugins if packer was not installed -if packer_not_installed > 0 then cmd 'PackerInstall' end +-- Source configurations +require 'plugins/lualine' +require 'plugins/bufferline' +require 'plugins/lsp' +require 'plugins/completion' +require 'plugins/treesitter' +require 'plugins/indent-blankline' +require 'plugins/nvim-tree' +require 'plugins/colorscheme' +require 'plugins/telescope' diff --git a/home/.config/nvim/lua/pluginconf/lsp.lua b/home/.config/nvim/lua/plugins/lsp.lua similarity index 99% rename from home/.config/nvim/lua/pluginconf/lsp.lua rename to home/.config/nvim/lua/plugins/lsp.lua index 0867847..94dab6c 100644 --- a/home/.config/nvim/lua/pluginconf/lsp.lua +++ b/home/.config/nvim/lua/plugins/lsp.lua @@ -1,5 +1,6 @@ local M = {} local lspconfig = require('lspconfig'); +-- M.lsp_map_keys = function(server, bufnr) local function map_key(...) diff --git a/home/.config/nvim/lua/pluginconf/lualine.lua b/home/.config/nvim/lua/plugins/lualine.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/lualine.lua rename to home/.config/nvim/lua/plugins/lualine.lua diff --git a/home/.config/nvim/lua/pluginconf/nvim-tree.lua b/home/.config/nvim/lua/plugins/nvim-tree.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/nvim-tree.lua rename to home/.config/nvim/lua/plugins/nvim-tree.lua diff --git a/home/.config/nvim/lua/pluginconf/telescope.lua b/home/.config/nvim/lua/plugins/telescope.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/telescope.lua rename to home/.config/nvim/lua/plugins/telescope.lua diff --git a/home/.config/nvim/lua/pluginconf/treesitter.lua b/home/.config/nvim/lua/plugins/treesitter.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/treesitter.lua rename to home/.config/nvim/lua/plugins/treesitter.lua