punkfairie
726663247e
Update .config/nvim/lua/config/autocmds.lua Update .config/packages/archgirlie Update .config/pacman/pacman.conf Update .config/picom/awesomewm Update tags
58 lines
1.8 KiB
Cheetah
58 lines
1.8 KiB
Cheetah
-- Autocmds are automatically loaded on the VeryLazy event
|
|
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
|
-- Add any additional autocmds here
|
|
|
|
-- Open help window in a vertical split to the right.
|
|
vim.api.nvim_create_autocmd("BufWinEnter", {
|
|
group = vim.api.nvim_create_augroup("help_window_right", {}),
|
|
pattern = { "*.txt" },
|
|
callback = function()
|
|
if vim.o.filetype == "help" then
|
|
vim.cmd.wincmd("L")
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
|
pattern = { "*" },
|
|
callback = function()
|
|
local save_cursor = vim.fn.getpos(".")
|
|
pcall(function()
|
|
vim.cmd([[%s/\s\+$//e]])
|
|
end)
|
|
vim.fn.setpos(".", save_cursor)
|
|
end,
|
|
})
|
|
|
|
-- Define an autocmd group for the blade workaround
|
|
local augroup =
|
|
vim.api.nvim_create_augroup("lsp_blade_workaround", { clear = true })
|
|
|
|
-- Autocommand to temporarily change 'blade' filetype to 'php' when opening for LSP server activation
|
|
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
|
group = augroup,
|
|
pattern = "*.blade.php",
|
|
callback = function()
|
|
vim.bo.filetype = "php"
|
|
end,
|
|
})
|
|
|
|
-- Additional autocommand to switch back to 'blade' after LSP has attached
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
pattern = "*.blade.php",
|
|
callback = function(args)
|
|
vim.schedule(function()
|
|
-- Check if the attached client is 'intelephense'
|
|
for _, client in ipairs(vim.lsp.get_active_clients()) do
|
|
if
|
|
client.name == "intelephense" and client.attached_buffers[args.buf]
|
|
then
|
|
vim.api.nvim_buf_set_option(args.buf, "filetype", "blade")
|
|
-- update treesitter parser to blade
|
|
vim.api.nvim_buf_set_option(args.buf, "syntax", "blade")
|
|
break
|
|
end
|
|
end
|
|
end)
|
|
end,
|
|
})
|