You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NvChad/lua/misc-utils.lua

46 lines
1.1 KiB
Lua

4 years ago
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
4 years ago
local function opt(scope, key, value)
4 years ago
scopes[scope][key] = value
if scope ~= "o" then
scopes["o"][key] = value
end
4 years ago
end
4 years ago
opt("o", "hidden", true)
opt("o", "ignorecase", true)
opt("o", "splitbelow", true)
opt("o", "splitright", true)
opt("o", "termguicolors", true)
opt("w", "number", true)
opt("o", "numberwidth", 2)
opt("w", "cul", true)
4 years ago
4 years ago
opt("o", "mouse", "a")
4 years ago
4 years ago
opt("w", "signcolumn", "yes")
opt("o", "cmdheight", 1)
4 years ago
opt("o", "updatetime", 250) -- update interval for gitsigns
4 years ago
opt("o", "clipboard", "unnamedplus")
opt("o", "timeoutlen", 500)
4 years ago
-- for indenline
opt("b", "expandtab", true)
opt("b", "shiftwidth", 2)
4 years ago
local M = {}
function M.is_buffer_empty()
4 years ago
-- Check whether the current buffer is empty
return vim.fn.empty(vim.fn.expand("%:t")) == 1
4 years ago
end
function M.has_width_gt(cols)
4 years ago
-- Check if the windows width is greater than a given number of columns
return vim.fn.winwidth(0) / 2 > cols
4 years ago
end
-- file extension specific tabbing
vim.cmd([[autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4]])
4 years ago
return M