update ci

This commit is contained in:
Jonathan Dönszelmann 2025-02-01 15:55:05 +01:00
parent d030ebe744
commit 76ed037b04
No known key found for this signature in database
11 changed files with 1278 additions and 55 deletions

View file

@ -1,8 +1,5 @@
vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
require("render-markdown").setup {
latex_converter = '${pkgs.python312Packages.pylatexenc}/bin/latex2text',
}
local otter = require'otter'
otter.setup{}
@ -91,30 +88,128 @@ vim.keymap.set('n', 'gd', (function() builtin.lsp_definitions({jump_type="vsplit
vim.keymap.set('n', 'gt', (function() builtin.lsp_type_definitions({jump_type="vsplit"}) end), {})
local barbar_state = require("barbar.state")
vim.api.nvim_create_user_command('CustomCloseBuffer', function (tbl)
count = 0
for _ in pairs(barbar_state.buffers) do count = count + 1 end
function find_windows_with_buffer(bufnum)
windows = {}
if count == 1 then
vim.cmd "quit"
local window_list = vim.api.nvim_list_wins()
for _, window in ipairs(window_list) do
local win_info = vim.fn.getwininfo(window)
if win_info ~= nil then
for _, buf in ipairs(win_info) do
if buf.bufnr == bufnum then
table.insert(windows, window)
end
end
end
end
vim.cmd "silent! BufferClose"
return windows
end
if vim.api.nvim_buf_get_name(0) == "" then
vim.cmd "quit"
function num_useful_windows()
local window_list = vim.api.nvim_tabpage_list_wins(0)
local num = 0
for _, window in ipairs(window_list) do
local win_info = vim.fn.getwininfo(window)
if win_info ~= nil then
for _, win_info in ipairs(win_info) do
if buf_is_useful(win_info.bufnr) then
num = num + 1
end
end
end
end
end, { desc = "Close Buffer without errors" })
return num
end
function buf_is_useful(bufnr)
local bufname = vim.api.nvim_buf_get_name(bufnr)
-- if the window's buffer has no name, it's not useful
if bufname == '' then
return false
end
-- print("bufname: ", bufname)
-- if the window's buffer is read only, it's not useful
local readonly = vim.api.nvim_buf_get_option(bufnr, 'readonly')
if readonly then
-- print("=readonly")
return false
end
-- -- if the buffer is not listed, it's not useful
local listed = vim.api.nvim_buf_get_option(bufnr, 'buflisted')
if not listed then
-- print("=unlisted")
return false
end
local buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype')
if buftype == "quickfix" then
-- print("=readonly")
return false
end
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
if #lines > 1 or (#lines == 1 and #lines[1] > 0) then
return true -- If the buffer has content, return false
else
return false
end
-- the window contains a useful buffer
return true
end
function quit_window(window)
vim.api.nvim_win_call(window, function()
vim.cmd "quit"
end)
end
vim.api.nvim_create_user_command('CloseBuffer', function (opts)
if num_useful_windows() > 1 then
vim.cmd {
cmd = "quit",
bang = opts.bang,
}
else
vim.cmd {
cmd = "BufferDelete",
bang = opts.bang,
}
if not buf_is_useful(vim.api.nvim_get_current_buf()) then
vim.cmd {
cmd = "quit",
bang = opts.bang,
}
end
end
end, { desc = "Close Current Buffer", bang = true, })
vim.keymap.set("ca", "W", "w")
vim.keymap.set("ca", "X", "x")
vim.keymap.set("ca", "Q", "q")
vim.keymap.set("ca", "q", "CloseBuffer")
vim.keymap.set("ca", "qw", "quit")
-- format on wq and x and replace X, W and Q with x, w and q
vim.cmd [[cnoreabbrev w execute "Format sync" <bar> w]]
vim.cmd [[cnoreabbrev x execute "Format sync" <bar> w <bar> CustomCloseBuffer <cr>]]
vim.cmd [[cabbrev W w]]
vim.cmd [[cabbrev X execute "Format sync" <bar> x]]
vim.cmd [[cabbrev Q CustomCloseBuffer]]
vim.cmd [[cnoreabbrev q CustomCloseBuffer <cr>]]
vim.cmd [[cnoreabbrev qa q]]
vim.cmd [[nnoremap ; :]]
-- vim.cmd [[cnoreabbrev w execute "Format sync" <bar> w]]
-- vim.cmd [[cnoreabbrev x execute "Format sync" <bar> w <bar> CustomCloseBuffer <cr>]]
-- vim.cmd [[cabbrev W w]]
-- vim.cmd [[cabbrev X execute "Format sync" <bar> x]]
-- vim.cmd [[cabbrev Q CustomCloseBuffer]]
-- vim.cmd [[cnoreabbrev q CustomCloseBuffer <cr>]]
-- vim.cmd [[cnoreabbrev qa q]]
-- vim.cmd [[nnoremap ; :]]
local builtin = require('telescope.builtin')
@ -137,7 +232,7 @@ vim.keymap.set('n', '<leader>cl', "<cmd>silent! BufferCloseBuffersLeft<cr>")
vim.keymap.set('n', '<leader>cr', "<cmd>silent! BufferCloseBuffersRight<cr>")
-- like quit but for a single tab
vim.keymap.set('n', '<leader>q', "<cmd>BD<cr>", {})
vim.keymap.set('n', '<leader>q', "<cmd>BufferClose<cr>", {})
vim.keymap.set('n', '<leader>oq', "<cmd>BufOnly<cr>", {})
vim.keymap.set("n", "<leader>x", require("telescope.builtin").resume, {