diff options
Diffstat (limited to 'mac/.config/LunarVim/lua/lvim/config')
| -rw-r--r-- | mac/.config/LunarVim/lua/lvim/config/_deprecated.lua | 215 | ||||
| -rw-r--r-- | mac/.config/LunarVim/lua/lvim/config/defaults.lua | 75 | ||||
| -rw-r--r-- | mac/.config/LunarVim/lua/lvim/config/init.lua | 108 | ||||
| -rw-r--r-- | mac/.config/LunarVim/lua/lvim/config/settings.lua | 120 |
4 files changed, 518 insertions, 0 deletions
diff --git a/mac/.config/LunarVim/lua/lvim/config/_deprecated.lua b/mac/.config/LunarVim/lua/lvim/config/_deprecated.lua new file mode 100644 index 0000000..ebcdbe9 --- /dev/null +++ b/mac/.config/LunarVim/lua/lvim/config/_deprecated.lua @@ -0,0 +1,215 @@ +---@diagnostic disable: deprecated +local M = {} + +local function deprecate(name, alternative) + local in_headless = #vim.api.nvim_list_uis() == 0 + if in_headless then + return + end + + alternative = alternative or "See https://github.com/LunarVim/LunarVim#breaking-changes" + + local trace = debug.getinfo(3, "Sl") + local shorter_src = trace.short_src + local t = shorter_src .. ":" .. (trace.currentline or trace.lastlinedefined) + vim.schedule(function() + vim.notify_once(string.format("%s: `%s` is deprecated.\n %s.", t, name, alternative), vim.log.levels.WARN) + end) +end + +function M.handle() + local mt = { + __newindex = function(_, k, _) + deprecate(k) + end, + } + + ---@deprecated + lvim.builtin.theme.options = {} + setmetatable(lvim.builtin.theme.options, { + __newindex = function(_, k, v) + deprecate("lvim.builtin.theme.options." .. k, "Use `lvim.builtin.theme.<theme>.options` instead") + lvim.builtin.theme.tokyonight.options[k] = v + end, + }) + + ---@deprecated + lvim.builtin.notify = {} + setmetatable(lvim.builtin.notify, { + __newindex = function(_, k, _) + deprecate("lvim.builtin.notify." .. k, "See LunarVim#3294") + end, + }) + + ---@deprecated + lvim.builtin.dashboard = {} + setmetatable(lvim.builtin.dashboard, { + __newindex = function(_, k, _) + deprecate("lvim.builtin.dashboard." .. k, "Use `lvim.builtin.alpha` instead. See LunarVim#1906") + end, + }) + + ---@deprecated + lvim.lsp.popup_border = {} + setmetatable(lvim.lsp.popup_border, mt) + + ---@deprecated + lvim.lsp.float = {} + setmetatable(lvim.lsp.float, { + __newindex = function(_, k, _) + deprecate("lvim.lsp.float." .. k, "Use options provided by the handler instead") + end, + }) + + ---@deprecated + lvim.lsp.diagnostics = {} + setmetatable(lvim.lsp.diagnostics, { + __newindex = function(table, k, v) + deprecate("lvim.lsp.diagnostics." .. k, string.format("Use `vim.diagnostic.config({ %s = %s })` instead", k, v)) + rawset(table, k, v) + end, + }) + + ---@deprecated + lvim.lang = {} + setmetatable(lvim.lang, mt) +end + +function M.post_load() + if lvim.lsp.diagnostics and not vim.tbl_isempty(lvim.lsp.diagnostics) then + vim.diagnostic.config(lvim.lsp.diagnostics) + end + + if lvim.lsp.override and not vim.tbl_isempty(lvim.lsp.override) then + deprecate("lvim.lsp.override", "Use `lvim.lsp.automatic_configuration.skipped_servers` instead") + vim.tbl_map(function(c) + if not vim.tbl_contains(lvim.lsp.automatic_configuration.skipped_servers, c) then + table.insert(lvim.lsp.automatic_configuration.skipped_servers, c) + end + end, lvim.lsp.override) + end + + if lvim.autocommands.custom_groups then + deprecate( + "lvim.autocommands.custom_groups", + "Use vim.api.nvim_create_autocmd instead or check LunarVim#2592 to learn about the new syntax" + ) + end + + if lvim.lsp.automatic_servers_installation then + deprecate( + "lvim.lsp.automatic_servers_installation", + "Use `lvim.lsp.installer.setup.automatic_installation` instead" + ) + end + + local function convert_spec_to_lazy(spec) + local alternatives = { + setup = "init", + as = "name", + opt = "lazy", + run = "build", + lock = "pin", + requires = "dependencies", + } + + alternatives.tag = function() + if spec.tag == "*" then + spec.version = "*" + return [[version = "*"]] + end + end + + alternatives.disable = function() + if type(spec.disabled) == "function" then + spec.enabled = function() + return not spec.disabled() + end + else + spec.enabled = not spec.disabled + end + return "enabled = " .. vim.inspect(spec.enabled) + end + + alternatives.wants = function() + return "dependencies = [value]" + end + alternatives.needs = alternatives.wants + + alternatives.module = function() + spec.lazy = true + return "lazy = true" + end + + for old_key, alternative in pairs(alternatives) do + if spec[old_key] ~= nil then + local message + local old_value = vim.inspect(spec[old_key]) or "value" + + if type(alternative) == "function" then + message = alternative() + else + spec[alternative] = spec[old_key] + end + + -- not every function in alternatives returns a message (e.g. tag) + if type(alternative) ~= "function" or message then + spec[old_key] = nil + + local new_value = vim.inspect(spec[alternative] or "[value]") + message = message or string.format("%s = %s", alternative, new_value) + vim.schedule(function() + vim.notify_once( + string.format( + [[`%s = %s` in `lvim.plugins` has been deprecated since the migration to lazy.nvim. Use `%s` instead. +Example: +`lvim.plugins = {... {... %s = %s ...} ...}` +-> +`lvim.plugins = {... {... %s ...} ...}` +See https://github.com/folke/lazy.nvim#-migration-guide"]], + old_key, + old_value, + message, + old_key, + old_value, + message + ), + vim.log.levels.WARN + ) + end) + end + end + end + + if spec[1] and spec[1]:match "^http" then + spec.url = spec[1] + spec[1] = nil + + vim.schedule(function() + vim.notify_once( + + string.format( + [[`"http..."` in `lvim.plugins` has been deprecated since the migration to lazy.nvim. Use `url = "http..."` instead. +Example: +`lvim.plugins = {... { "%s" ...} ...}` +-> +`lvim.plugins = {... { url = "%s" ...} ...}` +See https://github.com/folke/lazy.nvim#-migration-guide"]], + spec.url, + spec.url + ), + + vim.log.levels.WARN + ) + end) + end + end + + for _, plugin in ipairs(lvim.plugins) do + if type(plugin) == "table" then + convert_spec_to_lazy(plugin) + end + end +end + +return M diff --git a/mac/.config/LunarVim/lua/lvim/config/defaults.lua b/mac/.config/LunarVim/lua/lvim/config/defaults.lua new file mode 100644 index 0000000..5fa8a91 --- /dev/null +++ b/mac/.config/LunarVim/lua/lvim/config/defaults.lua @@ -0,0 +1,75 @@ +return { + leader = "space", + reload_config_on_save = true, + colorscheme = "lunar", + transparent_window = false, + format_on_save = { + ---@usage boolean: format on save (Default: false) + enabled = false, + ---@usage pattern string pattern used for the autocommand (Default: '*') + pattern = "*", + ---@usage timeout number timeout in ms for the format request (Default: 1000) + timeout = 1000, + ---@usage filter func to select client + filter = require("lvim.lsp.utils").format_filter, + }, + keys = {}, + + use_icons = true, + icons = require "lvim.icons", + + builtin = {}, + + plugins = { + -- use config.lua for this not put here + }, + + lazy = { + opts = { + install = { + missing = true, + colorscheme = { "lunar", "habamax" }, + }, + ui = { + border = "rounded", + }, + root = require("lvim.utils").join_paths(get_runtime_dir(), "site", "pack", "lazy", "opt"), + git = { + timeout = 120, + }, + lockfile = require("lvim.utils").join_paths(get_config_dir(), "lazy-lock.json"), + performance = { + rtp = { + reset = false, + }, + }, + defaults = { + lazy = false, + version = nil, + }, + readme = { + root = require("lvim.utils").join_paths(get_runtime_dir(), "lazy", "readme"), + }, + }, + }, + + autocommands = {}, + lang = {}, + log = { + ---@usage can be { "trace", "debug", "info", "warn", "error", "fatal" }, + level = "info", + viewer = { + ---@usage this will fallback on "less +F" if not found + cmd = "lnav", + layout_config = { + ---@usage direction = 'vertical' | 'horizontal' | 'window' | 'float', + direction = "horizontal", + open_mapping = "", + size = 40, + float_opts = {}, + }, + }, + -- currently disabled due to instabilities + override_notify = false, + }, +} diff --git a/mac/.config/LunarVim/lua/lvim/config/init.lua b/mac/.config/LunarVim/lua/lvim/config/init.lua new file mode 100644 index 0000000..90c1788 --- /dev/null +++ b/mac/.config/LunarVim/lua/lvim/config/init.lua @@ -0,0 +1,108 @@ +local utils = require "lvim.utils" +local Log = require "lvim.core.log" + +local M = {} +local user_config_dir = get_config_dir() +local user_config_file = utils.join_paths(user_config_dir, "config.lua") + +---Get the full path to the user configuration file +---@return string +function M:get_user_config_path() + return user_config_file +end + +--- Initialize lvim default configuration and variables +function M:init() + lvim = vim.deepcopy(require "lvim.config.defaults") + + require("lvim.keymappings").load_defaults() + + local builtins = require "lvim.core.builtins" + builtins.config { user_config_file = user_config_file } + + local settings = require "lvim.config.settings" + settings.load_defaults() + + local autocmds = require "lvim.core.autocmds" + autocmds.load_defaults() + + local lvim_lsp_config = require "lvim.lsp.config" + lvim.lsp = vim.deepcopy(lvim_lsp_config) + + lvim.builtin.luasnip = { + sources = { + friendly_snippets = true, + }, + } + + lvim.builtin.bigfile = { + active = true, + config = {}, + } + + require("lvim.config._deprecated").handle() +end + +--- Override the configuration with a user provided one +-- @param config_path The path to the configuration overrides +function M:load(config_path) + local autocmds = reload "lvim.core.autocmds" + config_path = config_path or self:get_user_config_path() + local ok, err = pcall(dofile, config_path) + if not ok then + if utils.is_file(user_config_file) then + vim.schedule(function() + Log:warn("Invalid configuration: " .. err) + end) + else + vim.schedule(function() + vim.notify_once( + string.format("User-configuration not found. Creating an example configuration in %s", config_path) + ) + end) + local config_name = vim.loop.os_uname().version:match "Windows" and "config_win" or "config" + local example_config = join_paths(get_lvim_base_dir(), "utils", "installer", config_name .. ".example.lua") + vim.fn.mkdir(user_config_dir, "p") + vim.loop.fs_copyfile(example_config, config_path) + end + end + + Log:set_level(lvim.log.level) + + require("lvim.config._deprecated").post_load() + + autocmds.define_autocmds(lvim.autocommands) + + vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader + + reload("lvim.keymappings").load(lvim.keys) + + if lvim.transparent_window then + autocmds.enable_transparent_mode() + end + + if lvim.reload_config_on_save then + autocmds.enable_reload_config_on_save() + end +end + +--- Override the configuration with a user provided one +-- @param config_path The path to the configuration overrides +function M:reload() + vim.schedule(function() + reload("lvim.utils.hooks").run_pre_reload() + + M:load() + + reload("lvim.core.autocmds").configure_format_on_save() + + local plugins = reload "lvim.plugins" + local plugin_loader = reload "lvim.plugin-loader" + + plugin_loader.reload { plugins, lvim.plugins } + reload("lvim.core.theme").setup() + reload("lvim.utils.hooks").run_post_reload() + end) +end + +return M diff --git a/mac/.config/LunarVim/lua/lvim/config/settings.lua b/mac/.config/LunarVim/lua/lvim/config/settings.lua new file mode 100644 index 0000000..2492f1d --- /dev/null +++ b/mac/.config/LunarVim/lua/lvim/config/settings.lua @@ -0,0 +1,120 @@ +local M = {} + +M.load_default_options = function() + local utils = require "lvim.utils" + local join_paths = utils.join_paths + + local undodir = join_paths(get_cache_dir(), "undo") + + if not utils.is_directory(undodir) then + vim.fn.mkdir(undodir, "p") + end + + local default_options = { + backup = false, -- creates a backup file + clipboard = "unnamedplus", -- allows neovim to access the system clipboard + cmdheight = 1, -- more space in the neovim command line for displaying messages + completeopt = { "menuone", "noselect" }, + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a file + foldmethod = "manual", -- folding, set to "expr" for treesitter based folding + foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding + hidden = true, -- required to keep multiple buffers and open multiple buffers + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + mouse = "a", -- allow the mouse to be used in neovim + pumheight = 10, -- pop up menu height + showmode = false, -- we don't need to see things like -- INSERT -- anymore + smartcase = true, -- smart case + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds) + title = true, -- set the title of window to the value of the titlestring + -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to + undodir = undodir, -- set an undo directory + undofile = true, -- enable persistent undo + updatetime = 100, -- faster completion + writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited + expandtab = true, -- convert tabs to spaces + shiftwidth = 2, -- the number of spaces inserted for each indentation + tabstop = 2, -- insert 2 spaces for a tab + cursorline = true, -- highlight the current line + number = true, -- set numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time + wrap = false, -- display lines as one long line + shadafile = join_paths(get_cache_dir(), "lvim.shada"), + scrolloff = 8, -- minimal number of screen lines to keep above and below the cursor. + sidescrolloff = 8, -- minimal number of screen lines to keep left and right of the cursor. + showcmd = false, + ruler = false, + laststatus = 3, + } + + --- SETTINGS --- + vim.opt.spelllang:append "cjk" -- disable spellchecking for asian characters (VIM algorithm does not support it) + vim.opt.shortmess:append "c" -- don't show redundant messages from ins-completion-menu + vim.opt.shortmess:append "I" -- don't show the default intro message + vim.opt.whichwrap:append "<,>,[,],h,l" + + for k, v in pairs(default_options) do + vim.opt[k] = v + end + + vim.filetype.add { + extension = { + tex = "tex", + zir = "zir", + cr = "crystal", + }, + pattern = { + ["[jt]sconfig.*.json"] = "jsonc", + }, + } + + local default_diagnostic_config = { + signs = { + active = true, + values = { + { name = "DiagnosticSignError", text = lvim.icons.diagnostics.Error }, + { name = "DiagnosticSignWarn", text = lvim.icons.diagnostics.Warning }, + { name = "DiagnosticSignHint", text = lvim.icons.diagnostics.Hint }, + { name = "DiagnosticSignInfo", text = lvim.icons.diagnostics.Information }, + }, + }, + virtual_text = true, + update_in_insert = false, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(default_diagnostic_config) +end + +M.load_headless_options = function() + vim.opt.shortmess = "" -- try to prevent echom from cutting messages off or prompting + vim.opt.more = false -- don't pause listing when screen is filled + vim.opt.cmdheight = 9999 -- helps avoiding |hit-enter| prompts. + vim.opt.columns = 9999 -- set the widest screen possible + vim.opt.swapfile = false -- don't use a swap file +end + +M.load_defaults = function() + if #vim.api.nvim_list_uis() == 0 then + M.load_headless_options() + return + end + M.load_default_options() +end + +return M |
