-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin):delete buffers before loading a session
- Loading branch information
Showing
6 changed files
with
39 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ require('possession').setup { | |
}, | ||
nvim_tree = true, | ||
tabby = true, | ||
delete_buffers = true, | ||
}, | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ local function defaults() | |
}, | ||
nvim_tree = true, | ||
tabby = true, | ||
delete_buffers = true, | ||
}, | ||
} | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local M = {} | ||
|
||
function M.before_load(_, _, plugin_data) | ||
-- Deleting the current buffer before deleting other buffers will cause autocmd "BufEnter" to be triggered. | ||
-- Lspconfig will use the invalid buffer handler in vim.schedule. | ||
-- So make sure the current buffer is the last one to delete. | ||
local current_buffer = vim.api.nvim_get_current_buf() | ||
for _, buffer in ipairs(vim.api.nvim_list_bufs()) do | ||
if vim.api.nvim_buf_is_valid(buffer) and current_buffer ~= buffer then | ||
vim.api.nvim_buf_delete(buffer, { force = true }) | ||
end | ||
end | ||
vim.api.nvim_buf_delete(current_buffer, { force = true }) | ||
vim.lsp.stop_client(vim.lsp.get_active_clients()) | ||
return plugin_data | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters