mirror of
https://github.com/Ascyii/nvim.git
synced 2026-01-01 04:04:24 -05:00
Full refactor of codebase and usage of lazyvim opts setting. Also split code in custom plugins
This commit is contained in:
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Neovim configuration in pure lua
|
||||||
|
|
||||||
|
You can configure the current semester that you are in for university integrations.
|
||||||
|
There are certain things required like `make` and `npm` for various plugins.
|
||||||
|
|
||||||
9
init.lua
9
init.lua
@@ -1,12 +1,3 @@
|
|||||||
-- Nvim config by Jonas Hahn
|
-- Nvim config by Jonas Hahn
|
||||||
|
|
||||||
-- set a diff flag
|
|
||||||
-- this stands for diff mode
|
|
||||||
if vim.o.diff then
|
|
||||||
vim.g.diffm = true
|
|
||||||
else
|
|
||||||
vim.g.diffm = false
|
|
||||||
end
|
|
||||||
|
|
||||||
require("config.init")
|
require("config.init")
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,16 @@
|
|||||||
"lazygit.nvim": { "branch": "main", "commit": "3c524ebec6072568064235c407195e9f9fd0cb8a" },
|
"lazygit.nvim": { "branch": "main", "commit": "3c524ebec6072568064235c407195e9f9fd0cb8a" },
|
||||||
"lspsaga.nvim": { "branch": "main", "commit": "8efe00d6aed9db6449969f889170f1a7e43101a1" },
|
"lspsaga.nvim": { "branch": "main", "commit": "8efe00d6aed9db6449969f889170f1a7e43101a1" },
|
||||||
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
|
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "1ec4da522fa49dcecee8d190efda273464dd2192" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "5e085efe67fccb13372d54331d849219662a7e93" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" },
|
"mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "52364267cd7edbc0e9b25ab3bfb1c8f45dd58fde" },
|
"nvim-lspconfig": { "branch": "master", "commit": "408cf07b97535825cca6f1afa908d98348712ba6" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "fefa335f1c8f690eb668a1efd18ee4fc6d64cd3e" },
|
"nvim-tree.lua": { "branch": "master", "commit": "fefa335f1c8f690eb668a1efd18ee4fc6d64cd3e" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||||
|
"nvim-web-devicons": { "branch": "master", "commit": "f66cdfef5e84112045b9ebc3119fee9bddb3c687" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
"telekasten.nvim": { "branch": "main", "commit": "b3ac2b07f2df504bb80112fec349714086a80037" },
|
"telekasten.nvim": { "branch": "main", "commit": "b3ac2b07f2df504bb80112fec349714086a80037" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
|
||||||
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
|
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
|
||||||
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
|
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"extras": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"news": {
|
|
||||||
"NEWS.md": "10960"
|
|
||||||
},
|
|
||||||
"version": 8
|
|
||||||
}
|
|
||||||
@@ -1,65 +1,3 @@
|
|||||||
|
|
||||||
-- Autocommands
|
|
||||||
|
|
||||||
vim.cmd(':colorscheme gruvbox')
|
|
||||||
|
|
||||||
if vim.g.diffm then
|
|
||||||
-- vim.api.nvim_create_autocmd("VimEnter", {
|
|
||||||
-- callback = function()
|
|
||||||
-- -- Create a new empty buffer
|
|
||||||
-- vim.cmd("enew")
|
|
||||||
--
|
|
||||||
-- -- Your multiline message
|
|
||||||
-- local lines = {
|
|
||||||
-- "Welcome to Neovim!",
|
|
||||||
-- "",
|
|
||||||
-- "You are in Diff Mode!",
|
|
||||||
-- "Press <leader>do to open the Difftab.",
|
|
||||||
-- "",
|
|
||||||
-- "Good luck!"
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- -- Get dimensions
|
|
||||||
-- local width = vim.api.nvim_get_option("columns")
|
|
||||||
-- local height = vim.api.nvim_get_option("lines")
|
|
||||||
--
|
|
||||||
-- -- Center vertically
|
|
||||||
-- local start_line = math.floor((height - #lines) / 3)
|
|
||||||
--
|
|
||||||
-- -- Insert empty lines at the top
|
|
||||||
-- for _ = 1, start_line do
|
|
||||||
-- vim.api.nvim_buf_set_lines(0, -1, -1, false, {""})
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- -- Center horizontally and insert text
|
|
||||||
-- for _, line in ipairs(lines) do
|
|
||||||
-- local padding = math.floor((width - #line) / 2)
|
|
||||||
-- local padded_line = string.rep(" ", math.max(padding, 0)) .. line
|
|
||||||
-- vim.api.nvim_buf_set_lines(0, -1, -1, false, {padded_line})
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- -- Make buffer not modifiable
|
|
||||||
-- vim.bo.modifiable = false
|
|
||||||
-- vim.bo.buflisted = false
|
|
||||||
-- end
|
|
||||||
-- })
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("Ex", function()
|
|
||||||
if vim.opt.diff:get() then
|
|
||||||
-- require("diffview").open()
|
|
||||||
print("running with diff view mode -> No ex")
|
|
||||||
else
|
|
||||||
-- fallback if not in diff mode (optional)
|
|
||||||
-- vim.cmd("Explore") -- or do nothing
|
|
||||||
-- Just disable EX
|
|
||||||
print("You have tree view (no ex anymore)")
|
|
||||||
end
|
|
||||||
end, {})
|
|
||||||
|
|
||||||
|
|
||||||
-- Save the last file on exit
|
-- Save the last file on exit
|
||||||
vim.api.nvim_create_autocmd("VimLeave", {
|
vim.api.nvim_create_autocmd("VimLeave", {
|
||||||
callback = function()
|
callback = function()
|
||||||
@@ -74,13 +12,3 @@ vim.api.nvim_create_autocmd("VimLeave", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Setting a transparent background
|
|
||||||
function Transparent(color)
|
|
||||||
color = color or "gruvbox"
|
|
||||||
vim.cmd.colorscheme(color)
|
|
||||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
|
||||||
end
|
|
||||||
Transparent()
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
-- Load lazy first
|
-- Load lazy first
|
||||||
require('config.lazy')
|
require('config.lazy')
|
||||||
|
|
||||||
-- General settings
|
-- General settings for nvim
|
||||||
require('config.options')
|
require('config.options')
|
||||||
require('config.keymaps')
|
require('config.keymaps')
|
||||||
require('config.autocmds')
|
require('config.autocmds')
|
||||||
require('config.lsp')
|
|
||||||
|
|||||||
@@ -1,68 +1,50 @@
|
|||||||
-- ###########################
|
-- Custom keymaps
|
||||||
-- the heart of neovim #######
|
|
||||||
-- ###########################
|
|
||||||
|
|
||||||
require("helpers.functions")
|
require("utils.functions")
|
||||||
|
require("custom.uni")
|
||||||
|
|
||||||
-- gloabal settings
|
|
||||||
vim.keymap.set('n', '<leader>q', function()
|
|
||||||
local success, _ = pcall(function()
|
|
||||||
vim.cmd('wa') -- Write (save) all buffers
|
|
||||||
end)
|
|
||||||
vim.cmd('qa!') -- Quit all buffers forcefully
|
|
||||||
end)
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>w", "<C-w>w")
|
|
||||||
|
|
||||||
vim.keymap.set('v', '<leader>p', function()
|
|
||||||
vim.cmd('normal! "+p')
|
|
||||||
end, { desc = 'Yank to clipboard and keep the selection' })
|
|
||||||
|
|
||||||
-- branching depeding on diff mode
|
|
||||||
if vim.g.diffm then
|
|
||||||
-- diff view commands
|
|
||||||
vim.keymap.set('n', '<leader>do', ":DiffviewClose<CR>:DiffviewOpen<CR>")
|
|
||||||
vim.keymap.set('n', '<leader>df', ":DiffviewClose<CR>:DiffviewFileHistory<CR>")
|
|
||||||
vim.keymap.set('n', '<leader>dt', ":DiffviewToggleFiles<CR>")
|
|
||||||
vim.keymap.set('n', '<leader>dc', ":DiffviewClose<CR>")
|
|
||||||
vim.keymap.set('n', '<leader>dl', ":DiffviewLog<CR>")
|
|
||||||
|
|
||||||
-- vim.keymap.set("n", "<leader>e", "<C-w>w<C-w>w")
|
|
||||||
else
|
|
||||||
-- not in diff mode
|
|
||||||
-- TODO: make this dynamic
|
|
||||||
local season = "S2"
|
local season = "S2"
|
||||||
|
|
||||||
local links = require("helpers.linker") -- replace with real file path
|
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 api = require("nvim-tree.api")
|
||||||
local builtin = require('telescope.builtin')
|
local builtin = require('telescope.builtin')
|
||||||
local current_date = os.date("%Y-%m-%d")
|
|
||||||
local week_number = os.date("%W") + 1 -- Week number (starting from Sunday)
|
|
||||||
local day_of_week = os.date("%a") -- Abbreviated weekday name (e.g., Mon, Tue)
|
|
||||||
|
|
||||||
-- this is how to access global vars
|
local function open_cal()
|
||||||
function set_obs()
|
local current_date = os.date("%Y-%m-%d")
|
||||||
-- _G is the global table. this creates variable 'obs' attached to
|
local week_number = os.date("%V")
|
||||||
-- the global table with the value 'some text value'
|
local day_of_week = os.date("%a")
|
||||||
_G.season = season
|
local path = "~/synced/brainstore/calendar/calendar_" .. os.date("%Y") .. ".txt"
|
||||||
|
local keys = ":e " ..
|
||||||
|
path .. "<CR>/" .. current_date .. " w" .. tonumber(week_number) .. " " .. day_of_week .. "<CR>$"
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(keys, true, false, true), 'n', true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------
|
||||||
|
--------------------- KEYMAPS -------------------------
|
||||||
|
-------------------------------------------------------
|
||||||
|
|
||||||
|
-- Fast quitter
|
||||||
|
vim.keymap.set('n', '<leader>q', function()
|
||||||
|
pcall(function()
|
||||||
|
vim.cmd('wa')
|
||||||
|
end)
|
||||||
|
vim.cmd('qa!')
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Fast window switch
|
||||||
|
vim.keymap.set("n", "<leader>w", "<C-w>w")
|
||||||
|
|
||||||
--------------------- NORMAL -------------------------
|
--------------------- NORMAL -------------------------
|
||||||
|
|
||||||
|
vim.keymap.set("n", "L", ":BufferNext<CR>", { silent = true })
|
||||||
-- vim.keymap.set("i", "<Tab>", "<C-p>", { 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", "L", ":BufferNext<CR>", { silent = true }) -- also update the root with the bang
|
vim.keymap.set("n", "<C-o>", "<C-o>zz", { silent = true })
|
||||||
vim.keymap.set("n", "n", "nzz", { silent = true }) -- also update the root with the bang
|
vim.keymap.set("n", "<C-i>", "<C-i>zz", { silent = true })
|
||||||
vim.keymap.set("n", "N", "Nzz", { silent = true }) -- also update the root with the bang
|
vim.keymap.set("n", "<C-u>", "<C-u>zz", { silent = true })
|
||||||
vim.keymap.set("n", "H", ":BufferPrevious<CR>", { silent = true }) -- also update the root with the bang
|
vim.keymap.set("n", "<C-d>", "<C-d>zz", { silent = true })
|
||||||
vim.keymap.set("n", "<C-o>", "<C-o>zz", { silent = true }) -- also update the root with the bang
|
|
||||||
vim.keymap.set("n", "<C-i>", "<C-i>zz", { silent = true }) -- also update the root with the bang
|
|
||||||
vim.keymap.set("n", "<C-u>", "<C-u>zz", { silent = true }) -- also update the root with the bang
|
|
||||||
vim.keymap.set("n", "<C-d>", "<C-d>zz", { silent = true }) -- also update the root with the bang
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>a', 'm9ggVG"+y`9')
|
vim.keymap.set('n', '<leader>a', 'm9ggVG"+y`9')
|
||||||
vim.keymap.set('n', '<leader>va', 'ggVG')
|
vim.keymap.set('n', '<leader>va', 'ggVG')
|
||||||
@@ -89,47 +71,34 @@ else
|
|||||||
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
|
-- 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>il", "<cmd>Telekasten insert_link<CR>")
|
||||||
|
|
||||||
require("custom.uni")
|
|
||||||
vim.keymap.set("n", "<leader>nv", function()
|
vim.keymap.set("n", "<leader>nv", function()
|
||||||
|
|
||||||
select_course_directory()
|
select_course_directory()
|
||||||
--pick_unicourse("/home/jonas/projects/university/S2") -- Change path accordingly
|
|
||||||
end, { desc = "Open UniCourse menu" })
|
end, { desc = "Open UniCourse menu" })
|
||||||
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>ca', 'ggVGd')
|
vim.keymap.set('n', '<leader>ca', 'ggVGd')
|
||||||
vim.keymap.set("n", "<leader>bd", ":BufferDelete<CR>", { silent = true }) -- also update the root with the bang
|
vim.keymap.set("n", "<leader>bd", ":BufferDelete<CR>", { silent = true })
|
||||||
|
|
||||||
-- Typstar stuff
|
-- Typstar stuff
|
||||||
vim.keymap.set("n", "<leader>ti", ":TypstarInsertRnote<CR>", { silent = true }) -- also update the root with the bang
|
vim.keymap.set("n", "<leader>ti", ":TypstarInsertRnote<CR>", { silent = true })
|
||||||
vim.keymap.set("n", "<leader>to", ":TypstarOpenDrawing<CR>", { silent = true }) -- also update the root with the bang
|
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" })
|
vim.keymap.set("n", "<leader>tt", ":Telescope<CR>", { desc = "Follow Link" })
|
||||||
vim.keymap.set('n', '<leader>tw', watch_and_open, { noremap = true, silent = true })
|
|
||||||
|
|
||||||
-- 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', open_vorlesung)
|
||||||
-- 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 }) -- also update the root with the bang
|
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", set_root)
|
||||||
|
|
||||||
-- Custom journal plugin disable temporary
|
|
||||||
-- local journal = require("custom.journal")
|
|
||||||
-- vim.keymap.set("n", "<leader>jt", journal.open_today, { desc = "Open Today's Journal" })
|
|
||||||
-- vim.keymap.set("n", "<leader>ja", journal.list_all_journals, { desc = "Open Today's Journal" })
|
|
||||||
-- vim.keymap.set("n", "<leader>jm", journal.search_this_month, { desc = "Search This Month's Journals" })
|
|
||||||
|
|
||||||
-- Quickly open some buffers
|
-- Quickly open some buffers
|
||||||
-- Open all the vim configs instant
|
|
||||||
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')
|
||||||
vim.keymap.set('n', '<leader>oct', ':e ~/synced/vault/contacts/contacts.txt<CR>`.zz')
|
vim.keymap.set('n', '<leader>oct', ':e ~/synced/vault/contacts/contacts.txt<CR>`.zz')
|
||||||
vim.keymap.set('n', '<leader>ock', ':e ~/.config/nvim/lua/config/keymaps.lua<CR>`.zz')
|
vim.keymap.set('n', '<leader>ock', ':e ~/.config/nvim/lua/config/keymaps.lua<CR>`.zz')
|
||||||
@@ -138,8 +107,8 @@ else
|
|||||||
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/main.lua<CR>`.zz')
|
||||||
vim.keymap.set('n', '<leader>ocf', ':e ~/.config/nvim/lua/helpers/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/helpers/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')
|
||||||
vim.keymap.set('n', '<leader>ohh', ':e ~/configuration/nixos/users/' .. user .. '/home.nix<CR>`.zz')
|
vim.keymap.set('n', '<leader>ohh', ':e ~/configuration/nixos/users/' .. user .. '/home.nix<CR>`.zz')
|
||||||
vim.keymap.set('n', '<leader>op', ':e ~/configuration/nixos/users/' .. user .. '/packages.nix<CR>`.zz')
|
vim.keymap.set('n', '<leader>op', ':e ~/configuration/nixos/users/' .. user .. '/packages.nix<CR>`.zz')
|
||||||
@@ -153,18 +122,8 @@ else
|
|||||||
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')
|
||||||
-- Map the function to a keybinding (e.g., <leader>lf to open the last file)
|
|
||||||
vim.keymap.set("n", "<leader>or", "<cmd>lua open_last_file()<CR>", { noremap = true, silent = true })
|
vim.keymap.set("n", "<leader>or", "<cmd>lua open_last_file()<CR>", { noremap = true, silent = true })
|
||||||
-- open the calendar
|
|
||||||
--
|
|
||||||
function open_cal()
|
|
||||||
local current_date = os.date("%Y-%m-%d")
|
|
||||||
local week_number = os.date("%V")
|
|
||||||
local day_of_week = os.date("%a")
|
|
||||||
local path = "~/synced/brainstore/calendar/calendar_" .. os.date("%Y") .. ".txt"
|
|
||||||
local keys = ":e " .. path .. "<CR>/" .. current_date .. " w" .. tonumber(week_number) .. " " .. day_of_week .. "<CR>$"
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(keys, true, false, true), 'n', true)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>ok', open_cal)
|
vim.keymap.set('n', '<leader>ok', open_cal)
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
@@ -176,19 +135,14 @@ else
|
|||||||
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
|
||||||
-- nvim tree
|
|
||||||
vim.keymap.set("n", "<leader>e", function()
|
vim.keymap.set("n", "<leader>e", function()
|
||||||
api.tree.toggle({ find_file = true, update_root = true, focus = true, })
|
api.tree.toggle({ find_file = true, update_root = true, focus = true, })
|
||||||
|
|
||||||
end, { silent = true }) -- also update the root with the bang
|
end, { silent = true }) -- also update the root with the bang
|
||||||
|
|
||||||
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>')
|
||||||
|
|
||||||
-- Map <leader>q to save and quit all buffers with error handling
|
|
||||||
-- Dangerous but feels good
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>ss', ':wa<CR>')
|
vim.keymap.set('n', '<leader>ss', ':wa<CR>')
|
||||||
vim.keymap.set('n', '<leader>sw', function()
|
vim.keymap.set('n', '<leader>sw', function()
|
||||||
local word = vim.fn.expand("<cword>")
|
local word = vim.fn.expand("<cword>")
|
||||||
@@ -218,13 +172,15 @@ else
|
|||||||
-- Restore previous register
|
-- Restore previous register
|
||||||
vim.fn.setreg('"', save_reg, save_regtype)
|
vim.fn.setreg('"', save_reg, save_regtype)
|
||||||
end, { desc = "Substitute selection in file" })
|
end, { desc = "Substitute selection in file" })
|
||||||
-- vim.keymap.set('n', '<leader>sl', search_brain_links)
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>pp', function()
|
vim.keymap.set('n', '<leader>pp', function()
|
||||||
vim.api.nvim_command('normal! "+p')
|
vim.api.nvim_command('normal! "+p')
|
||||||
end, { desc = 'Paste from system clipboard' })
|
end, { desc = 'Paste from system clipboard' })
|
||||||
|
|
||||||
-- vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
vim.keymap.set('v', '<leader>p', function()
|
||||||
|
vim.cmd('normal! "+p')
|
||||||
|
end, { desc = 'Yank to clipboard and keep the selection' })
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>fr', function()
|
vim.keymap.set('n', '<leader>fr', function()
|
||||||
require('telescope.builtin').oldfiles({
|
require('telescope.builtin').oldfiles({
|
||||||
disable_devicons = true,
|
disable_devicons = true,
|
||||||
@@ -245,7 +201,8 @@ else
|
|||||||
})
|
})
|
||||||
end, { noremap = true, silent = true })
|
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)' })
|
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 ------------------
|
||||||
|
|
||||||
@@ -288,5 +245,3 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end, { noremap = true, silent = true })
|
end, { noremap = true, silent = true })
|
||||||
end
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-- Bootstrap lazy.nvim
|
-- Bootstrap lazy manager first thing
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||||
@@ -15,34 +15,22 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
-- Must load before lazy
|
||||||
-- loading lazy.nvim so that mappings are correct.
|
|
||||||
-- This is also a good place to setup other settings (vim.opt)
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.g.maplocalleader = "\\"
|
vim.g.maplocalleader = "\\"
|
||||||
|
|
||||||
-- Setup lazy.nvim
|
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
spec = {
|
spec = {
|
||||||
-- import your plugins
|
-- Import all files in the plugin folder
|
||||||
-- { import = "plugins" },
|
{ import = "plugins" },
|
||||||
require("plugins")
|
|
||||||
},
|
},
|
||||||
-- Configure any other settings here. See the documentation for more details.
|
-- Automatically check for plugin updates
|
||||||
-- colorscheme that will be used when installing plugins.
|
|
||||||
install = { colorscheme = { "gruvbox" } },
|
|
||||||
-- automatically check for plugin updates
|
|
||||||
checker = { enabled = false },
|
checker = { enabled = false },
|
||||||
dev = {
|
dev = {
|
||||||
path = "~/projects",
|
path = "~/projects",
|
||||||
fallback = true,
|
fallback = true,
|
||||||
},
|
},
|
||||||
change_detection = {
|
change_detection = {
|
||||||
enabled = false, -- disable automatic reloading
|
enabled = false,
|
||||||
notify = false, -- optional: also disable notification when it would reload
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- after lazy did its job
|
|
||||||
require("helpers.after")
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
-- lsp.lua
|
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
local cmp = require("cmp")
|
|
||||||
|
|
||||||
|
|
||||||
require("lspconfig").clangd.setup({
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
-- nvim-cmp setup
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args) require("luasnip").lsp_expand(args.body) end,
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
||||||
["<Tab>"] = cmp.mapping.select_next_item(),
|
|
||||||
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
|
||||||
}),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "luasnip" },
|
|
||||||
}, {
|
|
||||||
{ name = "buffer" },
|
|
||||||
{ name = "path" },
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Capabilities for nvim-cmp
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
||||||
|
|
||||||
|
|
||||||
-- Example servers
|
|
||||||
local servers = { "gopls", "pyright", "lua_ls", "rust_analyzer", "clangd" }
|
|
||||||
|
|
||||||
|
|
||||||
require("mason-lspconfig").setup({
|
|
||||||
ensure_installed = servers
|
|
||||||
})
|
|
||||||
for _, lsp in ipairs(servers) do
|
|
||||||
local config = {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = function(_, bufnr)
|
|
||||||
local opts = { buffer = bufnr, noremap = true, silent = true }
|
|
||||||
|
|
||||||
-- LSP core
|
|
||||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- Jump to definition
|
|
||||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- Jump to declaration
|
|
||||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) -- Find references
|
|
||||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) -- Go to implementation
|
|
||||||
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts) -- Go to type definition
|
|
||||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) -- Hover docs
|
|
||||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts) -- Signature help
|
|
||||||
|
|
||||||
-- Refactor
|
|
||||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- Rename symbol
|
|
||||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts) -- Code actions
|
|
||||||
|
|
||||||
-- Diagnostics
|
|
||||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- Previous diagnostic
|
|
||||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- Next diagnostic
|
|
||||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts) -- Show diagnostic
|
|
||||||
vim.keymap.set("n", "<leader>lq", vim.diagnostic.setloclist, opts) -- List diagnostics
|
|
||||||
|
|
||||||
-- Workspace
|
|
||||||
vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
|
|
||||||
vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
|
||||||
vim.keymap.set("n", "<leader>wl", function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, opts)
|
|
||||||
|
|
||||||
-- Formatting
|
|
||||||
vim.keymap.set("n", "<leader>fff", function()
|
|
||||||
vim.lsp.buf.format({ async = true })
|
|
||||||
end, opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
if lsp == "lua_ls" then
|
|
||||||
config.settings = {
|
|
||||||
Lua = {
|
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
if lsp == "clangd" then
|
|
||||||
config.cmd = {
|
|
||||||
"clangd",
|
|
||||||
"--query-driver=/run/current-system/sw/bin/clang",
|
|
||||||
"--compile-commands-dir=build",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
lspconfig[lsp].setup(config)
|
|
||||||
end
|
|
||||||
-- Diagnostic config (inline virtual text + signs + underlines)
|
|
||||||
vim.diagnostic.config({
|
|
||||||
virtual_text = {
|
|
||||||
prefix = "●", -- could be '●', '▎', 'x'
|
|
||||||
spacing = 2,
|
|
||||||
},
|
|
||||||
signs = true,
|
|
||||||
underline = true,
|
|
||||||
update_in_insert = false,
|
|
||||||
severity_sort = true,
|
|
||||||
})
|
|
||||||
@@ -1,23 +1,18 @@
|
|||||||
|
|
||||||
-- vim.o.textwidth = 80
|
|
||||||
-- vim.o.wrap = true;
|
|
||||||
vim.o.shiftwidth = 4;
|
vim.o.shiftwidth = 4;
|
||||||
vim.o.tabstop = 4;
|
vim.o.tabstop = 4;
|
||||||
vim.o.number = true;
|
vim.o.number = true;
|
||||||
vim.o.ignorecase = true;
|
vim.o.ignorecase = true;
|
||||||
|
|
||||||
|
-- Disable mouse completly
|
||||||
vim.o.mouse = "";
|
vim.o.mouse = "";
|
||||||
|
|
||||||
-- this stands for undofile and should be always used because why not?
|
-- Turn on undofile
|
||||||
vim.o.udf = true;
|
vim.o.udf = true;
|
||||||
|
|
||||||
-- optionally enable 24-bit colour
|
-- Enable more colors
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
if vim.g.diffm then
|
|
||||||
vim.g.loaded_netrw = 0
|
|
||||||
vim.g.loaded_netrwPlugin = 0
|
|
||||||
else
|
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
end
|
|
||||||
vim.opt.signcolumn = "yes"
|
vim.opt.signcolumn = "yes"
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ M.open_today = function()
|
|||||||
-- If the file does not exist, create and write the header
|
-- If the file does not exist, create and write the header
|
||||||
local header = string.format("# Journal Entry - [[date:%s]]\n\n", os.date("%d.%m.%y"))
|
local header = string.format("# Journal Entry - [[date:%s]]\n\n", os.date("%d.%m.%y"))
|
||||||
file = io.open(full_path, "w")
|
file = io.open(full_path, "w")
|
||||||
|
if file == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
file:write(header)
|
file:write(header)
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ function M.remove_priority()
|
|||||||
vim.api.nvim_set_current_line(line)
|
vim.api.nvim_set_current_line(line)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function strip_ansi(s)
|
|
||||||
return s:gsub("\27%[[0-9;]*m", "")
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.mark_done()
|
function M.mark_done()
|
||||||
if not is_todo_file() then return end
|
if not is_todo_file() then return end
|
||||||
98
lua/custom/typst.lua
Normal file
98
lua/custom/typst.lua
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
local functions = require("utils.functions")
|
||||||
|
local watch_job_id = nil
|
||||||
|
local watch_buf_id = nil
|
||||||
|
|
||||||
|
local function watch_and_open()
|
||||||
|
local input = vim.fn.expand("%:p")
|
||||||
|
if not input:match("%.typ$") then
|
||||||
|
vim.notify("Not a Typst file", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local dir = vim.fn.fnamemodify(input, ":h") -- directory of the Typst file
|
||||||
|
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
|
||||||
|
if watch_job_id then
|
||||||
|
vim.notify("Typst watcher already running - please close zathura", vim.log.levels.INFO)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Start typst watch
|
||||||
|
local cwd = vim.fn.getcwd() -- set the starting directory
|
||||||
|
-- TODO: root setting does not work
|
||||||
|
local watch_cmd = { "typst", "watch", "--root", cwd, input, output }
|
||||||
|
watch_job_id = vim.fn.jobstart(watch_cmd, {
|
||||||
|
stdout_buffered = false,
|
||||||
|
stderr_buffered = false, -- Ensure stderr is unbuffered for real-time error output
|
||||||
|
on_stderr = function(_, data)
|
||||||
|
if data then
|
||||||
|
if not watch_tab_id then
|
||||||
|
pre_tab = vim.api.nvim_get_current_tabpage() -- Get the current tab ID
|
||||||
|
vim.cmd('tabnew') -- Open a new tab
|
||||||
|
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
|
||||||
|
vim.api.nvim_buf_set_option(watch_buf_id, "swapfile", false)
|
||||||
|
vim.api.nvim_buf_set_name(watch_buf_id, "/tmp/TypstLog")
|
||||||
|
vim.api.nvim_buf_set_lines(watch_buf_id, 0, 0, false, { "Watching: " .. input }) -- Insert at the top
|
||||||
|
vim.cmd('write!')
|
||||||
|
vim.api.nvim_set_current_tabpage(pre_tab)
|
||||||
|
end
|
||||||
|
-- Write stdout data to the same buffer
|
||||||
|
for _, line in ipairs(data) do
|
||||||
|
if line ~= "" then
|
||||||
|
vim.api.nvim_buf_set_lines(watch_buf_id, -1, -1, false, { "[LOG] " .. line })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
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
|
||||||
|
vim.notify("Typst watch stopped successfully", vim.log.levels.INFO)
|
||||||
|
else
|
||||||
|
vim.notify("Typst watch stopped with errors", vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
watch_job_id = nil
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
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")
|
||||||
|
functions.Sleep(0.5)
|
||||||
|
vim.fn.jobstart({ "zathura", output }, {
|
||||||
|
on_exit = function()
|
||||||
|
if watch_job_id then
|
||||||
|
vim.fn.jobstop(watch_job_id)
|
||||||
|
end
|
||||||
|
watch_job_id = nil
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
Watch_and_open = watch_and_open
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
local fzf = require("fzf-lua")
|
local fzf = require("fzf-lua")
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
local uv = vim.loop
|
|
||||||
local current_season = "S3"
|
local current_season = "S3"
|
||||||
|
|
||||||
-- Function to scan for .unicourse files and get their course directories
|
-- Function to scan for .unicourse files and get their course directories
|
||||||
@@ -148,4 +147,3 @@ function create_new_vl(course)
|
|||||||
print("Template file (template.typ) not found!")
|
print("Template file (template.typ) not found!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,247 +0,0 @@
|
|||||||
-- Disable lsp stuff
|
|
||||||
-- xzl
|
|
||||||
-- setup mason
|
|
||||||
-- xzl
|
|
||||||
--require("mason").setup()
|
|
||||||
--require("mason-lspconfig").setup({
|
|
||||||
-- ensure_installed = { "rust_analyzer", "pyright" }, -- Example LSPs
|
|
||||||
--})
|
|
||||||
|
|
||||||
-- Example: Configure a server
|
|
||||||
-- TODO: this has to be done better and automatically
|
|
||||||
--local lspconfig = require("lspconfig")
|
|
||||||
--lspconfig.rust_analyzer.setup({})
|
|
||||||
--lspconfig.pyright.setup({})
|
|
||||||
|
|
||||||
|
|
||||||
if vim.g.diffm then
|
|
||||||
-- setup tree
|
|
||||||
require("nvim-tree").setup({
|
|
||||||
sort_by = "case_sensitive",
|
|
||||||
view = {
|
|
||||||
width = 35,
|
|
||||||
},
|
|
||||||
disable_netrw = false,
|
|
||||||
})
|
|
||||||
else
|
|
||||||
-- stuff for only main
|
|
||||||
require 'telescope'.setup {
|
|
||||||
extensions = {
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- load custom todo plugin
|
|
||||||
require("custom.todo").setup()
|
|
||||||
|
|
||||||
|
|
||||||
-- configure a workflow that integrates image support in documents and a quick opening of them
|
|
||||||
local base_zet = "~/synced/brainstore/zettelkasten"
|
|
||||||
require('telekasten').setup({
|
|
||||||
home = vim.fn.expand(base_zet), -- Put the name of your notes directory here
|
|
||||||
dailies = vim.fn.expand(base_zet .. "/daily"),
|
|
||||||
-- how to change the defualt media folder?
|
|
||||||
image_subdir = vim.fn.expand(base_zet .. "/media"),
|
|
||||||
weeklies = vim.fn.expand(base_zet .. "/weekly"),
|
|
||||||
templates = vim.fn.expand(base_zet .. "/templates"),
|
|
||||||
template_new_note = vim.fn.expand(base_zet .. "/templates/note.md"),
|
|
||||||
template_new_daily = vim.fn.expand(base_zet .. "/templates/daily.md"),
|
|
||||||
template_new_weekly = vim.fn.expand(base_zet .. "/templates/weekly.md"),
|
|
||||||
|
|
||||||
-- auto_set_filetype = false,
|
|
||||||
-- Important part:
|
|
||||||
filename_format = "%Y%m%d%H%M-%title%", -- This adds the timestamp + slugged title
|
|
||||||
new_note_filename = "uuid-title", -- Set naming convention to use uuid first
|
|
||||||
uuid_type = "%Y%m%d%H%M", -- Timestamp as UUID
|
|
||||||
uuid_separator = "-",
|
|
||||||
})
|
|
||||||
|
|
||||||
-- setup tree
|
|
||||||
require("nvim-tree").setup({
|
|
||||||
sort_by = "case_sensitive",
|
|
||||||
-- open_on_tab = true,
|
|
||||||
|
|
||||||
view = {
|
|
||||||
width = 35,
|
|
||||||
side = "right",
|
|
||||||
preserve_window_proportions = true,
|
|
||||||
number = false,
|
|
||||||
relativenumber = false,
|
|
||||||
},
|
|
||||||
update_focused_file = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
|
|
||||||
renderer = {
|
|
||||||
group_empty = true,
|
|
||||||
highlight_git = true,
|
|
||||||
highlight_opened_files = "name",
|
|
||||||
indent_markers = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
icons = {
|
|
||||||
show = {
|
|
||||||
file = false,
|
|
||||||
folder = false,
|
|
||||||
folder_arrow = true,
|
|
||||||
git = false,
|
|
||||||
modified = false,
|
|
||||||
hidden = false,
|
|
||||||
diagnostics = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
filters = {
|
|
||||||
dotfiles = false, -- << SHOW dotfiles by default
|
|
||||||
git_clean = false,
|
|
||||||
no_buffer = false,
|
|
||||||
custom = { ".DS_Store", ".git" }, -- Mac stuff you probably don't need
|
|
||||||
},
|
|
||||||
|
|
||||||
git = {
|
|
||||||
enable = true,
|
|
||||||
ignore = false, -- so it shows even ignored files
|
|
||||||
},
|
|
||||||
|
|
||||||
actions = {
|
|
||||||
open_file = {
|
|
||||||
quit_on_open = false, -- keep tree open after opening a file
|
|
||||||
resize_window = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- stuff for both
|
|
||||||
|
|
||||||
-- lualine mode for the current workingdir
|
|
||||||
local function get_cwd()
|
|
||||||
local cwd = vim.fn.getcwd()
|
|
||||||
local home = os.getenv("HOME")
|
|
||||||
|
|
||||||
-- Check if the current directory starts with the home directory path
|
|
||||||
if cwd:sub(1, #home) == home then
|
|
||||||
return "~" .. cwd:sub(#home + 1)
|
|
||||||
else
|
|
||||||
return cwd
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require('lualine').setup {
|
|
||||||
options = {
|
|
||||||
icons_enabled = false,
|
|
||||||
theme = 'gruvbox',
|
|
||||||
-- think those icons are okay
|
|
||||||
component_separators = { left = '', right = '' },
|
|
||||||
section_separators = { left = '', right = '' },
|
|
||||||
always_divide_middle = true,
|
|
||||||
always_show_tabline = true,
|
|
||||||
globalstatus = false,
|
|
||||||
refresh = {
|
|
||||||
statusline = 300,
|
|
||||||
tabline = 300,
|
|
||||||
winbar = 300,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sections = {
|
|
||||||
lualine_a = { 'mode' },
|
|
||||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
|
||||||
lualine_c = { get_cwd, 'filename' },
|
|
||||||
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
|
||||||
lualine_y = { 'progress' },
|
|
||||||
lualine_z = { 'location' }
|
|
||||||
},
|
|
||||||
inactive_sections = {
|
|
||||||
lualine_a = {},
|
|
||||||
lualine_b = {},
|
|
||||||
lualine_c = { 'filename' },
|
|
||||||
lualine_x = { 'location' },
|
|
||||||
lualine_y = {},
|
|
||||||
lualine_z = {}
|
|
||||||
},
|
|
||||||
extensions = { "nvim-tree" }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require('gitsigns').setup {
|
|
||||||
on_attach = function(bufnr)
|
|
||||||
local gitsigns = require('gitsigns')
|
|
||||||
|
|
||||||
local function map(mode, l, r, opts)
|
|
||||||
opts = opts or {}
|
|
||||||
opts.buffer = bufnr
|
|
||||||
vim.keymap.set(mode, l, r, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
map('n', ']c', function()
|
|
||||||
if vim.wo.diff then
|
|
||||||
vim.cmd.normal({ ']c', bang = true })
|
|
||||||
else
|
|
||||||
gitsigns.nav_hunk('next')
|
|
||||||
end
|
|
||||||
vim.cmd("normal! zz") -- center cursor
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
map('n', '[c', function()
|
|
||||||
if vim.wo.diff then
|
|
||||||
vim.cmd.normal({ '[c', bang = true })
|
|
||||||
else
|
|
||||||
gitsigns.nav_hunk('prev')
|
|
||||||
end
|
|
||||||
vim.cmd("normal! zz") -- center cursor
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
-- Actions
|
|
||||||
map('n', '<leader>hs', gitsigns.stage_hunk)
|
|
||||||
map('n', '<leader>hr', gitsigns.reset_hunk)
|
|
||||||
|
|
||||||
map('v', '<leader>hs', function()
|
|
||||||
gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
|
||||||
end)
|
|
||||||
|
|
||||||
map('v', '<leader>hr', function()
|
|
||||||
gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
|
||||||
end)
|
|
||||||
|
|
||||||
map('n', '<leader>hS', gitsigns.stage_buffer)
|
|
||||||
map('n', '<leader>hR', gitsigns.reset_buffer)
|
|
||||||
map('n', '<leader>hp', gitsigns.preview_hunk)
|
|
||||||
map('n', '<leader>hi', gitsigns.preview_hunk_inline)
|
|
||||||
|
|
||||||
|
|
||||||
map('n', '<leader>hb', function()
|
|
||||||
gitsigns.blame_line({ full = true })
|
|
||||||
end)
|
|
||||||
|
|
||||||
map('n', '<leader>hd', gitsigns.diffthis)
|
|
||||||
|
|
||||||
map('n', '<leader>hD', function()
|
|
||||||
gitsigns.diffthis('~')
|
|
||||||
end)
|
|
||||||
|
|
||||||
map('n', '<leader>hQ', function() gitsigns.setqflist('all') end)
|
|
||||||
map('n', '<leader>hq', gitsigns.setqflist)
|
|
||||||
|
|
||||||
-- Toggles
|
|
||||||
map('n', '<leader>tb', gitsigns.toggle_current_line_blame)
|
|
||||||
map('n', '<leader>tw', gitsigns.toggle_word_diff)
|
|
||||||
|
|
||||||
-- Text object
|
|
||||||
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
require("lspsaga").setup({
|
|
||||||
lightbulb = {
|
|
||||||
enable = false,
|
|
||||||
enable_in_insert = false, -- don’t show in insert mode
|
|
||||||
sign = false,
|
|
||||||
|
|
||||||
virtual_text = false,
|
|
||||||
},
|
|
||||||
ui = {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
-- General helper functions
|
|
||||||
|
|
||||||
function sleep(n)
|
|
||||||
os.execute("sleep " .. tonumber(n))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- branching depeding on diff mode
|
|
||||||
if vim.g.diffm then
|
|
||||||
-- diffmode
|
|
||||||
else
|
|
||||||
-- Function to open NvimTree based on current file or Git root
|
|
||||||
local api = require("nvim-tree.api")
|
|
||||||
function open_tree_based_on_file()
|
|
||||||
local file_path = vim.fn.expand("%:p")
|
|
||||||
local git_root = vim.fn.system("git rev-parse --show-toplevel"):gsub("\n", "")
|
|
||||||
local dir = vim.fn.filereadable(file_path) and vim.fn.fnamemodify(file_path, ":p:h") or ""
|
|
||||||
|
|
||||||
-- If inside a Git repo, use the Git root as the base directory
|
|
||||||
local open_dir = git_root ~= "" and git_root or dir
|
|
||||||
|
|
||||||
-- Open NvimTree in that directory
|
|
||||||
api.tree.open({ path = open_dir })
|
|
||||||
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
|
|
||||||
|
|
||||||
-- TODO: fix not putting the pdf in another dir then the current workdir
|
|
||||||
-- when in a uni folder
|
|
||||||
-- Open and watch typst
|
|
||||||
local watch_job_id = nil
|
|
||||||
local watch_buf_id = nil
|
|
||||||
function watch_and_open()
|
|
||||||
local input = vim.fn.expand("%:p")
|
|
||||||
if not input:match("%.typ$") then
|
|
||||||
vim.notify("Not a Typst file", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local dir = vim.fn.fnamemodify(input, ":h") -- directory of the Typst file
|
|
||||||
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
|
|
||||||
if watch_job_id then
|
|
||||||
vim.notify("Typst watcher already running - please close zathura", vim.log.levels.INFO)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Start typst watch
|
|
||||||
local cwd = vim.fn.getcwd() -- set the starting directory
|
|
||||||
-- TODO: root setting does not work
|
|
||||||
local watch_cmd = { "typst", "watch", "--root", cwd, input, output }
|
|
||||||
watch_job_id = vim.fn.jobstart(watch_cmd, {
|
|
||||||
stdout_buffered = false,
|
|
||||||
stderr_buffered = false, -- Ensure stderr is unbuffered for real-time error output
|
|
||||||
on_stderr = function(_, data)
|
|
||||||
if data then
|
|
||||||
if not watch_tab_id then
|
|
||||||
pre_tab = vim.api.nvim_get_current_tabpage() -- Get the current tab ID
|
|
||||||
vim.cmd('tabnew') -- Open a new tab
|
|
||||||
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
|
|
||||||
vim.api.nvim_buf_set_option(watch_buf_id, "swapfile", false)
|
|
||||||
vim.api.nvim_buf_set_name(watch_buf_id, "/tmp/TypstLog")
|
|
||||||
vim.api.nvim_buf_set_lines(watch_buf_id, 0, 0, false, { "Watching: " .. input }) -- Insert at the top
|
|
||||||
vim.cmd('write!')
|
|
||||||
vim.api.nvim_set_current_tabpage(pre_tab)
|
|
||||||
end
|
|
||||||
-- Write stdout data to the same buffer
|
|
||||||
for _, line in ipairs(data) do
|
|
||||||
if line ~= "" then
|
|
||||||
vim.api.nvim_buf_set_lines(watch_buf_id, -1, -1, false, { "[LOG] " .. line })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
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
|
|
||||||
vim.notify("Typst watch stopped successfully", vim.log.levels.INFO)
|
|
||||||
else
|
|
||||||
vim.notify("Typst watch stopped with errors", vim.log.levels.ERROR)
|
|
||||||
end
|
|
||||||
watch_job_id = nil
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
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")
|
|
||||||
sleep(0.5)
|
|
||||||
vim.fn.jobstart({ "zathura", output }, {
|
|
||||||
on_exit = function()
|
|
||||||
if watch_job_id then
|
|
||||||
vim.fn.jobstop(watch_job_id)
|
|
||||||
end
|
|
||||||
watch_job_id = nil
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
|
||||||
local success, _ = 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
|
|
||||||
|
|
||||||
15
lua/plugins/colorscheme.lua
Normal file
15
lua/plugins/colorscheme.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
return {
|
||||||
|
"ellisonleao/gruvbox.nvim",
|
||||||
|
|
||||||
|
config = function()
|
||||||
|
-- Useful for terminal emulators with a transparent background
|
||||||
|
local function transparentBackground()
|
||||||
|
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||||
|
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd.colorscheme("gruvbox")
|
||||||
|
|
||||||
|
transparentBackground()
|
||||||
|
end
|
||||||
|
}
|
||||||
26
lua/plugins/custom.lua
Normal file
26
lua/plugins/custom.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
-- Custom modules
|
||||||
|
|
||||||
|
--- @param name string
|
||||||
|
--- @return string
|
||||||
|
local function get_dir(name)
|
||||||
|
return vim.fn.stdpath("config") .. "/lua/custom/" .. name
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
dir = get_dir("todo"),
|
||||||
|
name = "todo",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
|
||||||
|
config = function()
|
||||||
|
require("custom.todo").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dir = vim.fn.stdpath("config") .. "/lua/custom", -- folder containing typst.lua
|
||||||
|
name = "typst",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
|
||||||
|
keys = {
|
||||||
|
{ "<leader>tw", function() require("custom.typst").Watch_and_open() end, desc = "Watch Typst" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
return {
|
|
||||||
{"sindrets/diffview.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
"nvim-tree/nvim-web-devicons",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- this is the nvim tree but I dont use it yet
|
|
||||||
"nvim-tree/nvim-tree.lua",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'nvim-lualine/lualine.nvim',
|
|
||||||
-- dependencies = { 'nvim-tree/nvim-web-devicons' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ellisonleao/gruvbox.nvim",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"folke/which-key.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
opts = {
|
|
||||||
icons = {mappings = false,},
|
|
||||||
delay = 1500,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
92
lua/plugins/git.lua
Normal file
92
lua/plugins/git.lua
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"kdheepak/lazygit.nvim",
|
||||||
|
lazy = true,
|
||||||
|
cmd = {
|
||||||
|
"LazyGit",
|
||||||
|
"LazyGitConfig",
|
||||||
|
"LazyGitCurrentFile",
|
||||||
|
"LazyGitFilter",
|
||||||
|
"LazyGitFilterCurrentFile",
|
||||||
|
},
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim", -- Floating boarders
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = "LazyGit" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'lewis6991/gitsigns.nvim',
|
||||||
|
config = function()
|
||||||
|
local gitsigns = require("gitsigns")
|
||||||
|
|
||||||
|
local function on_attach(bufnr)
|
||||||
|
local function map(mode, l, r, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
map('n', ']c', function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
vim.cmd.normal({ ']c', bang = true })
|
||||||
|
else
|
||||||
|
gitsigns.nav_hunk('next')
|
||||||
|
end
|
||||||
|
vim.cmd("normal! zz") -- center cursor
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
map('n', '[c', function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
vim.cmd.normal({ '[c', bang = true })
|
||||||
|
else
|
||||||
|
gitsigns.nav_hunk('prev')
|
||||||
|
end
|
||||||
|
vim.cmd("normal! zz") -- center cursor
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
-- Actions
|
||||||
|
map('n', '<leader>hs', gitsigns.stage_hunk)
|
||||||
|
map('n', '<leader>hr', gitsigns.reset_hunk)
|
||||||
|
|
||||||
|
map('v', '<leader>hs', function()
|
||||||
|
gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
||||||
|
end)
|
||||||
|
|
||||||
|
map('v', '<leader>hr', function()
|
||||||
|
gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
||||||
|
end)
|
||||||
|
|
||||||
|
map('n', '<leader>hS', gitsigns.stage_buffer)
|
||||||
|
map('n', '<leader>hR', gitsigns.reset_buffer)
|
||||||
|
map('n', '<leader>hp', gitsigns.preview_hunk)
|
||||||
|
map('n', '<leader>hi', gitsigns.preview_hunk_inline)
|
||||||
|
|
||||||
|
|
||||||
|
map('n', '<leader>hb', function()
|
||||||
|
gitsigns.blame_line({ full = true })
|
||||||
|
end)
|
||||||
|
|
||||||
|
map('n', '<leader>hd', gitsigns.diffthis)
|
||||||
|
|
||||||
|
map('n', '<leader>hD', function()
|
||||||
|
gitsigns.diffthis('~')
|
||||||
|
end)
|
||||||
|
|
||||||
|
map('n', '<leader>hQ', function() gitsigns.setqflist('all') end)
|
||||||
|
map('n', '<leader>hq', gitsigns.setqflist)
|
||||||
|
|
||||||
|
-- Toggles
|
||||||
|
map('n', '<leader>tb', gitsigns.toggle_current_line_blame)
|
||||||
|
map('n', '<leader>tw', gitsigns.toggle_word_diff)
|
||||||
|
|
||||||
|
-- Text object
|
||||||
|
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk)
|
||||||
|
end
|
||||||
|
|
||||||
|
gitsigns.setup({ on_attach = on_attach })
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
local plugins = {}
|
|
||||||
|
|
||||||
if vim.g.diffm then
|
|
||||||
vim.list_extend(plugins, require("plugins.diff"))
|
|
||||||
else
|
|
||||||
vim.list_extend(plugins, require("plugins.main"))
|
|
||||||
end
|
|
||||||
|
|
||||||
return plugins
|
|
||||||
123
lua/plugins/lsp.lua
Normal file
123
lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
return {
|
||||||
|
{ "stevearc/aerial.nvim", opts = {} },
|
||||||
|
{
|
||||||
|
"nvimdev/lspsaga.nvim",
|
||||||
|
opts = {
|
||||||
|
lightbulb = {
|
||||||
|
enable = false,
|
||||||
|
enable_in_insert = false,
|
||||||
|
sign = false,
|
||||||
|
virtual_text = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
dependencies = {
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"nvimdev/lspsaga.nvim",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
|
-- Declarative important have npm and other tools installed
|
||||||
|
local servers = { "gopls", "pyright", "lua_ls", "rust_analyzer", "clangd" }
|
||||||
|
|
||||||
|
-- Custom overwrites for servers
|
||||||
|
local server_settings = {
|
||||||
|
lua_ls = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = { globals = { "vim" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local cmp = require("cmp")
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args) require("luasnip").lsp_expand(args.body) end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<Tab>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "path" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
|
local on_attach = function(_, bufnr)
|
||||||
|
local opts = { buffer = bufnr, noremap = true, silent = true }
|
||||||
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts)
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||||
|
--vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts)
|
||||||
|
vim.keymap.set("n", "<leader>lq", vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
|
||||||
|
vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
||||||
|
vim.keymap.set("n", "<leader>wl", function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, opts)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>ff", function()
|
||||||
|
vim.lsp.buf.format({ async = true })
|
||||||
|
end, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Setup servers manually
|
||||||
|
for _, server in ipairs(servers) do
|
||||||
|
local config = {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}
|
||||||
|
if server_settings[server] then
|
||||||
|
config = vim.tbl_deep_extend("force", config, server_settings[server])
|
||||||
|
end
|
||||||
|
lspconfig[server].setup(config)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Mason for autoinstall of servers
|
||||||
|
require("mason").setup()
|
||||||
|
require("mason-lspconfig").setup({
|
||||||
|
ensure_installed = servers,
|
||||||
|
automatic_installation = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Add text in diagnostics
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = true,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
17
lua/plugins/luasnip.lua
Normal file
17
lua/plugins/luasnip.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
version = "v2.*",
|
||||||
|
build = "make install_jsregexp",
|
||||||
|
event = "InsertEnter",
|
||||||
|
config = function()
|
||||||
|
local ls = require("luasnip")
|
||||||
|
ls.config.setup({
|
||||||
|
enable_autosnippets = true,
|
||||||
|
store_selection_keys = '<Tab>',
|
||||||
|
})
|
||||||
|
vim.keymap.set({ "i", "s" }, "<C-L>", function() ls.jump(1) end, { silent = true })
|
||||||
|
vim.keymap.set({ "i", "s" }, "<C-H>", function() ls.jump(-1) end, { silent = true })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,238 +0,0 @@
|
|||||||
return {
|
|
||||||
{
|
|
||||||
"ThePrimeagen/harpoon",
|
|
||||||
},
|
|
||||||
{ "akinsho/toggleterm.nvim", config = true },
|
|
||||||
{ "nvimdev/lspsaga.nvim", config = true },
|
|
||||||
{
|
|
||||||
"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" }
|
|
||||||
}},
|
|
||||||
{
|
|
||||||
-- treesitter
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
build = ":TSUpdate",
|
|
||||||
-- prio is needed for this
|
|
||||||
--
|
|
||||||
-- not needed cmd = { "NvimTreeToggle", "NvimTreeOpen" }, -- load only when you call these commands
|
|
||||||
priority = 1000,
|
|
||||||
config = function ()
|
|
||||||
local configs = require("nvim-treesitter.configs")
|
|
||||||
configs.setup({
|
|
||||||
ensure_installed = {"css", "typst", "bash", "markdown", "lua", "python", "rust", "c", "nix"},
|
|
||||||
sync_install = false,
|
|
||||||
highlight = { enable = true },
|
|
||||||
indent = { enable = true },
|
|
||||||
})
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- great typstar works only with luasnip
|
|
||||||
ft = {"typst"},
|
|
||||||
"Ascyii/typstar",
|
|
||||||
dev = true,
|
|
||||||
config = function()
|
|
||||||
require("typstar").setup({
|
|
||||||
typstarRoot = "~/projects/typstar",
|
|
||||||
rnote = {
|
|
||||||
assetsDir = 'assets',
|
|
||||||
-- can be modified to e.g. export full pages; default is to try to export strokes only and otherwise export the entire document
|
|
||||||
exportCommand = 'rnote-cli export selection --no-background --no-pattern --on-conflict overwrite --output-file %s all %s || rnote-cli export doc --no-background --no-pattern --on-conflict overwrite --output-file %s %s',
|
|
||||||
filename = 'drawing-%Y-%m-%d-%H-%M-%S',
|
|
||||||
fileExtension = '.rnote',
|
|
||||||
fileExtensionInserted = '.rnote.svg', -- valid rnote export type
|
|
||||||
uriOpenCommand = 'xdg-open', -- see comment above for excalidraw
|
|
||||||
templatePath = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{'romgrk/barbar.nvim',
|
|
||||||
dependencies = {
|
|
||||||
'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status
|
|
||||||
--'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons
|
|
||||||
},
|
|
||||||
init = function() vim.g.barbar_auto_setup = false end,
|
|
||||||
cmd = {"BufferNext", "BufferPrevious" },
|
|
||||||
opts = {
|
|
||||||
clickable = false,
|
|
||||||
tabpages = false,
|
|
||||||
animations = false,
|
|
||||||
icons = { filetype = { enabled = false } }
|
|
||||||
|
|
||||||
},
|
|
||||||
version = '^1.0.0', -- optional: only update when a new 1.x version is released
|
|
||||||
},
|
|
||||||
-- Does not work in nvim ?
|
|
||||||
|
|
||||||
-- {"freitass/todo.txt-vim"},
|
|
||||||
|
|
||||||
-- {
|
|
||||||
-- 'windwp/nvim-autopairs',
|
|
||||||
-- enable = false,
|
|
||||||
-- event = "InsertEnter",
|
|
||||||
-- config = true
|
|
||||||
-- -- use opts = {} for passing setup options
|
|
||||||
-- -- this is equivalent to setup({}) function
|
|
||||||
-- },
|
|
||||||
{
|
|
||||||
'nvim-lualine/lualine.nvim',
|
|
||||||
-- dependencies = { 'nvim-tree/nvim-web-devicons' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ibhagwan/fzf-lua",
|
|
||||||
-- optional for icon support
|
|
||||||
-- dependencies = { "nvim-tree/nvim-web-devicons" },
|
|
||||||
-- or if using mini.icons/mini.nvim
|
|
||||||
-- dependencies = { "echasnovski/mini.icons" },
|
|
||||||
opts = {},
|
|
||||||
cmd = { "FzfLua" }, -- load when you call :Telekasten
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- this is the nvim tree but I dont use it yet
|
|
||||||
"nvim-tree/nvim-tree.lua",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope.nvim", tag = '0.1.8',
|
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ellisonleao/gruvbox.nvim",
|
|
||||||
},
|
|
||||||
-- Will see how this integrates with the existing workflow and what features I can impleemtn by
|
|
||||||
-- {
|
|
||||||
-- "nvim-neorg/neorg",
|
|
||||||
-- lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
|
|
||||||
-- version = "*", -- Pin Neorg to the latest stable release
|
|
||||||
-- config = true,
|
|
||||||
-- },
|
|
||||||
-- Disable lsp stuff
|
|
||||||
--{
|
|
||||||
-- -- lsp stuff
|
|
||||||
-- "williamboman/mason.nvim",
|
|
||||||
-- -- TODO: implement things like rename variables and stuff
|
|
||||||
-- "williamboman/mason-lspconfig.nvim",
|
|
||||||
-- "neovim/nvim-lspconfig",
|
|
||||||
--},
|
|
||||||
{
|
|
||||||
-- LuaSnip configuration
|
|
||||||
"L3MON4D3/LuaSnip",
|
|
||||||
version = "v2.*",
|
|
||||||
build = "make install_jsregexp",
|
|
||||||
event = "InsertEnter",
|
|
||||||
config = function()
|
|
||||||
local ls = require("luasnip")
|
|
||||||
ls.config.setup({
|
|
||||||
enable_autosnippets = true,
|
|
||||||
store_selection_keys = '<Tab>',
|
|
||||||
})
|
|
||||||
vim.keymap.set({"i", "s"}, "<C-L>", function() ls.jump(1) end, {silent = true})
|
|
||||||
vim.keymap.set({"i", "s"}, "<C-H>", function() ls.jump(-1) end, {silent = true})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
-- {
|
|
||||||
-- "hrsh7th/nvim-cmp",
|
|
||||||
-- event = "InsertEnter",
|
|
||||||
-- dependencies = {
|
|
||||||
-- "hrsh7th/cmp-nvim-lsp",
|
|
||||||
-- "hrsh7th/cmp-buffer",
|
|
||||||
-- "hrsh7th/cmp-path",
|
|
||||||
-- "hrsh7th/cmp-cmdline",
|
|
||||||
-- "L3MON4D3/LuaSnip",
|
|
||||||
-- "saadparwaiz1/cmp_luasnip",
|
|
||||||
-- },
|
|
||||||
-- config = function()
|
|
||||||
-- local cmp = require("cmp")
|
|
||||||
-- local luasnip = require("luasnip")
|
|
||||||
--
|
|
||||||
-- cmp.setup({
|
|
||||||
-- completion = {
|
|
||||||
-- autocomplete = false,
|
|
||||||
-- },
|
|
||||||
-- snippet = {
|
|
||||||
-- expand = function(args)
|
|
||||||
-- require("luasnip").lsp_expand(args.body)
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
-- mapping = {
|
|
||||||
-- ["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
-- if cmp.visible() then
|
|
||||||
-- cmp.select_next_item()
|
|
||||||
-- elseif luasnip.expand_or_jumpable() then
|
|
||||||
-- luasnip.expand_or_jump()
|
|
||||||
-- else
|
|
||||||
-- cmp.complete()
|
|
||||||
-- vim.defer_fn(function()
|
|
||||||
-- if cmp.visible() then cmp.select_next_item() end
|
|
||||||
-- end, 10)
|
|
||||||
-- end
|
|
||||||
-- end, { "i", "s" }),
|
|
||||||
-- ["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
-- if cmp.visible() then
|
|
||||||
-- cmp.select_prev_item()
|
|
||||||
-- elseif luasnip.jumpable(-1) then
|
|
||||||
-- luasnip.jump(-1)
|
|
||||||
-- else
|
|
||||||
-- fallback()
|
|
||||||
-- end
|
|
||||||
-- end, { "i", "s" }),
|
|
||||||
-- ["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
||||||
-- },
|
|
||||||
-- sources = cmp.config.sources({
|
|
||||||
-- { name = "nvim_lsp" },
|
|
||||||
-- { name = "luasnip" },
|
|
||||||
-- }, {
|
|
||||||
-- { name = "buffer" },
|
|
||||||
-- }),
|
|
||||||
-- })
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
{
|
|
||||||
'Ascyii/telekasten.nvim',
|
|
||||||
dev = true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"folke/which-key.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
opts = {
|
|
||||||
-- your configuration comes here
|
|
||||||
-- or leave it empty to use the default settings
|
|
||||||
-- refer to the configuration section below
|
|
||||||
icons = {mappings = false,},
|
|
||||||
-- set this delay so that its only used for
|
|
||||||
delay = 1500,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- LSP support
|
|
||||||
{ "neovim/nvim-lspconfig" },
|
|
||||||
{ "stevearc/aerial.nvim", opts = {} },
|
|
||||||
{ "williamboman/mason.nvim", config = true },
|
|
||||||
{ "williamboman/mason-lspconfig.nvim" },
|
|
||||||
|
|
||||||
-- Autocompletion
|
|
||||||
{ "hrsh7th/nvim-cmp" },
|
|
||||||
{ "hrsh7th/cmp-nvim-lsp" },
|
|
||||||
{ "hrsh7th/cmp-buffer" },
|
|
||||||
{ "hrsh7th/cmp-path" },
|
|
||||||
{ "saadparwaiz1/cmp_luasnip" },
|
|
||||||
|
|
||||||
-- UI improvements
|
|
||||||
--{ "nvimdev/lspsaga.nvim", config = true },
|
|
||||||
--{ "folke/trouble.nvim", opts = {} },
|
|
||||||
--{ "j-hui/fidget.nvim", tag = "legacy", config = true },
|
|
||||||
};
|
|
||||||
26
lua/plugins/misc.lua
Normal file
26
lua/plugins/misc.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
local base_zet = "~/synced/brainstore/zettelkasten"
|
||||||
|
|
||||||
|
return {
|
||||||
|
{ "ThePrimeagen/harpoon" },
|
||||||
|
{ "akinsho/toggleterm.nvim", config = true },
|
||||||
|
{
|
||||||
|
'Ascyii/telekasten.nvim',
|
||||||
|
dev = true,
|
||||||
|
opts = {
|
||||||
|
home = vim.fn.expand(base_zet),
|
||||||
|
dailies = vim.fn.expand(base_zet .. "/daily"),
|
||||||
|
|
||||||
|
image_subdir = vim.fn.expand(base_zet .. "/media"),
|
||||||
|
weeklies = vim.fn.expand(base_zet .. "/weekly"),
|
||||||
|
templates = vim.fn.expand(base_zet .. "/templates"),
|
||||||
|
template_new_note = vim.fn.expand(base_zet .. "/templates/note.md"),
|
||||||
|
template_new_daily = vim.fn.expand(base_zet .. "/templates/daily.md"),
|
||||||
|
template_new_weekly = vim.fn.expand(base_zet .. "/templates/weekly.md"),
|
||||||
|
|
||||||
|
filename_format = "%Y%m%d%H%M-%title%",
|
||||||
|
new_note_filename = "uuid-title",
|
||||||
|
uuid_type = "%Y%m%d%H%M",
|
||||||
|
uuid_separator = "-",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
57
lua/plugins/nvimtree.lua
Normal file
57
lua/plugins/nvimtree.lua
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
return {
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
opts = {
|
||||||
|
sort_by = "case_sensitive",
|
||||||
|
|
||||||
|
view = {
|
||||||
|
width = 35,
|
||||||
|
side = "right",
|
||||||
|
preserve_window_proportions = true,
|
||||||
|
number = false,
|
||||||
|
relativenumber = false,
|
||||||
|
},
|
||||||
|
update_focused_file = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
|
||||||
|
renderer = {
|
||||||
|
group_empty = true,
|
||||||
|
highlight_git = true,
|
||||||
|
highlight_opened_files = "name",
|
||||||
|
indent_markers = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
icons = {
|
||||||
|
show = {
|
||||||
|
file = false,
|
||||||
|
folder = false,
|
||||||
|
folder_arrow = true,
|
||||||
|
git = false,
|
||||||
|
modified = false,
|
||||||
|
hidden = false,
|
||||||
|
diagnostics = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
dotfiles = false,
|
||||||
|
git_clean = false,
|
||||||
|
no_buffer = false,
|
||||||
|
custom = { ".git" },
|
||||||
|
},
|
||||||
|
|
||||||
|
git = {
|
||||||
|
enable = true,
|
||||||
|
ignore = false,
|
||||||
|
},
|
||||||
|
|
||||||
|
actions = {
|
||||||
|
open_file = {
|
||||||
|
quit_on_open = false,
|
||||||
|
resize_window = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
lua/plugins/searching.lua
Normal file
11
lua/plugins/searching.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"ibhagwan/fzf-lua",
|
||||||
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
|
cmd = { "FzfLua" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
|
},
|
||||||
|
}
|
||||||
14
lua/plugins/treesitter.lua
Normal file
14
lua/plugins/treesitter.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
build = ":TSUpdate",
|
||||||
|
priority = 1000, -- Load before everything else
|
||||||
|
config = function()
|
||||||
|
local configs = require("nvim-treesitter.configs")
|
||||||
|
configs.setup({
|
||||||
|
sync_install = true,
|
||||||
|
ensure_installed = { "typst" },
|
||||||
|
})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
}
|
||||||
38
lua/plugins/typstar.lua
Normal file
38
lua/plugins/typstar.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"Ascyii/typstar",
|
||||||
|
dependencies = {
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
},
|
||||||
|
dev = true,
|
||||||
|
ft = { "typst" },
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<M-t>",
|
||||||
|
"<Cmd>TypstarToggleSnippets<CR>",
|
||||||
|
mode = { "n", "i" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"<M-j>",
|
||||||
|
"<Cmd>TypstarSmartJump<CR>",
|
||||||
|
mode = { "s", "i" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"<M-k>",
|
||||||
|
"<Cmd>TypstarSmartJumpBack<CR>",
|
||||||
|
mode = { "s", "i" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local typstar = require("typstar")
|
||||||
|
typstar.setup({
|
||||||
|
add_undo_breakpoints = true,
|
||||||
|
typstarRoot = "~/projects/typstar",
|
||||||
|
rnote = {
|
||||||
|
assetsDir = 'typst-assets',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
76
lua/plugins/ui.lua
Normal file
76
lua/plugins/ui.lua
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
--- @return string
|
||||||
|
local function get_cwd()
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
local home = os.getenv("HOME")
|
||||||
|
|
||||||
|
if cwd:sub(1, #home) == home then
|
||||||
|
return "~" .. cwd:sub(#home + 1)
|
||||||
|
else
|
||||||
|
return cwd
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {
|
||||||
|
icons = { mappings = false, },
|
||||||
|
delay = 1500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'nvim-lualine/lualine.nvim',
|
||||||
|
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||||
|
opts = {
|
||||||
|
options = {
|
||||||
|
icons_enabled = false,
|
||||||
|
theme = 'gruvbox',
|
||||||
|
component_separators = { left = '', right = '' },
|
||||||
|
section_separators = { left = '', right = '' },
|
||||||
|
always_divide_middle = true,
|
||||||
|
always_show_tabline = true,
|
||||||
|
globalstatus = false,
|
||||||
|
refresh = {
|
||||||
|
statusline = 300,
|
||||||
|
tabline = 300,
|
||||||
|
winbar = 300,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = { 'mode' },
|
||||||
|
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||||
|
lualine_c = { get_cwd, 'filename' },
|
||||||
|
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||||
|
lualine_y = { 'progress' },
|
||||||
|
lualine_z = { 'location' }
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = { 'filename' },
|
||||||
|
lualine_x = { 'location' },
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {}
|
||||||
|
},
|
||||||
|
extensions = { "nvim-tree" }
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'romgrk/barbar.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'lewis6991/gitsigns.nvim',
|
||||||
|
'nvim-tree/nvim-web-devicons',
|
||||||
|
},
|
||||||
|
init = function() vim.g.barbar_auto_setup = false end,
|
||||||
|
cmd = { "BufferNext", "BufferPrevious" },
|
||||||
|
opts = {
|
||||||
|
clickable = false,
|
||||||
|
tabpages = false,
|
||||||
|
animations = false,
|
||||||
|
icons = { filetype = { enabled = false } }
|
||||||
|
},
|
||||||
|
version = '^1.0.0', -- only update when a new 1.x version is released
|
||||||
|
},
|
||||||
|
}
|
||||||
98
lua/utils/functions.lua
Normal file
98
lua/utils/functions.lua
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
-- General helper functions
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.Sleep(n)
|
||||||
|
os.execute("sleep " .. tonumber(n))
|
||||||
|
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
|
||||||
@@ -8,7 +8,7 @@ local mail_dir = "~/mail/plain_emails"
|
|||||||
local contacts_file = "~/synced/vault/contacts/contacts.txt"
|
local contacts_file = "~/synced/vault/contacts/contacts.txt"
|
||||||
local cal_dir = "~/synced/brainstore/calendar"
|
local cal_dir = "~/synced/brainstore/calendar"
|
||||||
|
|
||||||
function fzf_select(options, prompt, callback)
|
local function fzf_select(options, prompt, callback)
|
||||||
local fzf = require("fzf-lua")
|
local fzf = require("fzf-lua")
|
||||||
fzf.fzf_exec(options, {
|
fzf.fzf_exec(options, {
|
||||||
prompt = prompt .. "> ",
|
prompt = prompt .. "> ",
|
||||||
@@ -148,7 +148,8 @@ function M.insert_project_link()
|
|||||||
local selected = selection.path or selection.filename or selection[1]
|
local selected = selection.path or selection.filename or selection[1]
|
||||||
if selected then
|
if selected then
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local link = "[[project:" .. selected:gsub(vim.fn.expand(projects_dir) .. "/", "") .. "]]"
|
local link = "[[project:" ..
|
||||||
|
selected:gsub(vim.fn.expand(projects_dir) .. "/", "") .. "]]"
|
||||||
vim.api.nvim_put({ link }, "c", true, true)
|
vim.api.nvim_put({ link }, "c", true, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -169,9 +170,6 @@ function M.insert_project_link()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -183,7 +181,6 @@ function M.insert_project_link()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function spliting(inputstr, sep)
|
local function spliting(inputstr, sep)
|
||||||
if sep == nil then
|
if sep == nil then
|
||||||
sep = "%s"
|
sep = "%s"
|
||||||
@@ -253,4 +250,3 @@ function M.follow_link()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
Reference in New Issue
Block a user