Skip to content

Commit e20b041

Browse files
Kamilcukmehalter
andauthored
feat(session): add vim-workspace plugin and session directory (#1289)
* feat(session): add vim-workspace plugin and session directory * refactor(vim-workspace): refactor configuration to be user configurable --------- Co-authored-by: Micah Halter <[email protected]>
1 parent 5c50de2 commit e20b041

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# vim-workspace
2+
3+
Automated Vim session management with file auto-save and persistent undo history
4+
5+
The configuration of the plugin:
6+
7+
- disable resession.nvim - default astronvim session management
8+
- auto create and auto load the workspace when neovim was started without any arguments
9+
- just `cd dir` and `nvim` to start the workspace
10+
- auto save the workspace when neovim was closed
11+
- handle neotree, NERDTree, git windows
12+
- fix paths to use cache path of neovim
13+
14+
**Repository:** <https://github.com/thaerkh/vim-workspace>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
return {
2+
"thaerkh/vim-workspace",
3+
priority = 10000,
4+
lazy = false,
5+
specs = {
6+
{ "resession.nvim", enabled = false },
7+
{
8+
"AstroNvim/astrocore",
9+
---@param opts AstroCoreOpts
10+
opts = function(_, opts)
11+
local sessionoptions = {} -- https://github.com/thaerkh/vim-workspace/issues/11
12+
for _, value in ipairs(vim.tbl_get(opts, "options", "opt", "sessionoptions") or vim.opt.sessionoptions:get()) do
13+
if value ~= "blank" then table.insert(sessionoptions, value) end
14+
end
15+
return require("astrocore").extend_tbl(opts, {
16+
autocmds = {
17+
autoclose_neotree = {
18+
{
19+
event = "VimLeave",
20+
callback = function()
21+
if vim.fn.exists ":Neotree" == 2 then vim.cmd.Neotree "close" end
22+
if vim.fn.exists ":NERDTreeClose" == 2 then vim.cmd.NERDTreeClose() end
23+
end,
24+
},
25+
},
26+
},
27+
options = {
28+
opt = { sessionoptions = sessionoptions },
29+
g = {
30+
workspace_autosave_ignore = { "gitcommit", "neo-tree", "nerdtree", "qf", "tagbar" },
31+
workspace_session_disable_on_args = 1,
32+
workspace_session_directory = vim.fn.stdpath "cache" .. "/vim-workspace.sessions",
33+
workspace_undodir = vim.fn.stdpath "cache" .. "/vim-workspace.undodir",
34+
workspace_autocreate = 1,
35+
workspace_create_new_tabs = 0,
36+
-- Because a bug, these two populate search / history, just disable them.
37+
workspace_autosave_untrailtabs = 0,
38+
workspace_autosave_untrailspaces = 0,
39+
workspace_nocompatible = 0,
40+
},
41+
},
42+
})
43+
end,
44+
},
45+
},
46+
}

0 commit comments

Comments
 (0)