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, {

View file

@ -5,7 +5,11 @@ let
};
in
{
home = { sessionVariables = { EDITOR = "nvim"; }; };
home = {
sessionVariables = {
EDITOR = "nvim";
};
};
imports = [
./options.nix
@ -40,6 +44,9 @@ in
};
};
extraLuaPackages = ps: [ ps.magick ];
extraPackages = [ pkgs.imagemagick ];
# package = pkgs.neovim-unwrapped;
package = (pkgs.neovim-unwrapped.override { lua = pkgs.luajit; }).overrideAttrs (_: {
version = "git";
@ -49,20 +56,22 @@ in
rev = "76dcc7029b200e1d85024d7ba4a34c602e730dbe";
hash = "sha256-y3LmGebXuQhLz9w1IzkDU8b464WvMvPCbIImpVvxmcI=";
};
buildInputs = [
(pkgs.utf8proc.overrideAttrs (_: {
version = "git";
buildInputs =
[
(pkgs.utf8proc.overrideAttrs (_: {
version = "git";
src = pkgs.fetchFromGitHub
{
src = pkgs.fetchFromGitHub {
owner = "JuliaStrings";
repo = "utf8proc";
rev = "3de4596fbe28956855df2ecb3c11c0bbc3535838";
hash = "sha256-DNnrKLwks3hP83K56Yjh9P3cVbivzssblKIx4M/RKqw=";
};
}))
] ++ pkgs.neovim-unwrapped.buildInputs ++ pkgs.neovim-unwrapped.nativeBuildInputs;
}))
]
++ pkgs.neovim-unwrapped.buildInputs
++ pkgs.neovim-unwrapped.nativeBuildInputs;
});
keymaps = [
@ -92,6 +101,9 @@ in
(map "i" "<S-tab>" "<c-d>")
(map "v" "<tab>" ">gv")
(map "v" "<S-tab>" "<gv")
# to avoid many typos
(map "n" ";" ":")
];
colorschemes.onedark = {
@ -113,11 +125,32 @@ in
extraConfigLuaPre = ''
require("neoconf").setup({})
'';
extraConfigLua = ''
require("render-markdown").setup {
latex_converter = '${pkgs.python312Packages.pylatexenc}/bin/latex2text',
}
'' + (builtins.readFile ./config.lua);
extraConfigLua =
''
require("render-markdown").setup {
latex_converter = '${pkgs.python312Packages.pylatexenc}/bin/latex2text',
}
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'
if not configs.foo_lsp then
configs.noteslsp = {
default_config = {
-- cmd = {'${pkgs.custom.noteslsp}/bin/noteslsp'},
cmd = {'./noteslsp/target/debug/noteslsp'},
filetypes = {'markdown'},
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
end,
settings = {}
,
},
}
end
lspconfig.noteslsp.setup{}
''
+ (builtins.readFile ./config.lua);
};
}

View file

@ -11,7 +11,6 @@ _: {
wrap = false;
spell = false;
# don't change the directory when a file is opened
# to work more like an IDE
autochdir = false;
@ -20,11 +19,15 @@ _: {
smartindent = true;
smarttab = true;
backspace = [ "indent" "eol" "start" ];
backspace = [
"indent"
"eol"
"start"
];
list = true;
undofile = true;
undodir = "/home/jonathan/.vimdid";
undodir = "/home/jana/.vimdid";
tabstop = 4;
softtabstop = 4;

View file

@ -19,6 +19,15 @@ let
hash = "sha256-eya/8rG3O8UFeeBRDa5U8v3qay+q3iFwPnYtdX7ptCA=";
};
};
fzy-lua-native = pkgs.vimUtils.buildVimPlugin {
name = "fzy-lua-native";
src = pkgs.fetchFromGitHub {
owner = "romgrk";
repo = "fzy-lua-native";
rev = "9d720745d5c2fb563c0d86c17d77612a3519c506";
hash = "sha256-pBV5iGa1+5gtM9BcDk8I5SKoQ9sydOJHsmyoBcxAct0=";
};
};
in
{
programs.nixvim = {
@ -159,6 +168,15 @@ in
cmp.enable = true;
nvim-autopairs.enable = true;
image = {
enable = true;
integrations.markdown = {
enabled = true;
clearInInsertMode = true;
downloadRemoteImages = true;
};
};
# dial.nvim
which-key = {
@ -433,7 +451,7 @@ in
# filetypes =
# [ "javascript" "javascriptreact" "typescript" "typescriptreact" ];
# };
marksman.enable = true;
# marksman.enable = true;
yamlls = {
enable = true;
filetypes = [ "yaml" ];
@ -449,6 +467,104 @@ in
};
};
};
wilder = {
enable = true;
modes = [
"/"
":"
"?"
];
enableCmdlineEnter = true;
beforeCursor = true;
useCmdlinechanged = true;
nextKey = "<Tab>";
prevKey = "<S-Tab>";
acceptKey = "<Down>";
rejectKey = "<Up>";
pipeline = [
''
wilder.branch(
wilder.cmdline_pipeline({
language = 'python',
fuzzy = 2,
}),
wilder.python_search_pipeline({
pattern = wilder.python_fuzzy_pattern(),
sorter = wilder.python_difflib_sorter(),
engine = 're',
}),
wilder.substitute_pipeline({
pipeline = wilder.python_search_pipeline({
skip_cmdtype_check = 1,
pattern = wilder.python_fuzzy_pattern({
start_at_boundary = 0,
}),
}),
}),
{
wilder.check(function(ctx, x) return x == "" end),
wilder.history(),
},
wilder.python_file_finder_pipeline({
file_command = {'${pkgs.ripgrep}/bin/rg', '--files'},
dir_command = {'${pkgs.fd}/bin/fd', '-td'},
filters = {'cpsm_filter'},
})
)
''
];
renderer = ''
(function()
local highlighters = {
wilder.pcre2_highlighter(),
wilder.lua_fzy_highlighter(),
}
local popupmenu_renderer = wilder.popupmenu_renderer(
wilder.popupmenu_border_theme({
border = 'rounded',
empty_message = wilder.popupmenu_empty_message_with_spinner(),
highlighter = highlighters,
highlights = {
accent = wilder.make_hl('WilderAccent', 'Pmenu', {{a = 1}, {a = 1}, {foreground = '#f4468f'}}),
},
left = {
' ',
wilder.popupmenu_devicons(),
wilder.popupmenu_buffer_flags({
flags = ' a + ',
icons = {['+'] = '', a = '', h = ''},
}),
},
right = {
' ',
wilder.popupmenu_scrollbar(),
},
})
)
local wildmenu_renderer = wilder.wildmenu_renderer({
highlights = {
accent = wilder.make_hl('WilderAccent', 'Pmenu', {{a = 1}, {a = 1}, {foreground = '#f4468f'}}),
},
highlighter = highlighters,
separator = ' · ',
left = {' ', wilder.wildmenu_spinner(), ' '},
right = {' ', wilder.wildmenu_index()},
})
return wilder.renderer_mux({
[':'] = popupmenu_renderer,
['/'] = wildmenu_renderer,
substitute = wildmenu_renderer,
})
end)()
'';
};
floaterm = {
enable = true;
opener = "edit";
@ -518,6 +634,9 @@ in
vim-autoswap
targets-vim
fzy-lua-native
cpsm
# jj
vim-jjdescription