neotree shortcuts
This commit is contained in:
parent
1a228b6827
commit
f1d71dacb3
|
@ -1,2 +1,4 @@
|
|||
require("custom")
|
||||
_G.Custom = require("custom")
|
||||
_G.Lib = require("lib")
|
||||
|
||||
require("config.lazy")
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
---@class custom
|
||||
---@field ui custom.ui
|
||||
---@field language custom.language
|
||||
---@field shortcuts custom.shortcuts
|
||||
local M = {}
|
||||
|
||||
_G.Custom = M
|
||||
|
||||
setmetatable(M, {
|
||||
__index = function(_, k)
|
||||
return require("custom." .. k)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
-- NOTE: Managed by shortcuts script
|
||||
---@class custom.shortcuts
|
||||
return {
|
||||
gh = "/home/luca",
|
||||
gch = "/home/luca/.cache",
|
||||
gcf = "/home/luca/.config",
|
||||
gdt = "/home/luca/.local/share",
|
||||
gst = "/home/luca/.local/state",
|
||||
gsc = "/home/luca/.local/bin",
|
||||
gle = "/home/luca/.local/libexec",
|
||||
gmn = "/mnt",
|
||||
gco = "/home/luca/Documents/dev",
|
||||
gdl = "/home/luca/Downloads",
|
||||
gdm = "/home/luca/Documents",
|
||||
gdk = "/home/luca/Desktop",
|
||||
gms = "/home/luca/Music",
|
||||
gpc = "/home/luca/Pictures",
|
||||
gvd = "/home/luca/Videos",
|
||||
gds = "/home/luca/.local/share/stow/dots",
|
||||
glg = "/home/luca/.local/log",
|
||||
gsv = "/home/luca/.local/sv",
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
local M = {}
|
||||
|
||||
---@returns table<string, function>
|
||||
function M.generate_shortcut_maps()
|
||||
local shortcuts = Custom.shortcuts
|
||||
local fs = require("neo-tree.sources.filesystem")
|
||||
local maps = {}
|
||||
for map, path in pairs(shortcuts) do
|
||||
maps[map] = function(state)
|
||||
fs._navigate_internal(state, path, nil, nil, false)
|
||||
end
|
||||
end
|
||||
return maps
|
||||
end
|
||||
return M
|
|
@ -0,0 +1,20 @@
|
|||
return {
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.filesystem = {
|
||||
window = {
|
||||
mappings = Lib.generate_shortcut_maps(),
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
opts = {
|
||||
highlight = {
|
||||
multiline = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
|
@ -1,8 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
zsh=$ZDOTDIR/configs/hashes
|
||||
lf=$XDG_CONFIG_HOME/lf/shortcuts
|
||||
nvim=$XDG_CONFIG_HOME/nvim/lua/custom/shortcuts.lua
|
||||
|
||||
clean() {
|
||||
echo >"$ZDOTDIR/configs/hashes"
|
||||
echo >"$XDG_CONFIG_HOME/lf/shortcuts"
|
||||
echo "# NOTE: Managed by shortcuts script" >"$zsh"
|
||||
echo "# NOTE: Managed by shortcuts script" >"$lf"
|
||||
printf "%s\n%s\n%s\n" "-- NOTE: Managed by shortcuts script" "---@class custom.shortcuts" "return {" >"$nvim"
|
||||
}
|
||||
|
||||
finalize() {
|
||||
echo "}" >>"$nvim"
|
||||
}
|
||||
|
||||
write() {
|
||||
|
@ -11,8 +20,9 @@ write() {
|
|||
path=$(echo "$line" | cut -d' ' -f2)
|
||||
path=$(eval "echo $path")
|
||||
|
||||
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"$ZDOTDIR/configs/hashes"
|
||||
printf "map g%s cd %s\n" "$shortcut" "$path" >>"$XDG_CONFIG_HOME/lf/shortcuts"
|
||||
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"$zsh"
|
||||
printf "map g%s cd %s\n" "$shortcut" "$path" >>"$lf"
|
||||
printf " g%s = \"%s\",\n" "$shortcut" "$path" >>"$nvim"
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -24,3 +34,5 @@ filter() {
|
|||
clean
|
||||
|
||||
filter "$XDG_CONFIG_HOME/directories" | write
|
||||
|
||||
finalize
|
||||
|
|
Loading…
Reference in New Issue