LazyVim.LazyVim/lua/lazyvim/config/init.lua

316 lines
8.2 KiB
Lua
Raw Normal View History

_G.LazyVim = require("lazyvim.util")
2023-10-04 10:43:44 +02:00
---@class LazyVimConfig: LazyVimOptions
local M = {}
chore(main): release 14.9.0 (#5438) :robot: I have created a release *beep* *boop* --- ## [14.9.0](https://github.com/LazyVim/LazyVim/compare/v14.8.0...v14.9.0) (2025-01-30) ### Features * **markdown:** added markdown support for codecompanion ([e9db488](https://github.com/LazyVim/LazyVim/commit/e9db488acaa04f1a9eca6d022e57fed4271b8af8)) * **snacks.picker:** added &lt;leader&gt;si to search icons ([#5460](https://github.com/LazyVim/LazyVim/issues/5460)) ([eea52be](https://github.com/LazyVim/LazyVim/commit/eea52be3447502dde77d9e6fa75fd597a0b5a86a)) * **snacks.picker:** added &lt;leader&gt;su to search undotree ([#5447](https://github.com/LazyVim/LazyVim/issues/5447)) ([332b320](https://github.com/LazyVim/LazyVim/commit/332b32080c52727a16db90e06989caa0c378caa1)) * **snacks.picker:** added `leader-fB` to find any buffer (including hidden & nofile) ([83bf636](https://github.com/LazyVim/LazyVim/commit/83bf6360a1f28a3fc1afe31ae300247fc01c7a90)) * **snacks.picker:** added `leader-sp` to search for plugin spec ([7cf4185](https://github.com/LazyVim/LazyVim/commit/7cf4185dc4d1fe49ad004d33a6703603fb4500ff)) * **snacks.picker:** added alt-c to toggle between cwd/root dir ([6be7c4f](https://github.com/LazyVim/LazyVim/commit/6be7c4fee4fb755ff07f7bcc13eac96e1d8c279a)) * **snacks.picker:** flash.nvim integration ([5d24aa6](https://github.com/LazyVim/LazyVim/commit/5d24aa63111af68fbada8c97fedb75b07b8c3c92)) * **snacks.picker:** use snacks picker for notifications when enabled ([01a70cc](https://github.com/LazyVim/LazyVim/commit/01a70cc60ed2760afc819510177fb8d12a371b25)) * **snacks:** extra for snacks explorer (replacement for neo-tree) ([e20d9af](https://github.com/LazyVim/LazyVim/commit/e20d9afcbc980510093a3753a3991d8c934cbb75)) * **snippets:** an extra for mini.snippets ([#5274](https://github.com/LazyVim/LazyVim/issues/5274)) ([8b4e6ff](https://github.com/LazyVim/LazyVim/commit/8b4e6ff70d682cad3b1f4999623c3f0ac639fa82)) ### Bug Fixes * **keymaps:** remove unneeded and ambiguous `&lt;leader&gt;w` keymap ([#5459](https://github.com/LazyVim/LazyVim/issues/5459)) ([132986a](https://github.com/LazyVim/LazyVim/commit/132986a624b49bf740161d90ce94f16dd5ea5883)) * **luasnip:** schedule `jump` to be compatible with blink, nvim-cmp still works after change ([#5470](https://github.com/LazyVim/LazyVim/issues/5470)) ([0350934](https://github.com/LazyVim/LazyVim/commit/0350934d56579f3e6a9d40fa47313b2970d74772)) * **root:** pass args to root.get ([dc8512f](https://github.com/LazyVim/LazyVim/commit/dc8512fce1ec1cd4b0ca52d1077b2ed3894d51c8)) * **snacks.picker:** flash integration ([b5cd0d0](https://github.com/LazyVim/LazyVim/commit/b5cd0d0e27081be3ef1905475a0fe541b7661870)) * **snacks.picker:** snacks =&gt; flash ([3de7b24](https://github.com/LazyVim/LazyVim/commit/3de7b24cf6ed844772ea047476a400c56d5f4b42)) * **snacks:** use `Snacks.picker` for recent files ([#5485](https://github.com/LazyVim/LazyVim/issues/5485)) ([f0d2629](https://github.com/LazyVim/LazyVim/commit/f0d2629bd859eeac343999b0fe145f9beb227c4a)) * **sql:** better nvim-cmp check. Closes [#5188](https://github.com/LazyVim/LazyVim/issues/5188) ([1e83b4f](https://github.com/LazyVim/LazyVim/commit/1e83b4f843f88678189df81b1c88a400c53abdbc)) * **vscode:** diabled some snacks plugins. Fixes [#5364](https://github.com/LazyVim/LazyVim/issues/5364) ([c7a7ab5](https://github.com/LazyVim/LazyVim/commit/c7a7ab51129692927ae47f4e57ce22d10d48467e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-01-30 22:07:58 +01:00
M.version = "14.9.0" -- x-release-please-version
2024-03-29 09:45:31 +01:00
LazyVim.config = M
2023-10-04 10:43:44 +02:00
---@class LazyVimOptions
local defaults = {
-- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme
---@type string|fun()
colorscheme = function()
require("tokyonight").load()
end,
-- load the default settings
defaults = {
autocmds = true, -- lazyvim.config.autocmds
keymaps = true, -- lazyvim.config.keymaps
-- lazyvim.config.options can't be configured here since that's loaded before lazyvim setup
-- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua
},
news = {
-- When enabled, NEWS.md will be shown when changed.
-- This only contains big new features and breaking changes.
lazyvim = true,
-- Same but for Neovim's news.txt
neovim = false,
},
-- icons used by other plugins
2023-10-11 22:38:38 +02:00
-- stylua: ignore
icons = {
2023-10-03 14:56:28 +02:00
misc = {
dots = "󰇘",
},
ft = {
octo = "",
},
2023-04-16 21:35:38 +02:00
dap = {
2023-10-11 22:38:38 +02:00
Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" },
Breakpoint = "",
2023-04-16 21:35:38 +02:00
BreakpointCondition = "",
2023-10-11 22:38:38 +02:00
BreakpointRejected = { "", "DiagnosticError" },
LogPoint = ".>",
2023-04-16 21:35:38 +02:00
},
diagnostics = {
Error = "",
2023-10-11 22:38:38 +02:00
Warn = "",
Hint = "",
Info = "",
},
git = {
2023-10-11 22:38:38 +02:00
added = "",
modified = "",
2023-10-11 22:38:38 +02:00
removed = "",
},
kinds = {
2023-10-11 22:38:38 +02:00
Array = "",
Boolean = "󰨙 ",
Class = "",
Codeium = "󰘦 ",
Color = "",
Control = "",
Collapsed = "",
Constant = "󰏿 ",
Constructor = "",
Copilot = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "󰊕 ",
Interface = "",
Key = "",
Keyword = "",
Method = "󰊕 ",
Module = "",
Namespace = "󰦮 ",
Null = "",
Number = "󰎠 ",
Object = "",
Operator = "",
Package = "",
Property = "",
Reference = "",
2024-12-15 08:27:03 +01:00
Snippet = "󱄽 ",
2023-10-11 22:38:38 +02:00
String = "",
Struct = "󰆼 ",
Supermaven = "",
TabNine = "󰏚 ",
2023-10-11 22:38:38 +02:00
Text = "",
TypeParameter = "",
2023-10-11 22:38:38 +02:00
Unit = "",
Value = "",
Variable = "󰀫 ",
},
},
---@type table<string, string[]|boolean>?
kind_filter = {
default = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Namespace",
"Package",
"Property",
"Struct",
"Trait",
},
markdown = false,
help = false,
-- you can specify a different filter for each filetype
lua = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Namespace",
-- "Package", -- remove package since luals uses it for control flow structures
"Property",
"Struct",
"Trait",
},
},
}
M.json = {
version = 7,
path = vim.g.lazyvim_json or vim.fn.stdpath("config") .. "/lazyvim.json",
data = {
version = nil, ---@type string?
news = {}, ---@type table<string, string>
extras = {}, ---@type string[]
},
}
function M.json.load()
local f = io.open(M.json.path, "r")
if f then
local data = f:read("*a")
f:close()
local ok, json = pcall(vim.json.decode, data, { luanil = { object = true, array = true } })
if ok then
M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {})
if M.json.data.version ~= M.json.version then
LazyVim.json.migrate()
end
end
end
end
2023-10-04 10:43:44 +02:00
---@type LazyVimOptions
local options
local lazy_clipboard
2023-10-04 10:43:44 +02:00
---@param opts? LazyVimOptions
function M.setup(opts)
2023-10-04 10:43:44 +02:00
options = vim.tbl_deep_extend("force", defaults, opts or {}) or {}
-- autocmds can be loaded lazily when not opening a file
local lazy_autocmds = vim.fn.argc(-1) == 0
if not lazy_autocmds then
M.load("autocmds")
end
local group = vim.api.nvim_create_augroup("LazyVim", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = group,
pattern = "VeryLazy",
callback = function()
if lazy_autocmds then
M.load("autocmds")
end
M.load("keymaps")
if lazy_clipboard ~= nil then
vim.opt.clipboard = lazy_clipboard
end
LazyVim.format.setup()
LazyVim.news.setup()
LazyVim.root.setup()
vim.api.nvim_create_user_command("LazyExtras", function()
LazyVim.extras.show()
end, { desc = "Manage LazyVim extras" })
vim.api.nvim_create_user_command("LazyHealth", function()
vim.cmd([[Lazy! load all]])
vim.cmd([[checkhealth]])
end, { desc = "Load all plugins and run :checkhealth" })
local health = require("lazy.health")
vim.list_extend(health.valid, {
"recommended",
"desc",
"vscode",
})
end,
})
LazyVim.track("colorscheme")
LazyVim.try(function()
if type(M.colorscheme) == "function" then
M.colorscheme()
else
vim.cmd.colorscheme(M.colorscheme)
end
end, {
msg = "Could not load your colorscheme",
on_error = function(msg)
LazyVim.error(msg)
vim.cmd.colorscheme("habamax")
end,
})
LazyVim.track()
end
---@param buf? number
---@return string[]?
function M.get_kind_filter(buf)
buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf
local ft = vim.bo[buf].filetype
if M.kind_filter == false then
return
end
if M.kind_filter[ft] == false then
return
end
if type(M.kind_filter[ft]) == "table" then
return M.kind_filter[ft]
end
---@diagnostic disable-next-line: return-type-mismatch
return type(M.kind_filter) == "table" and type(M.kind_filter.default) == "table" and M.kind_filter.default or nil
end
---@param name "autocmds" | "options" | "keymaps"
function M.load(name)
local function _load(mod)
if require("lazy.core.cache").find(mod)[1] then
LazyVim.try(function()
require(mod)
end, { msg = "Failed loading " .. mod })
end
end
local pattern = "LazyVim" .. name:sub(1, 1):upper() .. name:sub(2)
-- always load lazyvim, then user file
if M.defaults[name] or name == "options" then
_load("lazyvim.config." .. name)
vim.api.nvim_exec_autocmds("User", { pattern = pattern .. "Defaults", modeline = false })
end
_load("config." .. name)
if vim.bo.filetype == "lazy" then
-- HACK: LazyVim may have overwritten options of the Lazy ui, so reset this here
vim.cmd([[do VimResized]])
end
2023-05-24 08:45:20 +02:00
vim.api.nvim_exec_autocmds("User", { pattern = pattern, modeline = false })
end
M.did_init = false
function M.init()
if M.did_init then
return
end
M.did_init = true
local plugin = require("lazy.core.config").spec.plugins.LazyVim
if plugin then
vim.opt.rtp:append(plugin.dir)
end
package.preload["lazyvim.plugins.lsp.format"] = function()
LazyVim.deprecate([[require("lazyvim.plugins.lsp.format")]], [[LazyVim.format]])
return LazyVim.format
end
2023-10-06 18:35:17 +02:00
-- delay notifications till vim.notify was replaced or after 500ms
LazyVim.lazy_notify()
-- load options here, before lazy init while sourcing plugin modules
-- this is needed to make sure options will be correctly applied
-- after installing missing plugins
M.load("options")
-- defer built-in clipboard handling: "xsel" and "pbcopy" can be slow
lazy_clipboard = vim.opt.clipboard
vim.opt.clipboard = ""
if vim.g.deprecation_warnings == false then
vim.deprecate = function() end
end
LazyVim.plugin.setup()
M.json.load()
end
setmetatable(M, {
__index = function(_, key)
if options == nil then
return vim.deepcopy(defaults)[key]
end
---@cast options LazyVimConfig
return options[key]
end,
})
return M