my-nvim-lua/lua/misc-utils.lua

44 lines
970 B
Lua
Raw Normal View History

2021-03-13 01:23:02 +00:00
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
2021-03-07 14:22:30 +00:00
local function opt(scope, key, value)
2021-03-13 01:23:02 +00:00
scopes[scope][key] = value
if scope ~= "o" then
scopes["o"][key] = value
end
2021-03-07 14:22:30 +00:00
end
2021-03-13 01:23:02 +00:00
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)
2021-04-08 02:08:29 +00:00
opt("w", "cul", true)
2021-03-07 14:22:30 +00:00
2021-03-13 01:23:02 +00:00
opt("o", "mouse", "a")
2021-03-07 14:22:30 +00:00
2021-03-13 01:23:02 +00:00
opt("w", "signcolumn", "yes")
opt("o", "cmdheight", 1)
2021-03-13 10:51:52 +00:00
2021-04-08 02:08:29 +00:00
opt("o", "updatetime", 250) -- update interval for gitsigns
2021-03-13 01:23:02 +00:00
opt("o", "clipboard", "unnamedplus")
2021-03-13 10:51:52 +00:00
-- for indenline
2021-04-08 02:08:29 +00:00
opt("b", "expandtab", true)
opt("b", "shiftwidth", 2)
2021-03-08 05:24:53 +00:00
local M = {}
function M.is_buffer_empty()
2021-03-13 01:23:02 +00:00
-- Check whether the current buffer is empty
return vim.fn.empty(vim.fn.expand("%:t")) == 1
2021-03-08 05:24:53 +00:00
end
function M.has_width_gt(cols)
2021-03-13 01:23:02 +00:00
-- Check if the windows width is greater than a given number of columns
return vim.fn.winwidth(0) / 2 > cols
2021-03-08 05:24:53 +00:00
end
return M