From 5566076ebb539a7d72dd64af257413fd4dde6157 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 3 May 2022 14:36:43 +0200 Subject: chore(ci): fix failing plugins-update action --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From e1d32ca42ee6fdef8c724e3f391e548895f0bdcf Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Tue, 3 May 2022 19:01:53 +0430 Subject: feat(quit): make sure to ask before discarding changes (#2554) --- lua/lvim/core/which-key.lua | 2 +- lua/lvim/utils/functions.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 lua/lvim/utils/functions.lua diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 3c3cc66b..be4487f3 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -82,7 +82,7 @@ M.config = function() mappings = { [";"] = { "Alpha", "Dashboard" }, ["w"] = { "w!", "Save" }, - ["q"] = { "q!", "Quit" }, + ["q"] = { "lua require('lvim.utils.functions').smart_quit()", "Quit" }, ["/"] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, ["c"] = { "BufferKill", "Close Buffer" }, ["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" }, 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 -- cgit v1.2.3 From cf426e1ff27931153357d0db3a5df4e180ac230b Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Thu, 5 May 2022 18:51:51 +0430 Subject: fix(dap): temporarily use dap-buddy dev branch which has older code (#2567) --- lua/lvim/plugins.lua | 3 ++- snapshots/default.json | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index c39311ed..e0445d58 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -214,7 +214,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/snapshots/default.json b/snapshots/default.json index 582b93ca..22ad665a 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -2,8 +2,8 @@ "Comment.nvim": { "commit": "cb0de89" }, - "DAPInstall.nvim": { - "commit": "bbda2b0" + "dap-buddy.nvim": { + "commit": "3679132" }, "FixCursorHold.nvim": { "commit": "1bfb32e" -- cgit v1.2.3 From e14ad73fa6fcf3e24108db9c21fd01bf7ae7529c Mon Sep 17 00:00:00 2001 From: Thomas Benard Date: Thu, 5 May 2022 16:23:48 +0200 Subject: fix(dap): pause key binding commmand (#2573) Co-authored-by: Thomas Bernard --- lua/lvim/core/dap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = { "lua require'dap'.step_into()", "Step Into" }, o = { "lua require'dap'.step_over()", "Step Over" }, u = { "lua require'dap'.step_out()", "Step Out" }, - p = { "lua require'dap'.pause.toggle()", "Pause" }, + p = { "lua require'dap'.pause()", "Pause" }, r = { "lua require'dap'.repl.toggle()", "Toggle Repl" }, s = { "lua require'dap'.continue()", "Start" }, q = { "lua require'dap'.close()", "Quit" }, -- cgit v1.2.3 From be5afb5b77879afebd745e8e35d6f683b14e7224 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 May 2022 01:37:09 +0430 Subject: chore: bump plugins version (#2563) * chore: bump plugins version * chore(plugins): update * chore(update): replace DAPInstall with dap-buddy Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Abouzar Parvan --- snapshots/default.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 22ad665a..3179bc77 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -2,14 +2,11 @@ "Comment.nvim": { "commit": "cb0de89" }, - "dap-buddy.nvim": { - "commit": "3679132" - }, "FixCursorHold.nvim": { "commit": "1bfb32e" }, "LuaSnip": { - "commit": "1dbafec" + "commit": "cc00863" }, "alpha-nvim": { "commit": "4781fcf" @@ -29,11 +26,14 @@ "cmp_luasnip": { "commit": "a9de941" }, + "dap-buddy.nvim": { + "commit": "bbda2b0" + }, "friendly-snippets": { "commit": "6e0881a" }, "gitsigns.nvim": { - "commit": "61c8398" + "commit": "0beb194" }, "lua-dev.nvim": { "commit": "54149d1" @@ -42,34 +42,34 @@ "commit": "45d07fc" }, "nlsp-settings.nvim": { - "commit": "fc3007e" + "commit": "0ca91e1" }, "null-ls.nvim": { "commit": "3dbded7" }, "nvim-autopairs": { - "commit": "63779ea" + "commit": "aea9131" }, "nvim-cmp": { - "commit": "baa8646" + "commit": "f81bfee" }, "nvim-dap": { - "commit": "d6d8317" + "commit": "d73ebd6" }, "nvim-lsp-installer": { - "commit": "193f171" + "commit": "91fe454" }, "nvim-lspconfig": { - "commit": "21102d5" + "commit": "2f37b2c" }, "nvim-notify": { - "commit": "ebe78be" + "commit": "d4a01ee" }, "nvim-tree.lua": { "commit": "483f155" }, "nvim-treesitter": { - "commit": "4067351" + "commit": "cf3e963" }, "nvim-ts-context-commentstring": { "commit": "8834375" @@ -93,7 +93,7 @@ "commit": "612443b" }, "schemastore.nvim": { - "commit": "57bb4e1" + "commit": "aaf3d78" }, "structlog.nvim": { "commit": "6f1403a" @@ -102,12 +102,12 @@ "commit": "281b07a" }, "telescope.nvim": { - "commit": "23e28d0" + "commit": "4681dcd" }, "toggleterm.nvim": { - "commit": "6c7f5db" + "commit": "c3fac3d" }, "which-key.nvim": { - "commit": "03de564" + "commit": "f03a259" } } -- cgit v1.2.3 From f7ba2c890238dcee8961ec5b59e5baf3dd27a5b5 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Fri, 6 May 2022 14:12:55 +0430 Subject: fix(autocmds): make sure we are using codelens correctly (#2576) --- lua/lvim/lsp/init.lua | 2 +- lua/lvim/lsp/utils.lua | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lua/lvim/lsp/init.lua b/lua/lvim/lsp/init.lua index 13fafae0..5bdebe52 100644 --- a/lua/lvim/lsp/init.lua +++ b/lua/lvim/lsp/init.lua @@ -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/utils.lua b/lua/lvim/lsp/utils.lua index c976ff72..9831c071 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", "CursorHold", "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 -- cgit v1.2.3 From cbeff80603d0e3b90c5e7be1ab4465ae2fac01e2 Mon Sep 17 00:00:00 2001 From: Rafael Madriz Date: Mon, 9 May 2022 22:07:07 -0300 Subject: ref(telescope): don't overwrite default cmd to show hidden files There's no need to overwrite default `find_files` command if we only want to show hidden files. Instead we can pass the `hidden` option. See: `help telescope.builtin.find_files()` Ref: #1702 --- lua/lvim/core/telescope.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index 5b55bdc3..07dd4b89 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 -- cgit v1.2.3 From 47e26746df7e0d85bccbe645a64bfea983d13e6a Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Tue, 10 May 2022 23:28:30 +0800 Subject: fix: use correct cache path (#2593) --- lua/lvim/bootstrap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From b0608275189f6adf389053e4a19447732eae08dd Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 May 2022 19:01:04 +0430 Subject: feat(codelens): cursorhold is too much intrusive for codelens (#2600) --- lua/lvim/lsp/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index 9831c071..cf9db68f 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -122,7 +122,7 @@ 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({ "BufEnter", "CursorHold", "InsertLeave" }, { + vim.api.nvim_create_autocmd({ "BufEnter", "InsertLeave" }, { group = "lsp_code_lens_refresh", buffer = bufnr, callback = vim.lsp.codelens.refresh, -- cgit v1.2.3 From a2714c3c382a1b6c9d4390eead924cc48ac594a3 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Wed, 11 May 2022 17:15:00 +0200 Subject: fix(autocmds): disable commentstring_calc on cursor-hold (#2581) --- lua/lvim/core/treesitter.lua | 7 +++---- lua/lvim/lsp/utils.lua | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) 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/lsp/utils.lua b/lua/lvim/lsp/utils.lua index cf9db68f..252e611c 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -153,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() -- cgit v1.2.3 From d868dc14fe04792fc989bb94592f3ba697edd692 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 May 2022 07:18:58 +0430 Subject: chore: bump plugins version (#2582) * chore: bump plugins version * chore(plugins): update Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Abouzar Parvan --- snapshots/default.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 3179bc77..26119e78 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,6 +1,6 @@ { "Comment.nvim": { - "commit": "cb0de89" + "commit": "79b356d" }, "FixCursorHold.nvim": { "commit": "1bfb32e" @@ -12,10 +12,10 @@ "commit": "4781fcf" }, "bufferline.nvim": { - "commit": "2d5266d" + "commit": "ee1d51e" }, "cmp-buffer": { - "commit": "d66c4c2" + "commit": "12463cf" }, "cmp-nvim-lsp": { "commit": "e6b5feb" @@ -30,46 +30,46 @@ "commit": "bbda2b0" }, "friendly-snippets": { - "commit": "6e0881a" + "commit": "4ef45d0" }, "gitsigns.nvim": { - "commit": "0beb194" + "commit": "aca84fd" }, "lua-dev.nvim": { "commit": "54149d1" }, "lualine.nvim": { - "commit": "45d07fc" + "commit": "619eded" }, "nlsp-settings.nvim": { - "commit": "0ca91e1" + "commit": "854a308" }, "null-ls.nvim": { - "commit": "3dbded7" + "commit": "dcad76e" }, "nvim-autopairs": { "commit": "aea9131" }, "nvim-cmp": { - "commit": "f81bfee" + "commit": "a226b6a" }, "nvim-dap": { - "commit": "d73ebd6" + "commit": "2249fcf" }, "nvim-lsp-installer": { - "commit": "91fe454" + "commit": "f5569f6" }, "nvim-lspconfig": { - "commit": "2f37b2c" + "commit": "ce8a4d8" }, "nvim-notify": { "commit": "d4a01ee" }, "nvim-tree.lua": { - "commit": "483f155" + "commit": "82ec79a" }, "nvim-treesitter": { - "commit": "cf3e963" + "commit": "10d57b3" }, "nvim-ts-context-commentstring": { "commit": "8834375" @@ -93,7 +93,7 @@ "commit": "612443b" }, "schemastore.nvim": { - "commit": "aaf3d78" + "commit": "88fc796" }, "structlog.nvim": { "commit": "6f1403a" @@ -102,10 +102,10 @@ "commit": "281b07a" }, "telescope.nvim": { - "commit": "4681dcd" + "commit": "795a63e" }, "toggleterm.nvim": { - "commit": "c3fac3d" + "commit": "ea21c3e" }, "which-key.nvim": { "commit": "f03a259" -- cgit v1.2.3 From 15da6658c8ba815f19dee802ff52c25c2ffe266c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez=20Rivero?= Date: Sun, 15 May 2022 15:58:53 +0200 Subject: chore: update templates (#2610) * fix: update general-issue-form.yaml * chore: update templates Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/general-issue-form.yaml | 30 ++++++++++++++------- .github/ISSUE_TEMPLATE/lsp-issue-form.yaml | 36 ++++++++++++++++---------- .github/pull_request_template.md | 24 ++++++++--------- 3 files changed, 54 insertions(+), 36 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,30 +57,37 @@ 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: 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 @@ # 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) + -## 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? + + + - Run command `:mycommand` - Check logs - ... -- cgit v1.2.3 From 42529e1c4f55824534184ec0658f0eefb328ac3d Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Sun, 15 May 2022 21:59:36 +0800 Subject: fix: load notify's telescope extension properly (#2586) * fix: load notify's telescope extension * fix: add which-key integration for notify --- lua/lvim/core/telescope.lua | 6 ++++++ lua/lvim/core/which-key.lua | 1 + lua/lvim/plugins.lua | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index 07dd4b89..6a04a866 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -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/which-key.lua b/lua/lvim/core/which-key.lua index be4487f3..b1ae6f87 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -234,6 +234,7 @@ M.config = function() }, P = { "edit $LUNARVIM_CACHE_DIR/packer.nvim.log", "Open the Packer logfile" }, }, + n = { "Telescope notify", "View Notifications" }, r = { "LvimReload", "Reload LunarVim's configuration" }, u = { "LvimUpdate", "Update LunarVim" }, }, diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index e0445d58..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, -- cgit v1.2.3 From a2454310b6c0b5b530521a77b9b8eb290274e040 Mon Sep 17 00:00:00 2001 From: Rafael Madriz Date: Wed, 18 May 2022 13:10:52 -0300 Subject: chore(docs): trim trailing white space --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 ``` -- cgit v1.2.3 From 23df368b00bda0ed4a01fac92f7ad80998c1d34a Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 21 May 2022 16:48:47 +0200 Subject: refactor: load the default options once (#2592) BREAKING CHANGE: modifying the default options for keymaps and autocmds is now done by overwriting them, since they won't be loaded into the global `lvim` table anymore * refactor: use the lua-commands api * refactor!: use the lua-autocmds api * fix(settings): let neovim handle spellfile * feat: add log:set_log_level() * chore: update examples * chore: add deprecation notice for custom_groups --- .github/workflows/commitlint.config.js | 11 +++ lua/lvim/config/init.lua | 37 +++----- lua/lvim/config/settings.lua | 17 ++-- lua/lvim/core/alpha.lua | 28 +++--- lua/lvim/core/alpha/dashboard.lua | 13 +-- lua/lvim/core/autocmds.lua | 167 ++++++++++++++++++++------------- lua/lvim/core/bufferline.lua | 6 +- lua/lvim/core/commands.lua | 78 ++++++++++++--- lua/lvim/core/log.lua | 17 +++- lua/lvim/keymappings.lua | 34 +++---- lua/lvim/lsp/init.lua | 4 +- lua/lvim/lsp/manager.lua | 13 --- lua/lvim/utils/git.lua | 14 +++ tests/specs/config_loader_spec.lua | 30 +++--- utils/installer/config.example.lua | 21 +++-- utils/installer/config_win.example.lua | 21 +++-- 16 files changed, 304 insertions(+), 207 deletions(-) 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/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 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 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 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 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", - "edit " .. require("lvim.config").get_user_config_path() .. " ", + "edit " .. require("lvim.config"):get_user_config_path() .. " ", }, }, } 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 q :close" }, + 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 q :q" }, + { + "FileType", + { + group = "_buffer_mappings", + pattern = { "qf", "help", "man", "floaterm", "lspinfo", "lsp-installer", "null-ls-info" }, + command = "nnoremap q :close", + }, }, - _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 q :close" }, + { + "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! * ]] - 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/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/keymappings.lua b/lua/lvim/keymappings.lua index 62a351ee..8c91b761 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"] = "", @@ -41,7 +48,6 @@ local defaults = { [""] = "l", }, - ---@usage change or add keymappings for normal mode normal_mode = { -- Better window movement [""] = "h", @@ -69,7 +75,6 @@ local defaults = { [""] = ":call QuickFixToggle()", }, - ---@usage change or add keymappings for terminal mode term_mode = { -- Terminal window navigation [""] = "h", @@ -78,7 +83,6 @@ local defaults = { [""] = "l", }, - ---@usage change or add keymappings for visual mode visual_mode = { -- Better indenting ["<"] = ""] = ":m '<-2gv-gv", }, - ---@usage change or add keymappings for command mode command_mode = { -- navigate tab completion with and -- runs conditionally @@ -116,16 +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) - 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) @@ -135,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 @@ -152,7 +144,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 @@ -180,9 +172,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 5bdebe52..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 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/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/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[""] = ":w" -- unmap a default keymapping --- lvim.keys.normal_mode[""] = false --- edit a default keymapping --- lvim.keys.normal_mode[""] = ":q" +-- vim.keymap.del("n", "") +-- override a default keymapping +-- lvim.keys.normal_mode[""] = ":q" -- or vim.keymap.set("n", "", ":q" ) -- 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[""] = ":w" -- unmap a default keymapping --- lvim.keys.normal_mode[""] = false --- edit a default keymapping --- lvim.keys.normal_mode[""] = ":q" +-- vim.keymap.del("n", "") +-- override a default keymapping +-- lvim.keys.normal_mode[""] = ":q" -- or vim.keymap.set("n", "", ":q" ) -- 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, +-- }) -- cgit v1.2.3 From cb6502ee30e043b13914f7bddb373a40dcc73af4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 May 2022 09:21:03 +0430 Subject: chore: bump plugins version (#2607) * chore: bump plugins version * chore(plugins): update Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Abouzar Parvan --- snapshots/default.json | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 26119e78..42529921 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,24 +1,24 @@ { "Comment.nvim": { - "commit": "79b356d" + "commit": "cc87c89" }, "FixCursorHold.nvim": { "commit": "1bfb32e" }, "LuaSnip": { - "commit": "cc00863" + "commit": "08b06c3" }, "alpha-nvim": { "commit": "4781fcf" }, "bufferline.nvim": { - "commit": "ee1d51e" + "commit": "82e3598" }, "cmp-buffer": { "commit": "12463cf" }, "cmp-nvim-lsp": { - "commit": "e6b5feb" + "commit": "affe808" }, "cmp-path": { "commit": "466b6b8" @@ -30,52 +30,52 @@ "commit": "bbda2b0" }, "friendly-snippets": { - "commit": "4ef45d0" + "commit": "02c92e3" }, "gitsigns.nvim": { - "commit": "aca84fd" + "commit": "44372ff" }, "lua-dev.nvim": { "commit": "54149d1" }, "lualine.nvim": { - "commit": "619eded" + "commit": "c12b167" }, "nlsp-settings.nvim": { - "commit": "854a308" + "commit": "7136038" }, "null-ls.nvim": { - "commit": "dcad76e" + "commit": "af19226" }, "nvim-autopairs": { "commit": "aea9131" }, "nvim-cmp": { - "commit": "a226b6a" + "commit": "033a817" }, "nvim-dap": { - "commit": "2249fcf" + "commit": "a9c49a5" }, "nvim-lsp-installer": { - "commit": "f5569f6" + "commit": "a655bdd" }, "nvim-lspconfig": { - "commit": "ce8a4d8" + "commit": "b86a37c" }, "nvim-notify": { - "commit": "d4a01ee" + "commit": "c6ca279" }, "nvim-tree.lua": { - "commit": "82ec79a" + "commit": "b2ba6de" }, "nvim-treesitter": { - "commit": "10d57b3" + "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,19 +93,19 @@ "commit": "612443b" }, "schemastore.nvim": { - "commit": "88fc796" + "commit": "675ec50" }, "structlog.nvim": { "commit": "6f1403a" }, "telescope-fzf-native.nvim": { - "commit": "281b07a" + "commit": "2330a7e" }, "telescope.nvim": { - "commit": "795a63e" + "commit": "1a91238" }, "toggleterm.nvim": { - "commit": "ea21c3e" + "commit": "c525442" }, "which-key.nvim": { "commit": "f03a259" -- cgit v1.2.3 From 6dbba1f9597e0ba090702aea41357c29874aab7c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 25 May 2022 11:44:13 +0200 Subject: refactor: remove redundant ftdetects (#2651) --- ftdetect/bicep.lua | 3 --- ftdetect/fish.lua | 3 --- ftdetect/fsautocomplete.lua | 3 --- ftdetect/julia.lua | 1 - ftdetect/nix.lua | 1 - ftdetect/sol.lua | 3 --- ftdetect/zig.lua | 1 - 7 files changed, 15 deletions(-) delete mode 100644 ftdetect/bicep.lua delete mode 100644 ftdetect/fish.lua delete mode 100644 ftdetect/fsautocomplete.lua delete mode 100644 ftdetect/julia.lua delete mode 100644 ftdetect/nix.lua delete mode 100644 ftdetect/sol.lua 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 ]] -- cgit v1.2.3