This commit is contained in:
2026-02-26 11:15:22 +01:00
commit d36d07d224
19 changed files with 2020 additions and 0 deletions

14
lua/custom/keymaps.lua Normal file
View File

@@ -0,0 +1,14 @@
-- Set custom maps
local map = vim.keymap.set
-- Horizontal split for terminal
map('n', '<C-t>', ':split | terminal<CR>', { desc = '[T]erminal (Horizontal Split)' })
-- Open neo-filetree
map('n', '<C-e>', ':Neotree toggle<CR>', { desc = '[E]xplorer (toggle neotree)' })
-- Open lazygit in overlay
map('n', '<C-g>', '<cmd>LazyGit<CR>', { desc = 'LazyGit' })
-- Telescope grep all files in working dir
map('n', '<C-f>', '<cmd>builtin.grep_string<CR>', { desc = '[F]ind (Telescope ripgrep all files in work_dir)' })

View File

@@ -0,0 +1,8 @@
-- Add custom comments package
-- https://github.com/numToStr/Comment.nvim
return {
'numToStr/Comment.nvim',
opts = {
-- add any options here
}
}

View File

@@ -0,0 +1,31 @@
-- Open fff.nvim
-- https://github.com/dmtrKovalenko/fff.nvim
return {
'dmtrKovalenko/fff.nvim',
build = function()
-- this will download prebuild binary or try to use existing rustup toolchain to build from source
-- (if you are using lazy you can use gb for rebuilding a plugin if needed)
require('fff.download').download_or_build_binary()
end,
-- if you are using nixos
-- build = "nix run .#release",
opts = { -- (optional)
debug = {
enabled = false, -- we expect your collaboration at least during the beta
show_scores = true, -- to help us optimize the scoring system, feel free to share your scores!
},
},
-- No need to lazy-load with lazy.nvim.
-- This plugin initializes itself lazily.
lazy = false,
keys = {
{
'ff', -- try it if you didn't it is a banger keybinding for a picker
function()
require('fff').find_files()
end,
desc = 'FFFind files',
},
},
}

View File

@@ -0,0 +1,18 @@
-- You can add your own plugins here or in other files in this directory!
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {
-- {
-- 'navarasu/onedark.nvim',
-- priority = 1000, -- make sure to load this before all the other start plugins
-- config = function()
-- require('onedark').setup {
-- style = 'warmer',
-- }
-- require('onedark').load()
-- end,
-- },
-- { 'catppuccin/nvim', name = 'catppuccin', priority = 1000 },
--
}

View File

@@ -0,0 +1,23 @@
-- Open lazygit
-- https://github.com/kdheepak/lazygit.nvim
return {
'kdheepak/lazygit.nvim',
lazy = true,
cmd = {
'LazyGit',
'LazyGitConfig',
'LazyGitCurrentFile',
'LazyGitFilter',
'LazyGitFilterCurrentFile',
},
-- optional for floating window border decoration
dependencies = {
'nvim-lua/plenary.nvim',
},
-- setting the keybinding for LazyGit with 'keys' is recommended in
-- order to load the plugin when the command is run for the first time
keys = {
{ '<leader>lg', '<cmd>LazyGit<cr>', desc = 'LazyGit' },
},
}

View File

@@ -0,0 +1,114 @@
-- Simple PDF viewer using pdftoppm + image.nvim
-- Requires: poppler (brew install poppler)
return {
'3rd/image.nvim',
config = function()
local image = require('image')
image.setup({})
local pdf_state = {}
vim.api.nvim_create_autocmd('BufReadPost', {
pattern = '*.pdf',
callback = function()
local pdf_path = vim.fn.expand('%:p')
local temp_dir = vim.fn.tempname()
vim.fn.mkdir(temp_dir, 'p')
local bufnr = vim.api.nvim_get_current_buf()
-- Convert all pages upfront
vim.notify('Converting PDF...', vim.log.levels.INFO)
vim.fn.jobstart({
'pdftoppm', '-png',
pdf_path, temp_dir .. '/page'
}, {
on_exit = function(_, code)
vim.schedule(function()
if code ~= 0 then
vim.notify('Failed to convert PDF', vim.log.levels.ERROR)
return
end
-- Count generated files
local handle = vim.loop.fs_scandir(temp_dir)
local page_count = 0
if handle then
while true do
local name = vim.loop.fs_scandir_next(handle)
if not name then break end
if name:match('^page%-%d+%.png$') then
page_count = page_count + 1
end
end
end
pdf_state[bufnr] = {
temp_dir = temp_dir,
current_page = 1,
total_pages = page_count,
}
local function show_page(page_num)
local state = pdf_state[bufnr]
if not state then return end
image.clear()
vim.bo[bufnr].modifiable = true
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {''})
vim.bo[bufnr].modifiable = false
local page_file = string.format('%s/page-%02d.png', state.temp_dir, page_num)
local img = image.from_file(page_file, { buffer = bufnr })
if img then
img:render()
vim.notify(string.format('Page %d / %d', page_num, state.total_pages), vim.log.levels.INFO)
else
vim.notify('Failed to load page ' .. page_num, vim.log.levels.ERROR)
end
end
local function change_page(delta)
local state = pdf_state[bufnr]
if not state then return end
local new_page = state.current_page + delta
if new_page < 1 or new_page > state.total_pages then
return
end
state.current_page = new_page
show_page(new_page)
end
-- Keymaps
vim.keymap.set('n', 'j', function() change_page(1) end, { buffer = bufnr, desc = 'Next page' })
vim.keymap.set('n', 'k', function() change_page(-1) end, { buffer = bufnr, desc = 'Previous page' })
vim.keymap.set('n', '<Right>', function() change_page(1) end, { buffer = bufnr, desc = 'Next page' })
vim.keymap.set('n', '<Left>', function() change_page(-1) end, { buffer = bufnr, desc = 'Previous page' })
vim.keymap.set('n', 'q', '<cmd>bd!<cr>', { buffer = bufnr, silent = true })
-- Show first page
show_page(1)
end)
end
})
end,
})
-- Cleanup
vim.api.nvim_create_autocmd('BufDelete', {
pattern = '*.pdf',
callback = function(args)
if pdf_state[args.buf] then
image.clear()
vim.fn.delete(pdf_state[args.buf].temp_dir, 'rf')
pdf_state[args.buf] = nil
end
end,
})
end,
}