Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

neovim/init.lua

Raw
-- A Neovim configuration, again...
--
-- ███     ▄     ▄▀  ██   ███   ▄█    ▄     ▄▀  ██
-- █  █     █  ▄▀    █ █  █  █  ██     █  ▄▀    █ █
-- █ ▀ ▄ █   █ █ ▀▄  █▄▄█ █ ▀ ▄ ██ ██   █ █ ▀▄  █▄▄█
-- █  ▄▀ █   █ █   █ █  █ █  ▄▀ ▐█ █ █  █ █   █ █  █
-- ███   █▄ ▄█  ███     █ ███    ▐ █  █ █  ███     █
--        ▀▀▀          █           █   ██         █
--                    ▀                          ▀

local version = vim.version()
local expected = { major = 0, minor = 12 }
if version.major ~= expected.major or version.minor ~= expected.minor then
	vim.notify(
		'This configuration assumes NeoVim version ' ..
		expected.major .. '.' .. expected.minor .. ', but it is ' .. version.major .. '.' .. version.minor .. '!',
		vim.log.levels.ERROR )
	return
end

-- setup debug mode
vim.g.bugabinga_debug_mode = false
-- start `profiler.nvim` with `NVIM_PROFILE=1 nvim ...` to instrument all modules,
-- but not start profiler yet.
-- or `NVIM_PROFILE=start nvim ...` to start the profiler on startup
-- then hit <F12> to save profile.
-- inspect profile on https://ui.perfetto.dev
require 'bugabinga.profile'

local start_time = vim.uv.hrtime()
local auto = require 'std.auto'
auto 'measure_startup_time' {
	events = 'VimEnter',
	description = 'Measure startup time of neovim.',
	once = true,
	command = function ()
		local end_time = vim.uv.hrtime() ---@diagnostic disable-line: undefined-field
		local time_elapsed = end_time - start_time
		vim.schedule( function ()
			local time_elapsed_ms = time_elapsed / 1e6
			local msg = string.format( 'Neovim started in (%d ms).', time_elapsed_ms )
			vim.notify( msg, vim.log.levels.INFO )
		end )
	end,
}

vim.cmd.colorscheme 'nugu'

require 'patches'

--- Defers loading the module to end of vim main loop.
--- Useful for modules, that need not be loaded immediately on nvim startup.
---
--- @see require
local defer = vim.schedule_wrap( require )

--- Some modules need to be loaded immediately, when vim is started with parameters (files or folders),
--- but could be deferred, when vim is started 'naked'.
--- This function does that.
--- If vim was started with no arguments, it defers loading the module, otherwise it is loaded immediately.
---
--- @param module_name string Name of lua module
local defer_on_naked = function ( module_name )
	local now_if_args = vim.fn.argc( -1 ) > 0 and require or defer
	now_if_args( module_name )
end

--[[ MY STUFF ]]
require 'bugabinga.options'
defer_on_naked 'bugabinga.treesitter'
defer_on_naked 'bugabinga.lsp'
defer_on_naked 'bugabinga.bigfile'
defer_on_naked 'bugabinga.file_changed'
defer_on_naked 'bugabinga.editorconfig'
defer 'bugabinga.sessions'
defer 'bugabinga.statusline'
defer 'bugabinga.diagnostic'
defer 'bugabinga.cmdline'
defer 'bugabinga.snippet'
defer 'bugabinga.code_action'
defer 'bugabinga.mkdir'
defer 'bugabinga.cycle'
defer 'bugabinga.terminal'
defer 'bugabinga.inlay'
defer 'bugabinga.d2'
defer 'bugabinga.pivi'
defer 'bugabinga.pivi_status'
defer 'bugabinga.pivi_keys'

-- Plugins handle deferred loading via puk.
-- No need to use `defer(...)`

--[[ PLUGINS ]]
--TODO: slowly move over plugins to "my stuff"
require 'bugabinga.autotag'
require 'bugabinga.devicons'
defer 'bugabinga.diff'
require 'bugabinga.file_explorer'
require 'bugabinga.format'
defer 'bugabinga.fuzzy_find'
defer 'bugabinga.jump2d'
defer 'bugabinga.key_preview'
defer 'bugabinga.move'
defer 'bugabinga.navigation'
defer 'bugabinga.patterns'
defer 'bugabinga.search_and_replace'
defer 'bugabinga.fun'
defer 'bugabinga.splitjoin'
require 'bugabinga.surround'
require 'bugabinga.textobjects'
defer 'bugabinga.winbar'
require 'bugabinga.suppress_warnings'
require 'bugabinga.autopairs'
defer 'bugabinga.notify'

require 'bugabinga.incubator'