diff options
37 files changed, 428 insertions, 311 deletions
| diff --git a/.github/ISSUE_TEMPLATE/general-issue-form.yaml b/.github/ISSUE_TEMPLATE/general-issue-form.yaml index fcf22684..be1dce81 100644 --- a/.github/ISSUE_TEMPLATE/general-issue-form.yaml +++ b/.github/ISSUE_TEMPLATE/general-issue-form.yaml @@ -23,7 +23,7 @@ body:      validations:        required: true    - type: input -    id: lunar-vim-version +    id: version      attributes:        label: LunarVim version        placeholder: | @@ -36,26 +36,36 @@ body:        label: Neovim version (>= 0.7)        description: "Output of `nvim --version`"        placeholder: | -        NVIM v0.7-dev+209-g0603eba6e -        Build type: Release -        LuaJIT 2.1.0-beta3 +        NVIM v0.8.0-dev+199-g2875d45e7      validations:        required: true    - type: input +    id: system-version      attributes:        label: "Operating system/version"        placeholder: "macOS 11.5"      validations:        required: true    - type: textarea -    id: logs +    id: steps      attributes: -      label: Relevant log output +      label: "Steps to reproduce" +      description: "Steps to reproduce using the minimal config."        placeholder: | -        :checkhealth -        :messages -        :e $LUNARVIM_CACHE/DIR/lvim.log -      render: shell +        1. `nvim -u ~/.local/share/lunarvim/lvim/tests/minimal_lsp.lua` +        2. ... +  - type: textarea +    id: support-info +    attributes: +      label: support info +      description: Information from LspInfo and LvimInfo +      placeholder: | +        ```console +        # :LspInfo +        ``` +        ```console +        # :LvimInfo +        ```      validations:        required: true    - type: textarea diff --git a/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml b/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml index 6b326b26..e8079ffa 100644 --- a/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml +++ b/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml @@ -17,7 +17,7 @@ body:      validations:        required: true    - type: input -    id: lunar-vim-version +    id: version      attributes:        label: LunarVim version        placeholder: | @@ -30,18 +30,18 @@ body:        label: Neovim version (>= 0.7)        description: "Output of `nvim --version`"        placeholder: | -        NVIM v0.7-dev+209-g0603eba6e -        Build type: Release -        LuaJIT 2.1.0-beta3 +        NVIM v0.8.0-dev+199-g2875d45e7      validations:        required: true    - type: input +    id: system-version      attributes:        label: "Operating system/version"        placeholder: "macOS 11.5"      validations:        required: true    - type: input +    id: servers      attributes:        label: "Affected language servers"        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:        required: true    - type: textarea +    id: steps      attributes:        label: "Steps to reproduce"        description: "Steps to reproduce using the minimal config." @@ -56,31 +57,38 @@ body:          1. `nvim -u ~/.local/share/lunarvim/lvim/tests/minimal_lsp.lua`          2. ...    - type: textarea +    id: behavior      attributes:        label: "Actual behavior"        description: "Observed behavior."      validations:        required: true    - type: textarea +    id: expected-behavior      attributes:        label: "Expected behavior"        description: "A description of the behavior you expected."    - type: textarea -    id: logs +    id: support-info      attributes: -      label: log and support info +      label: support info +      description: Information from LspInfo and LvimInfo        placeholder: | -        :LspInfo -        :LvimInfo -        :messages -        :checkhealth -        :e $LUNARVIM_CACHE/DIR/lsp.log -        :e $LUNARVIM_CACHE/DIR/lvim.log -        :e $LUNARVIM_CACHE/DIR/log -      render: shell +        ```console +        # :LspInfo +        ``` +        ```console +        # :LvimInfo +        ```      validations:        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      id: screenshots      attributes:        label: Screenshots diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7b3a25f3..48782e51 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,12 +1,12 @@  <!-- This won't be rendered!  [CHECKLIST]  I prefixed the title with one of the following tags: - - [Feature]: For feature addition / improvements - - [Bugfix]: When fixing a functionality - - [Refactor]: When moving code without adding any functionality - - [Doc]: On documentation updates + - feature: for feature addition / improvements + - fix: when fixing a functionality + - refactor: when moving code without adding any functionality + - 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  - I have performed a self-review of my code  - 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 -Please include a summary of the change and which issue is fixed. \ -List any dependencies that are required for this change. +summary of the change -Fixes #(issue) +<!--- Please list any dependencies that are required for this change. ---> -## How Has This Been Tested? +fixes #(issue) -Please describe the tests that you ran to verify your changes. \ -Provide instructions so we can reproduce. \ -Please also list any relevant details for your test configuration. +## How Has This Been Tested? +<!--- Please describe the tests that you ran to verify your changes. ---> +<!--- Also list any relevant details for your test configuration. ---> +<!--- Provide instructions so we can reproduce -->  - Run command `:mycommand`  - Check logs  - ... diff --git a/.github/workflows/commitlint.config.js b/.github/workflows/commitlint.config.js index 06cc7866..53ec4b76 100644 --- a/.github/workflows/commitlint.config.js +++ b/.github/workflows/commitlint.config.js @@ -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-'], +    }, +  },  }; diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index d84c6b36..3df32105 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -33,7 +33,7 @@ jobs:          uses: rhysd/action-setup-vim@v1          with:            neovim: true -          version: v0.7 +          version: v0.7.0        - name: Install LunarVim          timeout-minutes: 4 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bdf3d59f..9df262b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,7 +67,7 @@ shfmt -i 2 -ci -bn -l -d .    │       │           │    │       │           └─> Present tense.     'add something...'(O) vs 'added something...'(X)    │       │               Imperative mood.   'move cursor to...'(O) vs 'moves cursor to...'(X) -  │       │               Not capitalized.  +  │       │               Not capitalized.    │       │               No period at the end.    │       │    │       └─> Commit Scope is optional, but strongly recommended. @@ -91,10 +91,10 @@ shfmt -i 2 -ci -bn -l -d .  **Real world examples:**  ``` -feat(quickfix): add 'q' binding to quit quickfix window when focused  +feat(quickfix): add 'q' binding to quit quickfix window when focused  ```  ``` -fix(installer): add missing "HOME" variable  +fix(installer): add missing "HOME" variable  ``` diff --git a/ftdetect/bicep.lua b/ftdetect/bicep.lua deleted file mode 100644 index bdd52e5e..00000000 --- a/ftdetect/bicep.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.cmd [[ - au BufRead,BufNewFile *.bicep set filetype=bicep -]] diff --git a/ftdetect/fish.lua b/ftdetect/fish.lua deleted file mode 100644 index c908c46e..00000000 --- a/ftdetect/fish.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.cmd [[ - au BufRead,BufNewFile *.fish set filetype=fish -]] diff --git a/ftdetect/fsautocomplete.lua b/ftdetect/fsautocomplete.lua deleted file mode 100644 index 0b71987e..00000000 --- a/ftdetect/fsautocomplete.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.cmd [[ -  au BufNewFile,BufRead *.fs,*.fsx,*.fsi set filetype=fsharp -]] diff --git a/ftdetect/julia.lua b/ftdetect/julia.lua deleted file mode 100644 index 2f8087cd..00000000 --- a/ftdetect/julia.lua +++ /dev/null @@ -1 +0,0 @@ -vim.cmd [[ au BufRead,BufNewFile *.jl set filetype=julia ]] diff --git a/ftdetect/nix.lua b/ftdetect/nix.lua deleted file mode 100644 index a85bcfdf..00000000 --- a/ftdetect/nix.lua +++ /dev/null @@ -1 +0,0 @@ -vim.cmd [[ au BufRead,BufNewFile *.nix set filetype=nix ]] diff --git a/ftdetect/sol.lua b/ftdetect/sol.lua deleted file mode 100644 index b716f759..00000000 --- a/ftdetect/sol.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.cmd [[ - au BufRead,BufNewFile *.sol set filetype=solidity -]] diff --git a/ftdetect/zig.lua b/ftdetect/zig.lua index 7edf1f68..343c56c0 100644 --- a/ftdetect/zig.lua +++ b/ftdetect/zig.lua @@ -1,4 +1,3 @@  vim.cmd [[ -  au BufRead,BufNewFile *.zig set filetype=zig    au BufRead,BufNewFile *.zir set filetype=zir  ]] diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua index a3114a1e..f637c144 100644 --- a/lua/lvim/bootstrap.lua +++ b/lua/lvim/bootstrap.lua @@ -55,7 +55,7 @@ end  function _G.get_cache_dir()    local lvim_cache_dir = os.getenv "LUNARVIM_CACHE_DIR"    if not lvim_cache_dir then -    return vim.call("stdpath", "config") +    return vim.call("stdpath", "cache")    end    return lvim_cache_dir  end diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index 505029a2..1af9a971 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -5,26 +5,15 @@ local M = {}  local user_config_dir = get_config_dir()  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  ---@return string  function M:get_user_config_path()    return user_config_file  end ---- Initialize lvim default configuration --- Define lvim global variable +--- Initialize lvim default configuration and variables  function M:init() -  if vim.tbl_isempty(lvim or {}) then -    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 +  lvim = vim.deepcopy(require "lvim.config.defaults")    require("lvim.keymappings").load_defaults() @@ -32,13 +21,13 @@ function M:init()    builtins.config { user_config_file = user_config_file }    local settings = require "lvim.config.settings" -  settings.load_options() +  settings.load_defaults()    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" -  lvim.lsp = apply_defaults(lvim.lsp, vim.deepcopy(lvim_lsp_config)) +  lvim.lsp = vim.deepcopy(lvim_lsp_config)    ---@deprecated replaced with lvim.builtin.alpha    lvim.builtin.dashboard = { @@ -51,8 +40,6 @@ function M:init()      custom_section = {},      footer = {},    } - -  require("lvim.lsp.manager").init_defaults()  end  local function handle_deprecated_settings() @@ -99,25 +86,32 @@ local function handle_deprecated_settings()    if lvim.builtin.dashboard.active then      deprecation_notice("lvim.builtin.dashboard", "Use `lvim.builtin.alpha` instead. See LunarVim#1906")    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  --- Override the configuration with a user provided one  -- @param config_path The path to the configuration overrides  function M:load(config_path)    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)    if not ok then      if utils.is_file(user_config_file) then        Log:warn("Invalid configuration: " .. err)      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    handle_deprecated_settings() -  autocmds.define_augroups(lvim.autocommands) +  autocmds.define_autocmds(lvim.autocommands)    vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader @@ -134,7 +128,6 @@ function M:reload()    vim.schedule(function()      require_clean("lvim.utils.hooks").run_pre_reload() -    M:init()      M:load()      require("lvim.core.autocmds").configure_format_on_save() diff --git a/lua/lvim/config/settings.lua b/lua/lvim/config/settings.lua index 2f47a2dc..faa28641 100644 --- a/lua/lvim/config/settings.lua +++ b/lua/lvim/config/settings.lua @@ -1,7 +1,15 @@  local M = {} -local join_paths = require("lvim.utils").join_paths  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 @@ -29,7 +37,7 @@ M.load_default_options = function()      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      -- 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      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 @@ -42,9 +50,6 @@ M.load_default_options = function()      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 -    spell = false, -    spelllang = "en", -    spellfile = join_paths(get_config_dir(), "spell", "en.utf-8.add"),      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. @@ -68,7 +73,7 @@ M.load_headless_options = function()    vim.opt.swapfile = false -- don't use a swap file  end -M.load_options = function() +M.load_defaults = function()    if #vim.api.nvim_list_uis() == 0 then      M.load_headless_options()      return diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua index 7612854b..fd637818 100644 --- a/lua/lvim/core/alpha.lua +++ b/lua/lvim/core/alpha.lua @@ -47,23 +47,21 @@ local function resolve_config(theme_name)  end  local function configure_additional_autocmds() -  local aucmds = { -    { -      "FileType", -      "alpha", -      "set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value, -    }, -  } +  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 -    aucmds[#aucmds + 1] = -      -- https://github.com/goolord/alpha-nvim/issues/42 -      { -        "FileType", -        "alpha", -        "set laststatus=0 | autocmd BufUnload <buffer> set laststatus=" .. vim.opt.laststatus._value, -      } +    -- 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 -  require("lvim.core.autocmds").define_augroups { _alpha = aucmds }  end  function M.setup() diff --git a/lua/lvim/core/alpha/dashboard.lua b/lua/lvim/core/alpha/dashboard.lua index 010d8c1a..d65980fb 100644 --- a/lua/lvim/core/alpha/dashboard.lua +++ b/lua/lvim/core/alpha/dashboard.lua @@ -34,16 +34,7 @@ function M.get_sections()    }    local text = require "lvim.interface.text" -  local git_utils = require "lvim.utils.git" - -  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 lvim_version = require("lvim.utils.git").get_lvim_version()    local footer = {      type = "text", @@ -68,7 +59,7 @@ function M.get_sections()        {          "SPC L c",          "  Configuration", -        "<CMD>edit " .. require("lvim.config").get_user_config_path() .. " <CR>", +        "<CMD>edit " .. require("lvim.config"):get_user_config_path() .. " <CR>",        },      },    } diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index 64b0a9b9..0ca21439 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -2,7 +2,7 @@ local M = {}  local Log = require "lvim.core.log"  --- 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()    if vim.loop.os_uname().version:match "Windows" then @@ -10,51 +10,72 @@ function M.load_augroups()      user_config_file = user_config_file:gsub("\\", "/")    end -  return { -    _general_settings = { -      { "FileType", "qf,help,man", "nnoremap <silent> <buffer> q :close<CR>" }, +  local definitions = { +    { +      "TextYankPost",        { -        "TextYankPost", -        "*", -        "lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})", +        group = "_general_settings", +        pattern = "*", +        desc = "Highlight text on yank", +        callback = function() +          require("vim.highlight").on_yank { higroup = "Search", timeout = 200 } +        end,        }, +    }, +    { +      "BufWritePost",        { -        "BufWinEnter", -        "dashboard", -        "setlocal cursorline signcolumn=yes cursorcolumn number", +        group = "_general_settings", +        pattern = user_config_file, +        desc = "Trigger LvimReload on saving " .. vim.fn.expand "%:~", +        callback = function() +          require("lvim.config"):reload() +        end,        }, -      { "BufWritePost", user_config_file, "lua require('lvim.config'):reload()" }, -      { "FileType", "qf", "set nobuflisted" }, -      -- { "VimLeavePre", "*", "set title set titleold=" },      }, -    _formatoptions = { +    { +      "FileType",        { -        "BufWinEnter,BufRead,BufNewFile", -        "*", -        "setlocal formatoptions-=c formatoptions-=r formatoptions-=o", +        group = "_filetype_settings", +        pattern = "qf", +        command = "set nobuflisted",        },      }, -    _filetypechanges = {}, -    _git = { -      { "FileType", "gitcommit", "setlocal wrap" }, -      { "FileType", "gitcommit", "setlocal spell" }, -    }, -    _markdown = { -      { "FileType", "markdown", "setlocal wrap" }, -      { "FileType", "markdown", "setlocal spell" }, +    { +      "FileType", +      { +        group = "_filetype_settings", +        pattern = { "gitcommit", "markdown" }, +        command = "setlocal wrap spell", +      },      }, -    _buffer_bindings = { -      { "FileType", "floaterm", "nnoremap <silent> <buffer> q :q<CR>" }, +    { +      "FileType", +      { +        group = "_buffer_mappings", +        pattern = { "qf", "help", "man", "floaterm", "lspinfo", "lsp-installer", "null-ls-info" }, +        command = "nnoremap <silent> <buffer> q :close<CR>", +      },      }, -    _auto_resize = { -      -- will cause split windows to be resized evenly if main window is resized -      { "VimResized", "*", "tabdo wincmd =" }, +    { +      { "BufWinEnter", "BufRead", "BufNewFile" }, +      { +        group = "_format_options", +        pattern = "*", +        command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o", +      },      }, -    _general_lsp = { -      { "FileType", "lspinfo,lsp-installer,null-ls-info", "nnoremap <silent> <buffer> q :close<CR>" }, +    { +      "VimResized", +      { +        group = "_auto_resize", +        pattern = "*", +        command = "tabdo wincmd =", +      },      }, -    custom_groups = {},    } + +  M.define_autocmds(definitions)  end  local get_format_on_save_opts = function() @@ -84,7 +105,7 @@ function M.enable_format_on_save()  end  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"  end @@ -97,11 +118,11 @@ function M.configure_format_on_save()  end  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",      event = "BufWritePre",    }) -  if not status then +  if not exists then      M.enable_format_on_save()    else      M.disable_format_on_save() @@ -109,47 +130,61 @@ function M.toggle_format_on_save()  end  function M.enable_transparent_mode() -  vim.cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" -  vim.cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" -  vim.cmd "au ColorScheme * hi NormalNC ctermbg=none guibg=none" -  vim.cmd "au ColorScheme * hi MsgArea ctermbg=none guibg=none" -  vim.cmd "au ColorScheme * hi TelescopeBorder ctermbg=none guibg=none" -  vim.cmd "au ColorScheme * hi NvimTreeNormal ctermbg=none guibg=none" -  vim.cmd "au ColorScheme * hi EndOfBuffer ctermbg=none guibg=none" -  vim.cmd "let &fcs='eob: '" +  vim.api.nvim_create_autocmd("ColorScheme", { +    pattern = "*", +    callback = function() +      local hl_groups = { +        "Normal", +        "SignColumn", +        "NormalNC", +        "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 ---- Disable autocommand groups if it exists ---- This is more reliable than trying to delete the augroup itself +--- Clean autocommand in a group if it exists +--- This is safer than trying to delete the augroup itself  ---@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 +  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() -    if vim.fn.exists("#" .. name) == 1 then -      vim.cmd("augroup " .. name) -      vim.cmd "autocmd!" -      vim.cmd "augroup END" +    local status_ok, _ = xpcall(function() +      vim.api.nvim_clear_autocmds { group = name } +    end, debug.traceback) +    if not status_ok then +      Log:warn("problems detected while clearing autocmds from " .. name) +      Log:debug(debug.traceback())      end    end)  end  --- 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 -function M.define_augroups(definitions, buffer) -  for group_name, definition in pairs(definitions) do -    vim.cmd("augroup " .. group_name) -    if buffer then -      vim.cmd [[autocmd! * <buffer>]] -    else -      vim.cmd [[autocmd!]] -    end - -    for _, def in pairs(definition) do -      local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ") -      vim.cmd(command) +--- Also creates the augroup automatically if it doesn't exist +---@param definitions table contains a tuple of event, opts, see `:h nvim_create_autocmd` +function M.define_autocmds(definitions) +  for _, entry in ipairs(definitions) do +    local event = entry[1] +    local opts = entry[2] +    if type(opts.group) == "string" and opts.group ~= "" then +      local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group }) +      if not exists then +        vim.api.nvim_create_augroup(opts.group, {}) +      end      end - -    vim.cmd "augroup END" +    vim.api.nvim_create_autocmd(event, opts)    end  end diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index cb322032..2df1e514 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -144,9 +144,9 @@ end  -- Common kill function for bdelete and bwipeout  -- credits: based on bbye and nvim-bufdel ----@param kill_command String defaults to "bd" ----@param bufnr Number defaults to the current buffer ----@param force Boolean defaults to false +---@param kill_command string defaults to "bd" +---@param bufnr? number defaults to the current buffer +---@param force? boolean defaults to false  function M.buf_kill(kill_command, bufnr, force)    local bo = vim.bo    local api = vim.api diff --git a/lua/lvim/core/commands.lua b/lua/lvim/core/commands.lua index 4ddbfcf0..80c5bb03 100644 --- a/lua/lvim/core/commands.lua +++ b/lua/lvim/core/commands.lua @@ -1,7 +1,6 @@  local M = {} -M.defaults = { -  [[ +vim.cmd [[    function! QuickFixToggle()      if empty(filter(getwininfo(), 'v:val.quickfix'))        copen @@ -9,21 +8,70 @@ M.defaults = {        cclose      endif    endfunction -  ]], -  [[ command! BufferKill lua require('lvim.core.bufferline').buf_kill('bd') ]], -  -- :LvimInfo -  [[ command! LvimInfo lua require('lvim.core.info').toggle_popup(vim.bo.filetype) ]], -  [[ command! LvimCacheReset lua require('lvim.utils.hooks').reset_cache() ]], -  [[ command! LvimUpdate lua require('lvim.bootstrap').update() ]], -  [[ command! LvimSyncCorePlugins lua require('lvim.plugin-loader'):sync_core_plugins() ]], -  [[ command! LvimReload lua require('lvim.config'):reload() ]], -  [[ command! LvimToggleFormatOnSave lua require('lvim.core.autocmds').toggle_format_on_save() ]], -  [[ command! LvimVersion lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog() ]], +]] + +M.defaults = { +  { +    name = "BufferKill", +    fn = function() +      require("lvim.core.bufferline").buf_kill "bd" +    end, +  }, +  { +    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) -  for _, command in ipairs(commands) do -    vim.cmd(command) +function M.load(collection) +  local common_opts = { force = true } +  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 diff --git a/lua/lvim/core/dap.lua b/lua/lvim/core/dap.lua index 8f7eb294..727e238f 100644 --- a/lua/lvim/core/dap.lua +++ b/lua/lvim/core/dap.lua @@ -47,7 +47,7 @@ M.setup = function()      i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },      o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },      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" },      s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },      q = { "<cmd>lua require'dap'.close()<cr>", "Quit" }, diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua index 15ccb11c..bc05d72b 100644 --- a/lua/lvim/core/log.lua +++ b/lua/lvim/core/log.lua @@ -11,15 +11,26 @@ vim.tbl_add_reverse_lookup(Log.levels)  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()    local status_ok, structlog = pcall(require, "structlog")    if not status_ok then      return nil    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 lvim_log = {      lvim = { diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index 5b55bdc3..6a04a866 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -72,7 +72,7 @@ function M.config()        set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,        pickers = {          find_files = { -          find_command = { "fd", "--type=file", "--hidden", "--smart-case" }, +          hidden = true,          },          live_grep = {            --@usage don't include the filename in the search results @@ -130,6 +130,12 @@ function M.setup()      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      lvim.builtin.telescope.on_config_done(telescope)    end diff --git a/lua/lvim/core/treesitter.lua b/lua/lvim/core/treesitter.lua index d8b0c136..fcada24f 100644 --- a/lua/lvim/core/treesitter.lua +++ b/lua/lvim/core/treesitter.lua @@ -12,11 +12,12 @@ M.config = function()      },      highlight = {        enable = true, -- false will disable the whole extension -      additional_vim_regex_highlighting = true, +      additional_vim_regex_highlighting = false,        disable = { "latex" },      },      context_commentstring = {        enable = true, +      enable_autocmd = false,        config = {          -- Languages that have a single comment style          typescript = "// %s", @@ -28,9 +29,7 @@ M.config = function()          json = "",        },      }, -    -- indent = {enable = true, disable = {"python", "html", "javascript"}}, -    -- TODO seems to be broken -    indent = { enable = true, disable = { "yaml" } }, +    indent = { enable = true, disable = { "yaml", "python" } },      autotag = { enable = false },      textobjects = {        swap = { diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 3c3cc66b..b1ae6f87 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -82,7 +82,7 @@ M.config = function()      mappings = {        [";"] = { "<cmd>Alpha<CR>", "Dashboard" },        ["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" },        ["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" },        ["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" },          }, +        n = { "<cmd>Telescope notify<cr>", "View Notifications" },          r = { "<cmd>LvimReload<cr>", "Reload LunarVim's configuration" },          u = { "<cmd>LvimUpdate<cr>", "Update LunarVim" },        }, diff --git a/lua/lvim/keymappings.lua b/lua/lvim/keymappings.lua index 44ea1654..137f1cc0 100644 --- a/lua/lvim/keymappings.lua +++ b/lua/lvim/keymappings.lua @@ -21,8 +21,15 @@ local mode_adapters = {    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 = { -  ---@usage change or add keymappings for insert mode    insert_mode = {      -- 'jk' for quitting insert mode      ["jk"] = "<ESC>", @@ -41,7 +48,6 @@ local defaults = {      ["<A-Right>"] = "<C-\\><C-N><C-w>l",    }, -  ---@usage change or add keymappings for normal mode    normal_mode = {      -- Better window movement      ["<C-h>"] = "<C-w>h", @@ -69,7 +75,6 @@ local defaults = {      ["<C-q>"] = ":call QuickFixToggle()<CR>",    }, -  ---@usage change or add keymappings for terminal mode    term_mode = {      -- Terminal window navigation      ["<C-h>"] = "<C-\\><C-N><C-w>h", @@ -78,7 +83,6 @@ local defaults = {      ["<C-l>"] = "<C-\\><C-N><C-w>l",    }, -  ---@usage change or add keymappings for visual mode    visual_mode = {      -- Better indenting      ["<"] = "<gv", @@ -88,7 +92,6 @@ local defaults = {      -- ["P"] = '"0P',    }, -  ---@usage change or add keymappings for visual block mode    visual_block_mode = {      -- Move selected line / block of text in visual mode      ["K"] = ":move '<-2<CR>gv-gv", @@ -99,7 +102,6 @@ local defaults = {      ["<A-k>"] = ":m '<-2<CR>gv-gv",    }, -  ---@usage change or add keymappings for command mode    command_mode = {      -- navigate tab completion with <c-j> and <c-k>      -- runs conditionally @@ -116,18 +118,6 @@ if vim.fn.has "mac" == 1 then    Log:debug "Activated mac keymappings"  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  -- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..)  function M.clear(keymaps) @@ -137,7 +127,7 @@ function M.clear(keymaps)      for key, _ in pairs(mappings) do        -- 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 -        pcall(vim.api.nvim_del_keymap, translated_mode, key) +        pcall(vim.keymap.del, translated_mode, key)        end      end    end @@ -169,7 +159,7 @@ function M.set_keymaps(mode, key, val)      val = val[1]    end    if val then -    vim.api.nvim_set_keymap(mode, key, val, opt) +    vim.keymap.set(mode, key, val, opt)    else      pcall(vim.api.nvim_del_keymap, mode, key)    end @@ -197,9 +187,11 @@ end  -- Load the default keymappings  function M.load_defaults()    M.load(M.get_defaults()) -  lvim.keys = {} +  lvim.keys = lvim.keys or {}    for idx, _ in pairs(defaults) do -    lvim.keys[idx] = {} +    if not lvim.keys[idx] then +      lvim.keys[idx] = {} +    end    end  end diff --git a/lua/lvim/lsp/init.lua b/lua/lvim/lsp/init.lua index 13fafae0..2f3258c9 100644 --- a/lua/lvim/lsp/init.lua +++ b/lua/lvim/lsp/init.lua @@ -50,10 +50,10 @@ end  function M.common_on_exit(_, _)    if lvim.lsp.document_highlight then -    pcall(vim.api.nvim_del_augroup_by_name, "lsp_document_highlight") +    autocmds.clear_augroup "lsp_document_highlight"    end    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 @@ -74,7 +74,7 @@ function M.common_on_attach(client, bufnr)    if lvim.lsp.document_highlight then      lu.setup_document_highlight(client, bufnr)    end -  if lvim.lsp.code_lens_refresh == false then +  if lvim.lsp.code_lens_refresh then      lu.setup_codelens_refresh(client, bufnr)    end    add_lsp_buffer_keybindings(bufnr) diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index 2f24298d..9e898841 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -3,19 +3,6 @@ local M = {}  local Log = require "lvim.core.log"  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  ---@param server_name string  ---@vararg any config table [optional] diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index c976ff72..252e611c 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -122,16 +122,11 @@ function M.setup_codelens_refresh(client, bufnr)    if not augroup_exist then      vim.api.nvim_create_augroup("lsp_code_lens_refresh", {})    end -  vim.api.nvim_create_autocmd("InsertLeave", { +  vim.api.nvim_create_autocmd({ "BufEnter", "InsertLeave" }, {      group = "lsp_code_lens_refresh",      buffer = bufnr,      callback = vim.lsp.codelens.refresh,    }) -  vim.api.nvim_create_autocmd("InsertLeave", { -    group = "lsp_code_lens_refresh", -    buffer = bufnr, -    callback = vim.lsp.codelens.display, -  })  end  ---filter passed to vim.lsp.buf.format @@ -158,7 +153,7 @@ function M.format(opts)    opts = opts or { filter = M.format_filter }    if vim.lsp.buf.format then -    vim.lsp.buf.format(opts) +    return vim.lsp.buf.format(opts)    end    local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index c39311ed..3055a0a6 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -24,7 +24,6 @@ local core_plugins = {    },    {      "rcarriga/nvim-notify", -      config = function()        require("lvim.core.notify").setup()      end, @@ -38,7 +37,6 @@ local core_plugins = {    -- Telescope    {      "nvim-telescope/telescope.nvim", -      config = function()        require("lvim.core.telescope").setup()      end, @@ -214,7 +212,8 @@ local core_plugins = {    -- Debugger management    { -    "Pocco81/DAPInstall.nvim", +    "Pocco81/dap-buddy.nvim", +    branch = "dev",      -- event = "BufWinEnter",      -- event = "BufRead",      disable = not lvim.builtin.dap.active, diff --git a/lua/lvim/utils/functions.lua b/lua/lvim/utils/functions.lua new file mode 100644 index 00000000..de46bc8a --- /dev/null +++ b/lua/lvim/utils/functions.lua @@ -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 diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index f38a727f..81b1faf4 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -115,6 +115,20 @@ function M.get_lvim_tag()    return tag  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  ---@return string|nil  function M.get_lvim_current_sha() diff --git a/snapshots/default.json b/snapshots/default.json index 582b93ca..42529921 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,27 +1,24 @@  {    "Comment.nvim": { -    "commit": "cb0de89" -  }, -  "DAPInstall.nvim": { -    "commit": "bbda2b0" +    "commit": "cc87c89"    },    "FixCursorHold.nvim": {      "commit": "1bfb32e"    },    "LuaSnip": { -    "commit": "1dbafec" +    "commit": "08b06c3"    },    "alpha-nvim": {      "commit": "4781fcf"    },    "bufferline.nvim": { -    "commit": "2d5266d" +    "commit": "82e3598"    },    "cmp-buffer": { -    "commit": "d66c4c2" +    "commit": "12463cf"    },    "cmp-nvim-lsp": { -    "commit": "e6b5feb" +    "commit": "affe808"    },    "cmp-path": {      "commit": "466b6b8" @@ -29,53 +26,56 @@    "cmp_luasnip": {      "commit": "a9de941"    }, +  "dap-buddy.nvim": { +    "commit": "bbda2b0" +  },    "friendly-snippets": { -    "commit": "6e0881a" +    "commit": "02c92e3"    },    "gitsigns.nvim": { -    "commit": "61c8398" +    "commit": "44372ff"    },    "lua-dev.nvim": {      "commit": "54149d1"    },    "lualine.nvim": { -    "commit": "45d07fc" +    "commit": "c12b167"    },    "nlsp-settings.nvim": { -    "commit": "fc3007e" +    "commit": "7136038"    },    "null-ls.nvim": { -    "commit": "3dbded7" +    "commit": "af19226"    },    "nvim-autopairs": { -    "commit": "63779ea" +    "commit": "aea9131"    },    "nvim-cmp": { -    "commit": "baa8646" +    "commit": "033a817"    },    "nvim-dap": { -    "commit": "d6d8317" +    "commit": "a9c49a5"    },    "nvim-lsp-installer": { -    "commit": "193f171" +    "commit": "a655bdd"    },    "nvim-lspconfig": { -    "commit": "21102d5" +    "commit": "b86a37c"    },    "nvim-notify": { -    "commit": "ebe78be" +    "commit": "c6ca279"    },    "nvim-tree.lua": { -    "commit": "483f155" +    "commit": "b2ba6de"    },    "nvim-treesitter": { -    "commit": "4067351" +    "commit": "29b0ea8"    },    "nvim-ts-context-commentstring": {      "commit": "8834375"    },    "nvim-web-devicons": { -    "commit": "bdd4342" +    "commit": "0c5b6d1"    },    "onedarker.nvim": {      "commit": "b00dd21" @@ -84,7 +84,7 @@      "commit": "4dedd3b"    },    "plenary.nvim": { -    "commit": "9069d14" +    "commit": "1da13ad"    },    "popup.nvim": {      "commit": "b7404d3" @@ -93,21 +93,21 @@      "commit": "612443b"    },    "schemastore.nvim": { -    "commit": "57bb4e1" +    "commit": "675ec50"    },    "structlog.nvim": {      "commit": "6f1403a"    },    "telescope-fzf-native.nvim": { -    "commit": "281b07a" +    "commit": "2330a7e"    },    "telescope.nvim": { -    "commit": "23e28d0" +    "commit": "1a91238"    },    "toggleterm.nvim": { -    "commit": "6c7f5db" +    "commit": "c525442"    },    "which-key.nvim": { -    "commit": "03de564" +    "commit": "f03a259"    }  } diff --git a/tests/specs/config_loader_spec.lua b/tests/specs/config_loader_spec.lua index 40eaa350..99053548 100644 --- a/tests/specs/config_loader_spec.lua +++ b/tests/specs/config_loader_spec.lua @@ -1,10 +1,13 @@  local a = require "plenary.async_lib.tests"  local config = require "lvim.config" +local fmt = string.format  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() +    os.execute(fmt("cp -f %s %s", default_config_path, user_config_path))      vim.cmd [[  	    let v:errmsg = ""        let v:errors = [] @@ -41,23 +44,12 @@ a.describe("config-loader", function()    a.it("should not get interrupted by errors in user-config", function()      local test_path = "/tmp/lunarvim"      os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path)) -    config:reload() -    vim.schedule(function() -      assert.equal(vim.opt.undodir:get()[1], test_path) -    end) -    os.execute(string.format("echo 'bad_string_test' >> %s", user_config_path)) -    local error_handler = function(msg) -      return msg -    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) +    config:load(user_config_path) +    assert.equal(vim.opt.undodir:get()[1], test_path) +    require("lvim.core.log"):set_level "error" +    os.execute(string.format("echo 'invalid_function()' >> %s", user_config_path)) +    config:load(user_config_path) +    require("lvim.core.log"):set_level "error" +    assert.equal(vim.opt.undodir:get()[1], test_path)    end)  end) diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 562d4060..120cd783 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -20,9 +20,9 @@ lvim.leader = "space"  -- add your own keymapping  lvim.keys.normal_mode["<C-s>"] = ":w<cr>"  -- unmap a default keymapping --- lvim.keys.normal_mode["<C-Up>"] = false --- edit a default keymapping --- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" +-- vim.keymap.del("n", "<C-Up>") +-- override a default keymapping +-- 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.  -- 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) --- lvim.autocommands.custom_groups = { ---   { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, --- } +-- vim.api.nvim_create_autocmd("BufEnter", { +--   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, +-- }) diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index b659263a..78468194 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -37,9 +37,9 @@ lvim.leader = "space"  -- add your own keymapping  lvim.keys.normal_mode["<C-s>"] = ":w<cr>"  -- unmap a default keymapping --- lvim.keys.normal_mode["<C-Up>"] = false --- edit a default keymapping --- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" +-- vim.keymap.del("n", "<C-Up>") +-- override a default keymapping +-- 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.  -- 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) --- lvim.autocommands.custom_groups = { ---   { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, --- } +-- vim.api.nvim_create_autocmd("BufEnter", { +--   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, +-- }) | 
