Add textwidth to 80 on markdown files

main
antoine.lenours 2025-05-28 16:12:23 +02:00
parent e5bdddc7cb
commit 128996be26
5 changed files with 53 additions and 3 deletions

View File

@ -20,5 +20,7 @@ M.base46 = {
-- lazyload = false
-- }
--}
vim.defer_fn(function()
pcall(require, "custom.filetype")
end, 0)
return M

View File

@ -4,6 +4,7 @@ local options = {
css = { "prettier" },
html = { "prettier" },
python = { "ruff" },
markdown = { "prettier" },
},
format_on_save = {

10
lua/custom/filetype.lua Normal file
View File

@ -0,0 +1,10 @@
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.opt_local.textwidth = 60 -- soft wrap guide
vim.opt_local.wrap = true -- enable visual wrapping
vim.opt_local.linebreak = true -- wrap at word boundaries
vim.opt_local.spell = true -- optional: spell check
vim.opt_local.spelllang = "fr" -- optional: French spell check
end,
})

View File

@ -1,7 +1,17 @@
require "nvchad.options"
vim.opt.spelllang = fr
vim.opt.spell =true
vim.opt.spelllang = {"fr"}
vim.opt.spell = true
vim.textwidth = 80
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.opt_local.textwidth = 80 -- set line wrap at 60 characters
vim.opt_local.wrap = true -- enable visual line wrapping
vim.opt_local.linebreak = true -- wrap at word boundaries
end,
})
-- add yours here!
-- local o = vim.o

View File

@ -92,4 +92,31 @@ return {
require("render-markdown").setup(opts)
end,
},
{
"f3fora/cmp-spell",
dependencies = { "hrsh7th/nvim-cmp" },
event = "InsertEnter",
config = function()
local cmp = require("cmp")
cmp.setup({
sources = cmp.config.sources({
{ name = "spell" }, -- Add spell source
{ name = "buffer" },
{ name = "path" },
{ name = "nvim_lsp" },
-- ... your other sources
}),
-- Optional: enable spelling suggestions only in relevant filetypes
enabled = function()
local ft = vim.bo.filetype
return vim.o.spell and (ft == "markdown" or ft == "text" or ft == "tex")
end,
})
end,
},
{
"liuchengxu/vista.vim",
lazy = false,
},
}