Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
-- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution
-- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk.
local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(lazypath)

-- validate that lazy is available
if not pcall(require, "lazy") then
-- stylua: ignore
vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end

require "lazy_setup"
require "polish"
require("config.options")
require("config.lazy")
require("config.keymaps")
require("config.autocmds")
14 changes: 0 additions & 14 deletions nvim/lua/community.lua

This file was deleted.

65 changes: 65 additions & 0 deletions nvim/lua/config/autocmds.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- Autocommands

local augroup = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd

-- Auto-save on text change, insert leave, focus lost
autocmd({ "TextChanged", "InsertLeave", "FocusLost" }, {
group = augroup("auto_save", { clear = true }),
pattern = "*",
callback = function()
if vim.bo.modified and vim.bo.buftype == "" and vim.fn.expand("%") ~= "" then
vim.cmd("silent! write")
end
end,
})

-- Large file detection
local large_buf_group = augroup("large_buf", { clear = true })
autocmd("BufReadPre", {
group = large_buf_group,
callback = function(args)
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(args.buf))
if ok and stats and stats.size > 1024 * 500 then
vim.b[args.buf].large_buf = true
vim.opt_local.spell = false
vim.opt_local.swapfile = false
vim.opt_local.undofile = false
vim.opt_local.foldmethod = "manual"
-- Disable treesitter highlight for large files
pcall(function()
vim.treesitter.stop(args.buf)
end)
end
end,
})

-- Highlight on yank
autocmd("TextYankPost", {
group = augroup("highlight_yank", { clear = true }),
callback = function()
vim.highlight.on_yank({ timeout = 200 })
end,
})

-- Restore cursor position
autocmd("BufReadPost", {
group = augroup("restore_cursor", { clear = true }),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local line_count = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= line_count then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})

-- Close certain filetypes with q
autocmd("FileType", {
group = augroup("close_with_q", { clear = true }),
pattern = { "help", "qf", "man", "notify", "lspinfo", "checkhealth" },
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<Cmd>close<CR>", { buffer = event.buf, silent = true })
end,
})
39 changes: 39 additions & 0 deletions nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- Keymaps
local map = vim.keymap.set

-- Buffer navigation
map("n", "]b", "<Cmd>bnext<CR>", { desc = "Next buffer" })
map("n", "[b", "<Cmd>bprevious<CR>", { desc = "Previous buffer" })

-- Buffer close
map("n", "<Leader>bd", "<Cmd>bdelete<CR>", { desc = "Close buffer" })

-- Copy relative file path
map("n", "<Leader>cp", function()
local path = vim.fn.expand("%")
vim.fn.setreg("+", path)
vim.notify("Copied: " .. path)
end, { desc = "Copy relative file path" })

-- Window navigation
map("n", "<C-h>", "<C-w>h", { desc = "Move to left window" })
map("n", "<C-j>", "<C-w>j", { desc = "Move to lower window" })
map("n", "<C-k>", "<C-w>k", { desc = "Move to upper window" })
map("n", "<C-l>", "<C-w>l", { desc = "Move to right window" })

-- Resize windows
map("n", "<C-Up>", "<Cmd>resize +2<CR>", { desc = "Increase window height" })
map("n", "<C-Down>", "<Cmd>resize -2<CR>", { desc = "Decrease window height" })
map("n", "<C-Left>", "<Cmd>vertical resize -2<CR>", { desc = "Decrease window width" })
map("n", "<C-Right>", "<Cmd>vertical resize +2<CR>", { desc = "Increase window width" })

-- Move lines
map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move line down" })
map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move line up" })

-- Better indenting
map("v", "<", "<gv")
map("v", ">", ">gv")

-- Clear search highlights
map("n", "<Esc>", "<Cmd>nohlsearch<CR>", { desc = "Clear search highlights" })
28 changes: 28 additions & 0 deletions nvim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", lazypath,
})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
{ import = "plugins" },
}, {
install = { colorscheme = { "tokyonight-night", "habamax" } },
ui = { backdrop = 100 },
performance = {
rtp = {
disabled_plugins = {
"gzip",
"netrwPlugin",
"tarPlugin",
"tohtml",
"zipPlugin",
},
},
},
})
43 changes: 43 additions & 0 deletions nvim/lua/config/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- Options: vim.opt, vim.g settings
-- Must be loaded before lazy.nvim

vim.g.mapleader = " "
vim.g.maplocalleader = ","

-- Editor options
vim.opt.relativenumber = true
vim.opt.number = true
vim.opt.spell = false
vim.opt.signcolumn = "yes"
vim.opt.wrap = false
vim.opt.termguicolors = true
vim.opt.clipboard = "unnamedplus"
vim.opt.undofile = true
vim.opt.showmode = false
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.cursorline = true
vim.opt.scrolloff = 8
vim.opt.sidescrolloff = 8
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.updatetime = 300
vim.opt.timeoutlen = 500
vim.opt.completeopt = { "menu", "menuone", "noselect" }
vim.opt.shortmess:append("c")
vim.opt.fillchars = { eob = " " }

-- Folding (for nvim-ufo)
vim.opt.foldcolumn = "1"
vim.opt.foldlevel = 99
vim.opt.foldlevelstart = 99
vim.opt.foldenable = true

-- Diagnostics
vim.diagnostic.config({
virtual_text = true,
underline = true,
signs = true,
update_in_insert = false,
severity_sort = true,
})
32 changes: 0 additions & 32 deletions nvim/lua/lazy_setup.lua

This file was deleted.

Loading