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

307 lines
7.8 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 12.21.0 (#3827) :robot: I have created a release *beep* *boop* --- ## [12.21.0](https://github.com/LazyVim/LazyVim/compare/v12.20.1...v12.21.0) (2024-06-29) ### Features * **extras:** add `overseer.nvim` plugin extra ([#2421](https://github.com/LazyVim/LazyVim/issues/2421)) ([683bf52](https://github.com/LazyVim/LazyVim/commit/683bf52c024306f9c0fccc2b02348692c3f09bfa)) * **extras:** add chezmoi extra ([#2859](https://github.com/LazyVim/LazyVim/issues/2859)) ([88f2541](https://github.com/LazyVim/LazyVim/commit/88f25410e020fe64fe42a94d71f0be3db1b918b4)) * **extras:** switch to markdownlint-cli2 ([#3843](https://github.com/LazyVim/LazyVim/issues/3843)) ([f47d105](https://github.com/LazyVim/LazyVim/commit/f47d105b80dce615a572a13351a137653444d548)) * **java:** enable Lombok support in jdtls ([#3852](https://github.com/LazyVim/LazyVim/issues/3852)) ([0fede40](https://github.com/LazyVim/LazyVim/commit/0fede4040b15da7e74c6a741132ff3d48634c1ad)) ### Bug Fixes * **bufremove:** fix `Cancel` ([#3834](https://github.com/LazyVim/LazyVim/issues/3834)) ([87fe403](https://github.com/LazyVim/LazyVim/commit/87fe403df62fd8b89b886920c4f562da8e162cbe)) * **edgy:** improve edgy.lua bufferline offset logic ([#3794](https://github.com/LazyVim/LazyVim/issues/3794)) ([566753b](https://github.com/LazyVim/LazyVim/commit/566753b8889a6132f2e667606a6a002fdd8847b1)) * **extras:** don't load pkgs when parsing specs for LazyExtras ([3764735](https://github.com/LazyVim/LazyVim/commit/3764735fb20596dfc9cd0707d2830a40004c7f0e)) * **gitsigns:** fix inconsistent signs ([#3830](https://github.com/LazyVim/LazyVim/issues/3830)) ([44ed11c](https://github.com/LazyVim/LazyVim/commit/44ed11c4f8867cdc887fdcba6a22938125a403ee)) * **lazygit:** fix browsing private git hostings ([#3833](https://github.com/LazyVim/LazyVim/issues/3833)) ([b292a72](https://github.com/LazyVim/LazyVim/commit/b292a721bfce1b079428a3a42aa9ea3454c5692d)) * **lint:** make prepend_args opt work when default args is empty ([#3828](https://github.com/LazyVim/LazyVim/issues/3828)) ([ff1b44e](https://github.com/LazyVim/LazyVim/commit/ff1b44e67606080b8b40d066943c55c92856e3c6)) * **neotest:** support adapter key on adapter for playwright ([#3824](https://github.com/LazyVim/LazyVim/issues/3824)) ([e5e8d7a](https://github.com/LazyVim/LazyVim/commit/e5e8d7a8056a8c80456751385e73a4b184bcd436)) * **pick:** set recurse_submodules to false when using `auto` picker. Fixes [#3831](https://github.com/LazyVim/LazyVim/issues/3831), Closes [#3835](https://github.com/LazyVim/LazyVim/issues/3835) ([d6429a5](https://github.com/LazyVim/LazyVim/commit/d6429a5c8ad317057cb852d3cd67ce52e9c30727)) --- 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>
2024-06-29 12:19:44 +02:00
M.version = "12.21.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 = "",
Snippet = "",
String = "",
Struct = "󰆼 ",
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 = {
2024-05-30 14:41:13 +02:00
version = 6,
data = {
version = nil, ---@type string?
news = {}, ---@type table<string, string>
extras = {}, ---@type string[]
},
}
function M.json.load()
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
local f = io.open(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
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")
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
-- always load lazyvim, then user file
if M.defaults[name] or name == "options" then
_load("lazyvim.config." .. name)
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
local pattern = "LazyVim" .. name:sub(1, 1):upper() .. name:sub(2)
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")
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