1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 17:28:01 +00:00

[neovim] Move from session_manager to projections

This commit is contained in:
Daniel Carrillo 2022-12-15 19:50:32 +01:00
parent bc172e2e98
commit 803f745102
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
8 changed files with 52 additions and 14 deletions

View File

@ -35,3 +35,30 @@ vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
end end
end, end,
}) })
-- Autostore session on VimExit
local session = require("projections.session")
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
callback = function()
session.store(vim.loop.cwd())
end,
})
-- If vim was started with arguments, do nothing
-- If in some project's root, attempt to restore that project's session
-- If not, restore last session
-- If no sessions, do nothing
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
if vim.fn.argc() ~= 0 then
return
end
local session_info = session.info(vim.loop.cwd())
if session_info == nil then
session.restore_latest()
else
session.restore(vim.loop.cwd())
end
end,
desc = "Restore last session automatically",
})

View File

@ -13,3 +13,8 @@ end, {})
vim.api.nvim_create_user_command("RemoveTrailingSpaces", function() vim.api.nvim_create_user_command("RemoveTrailingSpaces", function()
vim.cmd("% s/\\s\\+$//e") vim.cmd("% s/\\s\\+$//e")
end, {}) end, {})
local workspace = require("projections.workspace")
vim.api.nvim_create_user_command("AddWorkspace", function()
workspace.add(vim.loop.cwd())
end, {})

View File

@ -96,10 +96,8 @@ keymap("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>", opts)
keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts) keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts)
keymap("n", "<leader>dt", "<cmd>lua require'dap'.terminate()<cr>", opts) keymap("n", "<leader>dt", "<cmd>lua require'dap'.terminate()<cr>", opts)
-- Session Manager -- Projections
keymap("n", "<leader>so", ":SessionManager load_session<cr>", opts) keymap("n", "<leader>fp", ":Telescope projections<CR>", opts)
keymap("n", "<leader>sd", ":SessionManager delete_session<cr>", opts)
keymap("n", "<leader>ss", ":SessionManager save_current_session<cr>", opts)
-- Base64 -- Base64
keymap("v", "<leader>64e", ":<c-u>lua require'b64'.encode()<cr>", opts) keymap("v", "<leader>64e", ":<c-u>lua require'b64'.encode()<cr>", opts)

View File

@ -52,7 +52,7 @@ return packer.startup(function(use)
use({ "gelguy/wilder.nvim", commit = "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }) use({ "gelguy/wilder.nvim", commit = "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" })
use({ "romgrk/fzy-lua-native", commit = "085c7d262aa35cc55a8523e8c1618d398bf717a7", run = "make" }) use({ "romgrk/fzy-lua-native", commit = "085c7d262aa35cc55a8523e8c1618d398bf717a7", run = "make" })
use({ "mg979/vim-visual-multi", tag = "v0.*" }) use({ "mg979/vim-visual-multi", tag = "v0.*" })
use({ "Shatur/neovim-session-manager", commit = "f8c85da390c5d1ad3bfd229ac2ed805c5742263d" }) use({ "gnikdroy/projections.nvim", commit = "be100ad3540952542c2a1135f39cddea8a1a00de" })
use({ "nvim-treesitter/nvim-treesitter", commit = "507527711fdd8f701544024aeb1a9a068f986d89" }) use({ "nvim-treesitter/nvim-treesitter", commit = "507527711fdd8f701544024aeb1a9a068f986d89" })
use({ "ray-x/sad.nvim", commit = "01b7d84f4f73c8963f5933f09e88c833757bc7d8" }) use({ "ray-x/sad.nvim", commit = "01b7d84f4f73c8963f5933f09e88c833757bc7d8" })
use({ use({

View File

@ -17,6 +17,6 @@ require("plugins.wilder")
require("plugins.trouble") require("plugins.trouble")
require("plugins.autosave") require("plugins.autosave")
require("plugins.markdowntoc") require("plugins.markdowntoc")
require("plugins.session-manager") require("plugins.projections")
require("plugins.diffview") require("plugins.diffview")
require("plugins.sad") require("plugins.sad")

View File

@ -0,0 +1,15 @@
local status_ok, projections = pcall(require, "projections")
if not status_ok then
return
end
projections.setup({
store_hooks = {
pre = function()
-- Close neo-tree before storing sessions
if pcall(require, "neo-tree") then
vim.cmd([[Neotree action=close]])
end
end,
},
})

View File

@ -1,8 +0,0 @@
local status_ok, session_manager = pcall(require, "session_manager")
if not status_ok then
return
end
session_manager.setup({
autosave_only_in_session = false,
})

View File

@ -43,3 +43,4 @@ telescope.setup({
telescope.load_extension("fzf") telescope.load_extension("fzf")
telescope.load_extension("ui-select") telescope.load_extension("ui-select")
telescope.load_extension("projections")