fix layout restore and diagnostic float behavior
This commit is contained in:
parent
9d2e376259
commit
4caeebcd1b
2
init.lua
2
init.lua
|
|
@ -186,7 +186,7 @@ vim.diagnostic.config {
|
|||
virtual_lines = false, -- Text shows up underneath the line, with virtual lines
|
||||
|
||||
-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
|
||||
jump = { float = true },
|
||||
jump = { on_jump = function() vim.diagnostic.open_float() end },
|
||||
}
|
||||
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"gitsigns.nvim": { "branch": "main", "commit": "e1fb5425c8812214209b3f24eaa582c6c552cf98" },
|
||||
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "25f609e7fca78af7cede4f9fa3af8a94b1c4950b" },
|
||||
"mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" },
|
||||
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
|
||||
|
|
|
|||
|
|
@ -37,6 +37,30 @@ local function find_window_by_filetype(filetype)
|
|||
return nil
|
||||
end
|
||||
|
||||
local function is_opencode_window(win)
|
||||
if not win or not vim.api.nvim_win_is_valid(win) then return false end
|
||||
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
local ft = vim.bo[buf].filetype
|
||||
if ft == 'opencode' then return true end
|
||||
|
||||
local bt = vim.bo[buf].buftype
|
||||
if bt ~= 'terminal' then return false end
|
||||
|
||||
if ft ~= '' and ft ~= 'snacks_terminal' and ft ~= 'toggleterm' then return false end
|
||||
|
||||
local buf_name = string.lower(vim.api.nvim_buf_get_name(buf))
|
||||
return buf_name:find('opencode', 1, true) ~= nil
|
||||
end
|
||||
|
||||
local function find_opencode_window()
|
||||
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if is_opencode_window(win) then return win end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.capture_focus()
|
||||
local current_win = vim.api.nvim_get_current_win()
|
||||
if not M.is_main_window(current_win) then return nil end
|
||||
|
|
@ -88,13 +112,13 @@ local function ensure_neotree_window()
|
|||
end
|
||||
|
||||
local function ensure_opencode_window()
|
||||
local opencode_win = find_window_by_filetype 'opencode'
|
||||
local opencode_win = find_opencode_window()
|
||||
if opencode_win then return opencode_win end
|
||||
|
||||
pcall(function() require('opencode').toggle() end)
|
||||
|
||||
vim.wait(1000, function() return find_window_by_filetype 'opencode' ~= nil end, 50)
|
||||
return find_window_by_filetype 'opencode'
|
||||
vim.wait(1000, function() return find_opencode_window() ~= nil end, 50)
|
||||
return find_opencode_window()
|
||||
end
|
||||
|
||||
function M.reset_ide_layout(opts)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ return {
|
|||
{
|
||||
'rmagatti/auto-session',
|
||||
lazy = false,
|
||||
init = function()
|
||||
-- Required by auto-session for filetype and highlighting to survive session restore
|
||||
vim.o.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions'
|
||||
end,
|
||||
keys = {
|
||||
-- Will use Telescope if installed or a vim.ui.select picker otherwise
|
||||
{ '<leader>wr', '<cmd>AutoSession search<CR>', desc = 'Session search' },
|
||||
|
|
|
|||
Loading…
Reference in New Issue