Latest configuration changes

This commit is contained in:
Alex Selimov 2026-04-07 11:30:06 -04:00
parent b2d372c538
commit beca7d3566
9 changed files with 93 additions and 60 deletions

View file

@ -1,4 +1,4 @@
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
vim.opt_local.tw = 180
vim.opt_local.tw = 100
vim.opt_local.colorcolumn = "+1"

37
ftplugin/sh.lua Normal file
View file

@ -0,0 +1,37 @@
vim.opt_local.colorcolumn = "100"
vim.opt_local.textwidth = 100
vim.opt_local.expandtab = true
local function detect_indent(bufnr)
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, 100, false)
local counts = {}
for _, line in ipairs(lines) do
local spaces = line:match("^( +)[^ ]")
if spaces then
local n = #spaces
counts[n] = (counts[n] or 0) + 1
end
end
-- find the smallest indent size with meaningful usage
for _, size in ipairs({ 2, 4, 8 }) do
if (counts[size] or 0) > 0 then
return size
end
end
return 4 -- default
end
local bufnr = vim.api.nvim_get_current_buf()
local size = detect_indent(bufnr)
vim.opt_local.shiftwidth = size
vim.opt_local.tabstop = size
vim.opt_local.softtabstop = size
-- update beautysh indent size for this buffer
local ok, conform = pcall(require, "conform")
if ok then
conform.formatters.beautysh = {
prepend_args = { "--indent-size", tostring(size) },
}
end

View file

@ -1,2 +0,0 @@
set colorcolumn=100
set tw=100