feat(nvim): no empty buffers, no volar, no .git
This commit is contained in:
parent
5a3d9a1d31
commit
0299545228
3 changed files with 39 additions and 4 deletions
|
@ -79,6 +79,10 @@ require("nvim-tree").setup {
|
|||
quit_on_open = true,
|
||||
},
|
||||
},
|
||||
filters = {
|
||||
custom = { ".git" },
|
||||
exclude = { ".gitignore" },
|
||||
},
|
||||
}
|
||||
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
@ -101,6 +105,37 @@ local function open_nvim_tree(data)
|
|||
|
||||
-- open the tree
|
||||
require("nvim-tree.api").tree.open()
|
||||
|
||||
-- Get a list of all buffers
|
||||
local buffers = vim.api.nvim_list_bufs()
|
||||
|
||||
-- Iterate over each buffer
|
||||
for _, bufnr in ipairs(buffers) do
|
||||
-- Check if the buffer is empty and doesn't have a name
|
||||
if
|
||||
vim.api.nvim_buf_is_loaded(bufnr)
|
||||
and vim.api.nvim_buf_get_name(bufnr) == ""
|
||||
and vim.api.nvim_buf_get_option(bufnr, "buftype") == ""
|
||||
then
|
||||
-- Get all lines in the buffer
|
||||
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||
|
||||
-- Initialize a variable to store the total number of characters
|
||||
local total_characters = 0
|
||||
|
||||
-- Iterate over each line and calculate the number of characters
|
||||
for _, line in ipairs(lines) do
|
||||
total_characters = total_characters + #line
|
||||
end
|
||||
|
||||
-- Close the buffer if it's empty:
|
||||
if total_characters == 0 then
|
||||
vim.api.nvim_buf_delete(bufnr, {
|
||||
force = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- This file needs to have same structure as nvconfig.lua
|
||||
-- This file needs to have same structure as nvconfig.lua
|
||||
-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua
|
||||
-- Please read that file to know all available options :(
|
||||
-- Please read that file to know all available options :(
|
||||
|
||||
---@type ChadrcConfig
|
||||
local M = {}
|
||||
|
@ -16,6 +16,6 @@ M.ui = {
|
|||
}
|
||||
|
||||
M.nvdash = {
|
||||
load_on_startup = true,
|
||||
load_on_startup = false,
|
||||
}
|
||||
return M
|
||||
|
|
|
@ -15,7 +15,7 @@ local servers = {
|
|||
"pylsp",
|
||||
"tailwindcss",
|
||||
"templ",
|
||||
"vuels",
|
||||
-- "volar",
|
||||
}
|
||||
local nvlsp = require "nvchad.configs.lspconfig"
|
||||
|
||||
|
|
Loading…
Reference in a new issue