diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 52e089b..5c5f535 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -5,3 +5,4 @@ require("config.lazy") require("commands.optolith") require("commands.open") +require("commands.CopyToPlayers") diff --git a/.config/nvim/lua/commands/CopyToPlayers.lua b/.config/nvim/lua/commands/CopyToPlayers.lua new file mode 100644 index 0000000..0cdbed7 --- /dev/null +++ b/.config/nvim/lua/commands/CopyToPlayers.lua @@ -0,0 +1,26 @@ +local fs = require("functions.fs") +local git = require("functions.git") + +vim.api.nvim_create_user_command("CopyToPlayers", function() + local CONFIGFILE = ".dsa-players-path" + + local pathFile = vim.fs.joinpath(vim.fn.getcwd(), CONFIGFILE) + local fileExists = vim.fn.empty(vim.fn.glob(pathFile)) == 0 + if not fileExists then + vim.notify("Can't find target path. Missing file", "error", { + title = "Copy to players", + }) + + return + end + + local targetPath = vim.fs.joinpath(vim.fn.getcwd(), table.concat(vim.fn.readfile(pathFile))) + + os.execute(string.format("mkdir -p '%s'", targetPath)) + + local localPath = fs.getCurrentPath() + local targetFilePath = vim.fs.joinpath(targetPath, vim.fn.fnamemodify(localPath, ":t")) + os.execute(string.format("ln -s '%s' '%s'", localPath, targetFilePath)) + + git.commitFile(targetFilePath) +end, {}) diff --git a/.config/nvim/lua/commands/optolith.lua b/.config/nvim/lua/commands/optolith.lua index ac71c93..6856d9e 100644 --- a/.config/nvim/lua/commands/optolith.lua +++ b/.config/nvim/lua/commands/optolith.lua @@ -1,27 +1,12 @@ local nio = require("nio") local git = require("functions.git") - -local function startswith(string, start) - return string:sub(1, #start) == start -end - -local function get_current_path() - local currentBuffer = vim.fn.expand("%") - - if not startswith(currentBuffer, "neo-tree") then - return currentBuffer - end - - local filesystemState = require("neo-tree.sources.manager").get_state("filesystem") - local currentLine = vim.fn.getpos(".")[2] - return filesystemState.tree:get_node(currentLine).path -end +local fs = require("functions.fs") vim.api.nvim_create_user_command("Optolith", function() local LAUNCH_COMMAND = vim.fs.normalize("~/.local/share/appimages/OptolithInsider.AppImage") local OPTOLITH_DIRECTORY = "~/.config/Optolith Insider" - local currentHeroFile = get_current_path() + local currentHeroFile = fs.get_current_path() if currentHeroFile:find(".opto$") == nil then vim.notify("Invalid hero", "error", { diff --git a/.config/nvim/lua/functions/fs.lua b/.config/nvim/lua/functions/fs.lua new file mode 100644 index 0000000..9f4bc43 --- /dev/null +++ b/.config/nvim/lua/functions/fs.lua @@ -0,0 +1,19 @@ +local fs = {} + +local function startswith(string, start) + return string:sub(1, #start) == start +end + +function fs.getCurrentPath() + local currentBuffer = vim.fn.expand("%") + + if not startswith(currentBuffer, "neo-tree") then + return currentBuffer + end + + local filesystemState = require("neo-tree.sources.manager").get_state("filesystem") + local currentLine = vim.fn.getpos(".")[2] + return filesystemState.tree:get_node(currentLine).path +end + +return fs diff --git a/.config/nvim/lua/plugins/neotree.lua b/.config/nvim/lua/plugins/neotree.lua index 89d730c..5a82709 100644 --- a/.config/nvim/lua/plugins/neotree.lua +++ b/.config/nvim/lua/plugins/neotree.lua @@ -21,4 +21,16 @@ return { }, }, }, + keys = { + { + "e", + function() + local filesystemState = require("neo-tree.sources.manager").get_state("filesystem") + local fsPath = table.concat(filesystemState.default_expanded_nodes) + + require("neo-tree.command").execute({ toggle = true, dir = fsPath }) + end, + desc = "Explorer NeoTree (reopen)", + }, + }, } diff --git a/.config/nvim/lua/plugins/obsidian.lua b/.config/nvim/lua/plugins/obsidian.lua index 9023dac..f6fe3cf 100644 --- a/.config/nvim/lua/plugins/obsidian.lua +++ b/.config/nvim/lua/plugins/obsidian.lua @@ -1,3 +1,7 @@ +if true then + return {} +end + return { "epwalsh/obsidian.nvim", version = "*", diff --git a/.config/terminal/.setuprc b/.config/terminal/.setuprc index cbeb413..d99ca70 100644 --- a/.config/terminal/.setuprc +++ b/.config/terminal/.setuprc @@ -10,5 +10,6 @@ alias vim='nvim' alias note='(cd ~/Notes/ && ENABLE_GIT_SETUP=true nvim ~/Notes/)' alias note-diary='(cd ~/Notes/ && ENABLE_GIT_SETUP=true nvim ~/Notes/Diary.md)' alias note-dsa='(cd ~/DSA/ && ENABLE_GIT_SETUP=true nvim ~/DSA/)' +alias note-dsa-players='(cd ~/DSA/Spieler/ && nvim ~/DSA/Spieler/)' eval "$(zoxide init bash --cmd cd)" diff --git a/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml b/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml index eaf4f3e..ce45dbd 100644 --- a/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml +++ b/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml @@ -11,7 +11,7 @@ - +