Cheatsheets and debuggin

This commit is contained in:
Chris
2026-06-16 16:26:28 +01:00
parent 5dd9b59b90
commit ecbc266165
14 changed files with 1297 additions and 142 deletions
+51 -1
View File
@@ -51,7 +51,57 @@ helpers.open_term = function(opts)
end
helpers.has_copilot = function()
return vim.fn.getenv('COPILOT_API_KEY') ~= vim.NIL
return vim.fn.getenv 'COPILOT_API_KEY' ~= vim.NIL
end
helpers.open_file_modal = function(path, title)
local width = math.floor(vim.o.columns * 0.85)
local height = math.floor(vim.o.lines * 0.85)
local row = math.floor((vim.o.lines - height) / 2)
local col = math.floor((vim.o.columns - width) / 2)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_open_win(buf, true, {
relative = 'editor',
width = width,
height = height,
row = row,
col = col,
style = 'minimal',
border = 'rounded',
title = ' ' .. title .. ' ',
title_pos = 'center',
})
vim.api.nvim_buf_set_name(buf, path)
local lines = vim.fn.readfile(path)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
vim.bo[buf].filetype = 'markdown'
vim.bo[buf].buftype = 'nofile'
vim.bo[buf].bufhidden = 'wipe'
vim.bo[buf].swapfile = false
vim.bo[buf].modifiable = false
vim.bo[buf].readonly = true
vim.wo.wrap = false
vim.wo.number = false
vim.wo.relativenumber = false
vim.wo.cursorline = true
vim.keymap.set('n', 'q', '<cmd>close<CR>', {
buffer = buf,
silent = true,
desc = 'Close cheatsheet',
})
vim.keymap.set('n', '<Esc>', '<cmd>close<CR>', {
buffer = buf,
silent = true,
desc = 'Close cheatsheet',
})
end
return helpers