mirror of
https://github.com/Ascyii/nvim.git
synced 2026-01-01 04:04:24 -05:00
Refactor all the custom modules into better structures. Clear separation of keybindings that belong to cusstom modules. Added custom snippets and vsc snippets.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
|
||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||
"fzf-lua": { "branch": "main", "commit": "bebc84e7ffc8fd86103f6ed6c590df72d524d342" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" },
|
||||
"gruvbox.nvim": { "branch": "main", "commit": "12c2624287dc827edb5d72b2bc4c9619e692a554" },
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
local config = {}
|
||||
|
||||
config.season = "S3"
|
||||
config.season = "S3" -- Current semester
|
||||
config.projects = vim.fn.expand("~/projects")
|
||||
config.uni_dir = vim.fn.expand("~/projects/university/" .. config.season)
|
||||
config.user = vim.fn.system('whoami'):gsub('\n', '')
|
||||
|
||||
return config
|
||||
|
||||
@@ -1,44 +1,22 @@
|
||||
-- Custom keymaps
|
||||
|
||||
require("utils.functions")
|
||||
require("custom.uni")
|
||||
|
||||
local conf = require("conf")
|
||||
|
||||
local links = require("utils.linker")
|
||||
local user = vim.fn.system('whoami'):gsub('\n', '')
|
||||
|
||||
local 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
|
||||
|
||||
-------------------------------------------------------
|
||||
--------------------- KEYMAPS -------------------------
|
||||
-------------------------------------------------------
|
||||
|
||||
|
||||
-- Fast window switch
|
||||
vim.keymap.set("n", "<leader>w", "<C-w>w")
|
||||
|
||||
--------------------- NORMAL -------------------------
|
||||
|
||||
|
||||
vim.keymap.set('n', '<leader>zq', ':e ~/synced/brainstore/zettelkasten/input.txt<CR>`.zz')
|
||||
|
||||
-- Buildin vim
|
||||
|
||||
vim.keymap.set("n", "<leader>me", ":mes<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", "n", "nzz", { silent = true })
|
||||
vim.keymap.set("n", "N", "Nzz", { silent = true })
|
||||
vim.keymap.set("n", "<C-o>", "<C-o>zz", { silent = true })
|
||||
@@ -51,31 +29,10 @@ vim.keymap.set('n', '<leader>tr', ':tabnew<CR>:term<CR>i')
|
||||
|
||||
-- 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>ya', 'ggVG"+y<C-o>')
|
||||
|
||||
vim.keymap.set('n', '<leader>ss', ':wa<CR>')
|
||||
|
||||
-- new quick note file
|
||||
-- TODO: make this smarter
|
||||
vim.keymap.set("n", "<leader>nn", ":e ~/synced/brainstore/zettelkasten/quick<CR>", { silent = true })
|
||||
|
||||
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
|
||||
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')
|
||||
@@ -88,8 +45,8 @@ vim.keymap.set('n', '<leader>ocp', ':e ~/.config/nvim/lua/plugins/misc.lua<CR>`.
|
||||
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>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>op', ':e ~/configuration/nixos/users/' .. user .. '/packages.nix<CR>`.zz')
|
||||
vim.keymap.set('n', '<leader>ohh', ':e ~/configuration/nixos/users/' .. conf.user .. '/home.nix<CR>`.zz')
|
||||
vim.keymap.set('n', '<leader>op', ':e ~/configuration/nixos/users/' .. conf.user .. '/packages.nix<CR>`.zz')
|
||||
vim.keymap.set('n', '<leader>on', ':e ~/configuration/nixos/configuration.nix<CR>`.zz')
|
||||
vim.keymap.set('n', '<leader>om', ':e ~/configuration/nixos/modules<CR>')
|
||||
vim.keymap.set('n', '<leader>ow', ':e ~/synced/brainstore/waste.txt<CR>')
|
||||
@@ -101,17 +58,7 @@ vim.keymap.set('n', '<leader>ou', ':e ~/projects/university/' .. conf.season ..
|
||||
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>ok', open_cal)
|
||||
-------------------------------------------------------------------------------------
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", links.insert_brainstore_link, { desc = "Link Brainstore file" })
|
||||
vim.keymap.set("n", "<leader>lm", links.insert_mail_link, { desc = "Link Mail" })
|
||||
vim.keymap.set('n', '<leader>ll', ':Lazy<CR>')
|
||||
vim.keymap.set("n", "<leader>lp", links.insert_project_link, { desc = "Link Project" })
|
||||
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>sw', function()
|
||||
local word = vim.fn.expand("<cword>")
|
||||
@@ -150,9 +97,6 @@ end, { desc = 'Paste from system clipboard' })
|
||||
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>nv", function()
|
||||
select_course_directory()
|
||||
end, { desc = "Open UniCourse menu" })
|
||||
|
||||
vim.keymap.set('v', 'p', function()
|
||||
local unnamed_content = vim.fn.getreg('""')
|
||||
@@ -235,3 +179,29 @@ vim.keymap.set('n', '<leader>ov',
|
||||
})
|
||||
end
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
vim.keymap.set('n', '<leader>ok', function()
|
||||
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)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local journal_base_raw = "~/management/brainstore/knowledge/journal"
|
||||
local journal_base = vim.fn.expand(journal_base_raw)
|
||||
local journal_base = vim.fn.expand("~/management/brainstore/knowledge/journal")
|
||||
|
||||
M.open_today = function()
|
||||
local date = os.date("*t")
|
||||
@@ -20,6 +20,26 @@ local function fzf_select(options, prompt, callback)
|
||||
})
|
||||
end
|
||||
|
||||
local function spliting(inputstr, sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
local t = {}
|
||||
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local function pad2(n)
|
||||
n = tonumber(n)
|
||||
if n < 10 then
|
||||
return "0" .. n
|
||||
else
|
||||
return tostring(n)
|
||||
end
|
||||
end
|
||||
|
||||
function M.insert_brainstore_link()
|
||||
require('telescope.builtin').find_files({
|
||||
hidden = true,
|
||||
@@ -85,7 +105,7 @@ function M.insert_date_link()
|
||||
local text = string.format("[[date:.%s]]", year)
|
||||
|
||||
vim.api.nvim_put({ text }, "c", true, true)
|
||||
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
local row, col = table.unpack(vim.api.nvim_win_get_cursor(0))
|
||||
vim.api.nvim_win_set_cursor(0, { row, col - 4 })
|
||||
vim.cmd("startinsert")
|
||||
end
|
||||
@@ -128,18 +148,18 @@ function M.insert_project_link()
|
||||
"--hidden",
|
||||
"--glob", "!**/.git/*",
|
||||
},
|
||||
attach_mappings = function(prompt_bufnr, map)
|
||||
local actions = require('telescope.actions')
|
||||
local action_state = require('telescope.actions.state')
|
||||
attach_mappings = function(prompt_bufnr_new, map_new)
|
||||
actions = require('telescope.actions')
|
||||
action_state = require('telescope.actions.state')
|
||||
|
||||
local function insert_link()
|
||||
local selection = action_state.get_selected_entry()
|
||||
local function insert_link_new()
|
||||
selection = action_state.get_selected_entry()
|
||||
if not selection then
|
||||
return
|
||||
end
|
||||
local selected = selection.path or selection.filename or selection[1]
|
||||
selected = selection.path or selection.filename or selection[1]
|
||||
if selected then
|
||||
actions.close(prompt_bufnr)
|
||||
actions.close(prompt_bufnr_new)
|
||||
local link = "[[project:" ..
|
||||
selected:gsub(vim.fn.expand(projects_dir) .. "/", "") .. "]]"
|
||||
vim.api.nvim_put({ link }, "c", true, true)
|
||||
@@ -147,16 +167,16 @@ function M.insert_project_link()
|
||||
end
|
||||
|
||||
local function insert_link_top()
|
||||
actions.close(prompt_bufnr)
|
||||
actions.close(prompt_bufnr_new)
|
||||
local link = "[[project:" .. project .. "]]"
|
||||
vim.api.nvim_put({ link }, "c", true, true)
|
||||
end
|
||||
|
||||
map('i', '<CR>', insert_link)
|
||||
map('n', '<CR>', insert_link)
|
||||
map_new('i', '<CR>', insert_link_new)
|
||||
map_new('n', '<CR>', insert_link_new)
|
||||
|
||||
map('i', '<ESC>', insert_link_top)
|
||||
map('n', '<ESC>', insert_link_top)
|
||||
map_new('i', '<ESC>', insert_link_top)
|
||||
map_new('n', '<ESC>', insert_link_top)
|
||||
|
||||
|
||||
return true
|
||||
@@ -173,28 +193,6 @@ function M.insert_project_link()
|
||||
})
|
||||
end
|
||||
|
||||
local function spliting(inputstr, sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
local t = {}
|
||||
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local function pad2(n)
|
||||
n = tonumber(n)
|
||||
if n < 10 then
|
||||
return "0" .. n
|
||||
else
|
||||
return tostring(n)
|
||||
end
|
||||
end
|
||||
|
||||
-- The heart of this project following
|
||||
-- Remember to go back with C-O
|
||||
function M.follow_link()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local link = line:match("%[%[(.-)%]%]")
|
||||
@@ -209,9 +207,7 @@ function M.follow_link()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-- List of all kinds that are available
|
||||
-- Here brainstore and projects are kind of the same but I keep them separated
|
||||
if kind == "brain" then
|
||||
vim.cmd("edit " .. brainstore_dir .. "/" .. target)
|
||||
elseif kind == "mail" then
|
||||
@@ -236,7 +232,7 @@ function M.follow_link()
|
||||
vim.cmd("/" .. "20" .. year .. "-" .. month .. "-" .. day)
|
||||
vim.cmd("normal! zz")
|
||||
else
|
||||
print("Unknown link type: " .. kind .. ". Must be one of: " .. "mail, contact, project, brain, date.")
|
||||
print("Unknown link type: " .. kind .. ".")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
-- custom module for todo file editing support in neovim
|
||||
-- inspired by a older plugin that does basically the same
|
||||
|
||||
local M = {}
|
||||
|
||||
local function is_todo_file()
|
||||
@@ -22,7 +19,6 @@ function M.remove_priority()
|
||||
vim.api.nvim_set_current_line(line)
|
||||
end
|
||||
|
||||
|
||||
function M.mark_done()
|
||||
if not is_todo_file() then return end
|
||||
print("Marked todo as done! (just deleted)")
|
||||
@@ -103,22 +99,5 @@ function M.sort_by_project()
|
||||
grouped_sort(get_project_key)
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
for i = string.byte("a"), string.byte("z") do
|
||||
local letter = string.char(i)
|
||||
vim.keymap.set("n", "<leader>p" .. letter, function() M.set_priority(letter) end, opts)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>p<leader>", M.remove_priority, opts)
|
||||
|
||||
vim.keymap.set("n", "<leader>sp", M.sort_by_priority, opts)
|
||||
vim.keymap.set("n", "<leader>sc", M.sort_by_context, opts)
|
||||
vim.keymap.set("n", "<leader>sr", M.sort_by_project, opts)
|
||||
|
||||
-- New keymap for marking todo as done
|
||||
vim.keymap.set("n", "<leader>td", M.mark_done, opts)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -6,7 +6,7 @@ local watch_job_id = nil
|
||||
local watch_buf_id = nil
|
||||
local watch_tab_id = nil
|
||||
|
||||
function M.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")
|
||||
@@ -66,7 +66,7 @@ function M.Watch_and_open()
|
||||
vim.notify("Started Typst watch", vim.log.levels.INFO)
|
||||
|
||||
vim.fn.system("killall .zathura-wrapped")
|
||||
functions.Sleep(0.5)
|
||||
functions.sleep(0.5)
|
||||
vim.fn.jobstart({ "zathura", output }, {
|
||||
on_exit = function()
|
||||
if watch_job_id then
|
||||
@@ -1,9 +1,11 @@
|
||||
local M = {}
|
||||
|
||||
local fzf = require("fzf-lua")
|
||||
local fn = vim.fn
|
||||
local current_season = "S3"
|
||||
local conf = require("conf")
|
||||
|
||||
-- Function to scan for .unicourse files and get their course directories
|
||||
function get_course_directories()
|
||||
function M.get_course_directories()
|
||||
local dirs = {}
|
||||
local function scan_dir(dir)
|
||||
for _, entry in ipairs(fn.glob(dir .. "/*", true, true)) do
|
||||
@@ -26,13 +28,13 @@ function get_course_directories()
|
||||
end
|
||||
end
|
||||
|
||||
scan_dir("~/projects/university/" .. current_season)
|
||||
scan_dir("~/projects/university/" .. conf.season)
|
||||
return dirs
|
||||
end
|
||||
|
||||
-- Function to show the fzf menu for selecting a course directory
|
||||
function select_course_directory()
|
||||
local courses = get_course_directories()
|
||||
function M.select_course_directory()
|
||||
local courses = M.get_course_directories()
|
||||
local course_names = {}
|
||||
|
||||
for _, course in ipairs(courses) do
|
||||
@@ -45,7 +47,7 @@ function select_course_directory()
|
||||
["default"] = function(selected)
|
||||
for _, course in ipairs(courses) do
|
||||
if selected[1] == (course.name .. " (" .. course.short .. ")") then
|
||||
show_course_menu(course)
|
||||
M.show_course_menu(course)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -55,7 +57,7 @@ function select_course_directory()
|
||||
end
|
||||
|
||||
-- Function to show the fzf menu for actions on a selected course folder
|
||||
function show_course_menu(course)
|
||||
function M.show_course_menu(course)
|
||||
local files = {}
|
||||
-- Collect all VL files in the Vorlesungen directory
|
||||
for _, file in ipairs(fn.glob(course.path .. "/VL/*", true, true)) do
|
||||
@@ -79,10 +81,10 @@ function show_course_menu(course)
|
||||
actions = {
|
||||
["default"] = function(selected)
|
||||
if selected[1] == "Open the newest VL file" then
|
||||
local newest_file = get_newest_vl_file(files)
|
||||
local newest_file = M.get_newest_vl_file(files)
|
||||
vim.cmd("edit " .. newest_file)
|
||||
elseif selected[1] == "Create a new VL" then
|
||||
create_new_vl(course)
|
||||
M.create_new_vl(course)
|
||||
elseif selected[1] == "Open the course folder" then
|
||||
vim.cmd("edit " .. course.path)
|
||||
elseif selected[1] == "Open a specific file" then
|
||||
@@ -101,7 +103,7 @@ function show_course_menu(course)
|
||||
end
|
||||
|
||||
-- Function to get the newest VL file based on modification time
|
||||
function get_newest_vl_file(files)
|
||||
function M.get_newest_vl_file(files)
|
||||
local newest_file = nil
|
||||
local newest_time = 0
|
||||
for _, file in ipairs(files) do
|
||||
@@ -115,18 +117,20 @@ function get_newest_vl_file(files)
|
||||
end
|
||||
|
||||
-- Function to create a new VL file based on the template and incrementing the number
|
||||
function create_new_vl(course)
|
||||
function M.create_new_vl(course)
|
||||
local vl_dir = course.path .. "/VL"
|
||||
local success, _ = pcall(function()
|
||||
pcall(function()
|
||||
vim.fn.mkdir(vl_dir)
|
||||
end)
|
||||
-- Hard coded this
|
||||
local template_path = vim.fn.expand("~/projects/university/data/template.typ")
|
||||
if fn.filereadable(template_path) == 1 then
|
||||
-- Find the latest VL number in the folder
|
||||
--- @type number?
|
||||
local latest_num = 0
|
||||
for _, file in ipairs(fn.glob(vl_dir .. "/*", true, true)) do
|
||||
if file:match(course.short .. "VL(%d+).typ$") then
|
||||
--- @type number?
|
||||
local num = tonumber(file:match(course.short .. "VL(%d+).typ$"))
|
||||
if num > latest_num then
|
||||
latest_num = num
|
||||
@@ -147,3 +151,5 @@ function create_new_vl(course)
|
||||
print("Template file (template.typ) not found!")
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -12,16 +12,53 @@ return {
|
||||
dir = get_custom_dir("todo"),
|
||||
name = "todo",
|
||||
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
|
||||
config = function()
|
||||
require("custom.todo").setup()
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>ta", function() require("custom.todo").mark_done() end, desc = "Watch Typst" },
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
dir = get_custom_dir(),
|
||||
dir = get_custom_dir("typst"),
|
||||
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" },
|
||||
{ "<leader>tw", function() require("custom.typst").watch_and_open() end, desc = "Watch Typst" },
|
||||
},
|
||||
},
|
||||
{
|
||||
dir = get_custom_dir("journal"),
|
||||
name = "journal",
|
||||
config = function ()
|
||||
local journal = require("custom.journal")
|
||||
vim.keymap.set("n", "<leader>joup", function()
|
||||
journal.open_today()
|
||||
end, { desc = "Open todays journal" })
|
||||
end
|
||||
},
|
||||
{
|
||||
dir = get_custom_dir("uni"),
|
||||
name = "uni",
|
||||
config = function ()
|
||||
local uni = require("custom.uni")
|
||||
vim.keymap.set("n", "<leader>nv", function()
|
||||
uni.select_course_directory()
|
||||
end, { desc = "Open UniCourse menu" })
|
||||
end
|
||||
|
||||
},
|
||||
{
|
||||
dir = get_custom_dir("linker"),
|
||||
name = "linker",
|
||||
config = function()
|
||||
local links = require("custom.linker")
|
||||
|
||||
vim.keymap.set("n", "<leader>fl", links.follow_link, { desc = "Try to follow current link" })
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", links.insert_brainstore_link, { desc = "Link Brainstore file" })
|
||||
vim.keymap.set("n", "<leader>lm", links.insert_mail_link, { desc = "Link Mail" })
|
||||
vim.keymap.set("n", "<leader>lp", links.insert_project_link, { desc = "Link Project" })
|
||||
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" })
|
||||
end
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
-- Prefilled with lsp that have no dependencies
|
||||
local servers = { "lua_ls", "rust_analyzer", "denols" }
|
||||
|
||||
local function populate_servers()
|
||||
if vim.fn.executable("go") == 1 then
|
||||
table.insert(servers, "gopls")
|
||||
else
|
||||
vim.notify("[mason] Skipping gopls (go not found)", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
if vim.fn.executable("npm") == 1 then
|
||||
table.insert(servers, "pyright")
|
||||
table.insert(servers, "clangd")
|
||||
table.insert(servers, "bashls")
|
||||
else
|
||||
vim.notify("[mason] Skipping install of some lsp (npm not found)", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
if vim.fn.executable("cargo") == 1 then
|
||||
table.insert(servers, "nil_ls")
|
||||
else
|
||||
vim.notify("[mason] Skipping nil (cargo not found)", vim.log.levels.WARN)
|
||||
end
|
||||
end
|
||||
populate_servers()
|
||||
-- Prefilled with servers that have no dependencies
|
||||
local servers = require("utils.functions").get_lsp_servers()
|
||||
|
||||
return {
|
||||
{
|
||||
@@ -77,7 +54,7 @@ return {
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim"
|
||||
},
|
||||
priority = -10;
|
||||
priority = -10,
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
|
||||
@@ -185,7 +162,7 @@ return {
|
||||
|
||||
-- Add text in diagnostics
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
virtual_text = false,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
return {
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets"
|
||||
},
|
||||
version = "v2.*",
|
||||
build = "make install_jsregexp",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
local ls = require("luasnip")
|
||||
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_lua").lazy_load({ paths = "~/.config/nvim/snippets" })
|
||||
|
||||
ls.config.setup({
|
||||
enable_autosnippets = true,
|
||||
store_selection_keys = '<Tab>',
|
||||
|
||||
@@ -7,7 +7,9 @@ return {
|
||||
local configs = require("nvim-treesitter.configs")
|
||||
configs.setup({
|
||||
sync_install = true,
|
||||
ensure_installed = { "typst" },
|
||||
ensure_installed = { "typst", "go", "bash", "python", "nix" },
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
end
|
||||
},
|
||||
|
||||
@@ -1,8 +1,72 @@
|
||||
-- General helper functions
|
||||
local M = {}
|
||||
|
||||
function M.Sleep(n)
|
||||
function M.sleep(n)
|
||||
os.execute("sleep " .. tonumber(n))
|
||||
end
|
||||
|
||||
--- @return {}
|
||||
function M.get_lsp_servers()
|
||||
local servers = { "lua_ls" }
|
||||
|
||||
-- persistent state file
|
||||
local state_file = vim.fn.stdpath("state") .. "/mason_skipped_jonas.json"
|
||||
|
||||
-- load previous warnings
|
||||
local warned = {}
|
||||
local ok, data = pcall(vim.fn.readfile, state_file)
|
||||
if ok and #data > 0 then
|
||||
local decoded = vim.fn.json_decode(data)
|
||||
if decoded then warned = decoded end
|
||||
end
|
||||
|
||||
local function save_state()
|
||||
vim.fn.writefile({ vim.fn.json_encode(warned) }, state_file)
|
||||
end
|
||||
|
||||
local function warn_once(key, msg)
|
||||
if not warned[key] then
|
||||
vim.notify(msg, vim.log.levels.WARN)
|
||||
warned[key] = true
|
||||
save_state()
|
||||
end
|
||||
end
|
||||
|
||||
local function populate_servers()
|
||||
if vim.fn.executable("go") == 1 then
|
||||
table.insert(servers, "gopls")
|
||||
else
|
||||
warn_once("gopls", "[mason] Skipping gopls (go not found)")
|
||||
end
|
||||
|
||||
if vim.fn.executable("npm") == 1 then
|
||||
table.insert(servers, "pyright")
|
||||
table.insert(servers, "clangd")
|
||||
table.insert(servers, "bashls")
|
||||
else
|
||||
warn_once("npm", "[mason] Skipping pyright/clangd/bashls (npm not found)")
|
||||
end
|
||||
|
||||
if vim.fn.executable("cargo") == 1 then
|
||||
if vim.fn.executable("nix") == 1 then
|
||||
table.insert(servers, "nil_ls")
|
||||
else
|
||||
warn_once("nix", "[mason] Skipping nil_ls (nix not found)")
|
||||
end
|
||||
table.insert(servers, "rust_analyzer")
|
||||
else
|
||||
warn_once("cargo", "[mason] Skipping nil_ls/rust_analyzer (cargo not found)")
|
||||
end
|
||||
|
||||
if vim.fn.executable("deno") == 1 then
|
||||
table.insert(servers, "denols")
|
||||
else
|
||||
warn_once("deno", "[mason] Skipping denols (deno not found)")
|
||||
end
|
||||
end
|
||||
|
||||
populate_servers()
|
||||
return servers
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
9
snippets/all.lua
Normal file
9
snippets/all.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
|
||||
return {
|
||||
s("sig", {
|
||||
t("Best regards,"), t({ "", "Jonas Hahn" }),
|
||||
}),
|
||||
}
|
||||
17
snippets/go.lua
Normal file
17
snippets/go.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
|
||||
return {
|
||||
s("cfo", { -- check for error
|
||||
t("if err != nil {"), t({ "", "\t" }),
|
||||
i(1, "return err"),
|
||||
t({ "", "}" })
|
||||
}),
|
||||
s("struct", {
|
||||
t("type "), i(1, "MyStruct"), t(" struct {"),
|
||||
t({ "", "\t" }), i(2, "Field type"),
|
||||
t({ "", "}" })
|
||||
}),
|
||||
}
|
||||
Reference in New Issue
Block a user