From c1e58a905bbdddf109dd3b7473edb2e8076d708b Mon Sep 17 00:00:00 2001
From: ben <ben@nagy.contact>
Date: Sat, 3 May 2025 14:28:00 -0700
Subject: current neovim config (lua)

---
 config/nvim/lua/core/autocmds.lua   | 38 +++++++++++++++++
 config/nvim/lua/core/keymaps.lua    | 57 ++++++++++++++++++++++++++
 config/nvim/lua/core/options.lua    | 38 +++++++++++++++++
 config/nvim/lua/core/statusline.lua | 82 +++++++++++++++++++++++++++++++++++++
 4 files changed, 215 insertions(+)
 create mode 100644 config/nvim/lua/core/autocmds.lua
 create mode 100644 config/nvim/lua/core/keymaps.lua
 create mode 100644 config/nvim/lua/core/options.lua
 create mode 100644 config/nvim/lua/core/statusline.lua

(limited to 'config/nvim/lua/core')

diff --git a/config/nvim/lua/core/autocmds.lua b/config/nvim/lua/core/autocmds.lua
new file mode 100644
index 0000000..3594112
--- /dev/null
+++ b/config/nvim/lua/core/autocmds.lua
@@ -0,0 +1,38 @@
+local augroup = vim.api.nvim_create_augroup
+local autocmd = vim.api.nvim_create_autocmd
+
+-- Compile LaTeX on Save
+autocmd("BufWritePost", {
+  pattern = "*.tex",
+  callback = function()
+    vim.fn.jobstart({ "pdflatex", vim.fn.expand("%:p") }, { stdout_buffered = true, stderr_buffered = true })
+  end,
+})
+
+-- Remove White Spaces on Save
+autocmd("BufWritePre", {
+	pattern = "*",
+	callback = function()
+		local currPos = vim.fn.getpos(".")
+		vim.cmd([[%s/\s\+$//e]])
+		vim.cmd([[%s/\n\+\%$//e]])
+		vim.fn.cursor(currPos[2], currPos[3])
+	end,
+})
+
+-- Stop Auto comemnting
+vim.api.nvim_create_autocmd("BufEnter", {
+  pattern = "*",
+  callback = function()
+    vim.opt.formatoptions:remove({ "r", "o" })
+    vim.opt_local.formatoptions:remove({ "r", "o" })
+  end,
+})
+
+-- let TabChars retain their assigned color
+vim.api.nvim_create_autocmd({"BufEnter", "TabNew", "WinEnter"}, {
+	pattern = "*",
+	callback = function()
+		vim.cmd("match TabChar /\t/")
+	end
+})
diff --git a/config/nvim/lua/core/keymaps.lua b/config/nvim/lua/core/keymaps.lua
new file mode 100644
index 0000000..3d6cc2a
--- /dev/null
+++ b/config/nvim/lua/core/keymaps.lua
@@ -0,0 +1,57 @@
+local keymap = vim.keymap
+
+-- <leader> -> \
+vim.g.mapleader = "\\"
+keymap.set("n", "<leader>pv", vim.cmd.Ex)
+
+-- alter indentation in visual mode
+keymap.set("v", "<", "<gv")
+keymap.set("v", ">", ">gv")
+
+-- Grab visual selection and place the line(s) anywhere
+keymap.set("v", "J", ":m '>+1<CR>gv=gv")
+keymap.set("v", "K", ":m '<-2<CR>gv=gv")
+
+-- Half-page Navigation, position preservation
+keymap.set("n", "<C-d>", "<C-d>zz")
+keymap.set("n", "<C-u>", "<C-u>zz")
+
+-- file-wide replace-substitution
+keymap.set("n", "<leader>r", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
+
+-- Make it executable
+keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
+
+-- Map CTRL-BS -> CTRL-W (delete prev. word)
+keymap.set("i", "<C-h>", "<C-\\><C-o>db", { noremap = true, silent = true })
+
+-- 2 fewer keystrokes to enter another file
+keymap.set("n", "E", ":e ")
+
+-- Get rid of this shit
+vim.api.nvim_set_keymap('n', 'q:', '<Nop>', { noremap = true, silent = true })
+
+-- Clear search highlight
+vim.api.nvim_set_keymap('n', '<Leader>cs', ':nohlsearch<CR><C-l>', { noremap = true, silent = true })
+
+
+--[[-- Tabs --]]
+
+-- Open a new tab
+keymap.set("n", "<M-n>", ":tabnew ", { noremap = true })
+
+-- Close the current tab
+keymap.set("n", "<C-n>", ":tabclose<CR>", { noremap = true, silent = true })
+
+-- Switch to the next tab (Normal, Insert, and Command modes)
+keymap.set("n", "<M-Tab>", ":<C-U>tabnext<CR>", { noremap = true })
+keymap.set("i", "<M-Tab>", "<C-\\><C-N>:tabnext<CR>", { noremap = true })
+keymap.set("c", "<M-Tab>", "<C-C>:tabnext<CR>", { noremap = true })
+
+-- Switch to the previous tab (Normal, Insert, and Command modes)
+keymap.set("n", "<S-Tab>", ":<C-U>tabprevious<CR>", { noremap = true })
+keymap.set("i", "<S-Tab>", "<C-\\><C-N>:tabprevious<CR>", { noremap = true })
+keymap.set("c", "<S-Tab>", "<C-C>:tabprevious<CR>", { noremap = true })
+
+-- Enable Spell Check
+keymap.set("n", "<leader>s", ":setlocal spell! spelllang=en_us<CR>", { silent = true })
diff --git a/config/nvim/lua/core/options.lua b/config/nvim/lua/core/options.lua
new file mode 100644
index 0000000..5796aef
--- /dev/null
+++ b/config/nvim/lua/core/options.lua
@@ -0,0 +1,38 @@
+local opt = vim.opt
+local cmd = vim.cmd
+
+-- Syntax and colors
+opt.termguicolors = true
+opt.background = "dark"
+opt.signcolumn = "yes"
+cmd("syntax on")
+
+-- Line Numbers
+opt.number = true
+opt.relativenumber = true
+
+-- Tabs
+opt.expandtab = false     -- Use tabs instead of spaces
+opt.tabstop = 4           -- Number of spaces a tab counts for
+opt.shiftwidth = 4        -- Number of spaces for auto-indentation
+opt.softtabstop = 4       -- Spaces used when hitting Tab or Backspace
+opt.smartindent = true
+opt.autoindent = true
+cmd("match TabChar /\t/")
+vim.opt.list = true
+vim.opt.listchars = { tab = ">." }
+
+-- File type detection
+vim.cmd("filetype on")
+vim.cmd("filetype plugin on")
+
+-- Mouse and clipboard
+vim.opt.mouse = ""
+vim.opt.clipboard = "unnamedplus"
+vim.api.nvim_set_keymap('v', 'yy', ':w !xclip -selection clipboard<CR><CR>',
+{ noremap = true, silent = true })
+
+-- MISC
+opt.swapfile = false
+opt.backup = false
+vim.opt.encoding = "utf-8"
diff --git a/config/nvim/lua/core/statusline.lua b/config/nvim/lua/core/statusline.lua
new file mode 100644
index 0000000..cc4bd09
--- /dev/null
+++ b/config/nvim/lua/core/statusline.lua
@@ -0,0 +1,82 @@
+local M = {}
+
+local branch_cache = ""
+local last_check = 0
+local check_interval = 1000 -- Check git branch every 1 second
+
+local function async_git_branch()
+    local check_time = vim.loop.now()
+    if check_time - last_check < check_interval then
+        return branch_cache
+    end
+    last_check = check_time
+
+    local stdout = vim.loop.new_pipe(false)
+    local stderr = vim.loop.new_pipe(false)
+
+    local handle
+    handle = vim.loop.spawn("git", {
+        args = { "branch", "--show-current" },
+        stdio = { nil, stdout, stderr }
+    }, function(code, signal)
+        stdout:close()
+        stderr:close()
+        handle:close()
+    end)
+
+    if handle then
+        stdout:read_start(vim.schedule_wrap(function(err, data)
+            if data then
+                branch_cache = data:gsub("\n", "")
+            end
+        end))
+    end
+
+    return branch_cache
+end
+
+function M.statusline_git()
+    local branch_name = async_git_branch()
+    return #branch_name > 0 and '  ' .. branch_name .. ' ' or ''
+end
+
+-- Rest of your statusline.lua remains exactly the same
+function M.setup()
+    vim.cmd('highlight clear StatusLine')
+    vim.cmd('highlight clear StatusLineNC')
+
+    local highlights = {
+        StatusLineGit      = { bg = "#161616", fg = "#D8DEE9" },
+        StatusLineBuffer   = { bg = "NONE",    fg = "#D8DEE9" },
+        StatusLine        = { bg = "NONE",    fg = "#D8DEE9" },
+        StatusLineFiletype = { bg = "NONE",    fg = "#D8DEE9" },
+        StatusLinePath     = { bg = "NONE",    fg = "#D8DEE9" },
+        StatusLineModified = { bg = "NONE",    fg = "#D8DEE9" },
+    }
+
+    for name, colors in pairs(highlights) do
+        vim.api.nvim_set_hl(0, name, colors)
+    end
+
+    vim.opt.statusline = table.concat({
+        "%#StatusLineGit#%{v:lua.require'core.statusline'.statusline_git()}",
+        "%#StatusLineBuffer# %n ",
+        "%#StatusLine#%{&ff} ",
+        "%#StatusLineFiletype#%y",
+        "%#StatusLinePath# %<%{expand('%:p:h')}/%f",
+        "%#StatusLineModified#%m",
+        "%=",
+        "%#StatusLine#%5l",
+        "/%L:%v ",
+        "%{char2nr(getline('.')[col('.')-1])} "
+    })
+end
+
+vim.api.nvim_create_autocmd("ColorScheme", {
+	pattern = "*",
+	callback = function()
+		M.setup()
+	end,
+})
+
+return M
-- 
cgit v1.2.3