-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
70 lines (61 loc) · 2.05 KB
/
Copy pathinit.lua
File metadata and controls
70 lines (61 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
_G.fignvim = {} -- Create global fignvim table
require("utils")
require("autocmds")
require("options")
require("mappings")
require("plugins")
require("ui")
require("diagnostics")
-- Load statusline module for native/Heirline toggle
require("statusline")
local cmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
-- Quit Nvim when only sidebars are left
augroup("auto_quit", { clear = true })
cmd("BufEnter", {
desc = "Quit AstroNvim if more than one window is open and only sidebar windows are list",
group = "auto_quit",
callback = function()
local wins = vim.api.nvim_tabpage_list_wins(0)
-- Both neo-tree and aerial will auto-quit if there is only a single window left
if #wins <= 1 then
return
end
local sidebar_fts = { aerial = true, ["neo-tree"] = true }
for _, winid in ipairs(wins) do
if vim.api.nvim_win_is_valid(winid) then
local bufnr = vim.api.nvim_win_get_buf(winid)
-- If any visible windows are not sidebars, early return
if not sidebar_fts[vim.api.nvim_buf_get_option(bufnr, "filetype")] then
return
end
end
end
if #vim.api.nvim_list_tabpages() > 1 then
vim.cmd.tabclose()
else
vim.cmd.qall()
end
end,
})
-- Modifies settings and mappings for certain plugin buffer types
augroup("support_buffers", { clear = true })
cmd("FileType", {
desc = "Close the matching buffer types with 'q'",
group = "support_buffers",
pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "grug-far" },
callback = function()
vim.keymap.set("n", "q", ":close<CR>", { silent = true, buffer = true })
vim.api.nvim_set_option_value("buflisted", false, { scope = "local" })
end,
})
-- Sets spelling option for certain filetypes
augroup("enable_spelling", { clear = true })
cmd("FileType", {
desc = "Enable spell checking for certain filetypes",
group = "enable_spelling",
pattern = { "markdown", "text", "tex", "org" },
callback = function()
vim.api.nvim_set_option_value("spell", true, { scope = "local" })
end,
})