Cleaned up the keymaps such that the keymaps are where the plugins are. This is for easy sharing of configurations

This commit is contained in:
2025-08-29 13:34:49 +02:00
parent e37215ae97
commit e085a5cc23
11 changed files with 235 additions and 214 deletions

View File

@@ -3,12 +3,11 @@
require("utils.functions") require("utils.functions")
require("custom.uni") require("custom.uni")
local season = "S2" -- TODO: move this to a config file
local season = "S3"
local links = require("utils.linker") local links = require("utils.linker")
local user = vim.fn.system('whoami'):gsub('\n', '') local user = vim.fn.system('whoami'):gsub('\n', '')
local api = require("nvim-tree.api")
local builtin = require('telescope.builtin')
local function open_cal() local function open_cal()
local current_date = os.date("%Y-%m-%d") local current_date = os.date("%Y-%m-%d")
@@ -37,66 +36,67 @@ vim.keymap.set("n", "<leader>w", "<C-w>w")
--------------------- NORMAL ------------------------- --------------------- NORMAL -------------------------
vim.keymap.set("n", "L", ":BufferNext<CR>", { silent = true })
vim.keymap.set("n", "n", "nzz", { silent = true })
vim.keymap.set("n", "N", "Nzz", { silent = true })
vim.keymap.set("n", "H", ":BufferPrevious<CR>", { silent = true })
vim.keymap.set("n", "<C-o>", "<C-o>zz", { silent = true })
vim.keymap.set("n", "<C-i>", "<C-i>zz", { silent = true })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { silent = true })
vim.keymap.set("n", "<C-d>", "<C-d>zz", { silent = true })
vim.keymap.set('n', '<leader>a', 'm9ggVG"+y`9')
vim.keymap.set('n', '<leader>va', 'ggVG')
-- Launch panel if nothing is typed after <leader>z
vim.keymap.set("n", "<leader>z", "<cmd>Telekasten panel<CR>")
-- Most used functions
vim.keymap.set("n", "<leader>zf", "<cmd>Telekasten find_notes<CR>")
vim.keymap.set("n", "<leader>zg", "<cmd>Telekasten search_notes<CR>")
vim.keymap.set('n', '<leader>zq', ':e ~/synced/brainstore/zettelkasten/input.txt<CR>`.zz') vim.keymap.set('n', '<leader>zq', ':e ~/synced/brainstore/zettelkasten/input.txt<CR>`.zz')
vim.keymap.set("n", "<leader>zd", "<cmd>Telekasten goto_today<CR>")
vim.keymap.set("n", "<leader>zr", "<cmd>Telekasten rename_note<CR>") -- Buildin vim
vim.keymap.set("n", "<leader>zz", "<cmd>Telekasten follow_link<CR>")
vim.keymap.set("n", "<leader>zn", "<cmd>Telekasten new_note<CR>")
vim.keymap.set("n", "<leader>zb", "<cmd>Telekasten show_backlinks<CR>")
vim.keymap.set("n", "<leader>zw", "<cmd>Telekasten find_weekly_notes<CR>")
vim.keymap.set("n", "<leader>zI", "<cmd>Telekasten insert_img_link<CR>")
vim.keymap.set("n", "<leader>me", ":mes<CR>") vim.keymap.set("n", "<leader>me", ":mes<CR>")
vim.keymap.set("n", "<C-/>", ":ToggleTerm<CR>")
vim.keymap.set("t", "<C-/>", "<C-\\><C-n>:ToggleTerm<CR>")
vim.keymap.set("n", "<leader>snt", "<cmd>set nu<CR>") vim.keymap.set("n", "<leader>snt", "<cmd>set nu<CR>")
vim.keymap.set("n", "<leader>snf", "<cmd>set nonu<CR>") vim.keymap.set("n", "<leader>snf", "<cmd>set nonu<CR>")
-- Call insert link automatically when we start typing a link
vim.keymap.set("n", "<leader>il", "<cmd>Telekasten insert_link<CR>")
vim.keymap.set("n", "<leader>nv", function() vim.keymap.set("n", "<leader>nv", function()
select_course_directory() select_course_directory()
end, { desc = "Open UniCourse menu" }) end, { desc = "Open UniCourse menu" })
vim.keymap.set("n", "n", "nzz", { silent = true })
vim.keymap.set("n", "N", "Nzz", { silent = true })
vim.keymap.set("n", "<C-o>", "<C-o>zz", { silent = true })
vim.keymap.set("n", "<C-i>", "<C-i>zz", { silent = true })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { silent = true })
vim.keymap.set("n", "<C-d>", "<C-d>zz", { silent = true })
vim.keymap.set('n', '<leader>a', 'm9ggVG"+y`9')
vim.keymap.set('n', '<leader>va', 'ggVG')
vim.keymap.set('n', '<leader>ca', 'ggVGd')
vim.keymap.set("n", "<leader>bd", ":BufferDelete<CR>", { silent = true })
-- Typstar stuff
vim.keymap.set("n", "<leader>ti", ":TypstarInsertRnote<CR>", { silent = true })
vim.keymap.set("n", "<leader>to", ":TypstarOpenDrawing<CR>", { silent = true })
-- Get a ready to use terminal -- Get a ready to use terminal
vim.keymap.set('n', '<leader>tr', ':tabnew<CR>:term<CR>i') vim.keymap.set('n', '<leader>tr', ':tabnew<CR>:term<CR>i')
vim.keymap.set("n", "<leader>tt", ":Telescope<CR>", { desc = "Follow Link" })
-- This needs to be refined for quick access to a new file or a recently edited one -- This needs to be refined for quick access to a new file or a recently edited one
vim.keymap.set('n', '<leader>ov', open_vorlesung) vim.keymap.set('n', '<leader>ov',
function()
local uni_dir = vim.fn.expand("~/projects/university/" .. season)
require('telescope.builtin').find_files {
prompt_title = "Select Vorlesung in " .. season,
cwd = uni_dir,
find_command = {
"eza", "-1", "-D"
},
}
end
)
-- new quick note file -- new quick note file
-- TODO: make this smarter -- TODO: make this smarter
vim.keymap.set("n", "<leader>nn", ":e ~/synced/brainstore/zettelkasten/quick<CR>", { silent = true }) vim.keymap.set("n", "<leader>nn", ":e ~/synced/brainstore/zettelkasten/quick<CR>", { silent = true })
vim.keymap.set("n", "<leader>r", set_root) vim.keymap.set("n", "<leader>r",
function()
local current_file = vim.fn.expand('%:p:h') -- get directory of current file
local cmd = 'git -C ' .. vim.fn.fnameescape(current_file) .. ' status'
vim.fn.system(cmd)
if vim.v.shell_error == 0 then
local git_root = vim.fn.systemlist('git -C ' ..
vim.fn.fnameescape(current_file) .. ' rev-parse --show-toplevel')
[1]
vim.cmd('cd ' .. vim.fn.fnameescape(git_root))
else
vim.cmd('cd ' .. vim.fn.fnameescape(current_file))
end
end
)
-- Quickly open some buffers -- Quickly open some buffers
vim.keymap.set('n', '<leader>occ', ':e ~/.config/nvim/init.lua<CR>`.zz') vim.keymap.set('n', '<leader>occ', ':e ~/.config/nvim/init.lua<CR>`.zz')
@@ -106,7 +106,7 @@ vim.keymap.set('n', '<leader>ocd', ':e ~/.config/nvim/lua/config/autocmds.lua<CR
vim.keymap.set('n', '<leader>oco', ':e ~/.config/nvim/lua/config/options.lua<CR>`.zz') vim.keymap.set('n', '<leader>oco', ':e ~/.config/nvim/lua/config/options.lua<CR>`.zz')
vim.keymap.set('n', '<leader>ocl', ':e ~/.config/nvim/lua/config/lazy.lua<CR>`.zz') vim.keymap.set('n', '<leader>ocl', ':e ~/.config/nvim/lua/config/lazy.lua<CR>`.zz')
vim.keymap.set('n', '<leader>oczl', ':e ~/.config/nvim/lua/config/lsp.lua<CR>`.zz') vim.keymap.set('n', '<leader>oczl', ':e ~/.config/nvim/lua/config/lsp.lua<CR>`.zz')
vim.keymap.set('n', '<leader>ocp', ':e ~/.config/nvim/lua/plugins/main.lua<CR>`.zz') vim.keymap.set('n', '<leader>ocp', ':e ~/.config/nvim/lua/plugins/misc.lua<CR>`.zz')
vim.keymap.set('n', '<leader>ocf', ':e ~/.config/nvim/lua/utils/functions.lua<CR>`.zz') vim.keymap.set('n', '<leader>ocf', ':e ~/.config/nvim/lua/utils/functions.lua<CR>`.zz')
vim.keymap.set('n', '<leader>oca', ':e ~/.config/nvim/lua/utils/after.lua<CR>`.zz') vim.keymap.set('n', '<leader>oca', ':e ~/.config/nvim/lua/utils/after.lua<CR>`.zz')
vim.keymap.set('n', '<leader>oq', ':e ~/synced/brainstore/input.txt<CR>`.zz') vim.keymap.set('n', '<leader>oq', ':e ~/synced/brainstore/input.txt<CR>`.zz')
@@ -122,7 +122,27 @@ vim.keymap.set('n', '<leader>od', ':e ~/synced/brainstore/todos/done.txt<CR>`.zz
vim.keymap.set('n', '<leader>ou', ':e ~/projects/university/' .. season .. '/input.txt<CR>`.zz') vim.keymap.set('n', '<leader>ou', ':e ~/projects/university/' .. season .. '/input.txt<CR>`.zz')
vim.keymap.set('n', '<leader>oz', ':e ~/.zshrc<CR>`.zz') vim.keymap.set('n', '<leader>oz', ':e ~/.zshrc<CR>`.zz')
vim.keymap.set('n', '<leader>oaa', ':e ~/.common_shell<CR>`.zz') vim.keymap.set('n', '<leader>oaa', ':e ~/.common_shell<CR>`.zz')
vim.keymap.set("n", "<leader>or", "<cmd>lua open_last_file()<CR>", { noremap = true, silent = true }) vim.keymap.set("n", "<leader>or",
function()
local last_file_path = vim.fn.stdpath('data') .. "/lastfile.txt"
local file = io.open(last_file_path, "r")
if file then
local last_file = file:read("*line")
file:close()
if last_file and vim.fn.filereadable(last_file) == 1 then
vim.cmd("edit " .. last_file)
pcall(function()
vim.cmd('normal! `.') -- Go to the last edit position
vim.cmd('normal! zz') -- Center the cursor on the screen
end)
else
print("Last file does not exist or is not readable")
end
else
print("No last file found")
end
end
, { noremap = true, silent = true })
vim.keymap.set('n', '<leader>ok', open_cal) vim.keymap.set('n', '<leader>ok', open_cal)
@@ -135,12 +155,10 @@ vim.keymap.set("n", "<leader>lp", links.insert_project_link, { desc = "Link Proj
vim.keymap.set("n", "<leader>lc", links.insert_contact_link, { desc = "Link Contact" }) vim.keymap.set("n", "<leader>lc", links.insert_contact_link, { desc = "Link Contact" })
vim.keymap.set("n", "<leader>ld", links.insert_date_link, { desc = "Link Contact" }) vim.keymap.set("n", "<leader>ld", links.insert_date_link, { desc = "Link Contact" })
-- Nvim tree
vim.keymap.set("n", "<leader>e", function()
api.tree.toggle({ find_file = true, update_root = true, focus = true, })
end, { silent = true }) -- also update the root with the bang
-- Indent all will be replaced by the formatting of lsp where the lsp is installed
vim.keymap.set('n', '<leader>ia', 'gg=G<C-o>zz') vim.keymap.set('n', '<leader>ia', 'gg=G<C-o>zz')
vim.keymap.set('n', '<leader>ya', 'ggVG"+y<C-o>') vim.keymap.set('n', '<leader>ya', 'ggVG"+y<C-o>')
vim.keymap.set('n', '<leader>ss', ':wa<CR>') vim.keymap.set('n', '<leader>ss', ':wa<CR>')
@@ -151,6 +169,8 @@ vim.keymap.set('n', '<leader>sw', function()
vim.cmd(string.format("%%s/\\<%s\\>/%s/gI", vim.fn.escape(word, '\\/'), vim.fn.escape(replacement, '\\/'))) vim.cmd(string.format("%%s/\\<%s\\>/%s/gI", vim.fn.escape(word, '\\/'), vim.fn.escape(replacement, '\\/')))
end end
end, { desc = "Substitute word under cursor (prompt)" }) end, { desc = "Substitute word under cursor (prompt)" })
-- Substitution in visual mode
vim.keymap.set('v', '<leader>sv', function() vim.keymap.set('v', '<leader>sv', function()
-- Save the current selection -- Save the current selection
local save_reg = vim.fn.getreg('"') local save_reg = vim.fn.getreg('"')
@@ -181,29 +201,6 @@ vim.keymap.set('v', '<leader>p', function()
vim.cmd('normal! "+p') vim.cmd('normal! "+p')
end, { desc = 'Yank to clipboard and keep the selection' }) end, { desc = 'Yank to clipboard and keep the selection' })
vim.keymap.set('n', '<leader>fr', function()
require('telescope.builtin').oldfiles({
disable_devicons = true,
})
end, { noremap = true, silent = true })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
vim.keymap.set("n", "<leader>fl", links.follow_link, { desc = "Follow Link" })
vim.keymap.set('n', '<leader>g', function()
require('telescope.builtin').live_grep({
disable_devicons = true,
cwd = vim.fn.getcwd(), -- set the starting directory
additional_args = function()
return { '--hidden', '--glob', '!.git/*' } -- include hidden files but exclude .git
end,
})
end, { noremap = true, silent = true })
vim.keymap.set('n', '<leader><leader>', find_eff,
{ desc = 'Telescope find files (with dotfiles and folders but excluding .git, .cache, .local, and large files)' })
------------------------ VISUAL ------------------ ------------------------ VISUAL ------------------
vim.keymap.set('v', 'p', function() vim.keymap.set('v', 'p', function()

View File

@@ -1,41 +1,33 @@
local M = {}
local functions = require("utils.functions") local functions = require("utils.functions")
local watch_job_id = nil local watch_job_id = nil
local watch_buf_id = nil local watch_buf_id = nil
local watch_tab_id = nil
local function watch_and_open() function M.Watch_and_open()
-- Parse the current file and check for typst
vim.notify("INIT", vim.log.levels.WARN)
local input = vim.fn.expand("%:p") local input = vim.fn.expand("%:p")
if not input:match("%.typ$") then if not input:match("%.typ$") then
vim.notify("Not a Typst file", vim.log.levels.WARN) vim.notify("Not a Typst file", vim.log.levels.WARN)
return return
end end
local dir = vim.fn.fnamemodify(input, ":h") -- directory of the Typst file local dir = vim.fn.fnamemodify(input, ":h") -- directory of the Typst file
local filename = vim.fn.expand("%:t:r") .. ".pdf" -- filename without extension + .pdf local filename = vim.fn.expand("%:t:r") .. ".pdf" -- filename without extension + .pdf
-- Get the underlying unicourse dir
local one_up = vim.fn.fnamemodify(dir, ":h")
print(one_up)
local pdf_dir = nil
if vim.fn.filereadable(one_up .. "/.unicourse") == 1 then
pdf_dir = one_up .. "/../../pdfs"
else
pdf_dir = dir
end
vim.fn.mkdir(pdf_dir, "p")
local output = pdf_dir .. "/" .. filename
-- Check if a watcher is already running for this file -- Check if a watcher is already running for this file
if watch_job_id then if watch_job_id then
vim.notify("Typst watcher already running - please close zathura", vim.log.levels.INFO) vim.notify("Typst watcher already running - please close zathura", vim.log.levels.INFO)
return return
end end
local output = dir .. "/" .. filename
-- Start typst watch -- Start typst watch
local cwd = vim.fn.getcwd() -- set the starting directory local cwd = vim.fn.getcwd() -- set the starting directory
-- TODO: root setting does not work -- TODO: root setting does not work
local watch_cmd = { "typst", "watch", "--root", cwd, input, output } local watch_cmd = { "typst", "watch", "--root", cwd, input, output }
watch_job_id = vim.fn.jobstart(watch_cmd, { watch_job_id = vim.fn.jobstart(watch_cmd, {
@@ -44,7 +36,7 @@ local function watch_and_open()
on_stderr = function(_, data) on_stderr = function(_, data)
if data then if data then
if not watch_tab_id then if not watch_tab_id then
pre_tab = vim.api.nvim_get_current_tabpage() -- Get the current tab ID local pre_tab = vim.api.nvim_get_current_tabpage() -- Get the current tab ID
vim.cmd('tabnew') -- Open a new tab vim.cmd('tabnew') -- Open a new tab
watch_tab_id = vim.api.nvim_get_current_tabpage() -- Get the current tab ID watch_tab_id = vim.api.nvim_get_current_tabpage() -- Get the current tab ID
watch_buf_id = vim.api.nvim_get_current_buf() -- Get the buffer ID of the new tab watch_buf_id = vim.api.nvim_get_current_buf() -- Get the buffer ID of the new tab
@@ -63,12 +55,6 @@ local function watch_and_open()
end end
end, end,
on_exit = function(_, exit_code) on_exit = function(_, exit_code)
-- Ensure to close the tab that holds the logs
--if watch_tab_id then
-- -- Switch to the tab holding the log buffer and close it
-- vim.api.nvim_set_current_tabpage(watch_tab_id)
-- vim.cmd('tabclose') -- Close the tab holding the log buffer
--end
if exit_code == 0 then if exit_code == 0 then
vim.notify("Typst watch stopped successfully", vim.log.levels.INFO) vim.notify("Typst watch stopped successfully", vim.log.levels.INFO)
else else
@@ -79,8 +65,6 @@ local function watch_and_open()
}) })
vim.notify("Started Typst watch", vim.log.levels.INFO) vim.notify("Started Typst watch", vim.log.levels.INFO)
-- Start sioyek with the --new-window flag and stop watch when it exits
-- ensure that there is no sioyek
vim.fn.system("killall .zathura-wrapped") vim.fn.system("killall .zathura-wrapped")
functions.Sleep(0.5) functions.Sleep(0.5)
vim.fn.jobstart({ "zathura", output }, { vim.fn.jobstart({ "zathura", output }, {
@@ -93,6 +77,4 @@ local function watch_and_open()
}) })
end end
return { return M
Watch_and_open = watch_and_open
}

View File

@@ -1,14 +1,15 @@
-- Custom modules --- @param name? string
--- @param name string
--- @return string --- @return string
local function get_dir(name) local function get_custom_dir(name)
if name == nil then
return vim.fn.stdpath("config") .. "/lua/custom"
end
return vim.fn.stdpath("config") .. "/lua/custom/" .. name return vim.fn.stdpath("config") .. "/lua/custom/" .. name
end end
return { return {
{ {
dir = get_dir("todo"), dir = get_custom_dir("todo"),
name = "todo", name = "todo",
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" }, dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
config = function() config = function()
@@ -16,7 +17,7 @@ return {
end, end,
}, },
{ {
dir = vim.fn.stdpath("config") .. "/lua/custom", -- folder containing typst.lua dir = get_custom_dir(),
name = "typst", name = "typst",
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" }, dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
keys = { keys = {

View File

@@ -80,7 +80,7 @@ return {
-- Toggles -- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame) map('n', '<leader>tb', gitsigns.toggle_current_line_blame)
map('n', '<leader>tw', gitsigns.toggle_word_diff) -- map('n', '<leader>tw', gitsigns.toggle_word_diff)
-- Text object -- Text object
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk) map({ 'o', 'x' }, 'ih', gitsigns.select_hunk)

View File

@@ -1,5 +1,5 @@
return { return {
{ "stevearc/aerial.nvim", opts = {} }, { "stevearc/aerial.nvim", config = true },
{ {
"nvimdev/lspsaga.nvim", "nvimdev/lspsaga.nvim",
opts = { opts = {

View File

@@ -1,26 +1,77 @@
local base_zet = "~/synced/brainstore/zettelkasten" local base_zet = "~/synced/brainstore/zettelkasten"
return { return {
{ "ThePrimeagen/harpoon" }, {
{ "akinsho/toggleterm.nvim", config = true }, "ThePrimeagen/harpoon",
config = function()
vim.keymap.set("n", "<leader>af", function()
require("harpoon.mark").add_file()
end)
vim.keymap.set("n", "<leader>hf", function()
require("harpoon.ui").toggle_quick_menu()
end)
vim.keymap.set("n", "<leader>Hn", function()
require("harpoon.ui").nav_next()
end)
vim.keymap.set("n", "<leader>Hp", function()
require("harpoon.ui").nav_prev()
end)
end
},
{
"akinsho/toggleterm.nvim",
config = function()
-- Cannot setup with opts here need to call before using the command for the plugin
require("toggleterm").setup({
size = 20,
direction = "horizontal",
})
local first_open = false
local function toggle_term()
vim.cmd("ToggleTerm")
if first_open == true then
vim.cmd("startinsert")
end
end
vim.keymap.set("n", "<C-/>", toggle_term, { noremap = true, silent = true })
vim.keymap.set("t", "<C-/>", toggle_term, { noremap = true, silent = true })
end
},
{ {
'Ascyii/telekasten.nvim', 'Ascyii/telekasten.nvim',
dev = true, dev = true,
opts = { config = function()
home = vim.fn.expand(base_zet), -- Again can only use opts when not using config
dailies = vim.fn.expand(base_zet .. "/daily"), require("telekasten").setup({
home = vim.fn.expand(base_zet),
dailies = vim.fn.expand(base_zet .. "/daily"),
image_subdir = vim.fn.expand(base_zet .. "/media"), image_subdir = vim.fn.expand(base_zet .. "/media"),
weeklies = vim.fn.expand(base_zet .. "/weekly"), weeklies = vim.fn.expand(base_zet .. "/weekly"),
templates = vim.fn.expand(base_zet .. "/templates"), templates = vim.fn.expand(base_zet .. "/templates"),
template_new_note = vim.fn.expand(base_zet .. "/templates/note.md"), template_new_note = vim.fn.expand(base_zet .. "/templates/note.md"),
template_new_daily = vim.fn.expand(base_zet .. "/templates/daily.md"), template_new_daily = vim.fn.expand(base_zet .. "/templates/daily.md"),
template_new_weekly = vim.fn.expand(base_zet .. "/templates/weekly.md"), template_new_weekly = vim.fn.expand(base_zet .. "/templates/weekly.md"),
filename_format = "%Y%m%d%H%M-%title%", filename_format = "%Y%m%d%H%M-%title%",
new_note_filename = "uuid-title", new_note_filename = "uuid-title",
uuid_type = "%Y%m%d%H%M", uuid_type = "%Y%m%d%H%M",
uuid_separator = "-", uuid_separator = "-",
} })
vim.keymap.set("n", "<leader>z", "<cmd>Telekasten panel<CR>")
vim.keymap.set("n", "<leader>zf", "<cmd>Telekasten find_notes<CR>")
vim.keymap.set("n", "<leader>zg", "<cmd>Telekasten search_notes<CR>")
vim.keymap.set("n", "<leader>zd", "<cmd>Telekasten goto_today<CR>")
vim.keymap.set("n", "<leader>zr", "<cmd>Telekasten rename_note<CR>")
vim.keymap.set("n", "<leader>zz", "<cmd>Telekasten follow_link<CR>")
vim.keymap.set("n", "<leader>zn", "<cmd>Telekasten new_note<CR>")
vim.keymap.set("n", "<leader>zb", "<cmd>Telekasten show_backlinks<CR>")
vim.keymap.set("n", "<leader>zw", "<cmd>Telekasten find_weekly_notes<CR>")
vim.keymap.set("n", "<leader>il", "<cmd>Telekasten insert_link<CR>")
vim.keymap.set("n", "<leader>zI", "<cmd>Telekasten insert_img_link<CR>")
end
}, },
}; };

View File

@@ -1,5 +1,11 @@
return { return {
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
keys = {
{ "<leader>e", function()
require("nvim-tree.api").tree.toggle({ find_file = true, update_root = true, focus = true, })
end
}
},
opts = { opts = {
sort_by = "case_sensitive", sort_by = "case_sensitive",

View File

@@ -7,5 +7,67 @@ return {
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
lazy = true,
keys = {
{
"<leader>tt",
":Telescope<CR>",
desc = "Telescope menu",
},
{
"<C-p>",
function()
require("telescope.builtin").buffers()
end,
desc = "Fzf current buffers"
},
{
"<leader>fr",
function()
require('telescope.builtin').oldfiles({
disable_devicons = true,
})
end,
desc = "Open last files"
},
{
"<leader>g",
function()
require('telescope.builtin').live_grep({
disable_devicons = true,
cwd = vim.fn.getcwd(),
additional_args = function()
return { '--hidden', '--glob', '!.git/*' }
end,
})
end
},
{
"<leader>fh",
function()
require('telescope.builtin').help_tags()
end,
},
{
"<leader><leader>",
function()
require('telescope.builtin').find_files({
hidden = true,
no_ignore = true, -- Also show files in gitignore
follow = true,
disable_devicons = true,
prompt_title = "Find Files - custom",
find_command = {
"rg", "--files",
"--glob", "!**/.git/*",
"--glob", "!**/build/*",
"--glob", "!**/*.{jpg,png,gif,mp4,mkv,tar,zip,iso}"
}
})
end
}
},
config = true,
}, },
} }

View File

@@ -23,6 +23,14 @@ return {
"<Cmd>TypstarSmartJumpBack<CR>", "<Cmd>TypstarSmartJumpBack<CR>",
mode = { "s", "i" }, mode = { "s", "i" },
}, },
{
"<leader>ti",
":TypstarInsertRnote<CR>",
},
{
"<leader>to",
":TypstarOpenDrawing<CR>",
},
}, },
config = function() config = function()
local typstar = require("typstar") local typstar = require("typstar")

View File

@@ -63,8 +63,6 @@ return {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
'nvim-tree/nvim-web-devicons', 'nvim-tree/nvim-web-devicons',
}, },
init = function() vim.g.barbar_auto_setup = false end,
cmd = { "BufferNext", "BufferPrevious" },
opts = { opts = {
clickable = false, clickable = false,
tabpages = false, tabpages = false,
@@ -72,5 +70,11 @@ return {
icons = { filetype = { enabled = false } } icons = { filetype = { enabled = false } }
}, },
version = '^1.0.0', -- only update when a new 1.x version is released version = '^1.0.0', -- only update when a new 1.x version is released
config = function()
vim.keymap.set("n", "L", ":BufferNext<CR>", { silent = true })
vim.keymap.set("n", "H", ":BufferPrevious<CR>", { silent = true })
vim.keymap.set("n", "<leader>bd", ":BufferDelete<CR>")
end
}, },
} }

View File

@@ -5,94 +5,4 @@ function M.Sleep(n)
os.execute("sleep " .. tonumber(n)) os.execute("sleep " .. tonumber(n))
end end
function open_vorlesung()
local mapss = require("config.keymaps")
-- get globals
set_obs()
local uni_dir = vim.fn.expand("~/projects/university/" .. _G.season)
require('telescope.builtin').find_files {
prompt_title = "Select Vorlesung in " .. _G.season,
cwd = uni_dir,
find_command = {
"eza", "-1", "-D"
},
}
end
function find_eff()
require('telescope.builtin').find_files({
hidden = true, -- show hidden files (dotfiles)
no_ignore = true, -- respect .gitignore (ignore files listed in .gitignore)
follow = true, -- follow symlinks
disable_devicons = true,
-- Additional filtering to exclude .git, .cache, .local, and large files
prompt_title = "Find Files - custom",
find_command = {
"rg", "--files",
"--glob", "!**/.git/*",
"--glob", "!**/.cache/*",
"--glob", "!**/.local/*",
"--glob", "!**/bigfiles/*", -- exclude large files folder
"--glob", "!**/*.{jpg,png,gif,mp4,mkv,tar,zip,iso}" -- exclude some large file types
}
})
end
-- TODO: implement this
--function search_brain_links()
-- local fzf = require('fzf')
-- local cmd = "grep -oP '\\[\\[.*:' " .. vim.fn.expand('%') -- grep pattern to search for [[.*:
-- fzf.fzf(cmd, {
-- preview = "bat --style=numbers --color=always --line-range :500", -- preview with bat (optional)
-- sink = function(selected)
-- if selected and #selected > 0 then
-- local line = vim.fn.search(selected[1], 'n') -- jump to the match
-- if line > 0 then
-- vim.api.nvim_win_set_cursor(0, {line, 0})
-- end
-- end
-- end
-- })
--end
function set_root()
local current_file = vim.fn.expand('%:p:h') -- get directory of current file
local cmd = 'git -C ' .. vim.fn.fnameescape(current_file) .. ' status'
vim.fn.system(cmd)
if vim.v.shell_error == 0 then
local git_root = vim.fn.systemlist('git -C ' .. vim.fn.fnameescape(current_file) .. ' rev-parse --show-toplevel')
[1]
vim.cmd('cd ' .. vim.fn.fnameescape(git_root))
else
vim.cmd('cd ' .. vim.fn.fnameescape(current_file))
end
end
-- Function to open the last file
function open_last_file()
local last_file_path = vim.fn.stdpath('data') .. "/lastfile.txt"
local file = io.open(last_file_path, "r")
if file then
local last_file = file:read("*line")
file:close()
if last_file and vim.fn.filereadable(last_file) == 1 then
vim.cmd("edit " .. last_file)
pcall(function()
vim.cmd('normal! `.') -- Go to the last edit position
vim.cmd('normal! zz') -- Center the cursor on the screen
end)
else
print("Last file does not exist or is not readable")
end
else
print("No last file found")
end
end
return M return M