Skip to content

Commit

Permalink
feat(session): add vim-workspace plugin and session directory (#1289)
Browse files Browse the repository at this point in the history
* feat(session): add vim-workspace plugin and session directory

* refactor(vim-workspace): refactor configuration to be user configurable

---------

Co-authored-by: Micah Halter <micah@mehalter.com>
  • Loading branch information
Kamilcuk and mehalter authored Dec 20, 2024
1 parent 5c50de2 commit e20b041
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lua/astrocommunity/session/vim-workspace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# vim-workspace

Automated Vim session management with file auto-save and persistent undo history

The configuration of the plugin:

- disable resession.nvim - default astronvim session management
- auto create and auto load the workspace when neovim was started without any arguments
- just `cd dir` and `nvim` to start the workspace
- auto save the workspace when neovim was closed
- handle neotree, NERDTree, git windows
- fix paths to use cache path of neovim

**Repository:** <https://github.com/thaerkh/vim-workspace>
46 changes: 46 additions & 0 deletions lua/astrocommunity/session/vim-workspace/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
return {
"thaerkh/vim-workspace",
priority = 10000,
lazy = false,
specs = {
{ "resession.nvim", enabled = false },
{
"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",
callback = function()
if vim.fn.exists ":Neotree" == 2 then vim.cmd.Neotree "close" end
if vim.fn.exists ":NERDTreeClose" == 2 then vim.cmd.NERDTreeClose() end
end,
},
},
},
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,
},
},
}

0 comments on commit e20b041

Please sign in to comment.