Skip to content

Commit 4caeebc

Browse files
hlsthlstwizard
authored andcommitted
fix layout restore and diagnostic float behavior
1 parent 9d2e376 commit 4caeebc

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ vim.diagnostic.config {
186186
virtual_lines = false, -- Text shows up underneath the line, with virtual lines
187187

188188
-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
189-
jump = { float = true },
189+
jump = { on_jump = function() vim.diagnostic.open_float() end },
190190
}
191191

192192
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })

lazy-lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"gitsigns.nvim": { "branch": "main", "commit": "e1fb5425c8812214209b3f24eaa582c6c552cf98" },
1111
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
1212
"indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" },
13-
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
13+
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
1414
"mason-lspconfig.nvim": { "branch": "main", "commit": "25f609e7fca78af7cede4f9fa3af8a94b1c4950b" },
1515
"mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" },
1616
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },

lua/custom/layout.lua

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ local function find_window_by_filetype(filetype)
3737
return nil
3838
end
3939

40+
local function is_opencode_window(win)
41+
if not win or not vim.api.nvim_win_is_valid(win) then return false end
42+
43+
local buf = vim.api.nvim_win_get_buf(win)
44+
local ft = vim.bo[buf].filetype
45+
if ft == 'opencode' then return true end
46+
47+
local bt = vim.bo[buf].buftype
48+
if bt ~= 'terminal' then return false end
49+
50+
if ft ~= '' and ft ~= 'snacks_terminal' and ft ~= 'toggleterm' then return false end
51+
52+
local buf_name = string.lower(vim.api.nvim_buf_get_name(buf))
53+
return buf_name:find('opencode', 1, true) ~= nil
54+
end
55+
56+
local function find_opencode_window()
57+
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
58+
if is_opencode_window(win) then return win end
59+
end
60+
61+
return nil
62+
end
63+
4064
function M.capture_focus()
4165
local current_win = vim.api.nvim_get_current_win()
4266
if not M.is_main_window(current_win) then return nil end
@@ -88,13 +112,13 @@ local function ensure_neotree_window()
88112
end
89113

90114
local function ensure_opencode_window()
91-
local opencode_win = find_window_by_filetype 'opencode'
115+
local opencode_win = find_opencode_window()
92116
if opencode_win then return opencode_win end
93117

94118
pcall(function() require('opencode').toggle() end)
95119

96-
vim.wait(1000, function() return find_window_by_filetype 'opencode' ~= nil end, 50)
97-
return find_window_by_filetype 'opencode'
120+
vim.wait(1000, function() return find_opencode_window() ~= nil end, 50)
121+
return find_opencode_window()
98122
end
99123

100124
function M.reset_ide_layout(opts)

lua/custom/plugins/enable/auto_session.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ return {
22
{
33
'rmagatti/auto-session',
44
lazy = false,
5+
init = function()
6+
-- Required by auto-session for filetype and highlighting to survive session restore
7+
vim.o.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions'
8+
end,
59
keys = {
610
-- Will use Telescope if installed or a vim.ui.select picker otherwise
711
{ '<leader>wr', '<cmd>AutoSession search<CR>', desc = 'Session search' },

0 commit comments

Comments
 (0)