Search code examples
luamarkdownindentationneovim

Indentation in markdown files in neovim (nvchad)


why am i not getting 8 indent spaces in neovim when it comes to markdown files. is there some standard, or something else. in visualstudio code, it is working fine.

in case of python, rust , i read that the community enforces it. but what is wrong with markdown files

i just added nvchad config using the command given on the official website. and in the init.lua inside nvim/lua/core, i changed the indent to 8 both tabstop and shiftwidth


Solution

  • By default, with NvChad, your configuration sets shiftwidth and tabstop to 2 => see https://github.com/NvChad/NvChad/blob/v2.0/lua/core/init.lua

    You can add a specific configuration file in lua/custom/init.lua (see https://nvchad.com/docs/config/walkthrough).

    In it, you could define a specific autocommand to set options for Markdown files :

    vim.api.nvim_create_autocmd("FileType", {
      pattern = "markdown",
      callback = function()
        vim.opt.shiftwidth = 8
        vim.opt.tabstop = 8
        vim.opt.softtabstop = 8
      end,
    })