fbb6655722
NOTE: lua/lazyload.lua is an MIT licensed file borrowed from another user's repository. The license header in that file reflects this.
69 lines
2.6 KiB
Lua
69 lines
2.6 KiB
Lua
--[[
|
|
┌────────────────────────────────────────────────────────────────┐
|
|
│ Options │
|
|
└────────────────────────────────────────────────────────────────┘
|
|
--]]
|
|
|
|
-- Copyright (C) 2026 rootiest
|
|
--
|
|
-- This program is free software: you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
--
|
|
-- This program is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
-- GNU General Public License for more details.
|
|
--
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
-- Autowrite/Autosave
|
|
-- This ensures changes are saved on every buffer change or when leaving insert mode.
|
|
vim.api.nvim_create_autocmd({ "InsertLeave", "TextChanged" }, {
|
|
group = vim.api.nvim_create_augroup("autosave", { clear = true }),
|
|
pattern = { "*" },
|
|
callback = function()
|
|
local buftype = vim.api.nvim_get_option_value("buftype", { buf = 0 })
|
|
if buftype == "" and vim.bo.modified then
|
|
vim.cmd("silent! update")
|
|
end
|
|
end,
|
|
})
|
|
|
|
-- Performance and UI defaults
|
|
vim.opt.updatetime = 200 -- Faster completion and CursorHold events
|
|
vim.opt.autowrite = true -- Enable auto write
|
|
vim.opt.number = true -- Show line numbers
|
|
vim.opt.relativenumber = true -- Relative line numbers
|
|
|
|
-- Persistent undo across sessions
|
|
vim.opt.undofile = true
|
|
|
|
-- Indentation
|
|
vim.opt.tabstop = 2 -- Tab width in spaces
|
|
vim.opt.shiftwidth = 2 -- Indent width for >> and auto-indent
|
|
vim.opt.expandtab = true -- Use spaces instead of tabs
|
|
|
|
-- FormatOnSave
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = "*",
|
|
callback = function(args)
|
|
require("conform").format({ bufnr = args.buf })
|
|
end,
|
|
})
|
|
|
|
-- Execute Format
|
|
vim.api.nvim_create_user_command("Format", function(args)
|
|
local range = nil
|
|
if args.count ~= -1 then
|
|
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
|
range = {
|
|
start = { args.line1, 0 },
|
|
["end"] = { args.line2, end_line:len() },
|
|
}
|
|
end
|
|
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
|
end, { range = true })
|