neotree shortcuts
This commit is contained in:
parent
1a228b6827
commit
f1d71dacb3
6 changed files with 77 additions and 7 deletions
|
@ -1,2 +1,4 @@
|
||||||
require("custom")
|
_G.Custom = require("custom")
|
||||||
|
_G.Lib = require("lib")
|
||||||
|
|
||||||
require("config.lazy")
|
require("config.lazy")
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
---@class custom
|
---@class custom
|
||||||
---@field ui custom.ui
|
---@field ui custom.ui
|
||||||
---@field language custom.language
|
---@field language custom.language
|
||||||
|
---@field shortcuts custom.shortcuts
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
_G.Custom = M
|
|
||||||
|
|
||||||
setmetatable(M, {
|
setmetatable(M, {
|
||||||
__index = function(_, k)
|
__index = function(_, k)
|
||||||
return require("custom." .. k)
|
return require("custom." .. k)
|
||||||
|
|
22
.config/nvim/lua/custom/shortcuts.lua
Normal file
22
.config/nvim/lua/custom/shortcuts.lua
Normal file
|
@ -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",
|
||||||
|
}
|
15
.config/nvim/lua/lib.lua
Normal file
15
.config/nvim/lua/lib.lua
Normal file
|
@ -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
|
20
.config/nvim/lua/plugins/editor.lua
Normal file
20
.config/nvim/lua/plugins/editor.lua
Normal file
|
@ -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
|
#!/bin/sh
|
||||||
|
|
||||||
|
zsh=$ZDOTDIR/configs/hashes
|
||||||
|
lf=$XDG_CONFIG_HOME/lf/shortcuts
|
||||||
|
nvim=$XDG_CONFIG_HOME/nvim/lua/custom/shortcuts.lua
|
||||||
|
|
||||||
clean() {
|
clean() {
|
||||||
echo >"$ZDOTDIR/configs/hashes"
|
echo "# NOTE: Managed by shortcuts script" >"$zsh"
|
||||||
echo >"$XDG_CONFIG_HOME/lf/shortcuts"
|
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() {
|
write() {
|
||||||
|
@ -11,8 +20,9 @@ write() {
|
||||||
path=$(echo "$line" | cut -d' ' -f2)
|
path=$(echo "$line" | cut -d' ' -f2)
|
||||||
path=$(eval "echo $path")
|
path=$(eval "echo $path")
|
||||||
|
|
||||||
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"$ZDOTDIR/configs/hashes"
|
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"$zsh"
|
||||||
printf "map g%s cd %s\n" "$shortcut" "$path" >>"$XDG_CONFIG_HOME/lf/shortcuts"
|
printf "map g%s cd %s\n" "$shortcut" "$path" >>"$lf"
|
||||||
|
printf " g%s = \"%s\",\n" "$shortcut" "$path" >>"$nvim"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,3 +34,5 @@ filter() {
|
||||||
clean
|
clean
|
||||||
|
|
||||||
filter "$XDG_CONFIG_HOME/directories" | write
|
filter "$XDG_CONFIG_HOME/directories" | write
|
||||||
|
|
||||||
|
finalize
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue