Adds CopyToPlayers command
This commit is contained in:
parent
132f9d0636
commit
6f74d3b3db
8 changed files with 66 additions and 18 deletions
26
.config/nvim/lua/commands/CopyToPlayers.lua
Normal file
26
.config/nvim/lua/commands/CopyToPlayers.lua
Normal file
|
|
@ -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, {})
|
||||
|
|
@ -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", {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue