fix error while closing file (#1002)
This commit is contained in:
parent
985217b93f
commit
9ae7c2aff3
@ -5,6 +5,7 @@ local g = vim.g
|
||||
g.did_load_filetypes = 0
|
||||
g.do_filetype_lua = 1
|
||||
|
||||
opt.confirm = true
|
||||
opt.laststatus = 3 -- global statusline
|
||||
opt.title = true
|
||||
opt.clipboard = "unnamedplus"
|
||||
|
@ -3,8 +3,22 @@ local M = {}
|
||||
local cmd = vim.cmd
|
||||
|
||||
M.close_buffer = function(force)
|
||||
if vim.bo.buftype == "terminal" then vim.api.nvim_win_hide(0) return end
|
||||
if vim.bo.buftype == "terminal" then
|
||||
vim.api.nvim_win_hide(0)
|
||||
return
|
||||
end
|
||||
|
||||
local fileExists = vim.fn.filereadable(vim.fn.expand "%p")
|
||||
local modified = vim.api.nvim_buf_get_option(vim.fn.bufnr(), "modified")
|
||||
|
||||
-- if file doesnt exist & its modified
|
||||
if fileExists == 0 and modified then
|
||||
print "no file name? add it now!"
|
||||
return
|
||||
end
|
||||
|
||||
force = force or not vim.bo.buflisted or vim.bo.buftype == "nofile"
|
||||
|
||||
-- if not force, change to prev buf and then close current
|
||||
local close_cmd = force and ":bd!" or ":bp | bd" .. vim.fn.bufnr()
|
||||
vim.cmd(close_cmd)
|
||||
@ -96,7 +110,9 @@ end
|
||||
M.remove_default_plugins = function(plugins)
|
||||
local removals = require("core.utils").load_config().plugins.remove or {}
|
||||
if not vim.tbl_isempty(removals) then
|
||||
for _, plugin in pairs(removals) do plugins[plugin] = nil end
|
||||
for _, plugin in pairs(removals) do
|
||||
plugins[plugin] = nil
|
||||
end
|
||||
end
|
||||
return plugins
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user