diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 3cff727fc..3bda8bed8 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,2 +1,4 @@ -require("custom") +_G.Custom = require("custom") +_G.Lib = require("lib") + require("config.lazy") diff --git a/.config/nvim/lua/custom/init.lua b/.config/nvim/lua/custom/init.lua index 5b4ab48e9..f36873d37 100644 --- a/.config/nvim/lua/custom/init.lua +++ b/.config/nvim/lua/custom/init.lua @@ -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) diff --git a/.config/nvim/lua/custom/shortcuts.lua b/.config/nvim/lua/custom/shortcuts.lua new file mode 100644 index 000000000..ebc1d8ca5 --- /dev/null +++ b/.config/nvim/lua/custom/shortcuts.lua @@ -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", +} diff --git a/.config/nvim/lua/lib.lua b/.config/nvim/lua/lib.lua new file mode 100644 index 000000000..476bc4e7b --- /dev/null +++ b/.config/nvim/lua/lib.lua @@ -0,0 +1,15 @@ +local M = {} + +---@returns table +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 diff --git a/.config/nvim/lua/plugins/editor.lua b/.config/nvim/lua/plugins/editor.lua new file mode 100644 index 000000000..1890cde2d --- /dev/null +++ b/.config/nvim/lua/plugins/editor.lua @@ -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, + }, + }, + }, +} diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index bc47f9e85..bc0ad9de6 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -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