diff options
| author | kylo252 <[email protected]> | 2022-06-10 14:37:32 +0200 | 
|---|---|---|
| committer | kylo252 <[email protected]> | 2022-06-10 14:37:32 +0200 | 
| commit | 2c520cf555a8c67493ce70859586f611b93d0f1d (patch) | |
| tree | 848b9fbf0255e79bd30b99256bb12782328e11c8 /lua/lvim/core | |
| parent | 3475f7675d8928b49c85878dfc2912407de57342 (diff) | |
| parent | 59361ebe7b677dea0ca490b989af89c8918e1618 (diff) | |
Merge branch 'rolling'
Diffstat (limited to 'lua/lvim/core')
| -rw-r--r-- | lua/lvim/core/autocmds.lua | 4 | ||||
| -rw-r--r-- | lua/lvim/core/bufferline.lua | 34 | ||||
| -rw-r--r-- | lua/lvim/core/log.lua | 2 | ||||
| -rw-r--r-- | lua/lvim/core/nvimtree.lua | 60 | 
4 files changed, 57 insertions, 43 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() 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 .. "!" 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", 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"] = { "<cmd>NvimTreeToggle<CR>", "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 | 
