Browse Source

feat: update lua config to source .nvim.lua if the file exists

master
Tovi Jaeschke-Rogers 1 week ago
parent
commit
174b4b1537
5 changed files with 44 additions and 65 deletions
  1. +5
    -3
      .config/alacritty/alacritty.toml
  2. +26
    -0
      .config/nvim/lua/core/autocmd.lua
  3. +0
    -56
      .config/nvim/lua/core/commands.lua
  4. +0
    -6
      .config/zsh/.zshrc
  5. +13
    -0
      .local/bin/remap-keys

+ 5
- 3
.config/alacritty/alacritty.toml View File

@ -1,6 +1,3 @@
import = [
"~/.config/alacritty/themes/kanagawa_wave.toml"
]
[env]
TERM = "xterm-256color"
@ -28,3 +25,8 @@ style = "Regular"
action = "SpawnNewInstance"
key = "Return"
mods = "Control|Shift"
[general]
import = [
"~/.config/alacritty/themes/kanagawa_wave.toml"
]

+ 26
- 0
.config/nvim/lua/core/autocmd.lua View File

@ -1,4 +1,30 @@
local aucmd_dict = {
VimEnter = {
{
callback = function()
local function find_project_root()
local current_dir = vim.fn.getcwd()
while current_dir ~= "/" do
if vim.fn.isdirectory(current_dir .. "/.git") == 1 or vim.fn.filereadable(current_dir .. "/.nvim.lua") then
return current_dir
end
current_dir = vim.fn.fnamemodify(current_dir, ":h")
end
return vim.fn.getcwd()
end
local project_root = find_project_root()
local project_specific_conf_file = project_root .. "/.nvim.lua"
if vim.fn.filereadable(project_specific_conf_file) == 1 then
vim.cmd("source " .. project_specific_conf_file)
print("Sourced project specific config file: " .. project_specific_conf_file)
end
end
}
},
FileType = {
{
-- Set tabstop to 2 for Dart, Vue, JavaScript, TypeScript, and JSON files


+ 0
- 56
.config/nvim/lua/core/commands.lua View File

@ -24,59 +24,3 @@ vim.api.nvim_create_user_command("ClearBuffers", function()
vim.cmd('%bd|e#|bd#')
end, {})
local function load_env_file()
local env_file_path = vim.fn.getcwd() .. "/.env" -- Construct the path relative to the current working directory
local env_file = io.open(env_file_path, "r") -- Open the .env file
if not env_file then
print("Could not open .env file")
return
end
for line in env_file:lines() do
local key, value = line:match("^(%S+)=(%S+)")
if key and value then
vim.env[key] = value
end
end
env_file:close()
end
local function sync_file_to_sftp()
load_env_file()
-- Get SFTP credentials from environment variables
local sftp_user = os.getenv("SFTP_USER")
local sftp_host = os.getenv("SFTP_HOST")
local sftp_port = os.getenv("SFTP_PORT")
local sftp_password = os.getenv("SFTP_PASSWORD")
local sftp_theme_directory = os.getenv("SFTP_THEME_DIRECTORY")
local current_file = vim.fn.expand("%:p") -- Get the full path of the current file
-- Define your project root path
local project_root = vim.fn.getcwd() -- Current working directory where Neovim was launched
local relative_path = current_file:sub(#project_root + 1)
-- Construct the full remote path
local remote_path = sftp_theme_directory .. relative_path -- Append the relative path to the remote base path
-- Command to sync the file using lftp
local lftp_cmd = string.format(
"lftp -u %s,%s sftp://%s:%s -e 'put %s -o %s; bye' > /dev/null 2>&1",
sftp_user,
sftp_password,
sftp_host,
sftp_port,
current_file,
remote_path
)
-- Execute the command
os.execute(lftp_cmd)
print("File synced to SFTP server: " .. remote_path)
end
-- Map the function to a command in Neovim
vim.api.nvim_create_user_command("SyncToNeto", sync_file_to_sftp, {})

+ 0
- 6
.config/zsh/.zshrc View File

@ -114,11 +114,5 @@ if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
fi
if type "pyenv" > /dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
# Speed debugging
# zprof

+ 13
- 0
.local/bin/remap-keys View File

@ -0,0 +1,13 @@
#!/bin/bash
# Get current state of Caps Lock and Escape key swap
current_state=$(setxkbmap -query | grep options | grep "caps:escape" | wc -l)
# If the swap is off, turn it on; otherwise, turn it off
if [ $current_state -eq 0 ]; then
echo "Swapping Caps Lock and Escape..."
setxkbmap -option caps:escape
else
echo "Reverting to normal layout..."
setxkbmap -option
fi

Loading…
Cancel
Save