mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
snacks rice + new colorscheme
This commit is contained in:
parent
66d50e274e
commit
d998429cb8
15 changed files with 1068 additions and 427 deletions
|
|
@ -1,7 +1,8 @@
|
|||
local M = {}
|
||||
M.load = function()
|
||||
sessions = require('mini.sessions')
|
||||
|
||||
M.get_id = function()
|
||||
local jj_root = vim.system({ 'jj', 'workspace', 'root' }):wait()
|
||||
local sessions = require('mini.sessions')
|
||||
|
||||
if jj_root.code ~= 0 then
|
||||
return
|
||||
|
|
@ -19,29 +20,42 @@ M.load = function()
|
|||
'--no-graph',
|
||||
})
|
||||
:wait()
|
||||
local branch = vim.trim(string.gsub(result.stdout, '[\n*]', ''))
|
||||
local branch = vim.trim(string.gsub(result.stdout, '[\n*]', '')) -- trim newlines and unpushed indicator
|
||||
local root = vim.trim(string.gsub(jj_root.stdout, '\n', ''))
|
||||
local jj_sesh = string.gsub(string.format('jj:%s:%s', root, branch), '[./]', '-')
|
||||
if jj_sesh ~= '' then
|
||||
vim.opt.shadafile = vim.fn.stdpath('data') .. '/myshada/' .. jj_sesh .. '.shada'
|
||||
for name, _ in pairs(sessions.detected) do
|
||||
if name == jj_sesh then
|
||||
vim.ui.select({
|
||||
'No',
|
||||
'Yes',
|
||||
}, { prompt = 'Session found at ' .. jj_sesh .. ', load it?' }, function(c)
|
||||
if c == 'Yes' then
|
||||
-- load session (buffers, etc) as well as shada (marks)
|
||||
sessions.read(jj_sesh)
|
||||
vim.cmd('rshada')
|
||||
vim.notify('loaded jj session: ' .. jj_sesh)
|
||||
end
|
||||
end)
|
||||
return
|
||||
end
|
||||
local id = string.gsub(string.format('jj:%s:%s', root, branch), '[./]', '-') -- slugify
|
||||
return id
|
||||
end
|
||||
|
||||
M.check_exists = function(id)
|
||||
for name, _ in pairs(sessions.detected) do
|
||||
if name == id then
|
||||
return true
|
||||
end
|
||||
vim.cmd('wshada')
|
||||
sessions.write(jj_sesh)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
M.load = function()
|
||||
local id = M.get_id()
|
||||
if id == '' then
|
||||
return
|
||||
end
|
||||
vim.opt.shadafile = vim.fn.stdpath('data') .. '/myshada/' .. id .. '.shada'
|
||||
if M.check_exists(id) then
|
||||
vim.ui.select({
|
||||
'Yes',
|
||||
'No',
|
||||
}, { prompt = 'Session found at ' .. id .. ', load it?' }, function(c)
|
||||
if c == 'Yes' then
|
||||
-- load session (buffers, etc) as well as shada (marks)
|
||||
sessions.read(id)
|
||||
vim.cmd('rshada')
|
||||
vim.notify('loaded jj session: ' .. id)
|
||||
end
|
||||
end)
|
||||
else
|
||||
vim.cmd('wshada') -- create session if it did not exist
|
||||
sessions.write(id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue