Files
vern-nvim/lua/vern/attach/init.lua
T
DarthMooMancer 4bcac5d09b REFACTOR: I spent all day on it but I am heavily refactoring the API and
organization because it was terrible before and hard to maintain. Now it
should be much easier and there is still of a design decisions to figure
out
2026-10-15 02:07:14 -04:00

26 lines
702 B
Lua

local M = {}
function M.buf(bufnr, user_opts)
bufnr = (bufnr == nil or bufnr == 0) and vim.api.nvim_get_current_buf()
or bufnr
local ft = vim.bo[bufnr].filetype
if not ft or ft == "" then
return
end
user_opts = user_opts or {}
local default = require("vern.configs.default")
local lang_opts = (user_opts or {})[ft] or {}
local final_opts =
vim.tbl_deep_extend("force", {}, default, user_opts, lang_opts)
final_opts[ft] = nil
local ok, lang_attach = pcall(require, "vern.attach." .. ft) --- like a try / catch block in c++
if ok and type(lang_attach) == "function" then
lang_attach(bufnr, final_opts)
end
end
return M