summaryrefslogtreecommitdiff
path: root/nvim/lua/autocommands.lua
diff options
context:
space:
mode:
author2025-05-13 10:07:17 +0300
committer2025-05-13 10:07:17 +0300
commite9a2f811b7d030cb8701bd8459fd5c842a521eff (patch)
tree2c59e183408f6d814bdb32453cae84f03f8bf88b /nvim/lua/autocommands.lua
parentПоправил тему zsh (diff)
downloaddotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.tar.gz
dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.tar.bz2
dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.tar.xz
dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.zip
Правки nvim конфига
Diffstat (limited to '')
-rw-r--r--nvim/lua/autocommands.lua42
1 files changed, 35 insertions, 7 deletions
diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua
index f0733f3..48c94d9 100644
--- a/nvim/lua/autocommands.lua
+++ b/nvim/lua/autocommands.lua
@@ -69,13 +69,6 @@ vim.api.nvim_create_autocmd("TextYankPost", {
end,
})
-vim.api.nvim_create_autocmd({ "BufReadPost", "FileReadPost" }, {
- pattern = "*",
- callback = function()
- vim.cmd("normal! zR")
- end,
-})
-
vim.api.nvim_create_autocmd("BufEnter", {
callback = function()
if vim.bo.filetype == "NvimTree" or vim.fn.expand("%") == "" then
@@ -92,6 +85,33 @@ vim.api.nvim_create_autocmd("BufEnter", {
end,
})
+vim.api.nvim_create_autocmd({ "BufEnter", "BufAdd", "BufNew", "BufNewFile", "BufWinEnter" }, {
+ group = vim.api.nvim_create_augroup("TS_FOLD_WORKAROUND", {}),
+ callback = function()
+ vim.opt.foldmethod = "expr"
+ vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
+ end,
+})
+vim.api.nvim_create_autocmd("FileType", {
+ pattern = "*",
+ callback = function(args)
+ local buf = args.buf
+ local ft = vim.bo[buf].filetype
+
+ if ft and ft ~= "" then
+ local has_parser, _ = pcall(vim.treesitter.language.get_lang, ft)
+ if has_parser then
+ pcall(vim.treesitter.start, buf, ft)
+ end
+ end
+ end
+})
+vim.api.nvim_create_autocmd("User", {
+ pattern = "TSUpdate",
+ callback = function()
+ vim.cmd([[TSEnable highlight]])
+ end,
+})
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
pattern = "*.templ",
callback = function()
@@ -146,6 +166,14 @@ vim.api.nvim_create_autocmd("FileType", {
vim.opt_local.cindent = false
end,
})
+
+vim.api.nvim_create_autocmd("VimResized", {
+ pattern = "*",
+ callback = function()
+ vim.opt.scrolloff = vim.fn.floor(vim.fn.winheight(0) / 2)
+ end,
+})
+
-- vim.api.nvim_create_autocmd("InsertEnter", {
-- pattern = "*",
-- command = "set norelativenumber",