Merge remote-tracking branch 'origin/rolling'

This commit is contained in:
kylo252 2022-05-25 13:35:38 +02:00
commit fc63a66ce8
37 changed files with 432 additions and 315 deletions

View file

@ -23,7 +23,7 @@ body:
validations: validations:
required: true required: true
- type: input - type: input
id: lunar-vim-version id: version
attributes: attributes:
label: LunarVim version label: LunarVim version
placeholder: | placeholder: |
@ -36,26 +36,36 @@ body:
label: Neovim version (>= 0.7) label: Neovim version (>= 0.7)
description: "Output of `nvim --version`" description: "Output of `nvim --version`"
placeholder: | placeholder: |
NVIM v0.7-dev+209-g0603eba6e NVIM v0.8.0-dev+199-g2875d45e7
Build type: Release
LuaJIT 2.1.0-beta3
validations: validations:
required: true required: true
- type: input - type: input
id: system-version
attributes: attributes:
label: "Operating system/version" label: "Operating system/version"
placeholder: "macOS 11.5" placeholder: "macOS 11.5"
validations: validations:
required: true required: true
- type: textarea - type: textarea
id: logs id: steps
attributes: attributes:
label: Relevant log output label: "Steps to reproduce"
description: "Steps to reproduce using the minimal config."
placeholder: | placeholder: |
:checkhealth 1. `nvim -u ~/.local/share/lunarvim/lvim/tests/minimal_lsp.lua`
:messages 2. ...
:e $LUNARVIM_CACHE/DIR/lvim.log - type: textarea
render: shell id: support-info
attributes:
label: support info
description: Information from LspInfo and LvimInfo
placeholder: |
```console
# :LspInfo
```
```console
# :LvimInfo
```
validations: validations:
required: true required: true
- type: textarea - type: textarea

View file

@ -17,7 +17,7 @@ body:
validations: validations:
required: true required: true
- type: input - type: input
id: lunar-vim-version id: version
attributes: attributes:
label: LunarVim version label: LunarVim version
placeholder: | placeholder: |
@ -30,18 +30,18 @@ body:
label: Neovim version (>= 0.7) label: Neovim version (>= 0.7)
description: "Output of `nvim --version`" description: "Output of `nvim --version`"
placeholder: | placeholder: |
NVIM v0.7-dev+209-g0603eba6e NVIM v0.8.0-dev+199-g2875d45e7
Build type: Release
LuaJIT 2.1.0-beta3
validations: validations:
required: true required: true
- type: input - type: input
id: system-version
attributes: attributes:
label: "Operating system/version" label: "Operating system/version"
placeholder: "macOS 11.5" placeholder: "macOS 11.5"
validations: validations:
required: true required: true
- type: input - type: input
id: servers
attributes: attributes:
label: "Affected language servers" label: "Affected language servers"
description: "If this issue is specific to one or more language servers, list them here. If not, write 'all'." description: "If this issue is specific to one or more language servers, list them here. If not, write 'all'."
@ -49,6 +49,7 @@ body:
validations: validations:
required: true required: true
- type: textarea - type: textarea
id: steps
attributes: attributes:
label: "Steps to reproduce" label: "Steps to reproduce"
description: "Steps to reproduce using the minimal config." description: "Steps to reproduce using the minimal config."
@ -56,30 +57,37 @@ body:
1. `nvim -u ~/.local/share/lunarvim/lvim/tests/minimal_lsp.lua` 1. `nvim -u ~/.local/share/lunarvim/lvim/tests/minimal_lsp.lua`
2. ... 2. ...
- type: textarea - type: textarea
id: behavior
attributes: attributes:
label: "Actual behavior" label: "Actual behavior"
description: "Observed behavior." description: "Observed behavior."
validations: validations:
required: true required: true
- type: textarea - type: textarea
id: expected-behavior
attributes: attributes:
label: "Expected behavior" label: "Expected behavior"
description: "A description of the behavior you expected." description: "A description of the behavior you expected."
- type: textarea - type: textarea
id: logs id: support-info
attributes: attributes:
label: log and support info label: support info
description: Information from LspInfo and LvimInfo
placeholder: | placeholder: |
:LspInfo ```console
:LvimInfo # :LspInfo
:messages ```
:checkhealth ```console
:e $LUNARVIM_CACHE/DIR/lsp.log # :LvimInfo
:e $LUNARVIM_CACHE/DIR/lvim.log ```
:e $LUNARVIM_CACHE/DIR/log
render: shell
validations: validations:
required: true required: true
- type: textarea
id: lsp-logs
attributes:
label: logs
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: console
- type: textarea - type: textarea
id: screenshots id: screenshots
attributes: attributes:

View file

@ -1,12 +1,12 @@
<!-- This won't be rendered! <!-- This won't be rendered!
[CHECKLIST] [CHECKLIST]
I prefixed the title with one of the following tags: I prefixed the title with one of the following tags:
- [Feature]: For feature addition / improvements - feature: for feature addition / improvements
- [Bugfix]: When fixing a functionality - fix: when fixing a functionality
- [Refactor]: When moving code without adding any functionality - refactor: when moving code without adding any functionality
- [Doc]: On documentation updates - doc: on documentation updates
- I read the contributing guide (CONTRIBUTING.md) - I read the contributing guide [CONTRIBUTING.md](../CONTRIBUTING.md)
- My code follows the style guidelines of this project - My code follows the style guidelines of this project
- I have performed a self-review of my code - I have performed a self-review of my code
- I have commented on my code, particularly in hard-to-understand areas - I have commented on my code, particularly in hard-to-understand areas
@ -15,17 +15,17 @@ I prefixed the title with one of the following tags:
--> -->
# Description # Description
Please include a summary of the change and which issue is fixed. \ summary of the change
List any dependencies that are required for this change.
Fixes #(issue) <!--- Please list any dependencies that are required for this change. --->
fixes #(issue)
## How Has This Been Tested? ## How Has This Been Tested?
Please describe the tests that you ran to verify your changes. \ <!--- Please describe the tests that you ran to verify your changes. --->
Provide instructions so we can reproduce. \ <!--- Also list any relevant details for your test configuration. --->
Please also list any relevant details for your test configuration. <!--- Provide instructions so we can reproduce -->
- Run command `:mycommand` - Run command `:mycommand`
- Check logs - Check logs
- ... - ...

View file

@ -32,4 +32,15 @@ module.exports = {
], ],
], ],
}, },
/*
add a custom parser to handle exclamation marks in a commit
see: https://github.com/conventional-changelog/commitlint/issues/2226#issuecomment-911749509
*/
parserPreset: {
parserOpts: {
headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
referenceActions: null,
issuePrefixes: ['ISS-'],
},
},
}; };

View file

@ -33,7 +33,7 @@ jobs:
uses: rhysd/action-setup-vim@v1 uses: rhysd/action-setup-vim@v1
with: with:
neovim: true neovim: true
version: v0.7 version: v0.7.0
- name: Install LunarVim - name: Install LunarVim
timeout-minutes: 4 timeout-minutes: 4

View file

@ -1,3 +0,0 @@
vim.cmd [[
au BufRead,BufNewFile *.bicep set filetype=bicep
]]

View file

@ -1,3 +0,0 @@
vim.cmd [[
au BufRead,BufNewFile *.fish set filetype=fish
]]

View file

@ -1,3 +0,0 @@
vim.cmd [[
au BufNewFile,BufRead *.fs,*.fsx,*.fsi set filetype=fsharp
]]

View file

@ -1 +0,0 @@
vim.cmd [[ au BufRead,BufNewFile *.jl set filetype=julia ]]

View file

@ -1 +0,0 @@
vim.cmd [[ au BufRead,BufNewFile *.nix set filetype=nix ]]

View file

@ -1,3 +0,0 @@
vim.cmd [[
au BufRead,BufNewFile *.sol set filetype=solidity
]]

View file

@ -1,4 +1,3 @@
vim.cmd [[ vim.cmd [[
au BufRead,BufNewFile *.zig set filetype=zig
au BufRead,BufNewFile *.zir set filetype=zir au BufRead,BufNewFile *.zir set filetype=zir
]] ]]

View file

@ -55,7 +55,7 @@ end
function _G.get_cache_dir() function _G.get_cache_dir()
local lvim_cache_dir = os.getenv "LUNARVIM_CACHE_DIR" local lvim_cache_dir = os.getenv "LUNARVIM_CACHE_DIR"
if not lvim_cache_dir then if not lvim_cache_dir then
return vim.call("stdpath", "config") return vim.call("stdpath", "cache")
end end
return lvim_cache_dir return lvim_cache_dir
end end

View file

@ -5,26 +5,15 @@ local M = {}
local user_config_dir = get_config_dir() local user_config_dir = get_config_dir()
local user_config_file = utils.join_paths(user_config_dir, "config.lua") local user_config_file = utils.join_paths(user_config_dir, "config.lua")
local function apply_defaults(configs, defaults)
configs = configs or {}
return vim.tbl_deep_extend("keep", configs, defaults)
end
---Get the full path to the user configuration file ---Get the full path to the user configuration file
---@return string ---@return string
function M:get_user_config_path() function M:get_user_config_path()
return user_config_file return user_config_file
end end
--- Initialize lvim default configuration --- Initialize lvim default configuration and variables
-- Define lvim global variable
function M:init() function M:init()
if vim.tbl_isempty(lvim or {}) then lvim = vim.deepcopy(require "lvim.config.defaults")
lvim = vim.deepcopy(require "lvim.config.defaults")
local home_dir = vim.loop.os_homedir()
lvim.vsnip_dir = utils.join_paths(home_dir, ".config", "snippets")
lvim.database = { save_location = utils.join_paths(home_dir, ".config", "lunarvim_db"), auto_execute = 1 }
end
require("lvim.keymappings").load_defaults() require("lvim.keymappings").load_defaults()
@ -32,13 +21,13 @@ function M:init()
builtins.config { user_config_file = user_config_file } builtins.config { user_config_file = user_config_file }
local settings = require "lvim.config.settings" local settings = require "lvim.config.settings"
settings.load_options() settings.load_defaults()
local autocmds = require "lvim.core.autocmds" local autocmds = require "lvim.core.autocmds"
lvim.autocommands = apply_defaults(lvim.autocommands, autocmds.load_augroups()) autocmds.load_defaults()
local lvim_lsp_config = require "lvim.lsp.config" local lvim_lsp_config = require "lvim.lsp.config"
lvim.lsp = apply_defaults(lvim.lsp, vim.deepcopy(lvim_lsp_config)) lvim.lsp = vim.deepcopy(lvim_lsp_config)
---@deprecated replaced with lvim.builtin.alpha ---@deprecated replaced with lvim.builtin.alpha
lvim.builtin.dashboard = { lvim.builtin.dashboard = {
@ -51,8 +40,6 @@ function M:init()
custom_section = {}, custom_section = {},
footer = {}, footer = {},
} }
require("lvim.lsp.manager").init_defaults()
end end
local function handle_deprecated_settings() local function handle_deprecated_settings()
@ -99,25 +86,32 @@ local function handle_deprecated_settings()
if lvim.builtin.dashboard.active then if lvim.builtin.dashboard.active then
deprecation_notice("lvim.builtin.dashboard", "Use `lvim.builtin.alpha` instead. See LunarVim#1906") deprecation_notice("lvim.builtin.dashboard", "Use `lvim.builtin.alpha` instead. See LunarVim#1906")
end end
if lvim.autocommands.custom_groups then
deprecation_notice(
"lvim.autocommands.custom_groups",
"Use vim.api.nvim_create_autocmd instead or check LunarVim#2592 to learn about the new syntax"
)
end
end end
--- Override the configuration with a user provided one --- Override the configuration with a user provided one
-- @param config_path The path to the configuration overrides -- @param config_path The path to the configuration overrides
function M:load(config_path) function M:load(config_path)
local autocmds = require "lvim.core.autocmds" local autocmds = require "lvim.core.autocmds"
config_path = config_path or self.get_user_config_path() config_path = config_path or self:get_user_config_path()
local ok, err = pcall(dofile, config_path) local ok, err = pcall(dofile, config_path)
if not ok then if not ok then
if utils.is_file(user_config_file) then if utils.is_file(user_config_file) then
Log:warn("Invalid configuration: " .. err) Log:warn("Invalid configuration: " .. err)
else else
Log:warn(string.format("Unable to find configuration file [%s]", config_path)) vim.notify_once(string.format("Unable to find configuration file [%s]", config_path), vim.log.levels.WARN)
end end
end end
handle_deprecated_settings() handle_deprecated_settings()
autocmds.define_augroups(lvim.autocommands) autocmds.define_autocmds(lvim.autocommands)
vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader
@ -134,7 +128,6 @@ function M:reload()
vim.schedule(function() vim.schedule(function()
require_clean("lvim.utils.hooks").run_pre_reload() require_clean("lvim.utils.hooks").run_pre_reload()
M:init()
M:load() M:load()
require("lvim.core.autocmds").configure_format_on_save() require("lvim.core.autocmds").configure_format_on_save()

View file

@ -1,7 +1,15 @@
local M = {} local M = {}
local join_paths = require("lvim.utils").join_paths
M.load_default_options = function() 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 = { local default_options = {
backup = false, -- creates a backup file backup = false, -- creates a backup file
clipboard = "unnamedplus", -- allows neovim to access the system clipboard clipboard = "unnamedplus", -- allows neovim to access the system clipboard
@ -29,7 +37,7 @@ M.load_default_options = function()
timeoutlen = 250, -- time to wait for a mapped sequence to complete (in milliseconds) timeoutlen = 250, -- time to wait for a mapped sequence to complete (in milliseconds)
title = true, -- set the title of window to the value of the titlestring 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 -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
undodir = join_paths(get_cache_dir(), "undo"), -- set an undo directory undodir = undodir, -- set an undo directory
undofile = true, -- enable persistent undo undofile = true, -- enable persistent undo
updatetime = 300, -- faster completion updatetime = 300, -- 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 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
@ -42,9 +50,6 @@ M.load_default_options = function()
numberwidth = 4, -- set number column width to 2 {default 4} 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 signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
wrap = false, -- display lines as one long line wrap = false, -- display lines as one long line
spell = false,
spelllang = "en",
spellfile = join_paths(get_config_dir(), "spell", "en.utf-8.add"),
shadafile = join_paths(get_cache_dir(), "lvim.shada"), shadafile = join_paths(get_cache_dir(), "lvim.shada"),
scrolloff = 8, -- minimal number of screen lines to keep above and below the cursor. 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. sidescrolloff = 8, -- minimal number of screen lines to keep left and right of the cursor.
@ -68,7 +73,7 @@ M.load_headless_options = function()
vim.opt.swapfile = false -- don't use a swap file vim.opt.swapfile = false -- don't use a swap file
end end
M.load_options = function() M.load_defaults = function()
if #vim.api.nvim_list_uis() == 0 then if #vim.api.nvim_list_uis() == 0 then
M.load_headless_options() M.load_headless_options()
return return

View file

@ -47,23 +47,21 @@ local function resolve_config(theme_name)
end end
local function configure_additional_autocmds() local function configure_additional_autocmds()
local aucmds = { local group = "_dashboard_settings"
{ vim.api.nvim_create_augroup(group, {})
"FileType", vim.api.nvim_create_autocmd("FileType", {
"alpha", group = group,
"set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value, pattern = "alpha",
}, command = "set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value,
} })
if not lvim.builtin.lualine.options.globalstatus then if not lvim.builtin.lualine.options.globalstatus then
aucmds[#aucmds + 1] = -- https://github.com/goolord/alpha-nvim/issues/42
-- https://github.com/goolord/alpha-nvim/issues/42 vim.api.nvim_create_autocmd("FileType", {
{ group = group,
"FileType", pattern = "alpha",
"alpha", command = "set laststatus=0 | autocmd BufUnload <buffer> set laststatus=" .. vim.opt.laststatus._value,
"set laststatus=0 | autocmd BufUnload <buffer> set laststatus=" .. vim.opt.laststatus._value, })
}
end end
require("lvim.core.autocmds").define_augroups { _alpha = aucmds }
end end
function M.setup() function M.setup()

View file

@ -34,16 +34,7 @@ function M.get_sections()
} }
local text = require "lvim.interface.text" local text = require "lvim.interface.text"
local git_utils = require "lvim.utils.git" local lvim_version = require("lvim.utils.git").get_lvim_version()
local current_branch = git_utils.get_lvim_branch()
local lvim_version
if current_branch ~= "HEAD" or "" then
lvim_version = current_branch .. "-" .. git_utils.get_lvim_current_sha()
else
lvim_version = "v" .. git_utils.get_lvim_tag()
end
local footer = { local footer = {
type = "text", type = "text",
@ -68,7 +59,7 @@ function M.get_sections()
{ {
"SPC L c", "SPC L c",
" Configuration", " Configuration",
"<CMD>edit " .. require("lvim.config").get_user_config_path() .. " <CR>", "<CMD>edit " .. require("lvim.config"):get_user_config_path() .. " <CR>",
}, },
}, },
} }

View file

@ -2,7 +2,7 @@ local M = {}
local Log = require "lvim.core.log" local Log = require "lvim.core.log"
--- Load the default set of autogroups and autocommands. --- Load the default set of autogroups and autocommands.
function M.load_augroups() function M.load_defaults()
local user_config_file = require("lvim.config"):get_user_config_path() local user_config_file = require("lvim.config"):get_user_config_path()
if vim.loop.os_uname().version:match "Windows" then if vim.loop.os_uname().version:match "Windows" then
@ -10,51 +10,72 @@ function M.load_augroups()
user_config_file = user_config_file:gsub("\\", "/") user_config_file = user_config_file:gsub("\\", "/")
end end
return { local definitions = {
_general_settings = { {
{ "FileType", "qf,help,man", "nnoremap <silent> <buffer> q :close<CR>" }, "TextYankPost",
{ {
"TextYankPost", group = "_general_settings",
"*", pattern = "*",
"lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})", desc = "Highlight text on yank",
}, callback = function()
{ require("vim.highlight").on_yank { higroup = "Search", timeout = 200 }
"BufWinEnter", end,
"dashboard",
"setlocal cursorline signcolumn=yes cursorcolumn number",
},
{ "BufWritePost", user_config_file, "lua require('lvim.config'):reload()" },
{ "FileType", "qf", "set nobuflisted" },
-- { "VimLeavePre", "*", "set title set titleold=" },
},
_formatoptions = {
{
"BufWinEnter,BufRead,BufNewFile",
"*",
"setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
}, },
}, },
_filetypechanges = {}, {
_git = { "BufWritePost",
{ "FileType", "gitcommit", "setlocal wrap" }, {
{ "FileType", "gitcommit", "setlocal spell" }, group = "_general_settings",
pattern = user_config_file,
desc = "Trigger LvimReload on saving " .. vim.fn.expand "%:~",
callback = function()
require("lvim.config"):reload()
end,
},
}, },
_markdown = { {
{ "FileType", "markdown", "setlocal wrap" }, "FileType",
{ "FileType", "markdown", "setlocal spell" }, {
group = "_filetype_settings",
pattern = "qf",
command = "set nobuflisted",
},
}, },
_buffer_bindings = { {
{ "FileType", "floaterm", "nnoremap <silent> <buffer> q :q<CR>" }, "FileType",
{
group = "_filetype_settings",
pattern = { "gitcommit", "markdown" },
command = "setlocal wrap spell",
},
}, },
_auto_resize = { {
-- will cause split windows to be resized evenly if main window is resized "FileType",
{ "VimResized", "*", "tabdo wincmd =" }, {
group = "_buffer_mappings",
pattern = { "qf", "help", "man", "floaterm", "lspinfo", "lsp-installer", "null-ls-info" },
command = "nnoremap <silent> <buffer> q :close<CR>",
},
}, },
_general_lsp = { {
{ "FileType", "lspinfo,lsp-installer,null-ls-info", "nnoremap <silent> <buffer> q :close<CR>" }, { "BufWinEnter", "BufRead", "BufNewFile" },
{
group = "_format_options",
pattern = "*",
command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
},
},
{
"VimResized",
{
group = "_auto_resize",
pattern = "*",
command = "tabdo wincmd =",
},
}, },
custom_groups = {},
} }
M.define_autocmds(definitions)
end end
local get_format_on_save_opts = function() local get_format_on_save_opts = function()
@ -84,7 +105,7 @@ function M.enable_format_on_save()
end end
function M.disable_format_on_save() function M.disable_format_on_save()
pcall(vim.api.nvim_del_augroup_by_name, "lsp_format_on_save") M.clear_augroup "lsp_format_on_save"
Log:debug "disabled format-on-save" Log:debug "disabled format-on-save"
end end
@ -97,11 +118,11 @@ function M.configure_format_on_save()
end end
function M.toggle_format_on_save() function M.toggle_format_on_save()
local status, _ = pcall(vim.api.nvim_get_autocmds, { local exists, _ = pcall(vim.api.nvim_get_autocmds, {
group = "lsp_format_on_save", group = "lsp_format_on_save",
event = "BufWritePre", event = "BufWritePre",
}) })
if not status then if not exists then
M.enable_format_on_save() M.enable_format_on_save()
else else
M.disable_format_on_save() M.disable_format_on_save()
@ -109,47 +130,61 @@ function M.toggle_format_on_save()
end end
function M.enable_transparent_mode() function M.enable_transparent_mode()
vim.cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" vim.api.nvim_create_autocmd("ColorScheme", {
vim.cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" pattern = "*",
vim.cmd "au ColorScheme * hi NormalNC ctermbg=none guibg=none" callback = function()
vim.cmd "au ColorScheme * hi MsgArea ctermbg=none guibg=none" local hl_groups = {
vim.cmd "au ColorScheme * hi TelescopeBorder ctermbg=none guibg=none" "Normal",
vim.cmd "au ColorScheme * hi NvimTreeNormal ctermbg=none guibg=none" "SignColumn",
vim.cmd "au ColorScheme * hi EndOfBuffer ctermbg=none guibg=none" "NormalNC",
vim.cmd "let &fcs='eob: '" "TelescopeBorder",
"NvimTreeNormal",
"EndOfBuffer",
"MsgArea",
}
for _, name in ipairs(hl_groups) do
vim.cmd(string.format("highlight %s ctermbg=none guibg=none", name))
end
end,
})
vim.opt.fillchars = "eob: "
end end
--- Disable autocommand groups if it exists --- Clean autocommand in a group if it exists
--- This is more reliable than trying to delete the augroup itself --- This is safer than trying to delete the augroup itself
---@param name string the augroup name ---@param name string the augroup name
function M.disable_augroup(name) function M.clear_augroup(name)
-- defer the function in case the autocommand is still in-use -- defer the function in case the autocommand is still in-use
local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = name })
if not exists then
Log:debug("ignoring request to clear autocmds from non-existent group " .. name)
return
end
vim.schedule(function() vim.schedule(function()
if vim.fn.exists("#" .. name) == 1 then local status_ok, _ = xpcall(function()
vim.cmd("augroup " .. name) vim.api.nvim_clear_autocmds { group = name }
vim.cmd "autocmd!" end, debug.traceback)
vim.cmd "augroup END" if not status_ok then
Log:warn("problems detected while clearing autocmds from " .. name)
Log:debug(debug.traceback())
end end
end) end)
end end
--- Create autocommand groups based on the passed definitions --- Create autocommand groups based on the passed definitions
---@param definitions table contains trigger, pattern and text. The key will be used as a group name --- Also creates the augroup automatically if it doesn't exist
function M.define_augroups(definitions, buffer) ---@param definitions table contains a tuple of event, opts, see `:h nvim_create_autocmd`
for group_name, definition in pairs(definitions) do function M.define_autocmds(definitions)
vim.cmd("augroup " .. group_name) for _, entry in ipairs(definitions) do
if buffer then local event = entry[1]
vim.cmd [[autocmd! * <buffer>]] local opts = entry[2]
else if type(opts.group) == "string" and opts.group ~= "" then
vim.cmd [[autocmd!]] local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group })
if not exists then
vim.api.nvim_create_augroup(opts.group, {})
end
end end
vim.api.nvim_create_autocmd(event, opts)
for _, def in pairs(definition) do
local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ")
vim.cmd(command)
end
vim.cmd "augroup END"
end end
end end

View file

@ -144,9 +144,9 @@ end
-- Common kill function for bdelete and bwipeout -- Common kill function for bdelete and bwipeout
-- credits: based on bbye and nvim-bufdel -- credits: based on bbye and nvim-bufdel
---@param kill_command String defaults to "bd" ---@param kill_command string defaults to "bd"
---@param bufnr Number defaults to the current buffer ---@param bufnr? number defaults to the current buffer
---@param force Boolean defaults to false ---@param force? boolean defaults to false
function M.buf_kill(kill_command, bufnr, force) function M.buf_kill(kill_command, bufnr, force)
local bo = vim.bo local bo = vim.bo
local api = vim.api local api = vim.api

View file

@ -1,7 +1,6 @@
local M = {} local M = {}
M.defaults = { vim.cmd [[
[[
function! QuickFixToggle() function! QuickFixToggle()
if empty(filter(getwininfo(), 'v:val.quickfix')) if empty(filter(getwininfo(), 'v:val.quickfix'))
copen copen
@ -9,21 +8,70 @@ M.defaults = {
cclose cclose
endif endif
endfunction endfunction
]], ]]
[[ command! BufferKill lua require('lvim.core.bufferline').buf_kill('bd') ]],
-- :LvimInfo M.defaults = {
[[ command! LvimInfo lua require('lvim.core.info').toggle_popup(vim.bo.filetype) ]], {
[[ command! LvimCacheReset lua require('lvim.utils.hooks').reset_cache() ]], name = "BufferKill",
[[ command! LvimUpdate lua require('lvim.bootstrap').update() ]], fn = function()
[[ command! LvimSyncCorePlugins lua require('lvim.plugin-loader'):sync_core_plugins() ]], require("lvim.core.bufferline").buf_kill "bd"
[[ command! LvimReload lua require('lvim.config'):reload() ]], end,
[[ command! LvimToggleFormatOnSave lua require('lvim.core.autocmds').toggle_format_on_save() ]], },
[[ command! LvimVersion lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog() ]], {
name = "LvimToggleFormatOnSave",
fn = function()
require("lvim.core.autocmds").toggle_format_on_save()
end,
},
{
name = "LvimInfo",
fn = function()
require("lvim.core.info").toggle_popup(vim.bo.filetype)
end,
},
{
name = "LvimCacheReset",
fn = function()
require("lvim.utils.hooks").reset_cache()
end,
},
{
name = "LvimReload",
fn = function()
require("lvim.config"):reload()
end,
},
{
name = "LvimUpdate",
fn = function()
require("lvim.bootstrap"):update()
end,
},
{
name = "LvimSyncCorePlugins",
fn = function()
require("lvim.plugin-loader").sync_core_plugins()
end,
},
{
name = "LvimChangelog",
fn = function()
require("lvim.core.telescope.custom-finders").view_lunarvim_changelog()
end,
},
{
name = "LvimVersion",
fn = function()
print(require("lvim.utils.git").get_lvim_version())
end,
},
} }
M.load = function(commands) function M.load(collection)
for _, command in ipairs(commands) do local common_opts = { force = true }
vim.cmd(command) for _, cmd in pairs(collection) do
local opts = vim.tbl_deep_extend("force", common_opts, cmd.opts or {})
vim.api.nvim_create_user_command(cmd.name, cmd.fn, opts)
end end
end end

View file

@ -47,7 +47,7 @@ M.setup = function()
i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" }, i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" }, o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" }, u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
p = { "<cmd>lua require'dap'.pause.toggle()<cr>", "Pause" }, p = { "<cmd>lua require'dap'.pause()<cr>", "Pause" },
r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" }, r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" },
s = { "<cmd>lua require'dap'.continue()<cr>", "Start" }, s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },
q = { "<cmd>lua require'dap'.close()<cr>", "Quit" }, q = { "<cmd>lua require'dap'.close()<cr>", "Quit" },

View file

@ -11,15 +11,26 @@ vim.tbl_add_reverse_lookup(Log.levels)
local notify_opts = {} local notify_opts = {}
function Log:set_level(level)
-- package.loaded["lvim.core.log"] = nil
local log_level = Log.levels[level:upper()]
local status_ok, logger = pcall(require("structlog").get_logger, "lvim")
if status_ok then
for _, s in ipairs(logger.sinks) do
s.level = log_level
end
end
package.loaded["packer.log"] = nil
require("packer.log").new { level = lvim.log.level }
end
function Log:init() function Log:init()
local status_ok, structlog = pcall(require, "structlog") local status_ok, structlog = pcall(require, "structlog")
if not status_ok then if not status_ok then
return nil return nil
end end
package.loaded["packer.log"] = nil
require("packer.log").new { level = lvim.log.level }
local log_level = Log.levels[(lvim.log.level):upper() or "WARN"] local log_level = Log.levels[(lvim.log.level):upper() or "WARN"]
local lvim_log = { local lvim_log = {
lvim = { lvim = {

View file

@ -72,7 +72,7 @@ function M.config()
set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
pickers = { pickers = {
find_files = { find_files = {
find_command = { "fd", "--type=file", "--hidden", "--smart-case" }, hidden = true,
}, },
live_grep = { live_grep = {
--@usage don't include the filename in the search results --@usage don't include the filename in the search results
@ -130,6 +130,12 @@ function M.setup()
end) end)
end end
if lvim.builtin.notify.active then
pcall(function()
require("telescope").load_extension "notify"
end)
end
if lvim.builtin.telescope.on_config_done then if lvim.builtin.telescope.on_config_done then
lvim.builtin.telescope.on_config_done(telescope) lvim.builtin.telescope.on_config_done(telescope)
end end

View file

@ -12,11 +12,12 @@ M.config = function()
}, },
highlight = { highlight = {
enable = true, -- false will disable the whole extension enable = true, -- false will disable the whole extension
additional_vim_regex_highlighting = true, additional_vim_regex_highlighting = false,
disable = { "latex" }, disable = { "latex" },
}, },
context_commentstring = { context_commentstring = {
enable = true, enable = true,
enable_autocmd = false,
config = { config = {
-- Languages that have a single comment style -- Languages that have a single comment style
typescript = "// %s", typescript = "// %s",
@ -28,9 +29,7 @@ M.config = function()
json = "", json = "",
}, },
}, },
-- indent = {enable = true, disable = {"python", "html", "javascript"}}, indent = { enable = true, disable = { "yaml", "python" } },
-- TODO seems to be broken
indent = { enable = true, disable = { "yaml" } },
autotag = { enable = false }, autotag = { enable = false },
textobjects = { textobjects = {
swap = { swap = {

View file

@ -82,7 +82,7 @@ M.config = function()
mappings = { mappings = {
[";"] = { "<cmd>Alpha<CR>", "Dashboard" }, [";"] = { "<cmd>Alpha<CR>", "Dashboard" },
["w"] = { "<cmd>w!<CR>", "Save" }, ["w"] = { "<cmd>w!<CR>", "Save" },
["q"] = { "<cmd>q!<CR>", "Quit" }, ["q"] = { "<cmd>lua require('lvim.utils.functions').smart_quit()<CR>", "Quit" },
["/"] = { "<cmd>lua require('Comment.api').toggle_current_linewise()<CR>", "Comment" }, ["/"] = { "<cmd>lua require('Comment.api').toggle_current_linewise()<CR>", "Comment" },
["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" }, ["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" },
["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" }, ["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" },
@ -234,6 +234,7 @@ M.config = function()
}, },
P = { "<cmd>edit $LUNARVIM_CACHE_DIR/packer.nvim.log<cr>", "Open the Packer logfile" }, P = { "<cmd>edit $LUNARVIM_CACHE_DIR/packer.nvim.log<cr>", "Open the Packer logfile" },
}, },
n = { "<cmd>Telescope notify<cr>", "View Notifications" },
r = { "<cmd>LvimReload<cr>", "Reload LunarVim's configuration" }, r = { "<cmd>LvimReload<cr>", "Reload LunarVim's configuration" },
u = { "<cmd>LvimUpdate<cr>", "Update LunarVim" }, u = { "<cmd>LvimUpdate<cr>", "Update LunarVim" },
}, },

View file

@ -21,8 +21,15 @@ local mode_adapters = {
command_mode = "c", command_mode = "c",
} }
---@class Keys
---@field insert_mode table
---@field normal_mode table
---@field terminal_mode table
---@field visual_mode table
---@field visual_block_mode table
---@field command_mode table
local defaults = { local defaults = {
---@usage change or add keymappings for insert mode
insert_mode = { insert_mode = {
-- 'jk' for quitting insert mode -- 'jk' for quitting insert mode
["jk"] = "<ESC>", ["jk"] = "<ESC>",
@ -41,7 +48,6 @@ local defaults = {
["<A-Right>"] = "<C-\\><C-N><C-w>l", ["<A-Right>"] = "<C-\\><C-N><C-w>l",
}, },
---@usage change or add keymappings for normal mode
normal_mode = { normal_mode = {
-- Better window movement -- Better window movement
["<C-h>"] = "<C-w>h", ["<C-h>"] = "<C-w>h",
@ -69,7 +75,6 @@ local defaults = {
["<C-q>"] = ":call QuickFixToggle()<CR>", ["<C-q>"] = ":call QuickFixToggle()<CR>",
}, },
---@usage change or add keymappings for terminal mode
term_mode = { term_mode = {
-- Terminal window navigation -- Terminal window navigation
["<C-h>"] = "<C-\\><C-N><C-w>h", ["<C-h>"] = "<C-\\><C-N><C-w>h",
@ -78,7 +83,6 @@ local defaults = {
["<C-l>"] = "<C-\\><C-N><C-w>l", ["<C-l>"] = "<C-\\><C-N><C-w>l",
}, },
---@usage change or add keymappings for visual mode
visual_mode = { visual_mode = {
-- Better indenting -- Better indenting
["<"] = "<gv", ["<"] = "<gv",
@ -88,7 +92,6 @@ local defaults = {
-- ["P"] = '"0P', -- ["P"] = '"0P',
}, },
---@usage change or add keymappings for visual block mode
visual_block_mode = { visual_block_mode = {
-- Move selected line / block of text in visual mode -- Move selected line / block of text in visual mode
["K"] = ":move '<-2<CR>gv-gv", ["K"] = ":move '<-2<CR>gv-gv",
@ -99,7 +102,6 @@ local defaults = {
["<A-k>"] = ":m '<-2<CR>gv-gv", ["<A-k>"] = ":m '<-2<CR>gv-gv",
}, },
---@usage change or add keymappings for command mode
command_mode = { command_mode = {
-- navigate tab completion with <c-j> and <c-k> -- navigate tab completion with <c-j> and <c-k>
-- runs conditionally -- runs conditionally
@ -116,18 +118,6 @@ if vim.fn.has "mac" == 1 then
Log:debug "Activated mac keymappings" Log:debug "Activated mac keymappings"
end end
-- Append key mappings to lunarvim's defaults for a given mode
-- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..)
function M.append_to_defaults(keymaps)
local default = M.get_defaults()
lvim.keys = lvim.keys or default
for mode, mappings in pairs(keymaps) do
for k, v in pairs(mappings) do
defaults[mode][k] = v
end
end
end
-- Unsets all keybindings defined in keymaps -- Unsets all keybindings defined in keymaps
-- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..) -- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..)
function M.clear(keymaps) function M.clear(keymaps)
@ -137,7 +127,7 @@ function M.clear(keymaps)
for key, _ in pairs(mappings) do for key, _ in pairs(mappings) do
-- some plugins may override default bindings that the user hasn't manually overridden -- some plugins may override default bindings that the user hasn't manually overridden
if default[mode][key] ~= nil or (default[translated_mode] ~= nil and default[translated_mode][key] ~= nil) then if default[mode][key] ~= nil or (default[translated_mode] ~= nil and default[translated_mode][key] ~= nil) then
pcall(vim.api.nvim_del_keymap, translated_mode, key) pcall(vim.keymap.del, translated_mode, key)
end end
end end
end end
@ -169,7 +159,7 @@ function M.set_keymaps(mode, key, val)
val = val[1] val = val[1]
end end
if val then if val then
vim.api.nvim_set_keymap(mode, key, val, opt) vim.keymap.set(mode, key, val, opt)
else else
pcall(vim.api.nvim_del_keymap, mode, key) pcall(vim.api.nvim_del_keymap, mode, key)
end end
@ -197,9 +187,11 @@ end
-- Load the default keymappings -- Load the default keymappings
function M.load_defaults() function M.load_defaults()
M.load(M.get_defaults()) M.load(M.get_defaults())
lvim.keys = {} lvim.keys = lvim.keys or {}
for idx, _ in pairs(defaults) do for idx, _ in pairs(defaults) do
lvim.keys[idx] = {} if not lvim.keys[idx] then
lvim.keys[idx] = {}
end
end end
end end

View file

@ -50,10 +50,10 @@ end
function M.common_on_exit(_, _) function M.common_on_exit(_, _)
if lvim.lsp.document_highlight then if lvim.lsp.document_highlight then
pcall(vim.api.nvim_del_augroup_by_name, "lsp_document_highlight") autocmds.clear_augroup "lsp_document_highlight"
end end
if lvim.lsp.code_lens_refresh then if lvim.lsp.code_lens_refresh then
pcall(vim.api.nvim_del_augroup_by_name, "lsp_code_lens_refresh") autocmds.clear_augroup "lsp_code_lens_refresh"
end end
end end
@ -74,7 +74,7 @@ function M.common_on_attach(client, bufnr)
if lvim.lsp.document_highlight then if lvim.lsp.document_highlight then
lu.setup_document_highlight(client, bufnr) lu.setup_document_highlight(client, bufnr)
end end
if lvim.lsp.code_lens_refresh == false then if lvim.lsp.code_lens_refresh then
lu.setup_codelens_refresh(client, bufnr) lu.setup_codelens_refresh(client, bufnr)
end end
add_lsp_buffer_keybindings(bufnr) add_lsp_buffer_keybindings(bufnr)

View file

@ -3,19 +3,6 @@ local M = {}
local Log = require "lvim.core.log" local Log = require "lvim.core.log"
local lvim_lsp_utils = require "lvim.lsp.utils" local lvim_lsp_utils = require "lvim.lsp.utils"
function M.init_defaults(languages)
languages = languages or lvim_lsp_utils.get_all_supported_filetypes()
for _, entry in ipairs(languages) do
if not lvim.lang[entry] then
lvim.lang[entry] = {
formatters = {},
linters = {},
lsp = {},
}
end
end
end
---Resolve the configuration for a server by merging with the default config ---Resolve the configuration for a server by merging with the default config
---@param server_name string ---@param server_name string
---@vararg any config table [optional] ---@vararg any config table [optional]

View file

@ -122,16 +122,11 @@ function M.setup_codelens_refresh(client, bufnr)
if not augroup_exist then if not augroup_exist then
vim.api.nvim_create_augroup("lsp_code_lens_refresh", {}) vim.api.nvim_create_augroup("lsp_code_lens_refresh", {})
end end
vim.api.nvim_create_autocmd("InsertLeave", { vim.api.nvim_create_autocmd({ "BufEnter", "InsertLeave" }, {
group = "lsp_code_lens_refresh", group = "lsp_code_lens_refresh",
buffer = bufnr, buffer = bufnr,
callback = vim.lsp.codelens.refresh, callback = vim.lsp.codelens.refresh,
}) })
vim.api.nvim_create_autocmd("InsertLeave", {
group = "lsp_code_lens_refresh",
buffer = bufnr,
callback = vim.lsp.codelens.display,
})
end end
---filter passed to vim.lsp.buf.format ---filter passed to vim.lsp.buf.format
@ -158,7 +153,7 @@ function M.format(opts)
opts = opts or { filter = M.format_filter } opts = opts or { filter = M.format_filter }
if vim.lsp.buf.format then if vim.lsp.buf.format then
vim.lsp.buf.format(opts) return vim.lsp.buf.format(opts)
end end
local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() local bufnr = opts.bufnr or vim.api.nvim_get_current_buf()

View file

@ -24,7 +24,6 @@ local core_plugins = {
}, },
{ {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
config = function() config = function()
require("lvim.core.notify").setup() require("lvim.core.notify").setup()
end, end,
@ -38,7 +37,6 @@ local core_plugins = {
-- Telescope -- Telescope
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
config = function() config = function()
require("lvim.core.telescope").setup() require("lvim.core.telescope").setup()
end, end,
@ -214,7 +212,8 @@ local core_plugins = {
-- Debugger management -- Debugger management
{ {
"Pocco81/DAPInstall.nvim", "Pocco81/dap-buddy.nvim",
branch = "dev",
-- event = "BufWinEnter", -- event = "BufWinEnter",
-- event = "BufRead", -- event = "BufRead",
disable = not lvim.builtin.dap.active, disable = not lvim.builtin.dap.active,

View file

@ -0,0 +1,19 @@
local M = {}
function M.smart_quit()
local bufnr = vim.api.nvim_get_current_buf()
local modified = vim.api.nvim_buf_get_option(bufnr, "modified")
if modified then
vim.ui.input({
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
}, function(input)
if input == "y" then
vim.cmd "q!"
end
end)
else
vim.cmd "q!"
end
end
return M

View file

@ -115,6 +115,20 @@ function M.get_lvim_tag()
return tag return tag
end end
---Get currently running version of Lunarvim
---@return string
function M.get_lvim_version()
local current_branch = M.get_lvim_branch()
local lvim_version
if current_branch ~= "HEAD" or "" then
lvim_version = current_branch .. "-" .. M.get_lvim_current_sha()
else
lvim_version = "v" .. M.get_lvim_tag()
end
return lvim_version
end
---Get the commit hash of currently checked-out commit of Lunarvim ---Get the commit hash of currently checked-out commit of Lunarvim
---@return string|nil ---@return string|nil
function M.get_lvim_current_sha() function M.get_lvim_current_sha()

View file

@ -1,27 +1,24 @@
{ {
"Comment.nvim": { "Comment.nvim": {
"commit": "cb0de89" "commit": "cc87c89"
},
"DAPInstall.nvim": {
"commit": "bbda2b0"
}, },
"FixCursorHold.nvim": { "FixCursorHold.nvim": {
"commit": "1bfb32e" "commit": "1bfb32e"
}, },
"LuaSnip": { "LuaSnip": {
"commit": "1dbafec" "commit": "08b06c3"
}, },
"alpha-nvim": { "alpha-nvim": {
"commit": "4781fcf" "commit": "4781fcf"
}, },
"bufferline.nvim": { "bufferline.nvim": {
"commit": "2d5266d" "commit": "82e3598"
}, },
"cmp-buffer": { "cmp-buffer": {
"commit": "d66c4c2" "commit": "12463cf"
}, },
"cmp-nvim-lsp": { "cmp-nvim-lsp": {
"commit": "e6b5feb" "commit": "affe808"
}, },
"cmp-path": { "cmp-path": {
"commit": "466b6b8" "commit": "466b6b8"
@ -29,53 +26,56 @@
"cmp_luasnip": { "cmp_luasnip": {
"commit": "a9de941" "commit": "a9de941"
}, },
"dap-buddy.nvim": {
"commit": "bbda2b0"
},
"friendly-snippets": { "friendly-snippets": {
"commit": "6e0881a" "commit": "02c92e3"
}, },
"gitsigns.nvim": { "gitsigns.nvim": {
"commit": "61c8398" "commit": "44372ff"
}, },
"lua-dev.nvim": { "lua-dev.nvim": {
"commit": "54149d1" "commit": "54149d1"
}, },
"lualine.nvim": { "lualine.nvim": {
"commit": "45d07fc" "commit": "c12b167"
}, },
"nlsp-settings.nvim": { "nlsp-settings.nvim": {
"commit": "fc3007e" "commit": "7136038"
}, },
"null-ls.nvim": { "null-ls.nvim": {
"commit": "3dbded7" "commit": "af19226"
}, },
"nvim-autopairs": { "nvim-autopairs": {
"commit": "63779ea" "commit": "aea9131"
}, },
"nvim-cmp": { "nvim-cmp": {
"commit": "baa8646" "commit": "033a817"
}, },
"nvim-dap": { "nvim-dap": {
"commit": "d6d8317" "commit": "a9c49a5"
}, },
"nvim-lsp-installer": { "nvim-lsp-installer": {
"commit": "193f171" "commit": "a655bdd"
}, },
"nvim-lspconfig": { "nvim-lspconfig": {
"commit": "21102d5" "commit": "b86a37c"
}, },
"nvim-notify": { "nvim-notify": {
"commit": "ebe78be" "commit": "c6ca279"
}, },
"nvim-tree.lua": { "nvim-tree.lua": {
"commit": "483f155" "commit": "b2ba6de"
}, },
"nvim-treesitter": { "nvim-treesitter": {
"commit": "4067351" "commit": "29b0ea8"
}, },
"nvim-ts-context-commentstring": { "nvim-ts-context-commentstring": {
"commit": "8834375" "commit": "8834375"
}, },
"nvim-web-devicons": { "nvim-web-devicons": {
"commit": "bdd4342" "commit": "0c5b6d1"
}, },
"onedarker.nvim": { "onedarker.nvim": {
"commit": "b00dd21" "commit": "b00dd21"
@ -84,7 +84,7 @@
"commit": "4dedd3b" "commit": "4dedd3b"
}, },
"plenary.nvim": { "plenary.nvim": {
"commit": "9069d14" "commit": "1da13ad"
}, },
"popup.nvim": { "popup.nvim": {
"commit": "b7404d3" "commit": "b7404d3"
@ -93,21 +93,21 @@
"commit": "612443b" "commit": "612443b"
}, },
"schemastore.nvim": { "schemastore.nvim": {
"commit": "57bb4e1" "commit": "675ec50"
}, },
"structlog.nvim": { "structlog.nvim": {
"commit": "6f1403a" "commit": "6f1403a"
}, },
"telescope-fzf-native.nvim": { "telescope-fzf-native.nvim": {
"commit": "281b07a" "commit": "2330a7e"
}, },
"telescope.nvim": { "telescope.nvim": {
"commit": "23e28d0" "commit": "1a91238"
}, },
"toggleterm.nvim": { "toggleterm.nvim": {
"commit": "6c7f5db" "commit": "c525442"
}, },
"which-key.nvim": { "which-key.nvim": {
"commit": "03de564" "commit": "f03a259"
} }
} }

View file

@ -1,10 +1,13 @@
local a = require "plenary.async_lib.tests" local a = require "plenary.async_lib.tests"
local config = require "lvim.config" local config = require "lvim.config"
local fmt = string.format
a.describe("config-loader", function() a.describe("config-loader", function()
local user_config_path = config:get_user_config_path() local user_config_path = join_paths(get_config_dir(), "config.lua")
local default_config_path = join_paths(get_lvim_base_dir(), "utils", "installer", "config.example.lua")
before_each(function() before_each(function()
os.execute(fmt("cp -f %s %s", default_config_path, user_config_path))
vim.cmd [[ vim.cmd [[
let v:errmsg = "" let v:errmsg = ""
let v:errors = [] let v:errors = []
@ -41,23 +44,12 @@ a.describe("config-loader", function()
a.it("should not get interrupted by errors in user-config", function() a.it("should not get interrupted by errors in user-config", function()
local test_path = "/tmp/lunarvim" local test_path = "/tmp/lunarvim"
os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path)) os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path))
config:reload() config:load(user_config_path)
vim.schedule(function() assert.equal(vim.opt.undodir:get()[1], test_path)
assert.equal(vim.opt.undodir:get()[1], test_path) require("lvim.core.log"):set_level "error"
end) os.execute(string.format("echo 'invalid_function()' >> %s", user_config_path))
os.execute(string.format("echo 'bad_string_test' >> %s", user_config_path)) config:load(user_config_path)
local error_handler = function(msg) require("lvim.core.log"):set_level "error"
return msg assert.equal(vim.opt.undodir:get()[1], test_path)
end
local err = xpcall(config:reload(), error_handler)
assert.falsy(err)
vim.schedule(function()
assert.equal(vim.opt.undodir:get()[1], test_path)
local errmsg = vim.fn.eval "v:errmsg"
local exception = vim.fn.eval "v:exception"
assert.equal("", errmsg) -- v:errmsg was not updated.
assert.equal("", exception)
os.execute(string.format("echo '' > %s", user_config_path))
end)
end) end)
end) end)

View file

@ -20,9 +20,9 @@ lvim.leader = "space"
-- add your own keymapping -- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>" lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- unmap a default keymapping -- unmap a default keymapping
-- lvim.keys.normal_mode["<C-Up>"] = false -- vim.keymap.del("n", "<C-Up>")
-- edit a default keymapping -- override a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- or vim.keymap.set("n", "<C-q>", ":q<cr>" )
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. -- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. -- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
@ -153,6 +153,15 @@ lvim.builtin.treesitter.highlight.enabled = true
-- } -- }
-- Autocommands (https://neovim.io/doc/user/autocmd.html) -- Autocommands (https://neovim.io/doc/user/autocmd.html)
-- lvim.autocommands.custom_groups = { -- vim.api.nvim_create_autocmd("BufEnter", {
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, -- pattern = { "*.json", "*.jsonc" },
-- } -- -- enable wrap mode for json files only
-- command = "setlocal wrap",
-- })
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = "zsh",
-- callback = function()
-- -- let treesitter use bash highlight for zsh files as well
-- require("nvim-treesitter.highlight").attach(0, "bash")
-- end,
-- })

View file

@ -37,9 +37,9 @@ lvim.leader = "space"
-- add your own keymapping -- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>" lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- unmap a default keymapping -- unmap a default keymapping
-- lvim.keys.normal_mode["<C-Up>"] = false -- vim.keymap.del("n", "<C-Up>")
-- edit a default keymapping -- override a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- or vim.keymap.set("n", "<C-q>", ":q<cr>" )
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. -- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. -- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
@ -168,6 +168,15 @@ lvim.builtin.treesitter.highlight.enabled = true
-- } -- }
-- Autocommands (https://neovim.io/doc/user/autocmd.html) -- Autocommands (https://neovim.io/doc/user/autocmd.html)
-- lvim.autocommands.custom_groups = { -- vim.api.nvim_create_autocmd("BufEnter", {
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, -- pattern = { "*.json", "*.jsonc" },
-- } -- -- enable wrap mode for json files only
-- command = "setlocal wrap",
-- })
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = "zsh",
-- callback = function()
-- -- let treesitter use bash highlight for zsh files as well
-- require("nvim-treesitter.highlight").attach(0, "bash")
-- end,
-- })