repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
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.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'
-- Key changes
-- - 6 redundant keymaps removedj(gra/gri/grn/grr/grt/CTRL-S — Neovim 0.11 defaults)
-- - 8 keymaps moved to buffer-local (grd, grwl, grwa, grwr, grc, grC, grh, grH)
-- - 3 new keymaps added (grD, grs, grl)
-- - Document highlight added (CursorHold + clear on CursorMoved)
-- - Codelens support added (grl + auto-refresh)
-- - LspRestart now: no args=buffer-local, bang=global, args=named
-- - LspReload uses vim.lsp.enable instead of deprecated stop_client
-- - Nil guards added to LspCapabilities/LspConfig
-- - Buffer-scoped inlay hint toggle
-- 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.colorizer'
require 'bugabinga.devicons'
require 'bugabinga.diff'
require 'bugabinga.file_explorer'
require 'bugabinga.format'
require 'bugabinga.fuzzy_find'
require 'bugabinga.bookmarks'
require 'bugabinga.jump2d'
require 'bugabinga.key_preview'
require 'bugabinga.move'
require 'bugabinga.navigation'
require 'bugabinga.patterns'
require 'bugabinga.search_and_replace'
require 'bugabinga.fun'
require 'bugabinga.splitjoin'
require 'bugabinga.surround'
require 'bugabinga.textobjects'
require 'bugabinga.winbar'
require 'bugabinga.suppress_warnings'
require 'bugabinga.autopairs'
require 'bugabinga.notify'
require 'bugabinga.incubator'