From d766f5ed87f585ea823d4b75ce73dca560892572 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Fri, 20 Dec 2024 12:15:17 -0500 Subject: [PATCH] refactor(vim-workspace): refactor configuration to be user configurable --- .../session/vim-workspace/init.lua | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/lua/astrocommunity/session/vim-workspace/init.lua b/lua/astrocommunity/session/vim-workspace/init.lua index 3a232af3d..b3406b9a2 100644 --- a/lua/astrocommunity/session/vim-workspace/init.lua +++ b/lua/astrocommunity/session/vim-workspace/init.lua @@ -2,29 +2,44 @@ return { { "resession.nvim", enabled = false }, { "thaerkh/vim-workspace", - enabled = true, priority = 10000, lazy = false, - init = function() - vim.cmd [[ - let g:workspace_autosave_ignore = ['gitcommit', "neo-tree", "nerdtree", "qf", "tagbar"] - let g:workspace_session_disable_on_args = 1 - let g:workspace_session_directory = stdpath("cache") . '/vim-workspace.sessions' - let g:workspace_undodir= stdpath("cache") . "/vim-workspace.undodir" - let g:workspace_autocreate = 1 - " nnoremap W :ToggleWorkspace - autocmd VimLeave * - \ if exists(":Neotree") | execute 'Neotree close' | endif | - \ if exists(":NERDTreeClose") | execute 'NERDTreeClose' | endif - let g:workspace_create_new_tabs = 0 - " Because a bug, these two populate search / history, just disable them. - let g:workspace_autosave_untrailtabs = 0 - let g:workspace_autosave_untrailspaces = 0 - let g:workspace_nocompatible = 0 - let g:workspace_session_disable_on_args = 1 - " https://github.com/thaerkh/vim-workspace/issues/11 - set sessionoptions-=blank - ]] - end, + specs = { + { + "AstroNvim/astrocore", + ---@param opts AstroCoreOpts + opts = function(_, opts) + local sessionoptions = {} -- https://github.com/thaerkh/vim-workspace/issues/11 + for _, value in ipairs(vim.tbl_get(opts, "options", "opt", "sessionoptions") or vim.opt.sessionoptions:get()) do + if value ~= "blank" then table.insert(sessionoptions, value) end + end + return require("astrocore").extend_tbl(opts, { + autocmds = { + autoclose_neotree = { + { + event = "VimLeave", + command = [[ if exists(":Neotree") | execute 'Neotree close' | endif | if exists(":NERDTreeClose") | execute 'NERDTreeClose' | endif ]], + }, + }, + }, + options = { + opt = { sessionoptions = sessionoptions }, + g = { + workspace_autosave_ignore = { "gitcommit", "neo-tree", "nerdtree", "qf", "tagbar" }, + workspace_session_disable_on_args = 1, + workspace_session_directory = vim.fn.stdpath "cache" .. "/vim-workspace.sessions", + workspace_undodir = vim.fn.stdpath "cache" .. "/vim-workspace.undodir", + workspace_autocreate = 1, + workspace_create_new_tabs = 0, + -- Because a bug, these two populate search / history, just disable them. + workspace_autosave_untrailtabs = 0, + workspace_autosave_untrailspaces = 0, + workspace_nocompatible = 0, + }, + }, + }) + end, + }, + }, }, }