From a11c46c29ac23b367dae2b8ff2887879fb9cdbe2 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 26 May 2022 13:28:04 +0200 Subject: [PATCH 1/6] feat: prompt when closing modified/term buffers (#2658) --- lua/lvim/core/bufferline.lua | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index 2df1e514..28e0f06d 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -142,26 +142,42 @@ M.setup = function() end end +--stylua: ignore + -- Common kill function for bdelete and bwipeout -- credits: based on bbye and nvim-bufdel ----@param kill_command string defaults to "bd" +---@param kill_command? string defaults to "bd" ---@param bufnr? number defaults to the current buffer ---@param force? boolean defaults to false function M.buf_kill(kill_command, bufnr, force) + kill_command = kill_command or "bd" + local bo = vim.bo local api = vim.api + local fmt = string.format + local fnamemodify = vim.fn.fnamemodify if bufnr == 0 or bufnr == nil then bufnr = api.nvim_get_current_buf() end - kill_command = kill_command or "bd" + local bufname = api.nvim_buf_get_name(bufnr) - -- If buffer is modified and force isn't true, print error and abort - if not force and bo[bufnr].modified then - return api.nvim_err_writeln( - string.format("No write since last change for buffer %d (set force to true to override)", bufnr) - ) + if not force then + local warning + if bo[bufnr].modified then + warning = fmt([[No write since last change for (%s)]], fnamemodify(bufname, ":t")) + elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then + warning = fmt([[Terminal %s will be killed]], bufname) + end + if warning then + vim.ui.input({ + prompt = string.format([[%s. Close it anyway? [y]es or [n]o (default: no): ]], warning), + }, function(choice) + if choice:match "ye?s?" then force = true end + end) + if not force then return end + end end -- Get list of windows IDs with the buffer to close @@ -169,9 +185,7 @@ function M.buf_kill(kill_command, bufnr, force) return api.nvim_win_get_buf(win) == bufnr end, api.nvim_list_wins()) - if #windows == 0 then - return - end + if #windows == 0 then return end if force then kill_command = kill_command .. "!" From 7220f1f2041c35580cff799037f1421a211ccf79 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 26 May 2022 16:06:49 +0200 Subject: [PATCH 2/6] feat(cmp): add option to disable friendly-snippets (#2660) authored-by: Emerson Max de Medeiros Silva --- lua/lvim/config/init.lua | 6 ++++++ lua/lvim/plugins.lua | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index 1af9a971..4343ace9 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -40,6 +40,12 @@ function M:init() custom_section = {}, footer = {}, } + + lvim.builtin.luasnip = { + sources = { + friendly_snippets = true, + }, + } end local function handle_deprecated_settings() diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index 3055a0a6..9397318e 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -58,19 +58,20 @@ local core_plugins = { end, requires = { "L3MON4D3/LuaSnip", - "rafamadriz/friendly-snippets", }, }, { "rafamadriz/friendly-snippets", + disable = not lvim.builtin.luasnip.sources.friendly_snippets, }, { "L3MON4D3/LuaSnip", config = function() local utils = require "lvim.utils" - local paths = { - utils.join_paths(get_runtime_dir(), "site", "pack", "packer", "start", "friendly-snippets"), - } + local paths = {} + if lvim.builtin.luasnip.sources.friendly_snippets then + paths[#paths + 1] = utils.join_paths(get_runtime_dir(), "site", "pack", "packer", "start", "friendly-snippets") + end local user_snippets = utils.join_paths(get_config_dir(), "snippets") if utils.is_directory(user_snippets) then paths[#paths + 1] = user_snippets From ed50b7d33fe4a00494343dcb3db861f483d147f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez=20Rivero?= Date: Mon, 30 May 2022 08:29:12 +0200 Subject: [PATCH 3/6] fix(log): add date to the timestamp of logs (#2669) --- lua/lvim/core/log.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua index bc05d72b..49c70f83 100644 --- a/lua/lvim/core/log.lua +++ b/lua/lvim/core/log.lua @@ -52,7 +52,7 @@ function Log:init() processors = { structlog.processors.Namer(), structlog.processors.StackWriter({ "line", "file" }, { max_parents = 3, stack_level = 2 }), - structlog.processors.Timestamper "%H:%M:%S", + structlog.processors.Timestamper "%F %H:%M:%S", }, formatter = structlog.formatters.Format( -- "%s [%-5s] %s: %-30s", From 7c53bd64c570c1e7151090eb758a17211f45965d Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Tue, 31 May 2022 19:45:43 +0430 Subject: [PATCH 4/6] fix(nvimtree): update nvim-tree setup (#2681) --- lua/lvim/core/nvimtree.lua | 60 +++++++++++++------------- snapshots/default.json | 40 ++++++++--------- utils/installer/config.example.lua | 2 +- utils/installer/config_win.example.lua | 4 +- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index e4d28220..7f50f256 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -2,7 +2,6 @@ local M = {} local Log = require "lvim.core.log" function M.config() - local vim_show_icons = lvim.use_icons and 1 or 0 lvim.builtin.nvimtree = { active = true, on_config_done = nil, @@ -76,7 +75,35 @@ function M.config() }, icons = { webdev_colors = lvim.use_icons, + show = { + git = lvim.use_icons, + folder = lvim.use_icons, + file = lvim.use_icons, + folder_arrow = lvim.use_icons, + }, + glyphs = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, }, + highlight_git = true, + root_folder_modifier = ":t", }, filters = { dotfiles = false, @@ -120,34 +147,6 @@ function M.config() }, }, }, - show_icons = { - git = vim_show_icons, - folders = vim_show_icons, - files = vim_show_icons, - folder_arrows = vim_show_icons, - }, - git_hl = 1, - root_folder_modifier = ":t", - icons = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - }, - }, } lvim.builtin.which_key.mappings["e"] = { "NvimTreeToggle", "Explorer" } end @@ -165,7 +164,7 @@ function M.setup() -- Implicitly update nvim-tree when project module is active if lvim.builtin.project.active then - lvim.builtin.nvimtree.respect_buf_cwd = 1 + lvim.builtin.nvimtree.setup.respect_buf_cwd = true lvim.builtin.nvimtree.setup.update_cwd = true lvim.builtin.nvimtree.setup.update_focused_file = { enable = true, update_cwd = true } end @@ -173,6 +172,7 @@ function M.setup() local function telescope_find_files(_) require("lvim.core.nvimtree").start_telescope "find_files" end + local function telescope_live_grep(_) require("lvim.core.nvimtree").start_telescope "live_grep" end diff --git a/snapshots/default.json b/snapshots/default.json index 42529921..a08c9ebc 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,18 +1,18 @@ { "Comment.nvim": { - "commit": "cc87c89" + "commit": "bdf9ca6" }, "FixCursorHold.nvim": { "commit": "1bfb32e" }, "LuaSnip": { - "commit": "08b06c3" + "commit": "52f4aed" }, "alpha-nvim": { "commit": "4781fcf" }, "bufferline.nvim": { - "commit": "82e3598" + "commit": "e2b1e99" }, "cmp-buffer": { "commit": "12463cf" @@ -30,52 +30,52 @@ "commit": "bbda2b0" }, "friendly-snippets": { - "commit": "02c92e3" + "commit": "974d792" }, "gitsigns.nvim": { - "commit": "44372ff" + "commit": "27aeb2e" }, "lua-dev.nvim": { "commit": "54149d1" }, "lualine.nvim": { - "commit": "c12b167" + "commit": "3362b28" }, "nlsp-settings.nvim": { - "commit": "7136038" + "commit": "4690da2" }, "null-ls.nvim": { - "commit": "af19226" + "commit": "7b8560d" }, "nvim-autopairs": { - "commit": "aea9131" + "commit": "b9cc0a2" }, "nvim-cmp": { "commit": "033a817" }, "nvim-dap": { - "commit": "a9c49a5" + "commit": "0062c19" }, "nvim-lsp-installer": { - "commit": "a655bdd" + "commit": "d40cc5c" }, "nvim-lspconfig": { - "commit": "b86a37c" + "commit": "84252b0" }, "nvim-notify": { "commit": "c6ca279" }, "nvim-tree.lua": { - "commit": "b2ba6de" + "commit": "2002b21" }, "nvim-treesitter": { - "commit": "29b0ea8" + "commit": "5e24e8d" }, "nvim-ts-context-commentstring": { "commit": "8834375" }, "nvim-web-devicons": { - "commit": "0c5b6d1" + "commit": "8d2c533" }, "onedarker.nvim": { "commit": "b00dd21" @@ -90,22 +90,22 @@ "commit": "b7404d3" }, "project.nvim": { - "commit": "612443b" + "commit": "541115e" }, "schemastore.nvim": { - "commit": "675ec50" + "commit": "af73c24" }, "structlog.nvim": { - "commit": "6f1403a" + "commit": "232a8e2" }, "telescope-fzf-native.nvim": { "commit": "2330a7e" }, "telescope.nvim": { - "commit": "1a91238" + "commit": "54be102" }, "toggleterm.nvim": { - "commit": "c525442" + "commit": "93c2f2c" }, "which-key.nvim": { "commit": "f03a259" diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 120cd783..1bcff7f0 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -61,7 +61,7 @@ lvim.builtin.alpha.mode = "dashboard" lvim.builtin.notify.active = true lvim.builtin.terminal.active = true lvim.builtin.nvimtree.setup.view.side = "left" -lvim.builtin.nvimtree.show_icons.git = 0 +lvim.builtin.nvimtree.setup.renderer.icons.show.git = false -- if you don't want all the parsers change this to a table of the ones you want lvim.builtin.treesitter.ensure_installed = { diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index 78468194..011ca0da 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -85,8 +85,8 @@ lvim.builtin.nvimtree.setup.git.enable = false lvim.builtin.nvimtree.setup.update_cwd = false lvim.builtin.nvimtree.setup.update_focused_file.update_cwd = false lvim.builtin.nvimtree.setup.view.side = "left" -lvim.builtin.nvimtree.git_hl = false -lvim.builtin.nvimtree.show_icons.git = 0 +lvim.builtin.nvimtree.setup.renderer.highlight_git = false +lvim.builtin.nvimtree.setup.renderer.icons.show.git = false -- if you don't want all the parsers change this to a table of the ones you want lvim.builtin.treesitter.ensure_installed = { From f778a38c31daf53db42c4187faf08fcd004d441b Mon Sep 17 00:00:00 2001 From: Akihiro Okuno Date: Mon, 6 Jun 2022 18:50:24 +0900 Subject: [PATCH 5/6] fix(autocmds): toggle format-on-save properly (#2659) --- lua/lvim/core/autocmds.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index 0ca21439..20716e83 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -118,11 +118,11 @@ function M.configure_format_on_save() end function M.toggle_format_on_save() - local exists, _ = pcall(vim.api.nvim_get_autocmds, { + local exists, autocmds = pcall(vim.api.nvim_get_autocmds, { group = "lsp_format_on_save", event = "BufWritePre", }) - if not exists then + if not exists or #autocmds == 0 then M.enable_format_on_save() else M.disable_format_on_save() From 59361ebe7b677dea0ca490b989af89c8918e1618 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 09:53:16 +0430 Subject: [PATCH 6/6] chore: bump plugins version (#2654) * 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 | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index a08c9ebc..de28eeaf 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -12,7 +12,7 @@ "commit": "4781fcf" }, "bufferline.nvim": { - "commit": "e2b1e99" + "commit": "c78b3ec" }, "cmp-buffer": { "commit": "12463cf" @@ -42,10 +42,10 @@ "commit": "3362b28" }, "nlsp-settings.nvim": { - "commit": "4690da2" + "commit": "f27faa4" }, "null-ls.nvim": { - "commit": "7b8560d" + "commit": "474372a" }, "nvim-autopairs": { "commit": "b9cc0a2" @@ -54,22 +54,22 @@ "commit": "033a817" }, "nvim-dap": { - "commit": "0062c19" + "commit": "688cb52" }, "nvim-lsp-installer": { - "commit": "d40cc5c" + "commit": "ce70a78" }, "nvim-lspconfig": { - "commit": "84252b0" + "commit": "eb03999" }, "nvim-notify": { - "commit": "c6ca279" + "commit": "8252aae" }, "nvim-tree.lua": { - "commit": "2002b21" + "commit": "1caca62" }, "nvim-treesitter": { - "commit": "5e24e8d" + "commit": "178f24e" }, "nvim-ts-context-commentstring": { "commit": "8834375" @@ -81,10 +81,10 @@ "commit": "b00dd21" }, "packer.nvim": { - "commit": "4dedd3b" + "commit": "00ec5ad" }, "plenary.nvim": { - "commit": "1da13ad" + "commit": "54b2e3d" }, "popup.nvim": { "commit": "b7404d3" @@ -93,19 +93,19 @@ "commit": "541115e" }, "schemastore.nvim": { - "commit": "af73c24" + "commit": "3a15757" }, "structlog.nvim": { "commit": "232a8e2" }, "telescope-fzf-native.nvim": { - "commit": "2330a7e" + "commit": "f0dba7d" }, "telescope.nvim": { - "commit": "54be102" + "commit": "e6b69b1" }, "toggleterm.nvim": { - "commit": "93c2f2c" + "commit": "5bf839a" }, "which-key.nvim": { "commit": "f03a259"