nvim: soft-wrap prose buffers and rework lsp config

This commit is contained in:
Rasyidan Akbar F. 2026-09-23 11:02:15 +07:00
commit 86b3bc3f0b
2 changed files with 107 additions and 74 deletions

View file

@ -7,3 +7,35 @@ vim.api.nvim_create_autocmd("TextYankPost", {
vim.highlight.on_yank()
end,
})
-- Prose-friendly buffers: soft-wrap long lines instead of truncating them.
-- markdown notes are authored as one long line per paragraph, and the global
-- `wrap = false` in options.lua makes those lines look "capped" at the edge.
local prose_filetypes = {
markdown = true,
text = true,
gitcommit = true,
}
vim.api.nvim_create_autocmd("FileType", {
group = group,
desc = "Soft-wrap prose filetypes, keep code nowrap",
callback = function(args)
local prose = prose_filetypes[args.match] == true
-- Window-local display options.
vim.wo.wrap = prose
vim.wo.linebreak = prose
vim.wo.breakindent = prose
vim.wo.spell = prose
-- Line numbers are noise when reading/writing prose.
vim.wo.number = not prose
vim.wo.relativenumber = not prose
if prose then
-- Never hard-wrap on insert; keep visual wrapping only.
vim.bo.textwidth = 0
end
end,
})