From 736ff3bef453c7170a2bf7a49555b596de109fb7 Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Sun, 14 Sep 2025 02:33:21 +0100 Subject: [PATCH] feat: initial NEAR functional commit This commit is enough to make nvim start and bootstrap lazy to actually use this commit as a base for your own config - Add the directory 'lua/plugins/spec' - Place plugin specs there - Edit configuration as needed --- .pre-commit-config.yaml | 12 +++++ init.lua | 1 + lazy-lock.json | 4 ++ lua/core/autocommands.lua | 30 ++++++++++++ lua/core/init.lua | 9 ++++ lua/core/options.lua | 96 +++++++++++++++++++++++++++++++++++++++ lua/plugins/lazy/init.lua | 23 ++++++++++ 7 files changed, 175 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/core/autocommands.lua create mode 100644 lua/core/init.lua create mode 100644 lua/core/options.lua create mode 100644 lua/plugins/lazy/init.lua diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1d02f32 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: check-toml + - id: check-yaml + - id: mixed-line-ending + - repo: https://github.com/JohnnyMorganz/StyLua + rev: v0.18.0 + hooks: + - id: stylua # or stylua-system / stylua-github diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..93750f5 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("core").setup() diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..850d50f --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,4 @@ +{ + "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" } +} diff --git a/lua/core/autocommands.lua b/lua/core/autocommands.lua new file mode 100644 index 0000000..8eb56e1 --- /dev/null +++ b/lua/core/autocommands.lua @@ -0,0 +1,30 @@ +-- Control cursorline option +-- This function allows the easy creation of autocommands that configure cursorline for one buffer +-- either based on events or filetypes +local auGroupCursorLine = vim.api.nvim_create_augroup("CursorLine", { clear = true }) +local set_cursorline = function(event, value, pattern) + vim.api.nvim_create_autocmd(event, { + group = auGroupCursorLine, + pattern = pattern, + callback = function() + vim.opt_local.cursorline = value + end, + }) +end +set_cursorline("WinLeave", false) +set_cursorline("WinEnter", true) +set_cursorline("FileType", false, "TelescopePrompt") + +-- Wrangle formatoptions +-- Format options is local to the buffer +-- This autocommand fixes formatoptions for all buffers at load +local auGroupFormatOptions = vim.api.nvim_create_augroup("FormatOptions", { clear = true }) +vim.api.nvim_create_autocmd("FileType", { + group = auGroupFormatOptions, + pattern = "*", + callback = function() + vim.opt.formatoptions = vim.opt.formatoptions -- take the default + - "r" -- remove auto commenting + - "o" -- and for newlines + end, +}) diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..56cac13 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,9 @@ +local M = {} + +M.setup = function() + require("core.options") + require("core.autocommands") + require("plugins.lazy") +end + +return M diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..10f8c26 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,96 @@ +-- Default options for all file types + +local opt = vim.opt -- lazy shortcut to save on typing + +vim.g.mapleader = "\\" +vim.g.maplocalleader = "," + +-- Show line number for current line +-- And the relative line for all others +opt.relativenumber = true +opt.number = true + +-- Make searching easier +opt.ignorecase = true -- Searching should not care about case +opt.smartcase = true -- except from when you specify it in the search +opt.hlsearch = true -- highlights all searches (this is now a Nvim DEFAULT) +opt.incsearch = ture -- begins searching as you type (also a DEFAULT) + +-- Split in a more sensible manner +-- Splits go to the right or bottom keeping the original in the top left +-- This is similar to the dwm/dwl attachtop patch +opt.splitright = true +opt.splitbelow = true + +-- Setting timeout allows whichkey to appear much faster +-- In this case immediately +opt.timeout = true +opt.timeoutlen = 0 + +-- Keep more context on screen where possible +opt.scrolloff = 15 +opt.sidescroll = 6 + +-- Force full 24 colour support +-- Nvim should detect this but it doesn't always +opt.termguicolors = true + +-- let Nvim set terminal title +opt.title = true + +-- Set default spell language (correctly this time) +opt.spelllang = "en_gb" + +-- Ignore some files (compiled) when expanding or globbing +opt.wildignore = { + "*pycache*", + "*.o", + "*~", + "*.pyc", + "*.pdf", +} + +-- configure folding +opt.foldmethod = "expr" -- use an expression for folding +opt.foldexpr = "nvim_treesitter#foldexpr()" -- Use treesitter to fold +opt.foldminlines = 5 -- don't fold small items +opt.foldclose = "all" -- close any out of focus fold +opt.foldlevelstart = 1 -- always show top level + +-- configure sign column (this is used by some plugins) +opt.signcolumn = "auto:2-5" -- auto-size from 2 to 5 cells + +-- highlight the line the cursor is on +opt.cursorline = true + +-- UI +opt.showmode = false -- do not show current mode (this is done by my statusline plugin) +opt.showcmd = true +opt.cmdheight = 1 +opt.background = "dark" +opt.laststatus = 0 + +-- indentation & wrapping +opt.autoindent = true -- inherit indenting when adding new lines +opt.cindent = true +opt.wrap = true -- long lines will wrap + +opt.tabstop = 4 -- medium tabs +opt.shiftwidth = 4 +opt.softtabstop = 4 +opt.expandtab = false -- Tabs > Spaces Tab Supremacy!! + +opt.breakindent = true -- make it easier to see where line wrapping occured +opt.showbreak = "" +opt.linebreak = true + +-- MISC +opt.belloff = "all" -- no window flashing or beeping +opt.clipboard = "unnamedplus" -- clipboard links to system clipboard (providing appropriate tools are installed) +opt.mouse = "a" -- use mouse in all modes + +opt.shortmess = "" + .. "s" -- don't give search messages + .. "W" -- don't give file written messages + .. "I" -- don't give intro message + .. "F" -- don't give file info when editing diff --git a/lua/plugins/lazy/init.lua b/lua/plugins/lazy/init.lua new file mode 100644 index 0000000..299852f --- /dev/null +++ b/lua/plugins/lazy/init.lua @@ -0,0 +1,23 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { + { import = "plugins.spec" }, + }, + + checker = { enabled = true }, +})