Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  perf(toggleterm): on-demand lazy load (LunarVim#3811)
  fix(lsp): template generation for filetypes with dots (LunarVim#3833)
  chore(lsp): add unocss to skipped_list (LunarVim#3834)
  fix(alpha): rollback to older commit (LunarVim#3832)
  docs(ts): add hint about `ensure_installed` (LunarVim#3827)
  chore: bump plugins version (LunarVim#3823)
  feat(which-key): keybind for `:Telescope resume` (LunarVim#3826)
  fix(lsp): lazy loading (LunarVim#3824)
  chore: bump plugins version (LunarVim#3819)
  chore: bump plugins version (LunarVim#3814)
  fix(plugin-loader): support older git versions (LunarVim#3769)
  chore: bump plugins version (LunarVim#3763)
  fix: remove deprecated nvim-tree options (LunarVim#3810)
  refactor(alpha): remove laststatus and tabline autocmds (LunarVim#3809)
  perf: lazy load most plugins (LunarVim#3750)
  • Loading branch information
hexsailor committed Feb 13, 2023
2 parents 41a9a64 + fde46c4 commit d277f0f
Show file tree
Hide file tree
Showing 23 changed files with 245 additions and 159 deletions.
2 changes: 0 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ Log:debug "Starting LunarVim"

local commands = require "lvim.core.commands"
commands.load(commands.defaults)

require("lvim.lsp").setup()
1 change: 0 additions & 1 deletion lua/lvim/config/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ M.load_default_options = function()
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
showtabline = 2, -- always show tabs
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
Expand Down
19 changes: 0 additions & 19 deletions lua/lvim/core/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ local function resolve_config(theme_name)
return selected_theme.config
end

local function configure_additional_autocmds()
local group = "_dashboard_settings"
vim.api.nvim_create_augroup(group, {})
vim.api.nvim_create_autocmd("FileType", {
group = group,
pattern = "alpha",
command = "set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value,
})
if not lvim.builtin.lualine.options.globalstatus then
-- https://github.com/goolord/alpha-nvim/issues/42
vim.api.nvim_create_autocmd("FileType", {
group = group,
pattern = "alpha",
command = "set laststatus=0 | autocmd BufUnload <buffer> set laststatus=" .. vim.opt.laststatus._value,
})
end
end

function M.setup()
local status_ok, alpha = pcall(require, "alpha")
if not status_ok then
Expand All @@ -98,7 +80,6 @@ function M.setup()
end

alpha.setup(config)
configure_additional_autocmds()
end

return M
29 changes: 29 additions & 0 deletions lua/lvim/core/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,35 @@ function M.load_defaults()
end,
},
},
{ -- taken from AstroNvim
"BufEnter",
{
group = "_dir_opened",
once = true,
callback = function(args)
local bufname = vim.api.nvim_buf_get_name(args.buf)
if require("lvim.utils").is_directory(bufname) then
vim.api.nvim_del_augroup_by_name "_dir_opened"
vim.cmd "do User DirOpened"
vim.api.nvim_exec_autocmds("BufEnter", {})
end
end,
},
},
{ -- taken from AstroNvim
{ "BufRead", "BufWinEnter", "BufNewFile" },
{
group = "_file_opened",
once = true,
callback = function(args)
local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf })
if not (vim.fn.expand "%" == "" or buftype == "nofile") then
vim.cmd "do User FileOpened"
require("lvim.lsp").setup()
end
end,
},
},
}

M.define_autocmds(definitions)
Expand Down
3 changes: 3 additions & 0 deletions lua/lvim/core/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ M.setup = function()
return
end

-- can't be set in settings.lua because default tabline would flash before bufferline is loaded
vim.opt.showtabline = 2

bufferline.setup {
options = lvim.builtin.bufferline.options,
highlights = lvim.builtin.bufferline.highlights,
Expand Down
55 changes: 29 additions & 26 deletions lua/lvim/core/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,17 @@ end
M.methods.jumpable = jumpable

M.config = function()
local status_cmp_ok, cmp = pcall(require, "cmp")
local status_cmp_ok, cmp_types = pcall(require, "cmp.types.cmp")
if not status_cmp_ok then
return
end
local status_luasnip_ok, luasnip = pcall(require, "luasnip")
if not status_luasnip_ok then
return
end
local ConfirmBehavior = cmp_types.ConfirmBehavior
local SelectBehavior = cmp_types.SelectBehavior

local cmp = require("lvim.utils.modules").require_on_index "cmp"
local luasnip = require("lvim.utils.modules").require_on_index "luasnip"
local cmp_window = require "cmp.config.window"
local cmp_mapping = require "cmp.config.mapping"

lvim.builtin.cmp = {
active = true,
Expand All @@ -138,7 +141,7 @@ M.config = function()
return lvim.builtin.cmp.active
end,
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
behavior = ConfirmBehavior.Replace,
select = false,
},
completion = {
Expand Down Expand Up @@ -214,12 +217,12 @@ M.config = function()
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
completion = cmp_window.bordered(),
documentation = cmp_window.bordered(),
},
sources = {
{
Expand Down Expand Up @@ -255,7 +258,7 @@ M.config = function()
{
name = "nvim_lsp",
entry_filter = function(entry, ctx)
local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()]
local kind = require("cmp.types.lsp").CompletionItemKind[entry:get_kind()]
if kind == "Snippet" and ctx.prev_context.filetype == "java" then
return false
end
Expand All @@ -277,24 +280,24 @@ M.config = function()
{ name = "crates" },
{ name = "tmux" },
},
mapping = cmp.mapping.preset.insert {
["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, { "i" }),
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, { "i" }),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping {
i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false },
mapping = cmp_mapping.preset.insert {
["<C-k>"] = cmp_mapping(cmp_mapping.select_prev_item(), { "i", "c" }),
["<C-j>"] = cmp_mapping(cmp_mapping.select_next_item(), { "i", "c" }),
["<Down>"] = cmp_mapping(cmp_mapping.select_next_item { behavior = SelectBehavior.Select }, { "i" }),
["<Up>"] = cmp_mapping(cmp_mapping.select_prev_item { behavior = SelectBehavior.Select }, { "i" }),
["<C-d>"] = cmp_mapping.scroll_docs(-4),
["<C-f>"] = cmp_mapping.scroll_docs(4),
["<C-y>"] = cmp_mapping {
i = cmp_mapping.confirm { behavior = ConfirmBehavior.Replace, select = false },
c = function(fallback)
if cmp.visible() then
cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }
cmp.confirm { behavior = ConfirmBehavior.Replace, select = false }
else
fallback()
end
end,
},
["<Tab>"] = cmp.mapping(function(fallback)
["<Tab>"] = cmp_mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
Expand All @@ -308,7 +311,7 @@ M.config = function()
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
["<S-Tab>"] = cmp_mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
Expand All @@ -317,16 +320,16 @@ M.config = function()
fallback()
end
end, { "i", "s" }),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping(function(fallback)
["<C-Space>"] = cmp_mapping.complete(),
["<C-e>"] = cmp_mapping.abort(),
["<CR>"] = cmp_mapping(function(fallback)
if cmp.visible() then
local confirm_opts = vim.deepcopy(lvim.builtin.cmp.confirm_opts) -- avoid mutating the original opts below
local is_insert_mode = function()
return vim.api.nvim_get_mode().mode:sub(1, 1) == "i"
end
if is_insert_mode() then -- prevent overwriting brackets
confirm_opts.behavior = cmp.ConfirmBehavior.Insert
confirm_opts.behavior = ConfirmBehavior.Insert
end
if cmp.confirm(confirm_opts) then
return -- success, exit early
Expand Down
12 changes: 6 additions & 6 deletions lua/lvim/core/comment.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
local M = {}

function M.config()
local pre_hook
local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim")
if loaded and ts_comment then
pre_hook = ts_comment.create_pre_hook()
end
lvim.builtin.comment = {
active = true,
on_config_done = nil,
Expand Down Expand Up @@ -66,7 +61,12 @@ function M.config()

---Pre-hook, called before commenting the line
---@type function|nil
pre_hook = pre_hook,
pre_hook = function(...)
local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim")
if loaded and ts_comment then
return ts_comment.create_pre_hook()(...)
end
end,

---Post-hook, called after commenting is done
---@type function|nil
Expand Down
21 changes: 7 additions & 14 deletions lua/lvim/core/lir.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
local M = {}

M.config = function()
local utils = require "lvim.utils.modules"
local actions = utils.require_on_exported_call "lir.actions"
local clipboard_actions = utils.require_on_exported_call "lir.clipboard.actions"

lvim.builtin.lir = {
active = true,
on_config_done = nil,
icon = "",
}

local status_ok, _ = pcall(require, "lir")
if not status_ok then
return
end

local actions = require "lir.actions"
local mark_actions = require "lir.mark.actions"
local clipboard_actions = require "lir.clipboard.actions"

lvim.builtin.lir = vim.tbl_extend("force", lvim.builtin.lir, {
show_hidden_files = false,
ignore = {}, -- { ".DS_Store" "node_modules" } etc.
devicons = {
Expand All @@ -42,7 +34,7 @@ M.config = function()
["d"] = actions.delete,

["J"] = function()
mark_actions.toggle_mark()
require("lir.mark.actions").toggle_mark()
vim.cmd "normal! j"
end,
["c"] = clipboard_actions.copy,
Expand Down Expand Up @@ -79,7 +71,7 @@ M.config = function()
{ noremap = true, silent = true }
)
end,
})
}
end

function M.icon_setup()
Expand Down Expand Up @@ -118,6 +110,7 @@ function M.setup()
end

lir.setup(lvim.builtin.lir)
M.icon_setup()

if lvim.builtin.lir.on_config_done then
lvim.builtin.lir.on_config_done(lir)
Expand Down
2 changes: 1 addition & 1 deletion lua/lvim/core/lualine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ M.config = function()
component_separators = nil,
section_separators = nil,
theme = nil,
disabled_filetypes = nil,
disabled_filetypes = { statusline = { "alpha" } },
globalstatus = true,
},
sections = {
Expand Down
7 changes: 0 additions & 7 deletions lua/lvim/core/nvimtree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ function M.config()
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false,
open_on_setup = false,
open_on_setup_file = false,
sort_by = "name",
root_dirs = {},
prefer_startup_root = false,
Expand Down Expand Up @@ -117,11 +115,6 @@ function M.config()
update_root = true,
ignore_list = {},
},
ignore_ft_on_setup = {
"startify",
"dashboard",
"alpha",
},
diagnostics = {
enable = lvim.use_icons,
show_on_dirs = false,
Expand Down
22 changes: 9 additions & 13 deletions lua/lvim/core/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,11 @@ local M = {}
---| "center" # retain the default telescope theme

function M.config()
-- Define this minimal config so that it's available if telescope is not yet available.

local actions = require("lvim.utils.modules").require_on_exported_call "telescope.actions"
lvim.builtin.telescope = {
---@usage disable telescope completely [not recommended]
active = true,
on_config_done = nil,
}

local ok, actions = pcall(require, "telescope.actions")
if not ok then
return
end
lvim.builtin.telescope = {
active = true,
on_config_done = nil,
theme = "dropdown", ---@type telescope_themes
defaults = {
prompt_prefix = lvim.icons.ui.Telescope .. " ",
Expand Down Expand Up @@ -51,13 +41,19 @@ function M.config()
["<C-c>"] = actions.close,
["<C-j>"] = actions.cycle_history_next,
["<C-k>"] = actions.cycle_history_prev,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
["<C-q>"] = function(...)
actions.smart_send_to_qflist(...)
actions.open_qflist(...)
end,
["<CR>"] = actions.select_default,
},
n = {
["<C-n>"] = actions.move_selection_next,
["<C-p>"] = actions.move_selection_previous,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
["<C-q>"] = function(...)
actions.smart_send_to_qflist(...)
actions.open_qflist(...)
end,
},
},
file_ignore_patterns = {},
Expand Down
9 changes: 5 additions & 4 deletions lua/lvim/core/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ local function get_dynamic_terminal_size(direction, size)
end
end

M.setup = function()
local terminal = require "toggleterm"
terminal.setup(lvim.builtin.terminal)

M.init = function()
for i, exec in pairs(lvim.builtin.terminal.execs) do
local direction = exec[4] or lvim.builtin.terminal.direction

Expand All @@ -98,7 +95,11 @@ M.setup = function()

M.add_exec(opts)
end
end

M.setup = function()
local terminal = require "toggleterm"
terminal.setup(lvim.builtin.terminal)
if lvim.builtin.terminal.on_config_done then
lvim.builtin.terminal.on_config_done(terminal)
end
Expand Down
Loading

0 comments on commit d277f0f

Please sign in to comment.