Files
dotfiles/dot_config/nvim/lua/autocmds.lua
2026-01-28 15:06:46 +01:00

48 lines
937 B
Lua

require "nvchad.autocmds"
vim.api.nvim_create_autocmd("FileType", {
pattern = "java",
command = "setlocal shiftwidth=4 tabstop=4",
})
vim.filetype.add {
extension = {
yml = "yaml.ansible",
},
}
-- Nvim Tree
local function open_nvim_tree(data)
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
if not directory then
return
end
-- change to the directory
vim.cmd.cd(data.file)
-- open the tree
require("nvim-tree.api").tree.open()
end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
vim.api.nvim_create_autocmd({ "QuitPre" }, {
callback = function()
vim.cmd "NvimTreeClose"
end,
})
-- venv
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*.py",
callback = function()
local venv = vim.fn.finddir(".venv", vim.fn.getcwd() .. ";")
if venv ~= "" then
require("venv-selector").retrieve_from_cache()
end
end,
})