Add persistence
This commit is contained in:
parent
dced8c0e0b
commit
12a46ad57b
|
|
@ -22,6 +22,7 @@
|
|||
"nvim-treesitter": { "branch": "main", "commit": "7caec274fd19c12b55902a5b795100d21531391f" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
|
||||
"opencode.nvim": { "branch": "main", "commit": "df533d6da724109bf08446392db860fdceddbd0c" },
|
||||
"persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
||||
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
||||
|
|
|
|||
|
|
@ -25,6 +25,28 @@ return {
|
|||
},
|
||||
},
|
||||
config = function()
|
||||
local sidebar_filetypes = {
|
||||
['neo-tree'] = true,
|
||||
['snacks_layout_box'] = true,
|
||||
['snacks_terminal'] = true,
|
||||
['toggleterm'] = true,
|
||||
['opencode'] = true,
|
||||
}
|
||||
|
||||
local function focus_main_window()
|
||||
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
local ft = vim.bo[buf].filetype
|
||||
local bt = vim.bo[buf].buftype
|
||||
if not sidebar_filetypes[ft] and bt == '' then
|
||||
vim.api.nvim_set_current_win(win)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---@type opencode.Opts
|
||||
vim.g.opencode_opts = {
|
||||
server = {
|
||||
|
|
@ -60,5 +82,21 @@ return {
|
|||
-- You may want these if you use the opinionated `<C-a>` and `<C-x>` keymaps above — otherwise consider `<leader>o…` (and remove terminal mode from the `toggle` keymap)
|
||||
vim.keymap.set('n', '+', '<C-a>', { desc = 'Increment under cursor', noremap = true })
|
||||
vim.keymap.set('n', '-', '<C-x>', { desc = 'Decrement under cursor', noremap = true })
|
||||
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
callback = function()
|
||||
if vim.fn.argc() == 1 and vim.fn.isdirectory(vim.fn.argv(0)) == 1 then
|
||||
vim.schedule(function()
|
||||
pcall(function() require('persistence').load() end)
|
||||
|
||||
vim.schedule(function()
|
||||
focus_main_window()
|
||||
require('opencode').toggle()
|
||||
focus_main_window()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
return {
|
||||
{
|
||||
'folke/persistence.nvim',
|
||||
event = 'BufReadPre',
|
||||
opts = {
|
||||
need = 1,
|
||||
},
|
||||
keys = {
|
||||
{ '<leader>qs', function() require('persistence').load() end, desc = '[Q]uit: restore [S]ession' },
|
||||
{ '<leader>qS', function() require('persistence').select() end, desc = '[Q]uit: restore [S]ession (picker)' },
|
||||
{ '<leader>ql', function() require('persistence').load { last = true } end, desc = '[Q]uit: restore [L]ast session' },
|
||||
{ '<leader>qd', function() require('persistence').stop() end, desc = '[Q]uit: [D]isable session save' },
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue