Adds CopyToPlayers command
This commit is contained in:
parent
132f9d0636
commit
6f74d3b3db
8 changed files with 66 additions and 18 deletions
|
|
@ -5,3 +5,4 @@ require("config.lazy")
|
||||||
|
|
||||||
require("commands.optolith")
|
require("commands.optolith")
|
||||||
require("commands.open")
|
require("commands.open")
|
||||||
|
require("commands.CopyToPlayers")
|
||||||
|
|
|
||||||
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 nio = require("nio")
|
||||||
local git = require("functions.git")
|
local git = require("functions.git")
|
||||||
|
local fs = require("functions.fs")
|
||||||
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
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("Optolith", function()
|
vim.api.nvim_create_user_command("Optolith", function()
|
||||||
local LAUNCH_COMMAND = vim.fs.normalize("~/.local/share/appimages/OptolithInsider.AppImage")
|
local LAUNCH_COMMAND = vim.fs.normalize("~/.local/share/appimages/OptolithInsider.AppImage")
|
||||||
local OPTOLITH_DIRECTORY = "~/.config/Optolith Insider"
|
local OPTOLITH_DIRECTORY = "~/.config/Optolith Insider"
|
||||||
|
|
||||||
local currentHeroFile = get_current_path()
|
local currentHeroFile = fs.get_current_path()
|
||||||
|
|
||||||
if currentHeroFile:find(".opto$") == nil then
|
if currentHeroFile:find(".opto$") == nil then
|
||||||
vim.notify("Invalid hero", "error", {
|
vim.notify("Invalid hero", "error", {
|
||||||
|
|
|
||||||
19
.config/nvim/lua/functions/fs.lua
Normal file
19
.config/nvim/lua/functions/fs.lua
Normal file
|
|
@ -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
|
||||||
|
|
@ -21,4 +21,16 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>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)",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
if true then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"epwalsh/obsidian.nvim",
|
"epwalsh/obsidian.nvim",
|
||||||
version = "*",
|
version = "*",
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ alias vim='nvim'
|
||||||
alias note='(cd ~/Notes/ && ENABLE_GIT_SETUP=true nvim ~/Notes/)'
|
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-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='(cd ~/DSA/ && ENABLE_GIT_SETUP=true nvim ~/DSA/)'
|
||||||
|
alias note-dsa-players='(cd ~/DSA/Spieler/ && nvim ~/DSA/Spieler/)'
|
||||||
|
|
||||||
eval "$(zoxide init bash --cmd cd)"
|
eval "$(zoxide init bash --cmd cd)"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<property name="last-side-pane" type="string" value="ThunarShortcutsPane"/>
|
<property name="last-side-pane" type="string" value="ThunarShortcutsPane"/>
|
||||||
<property name="last-location-bar" type="string" value="ThunarLocationEntry"/>
|
<property name="last-location-bar" type="string" value="ThunarLocationEntry"/>
|
||||||
<property name="last-details-view-zoom-level" type="string" value="THUNAR_ZOOM_LEVEL_50_PERCENT"/>
|
<property name="last-details-view-zoom-level" type="string" value="THUNAR_ZOOM_LEVEL_50_PERCENT"/>
|
||||||
<property name="last-details-view-column-widths" type="string" value="117,50,124,117,82,1214,50,50,993,50,50,79,50,137"/>
|
<property name="last-details-view-column-widths" type="string" value="117,50,124,117,82,1214,50,50,509,50,50,299,50,401"/>
|
||||||
<property name="last-sort-column" type="string" value="THUNAR_COLUMN_NAME"/>
|
<property name="last-sort-column" type="string" value="THUNAR_COLUMN_NAME"/>
|
||||||
<property name="last-sort-order" type="string" value="GTK_SORT_ASCENDING"/>
|
<property name="last-sort-order" type="string" value="GTK_SORT_ASCENDING"/>
|
||||||
<property name="last-details-view-visible-columns" type="string" value="THUNAR_COLUMN_DATE_CREATED,THUNAR_COLUMN_DATE_MODIFIED,THUNAR_COLUMN_NAME,THUNAR_COLUMN_SIZE,THUNAR_COLUMN_TYPE"/>
|
<property name="last-details-view-visible-columns" type="string" value="THUNAR_COLUMN_DATE_CREATED,THUNAR_COLUMN_DATE_MODIFIED,THUNAR_COLUMN_NAME,THUNAR_COLUMN_SIZE,THUNAR_COLUMN_TYPE"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue