From 8a021a6e0af8ae7d1d33cf7fc5953f4483f4bba6 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Sat, 4 Nov 2023 14:39:58 +0000 Subject: [PATCH] feat(pp): migrate the nvim config over to configz --- manifests/workstation.pp | 1 - modules/nvim.lua | 73 +++++++++++++++++++++++++---- site-modules/core/manifests/vim.pp | 74 ------------------------------ 3 files changed, 65 insertions(+), 83 deletions(-) delete mode 100644 site-modules/core/manifests/vim.pp diff --git a/manifests/workstation.pp b/manifests/workstation.pp index 2280f37..0a44582 100644 --- a/manifests/workstation.pp +++ b/manifests/workstation.pp @@ -18,7 +18,6 @@ node default { include core::git include core::zsh include core::bin - include core::vim include core::tmux include core::fonts include core::emacs diff --git a/modules/nvim.lua b/modules/nvim.lua index 2611662..f22c825 100644 --- a/modules/nvim.lua +++ b/modules/nvim.lua @@ -1,16 +1,73 @@ local git = require "lib.git" local nvim_dir = os.getenv "HOME" .. "/.config/nvim" -local nvim_pluing_dir_start = nvim_dir .. "/pack/bundle/start" +local nvim_plugin_dir_start = nvim_dir .. "/pack/bundle/start" +local nvim_plugin_dir_opt = nvim_dir .. "/pack/bundle/opt" -if not configz.is_directory(nvim_dir .. "/snippets") then - configz.link(nvim_dir .. "/snippets", { - source = os.getenv "PWD" .. "/site-modules/core/files/vim/snippets/snippets", +if not configz.is_directory(nvim_dir) then + configz.directory(nvim_dir) +end + +-- Link the main init file +if not configz.is_file(nvim_dir .. "/init.vim") then + configz.link(nvim_dir .. "/init.vim", { + source = os.getenv "PWD" .. "/site-modules/core/files/vim/init.vim", }) end -git.repo { - src = "https://github.com/sbdchd/neoformat", - target = nvim_pluing_dir_start .. "/neoformat", - version = "master", +-- Link all of the configs into the nvim config directory +local dirs_to_link = { "after", "ftplugin", "snippets", "plugin", "spell" } +for _, dir in ipairs(dirs_to_link) do + local dir_to_link = nvim_dir .. "/" .. dir + if not configz.is_directory(dir_to_link) then + configz.link(dir_to_link, { + source = os.getenv "PWD" .. "/site-modules/core/files/vim/" .. dir_to_link, + }) + end +end + +local start_plugins = { + ["auto-pairs"] = { url = "https://github.com/jiangmiao/auto-pairs.git" }, + ["base16-vim"] = { url = "https://github.com/tinted-theming/base16-vim.git", revision = "main" }, + ["cmp_luasnip"] = { url = "https://github.com/saadparwaiz1/cmp_luasnip.git" }, + ["cmp-buffer"] = { url = "https://github.com/hrsh7th/cmp-buffer.git", revision = "main" }, + ["cmp-nvim-lsp"] = { url = "https://github.com/hrsh7th/cmp-nvim-lsp.git", revision = "main" }, + ["cmp-path"] = { url = "https://github.com/hrsh7th/cmp-path.git", revision = "main" }, + ["Comment.nvim"] = { url = "https://github.com/numToStr/Comment.nvim.git" }, + ["ferret"] = { url = "https://github.com/wincent/ferret.git" }, + ["indent-line"] = { url = "https://github.com/Yggdroot/indentLine.git" }, + ["LuaSnip"] = { url = "https://github.com/L3MON4D3/LuaSnip.git" }, + ["nvim-cmp"] = { url = "https://github.com/hrsh7th/nvim-cmp.git", revision = "main" }, + ["nvim-lint"] = { url = "https://github.com/mfussenegger/nvim-lint.git" }, + ["nvim-lspconfig"] = { url = "https://github.com/neovim/nvim-lspconfig.git" }, + ["nvim-treesitter"] = { url = "https://github.com/nvim-treesitter/nvim-treesitter.git" }, + ["orgmode"] = { url = "https://github.com/nvim-orgmode/orgmode.git" }, + ["vim-puppet"] = { url = "https://github.com/rodjek/vim-puppet.git" }, + ["vim-surround"] = { url = "https://github.com/tpope/vim-surround.git" }, + ["vim-tmux-navigator"] = { url = "https://github.com/christoomey/vim-tmux-navigator.git" }, + ["vim-fugitive"] = { url = "https://github.com/tpope/vim-fugitive.git" }, + ["vim-rhubarb"] = { url = "https://github.com/tpope/vim-rhubarb.git" }, + ["conjure"] = { url = "https://github.com/Olical/conjure.git" }, } + +local opt_plugins = { + ["command-t"] = { url = "https://github.com/wincent/command-t.git" }, +} + +-- Install all of the plugins I want to start at boot +for plugin, config in pairs(start_plugins) do + git.repo { + src = config.url, + target = nvim_plugin_dir_start .. "/" .. plugin, + version = config.revision or "master", + } +end + +-- Install all of the plugins I want to start manually +for plugin, config in pairs(opt_plugins) do + git.repo { + src = config.url, + target = nvim_plugin_dir_opt .. "/" .. plugin, + version = config.revision or "master", + } +end diff --git a/site-modules/core/manifests/vim.pp b/site-modules/core/manifests/vim.pp deleted file mode 100644 index 8d87f64..0000000 --- a/site-modules/core/manifests/vim.pp +++ /dev/null @@ -1,74 +0,0 @@ -class core::vim { - file { "${user_home}/.config/nvim": - ensure => 'directory', - force => true, - owner => $user, - } - - file { "${user_home}/.config/nvim/after": - ensure => 'link', - force => true, - owner => $user, - target => find_file('core/vim/after'), - } - - file { "${user_home}/.config/nvim/ftplugin": - ensure => 'link', - force => true, - owner => $user, - target => find_file('core/vim/ftplugin'), - } - - file { "${user_home}/.config/nvim/plugin": - ensure => 'link', - force => true, - owner => $user, - target => find_file('core/vim/plugin'), - } - - file { "${user_home}/.config/nvim/spell": - ensure => 'link', - force => true, - owner => $user, - target => find_file('core/vim/spell'), - } - - file { "${user_home}/.config/nvim/init.vim": - ensure => 'link', - force => true, - owner => $user, - target => find_file('core/vim/init.vim'), - } - - $plugins_start= { - 'auto-pairs' => { url => 'https://github.com/jiangmiao/auto-pairs.git' }, - 'base16-vim' => { url => 'https://github.com/tinted-theming/base16-vim.git', revision => 'main' }, - 'cmp_luasnip' => { url => 'https://github.com/saadparwaiz1/cmp_luasnip.git' }, - 'cmp-buffer' => { url => 'https://github.com/hrsh7th/cmp-buffer.git', revision => 'main' }, - 'cmp-nvim-lsp' => { url => 'https://github.com/hrsh7th/cmp-nvim-lsp.git', revision => 'main' }, - 'cmp-path' => { url => 'https://github.com/hrsh7th/cmp-path.git', revision => 'main' }, - 'Comment.nvim' => { url => 'https://github.com/numToStr/Comment.nvim.git' }, - 'ferret' => { url => 'https://github.com/wincent/ferret.git' }, - 'indent-line' => { url => 'https://github.com/Yggdroot/indentLine.git' }, - 'LuaSnip' => { url => 'https://github.com/L3MON4D3/LuaSnip.git' }, - 'nvim-cmp' => { url => 'https://github.com/hrsh7th/nvim-cmp.git', revision => 'main' }, - 'nvim-lint' => { url => 'https://github.com/mfussenegger/nvim-lint.git' }, - 'nvim-lspconfig' => { url => 'https://github.com/neovim/nvim-lspconfig.git' }, - 'nvim-treesitter' => { url => 'https://github.com/nvim-treesitter/nvim-treesitter.git' }, - 'orgmode' => { url => 'https://github.com/nvim-orgmode/orgmode.git' }, - 'vim-puppet' => { url => 'https://github.com/rodjek/vim-puppet.git' }, - 'vim-surround' => { url => 'https://github.com/tpope/vim-surround.git' }, - 'vim-tmux-navigator' => { url => 'https://github.com/christoomey/vim-tmux-navigator.git' }, - 'vim-fugitive' => { url => 'https://github.com/tpope/vim-fugitive.git' }, - 'vim-rhubarb' => { url => 'https://github.com/tpope/vim-rhubarb.git' }, - 'conjure' => { url => 'https://github.com/Olical/conjure.git' } - } - - create_resources(core::vim::plugin_start, $plugins_start) - - $plugins_opt= { - 'command-t' => { url => 'https://github.com/wincent/command-t.git' }, - } - - create_resources(core::vim::plugin_opt, $plugins_opt) -}