feat(markdownlint): install and configure Markdownlint

This commit is contained in:
Stefan Imhoff
2024-09-28 14:02:41 +02:00
parent 28c6b89753
commit b7ca39ba33
7 changed files with 187 additions and 136 deletions

View File

@@ -5,6 +5,7 @@
"lazyvim.plugins.extras.editor.aerial",
"lazyvim.plugins.extras.formatting.prettier",
"lazyvim.plugins.extras.lang.go",
"lazyvim.plugins.extras.lang.markdown",
"lazyvim.plugins.extras.lang.tailwind",
"lazyvim.plugins.extras.lang.yaml"
],

View File

@@ -24,6 +24,7 @@ require("lazy").setup({
{ import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.ruby" },
{ import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.lang.typescript" },

View File

@@ -19,38 +19,56 @@ return {
},
opts = {
formatters = {
eslint_d = {
["eslint_d"] = {
command = "eslint_d",
args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" },
stdin = true,
},
nixpkgs_fmt = {
["markdown-toc"] = {
condition = function(_, ctx)
for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do
if line:find("<!%-%- toc %-%->") then
return true
end
end
end,
},
["markdownlint-cli2"] = {
condition = function(_, ctx)
local diag = vim.tbl_filter(function(d)
return d.source == "markdownlint"
end, vim.diagnostic.get(ctx.buf))
return #diag > 0
end,
},
["nixpkgs_fmt"] = {
command = "nixpkgs-fmt",
},
},
formatters_by_ft = {
-- ["*"] = { "codespell" },
["_"] = { "trim_whitespace" },
astro = { { "prettierd", "prettier" } },
css = { { "prettierd", "prettier" }, "stylelint" },
fish = { "fish_indent" },
go = { "goimports", "gofumpt" },
graphql = { { "prettierd", "prettier" } },
html = { { "prettierd", "prettier" } },
javascript = { { "prettierd", "prettier" }, "eslint_d" },
javascriptreact = { { "prettierd", "prettier" }, "eslint_d" },
json = { { "prettierd", "prettier" } },
lua = { "stylua" },
markdown = { { "prettierd", "prettier" } },
mdx = { { "prettierd", "prettier" } },
nix = { "nixpkgs_fmt" },
python = { "isort", "black" },
ruby = { "rubyfmt", "rubocop" },
eruby = { "htmlbeautifier" },
svelte = { { "prettierd", "prettier" } },
typescript = { { "prettierd", "prettier" }, "eslint_d" },
typescriptreact = { { "prettierd", "prettier" }, "eslint_d" },
yaml = { { "prettierd", "prettier" } },
["astro"] = { { "prettierd", "prettier" } },
["css"] = { { "prettierd", "prettier" }, "stylelint" },
["eruby"] = { "htmlbeautifier" },
["fish"] = { "fish_indent" },
["go"] = { "goimports", "gofumpt" },
["graphql"] = { { "prettierd", "prettier" } },
["html"] = { { "prettierd", "prettier" } },
["javascript"] = { { "prettierd", "prettier" }, "eslint_d" },
["javascriptreact"] = { { "prettierd", "prettier" }, "eslint_d" },
["json"] = { { "prettierd", "prettier" } },
["lua"] = { "stylua" },
["markdown"] = { "prettierd", "prettier", "markdownlint-cli2", "markdown-toc" },
["markdown.mdx"] = { "prettierd", "prettier", "markdownlint-cli2", "markdown-toc" },
["mdx"] = { { "prettierd", "prettier" } },
["nix"] = { "nixpkgs_fmt" },
["python"] = { "isort", "black" },
["ruby"] = { "rubyfmt", "rubocop" },
["svelte"] = { { "prettierd", "prettier" } },
["typescript"] = { { "prettierd", "prettier" }, "eslint_d" },
["typescriptreact"] = { { "prettierd", "prettier" }, "eslint_d" },
["yaml"] = { { "prettierd", "prettier" } },
},
},
}

View File

@@ -1,5 +1,7 @@
-- Linting
-- https://github.com/mfussenegger/nvim-lint
local HOME = os.getenv("HOME")
return {
"mfussenegger/nvim-lint",
event = {
@@ -18,17 +20,24 @@ return {
},
opts = {
events = { "BufEnter", "BufWritePost", "BufReadPost", "InsertLeave" },
linters = {
-- https://github.com/LazyVim/LazyVim/discussions/4094#discussioncomment-10178217
["markdownlint-cli2"] = {
args = { "--config", HOME .. "/.markdownlint.yaml", "--" },
},
},
linters_by_ft = {
["*"] = { "codespell" },
astro = { "eslint_d", "cspell" },
fish = { "fish" },
javascript = { "eslint_d", "cspell" },
javascriptreact = { "eslint_d", "cspell" },
python = { "pylint" },
ruby = { "rubocop" },
svelte = { "eslint_d" },
typescript = { "eslint_d", "cspell" },
typescriptreact = { "eslint_d", "cspell" },
["astro"] = { "eslint_d", "cspell" },
["fish"] = { "fish" },
["javascript"] = { "eslint_d", "cspell" },
["javascriptreact"] = { "eslint_d", "cspell" },
["markdown"] = { "markdownlint-cli2" },
["python"] = { "pylint" },
["ruby"] = { "rubocop" },
["svelte"] = { "eslint_d" },
["typescript"] = { "eslint_d", "cspell" },
["typescriptreact"] = { "eslint_d", "cspell" },
},
},
}

View File

@@ -3,7 +3,16 @@
return {
"MeanderingProgrammer/render-markdown.nvim",
opts = {
file_types = { "markdown", "mdx" },
file_types = { "markdown", "mdx", "norg", "rmd", "org" },
code = {
sign = false,
width = "block",
right_pad = 1,
},
heading = {
sign = false,
icons = {},
},
},
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" },
}

View File

@@ -32,6 +32,7 @@
~/.gitmux.conf: gitmux.conf
~/.gnupg/dirmngr.conf: gnupg/dirmngr.conf
~/.gnupg/gpg.conf: gnupg/gpg.conf
~/.markdownlint.yaml: markdownlint.yaml
~/.profile: profile
~/.session-variables.sh: session-variables.sh
~/.tool-versions: tool-versions

12
markdownlint.yaml Normal file
View File

@@ -0,0 +1,12 @@
# Filename: ~/.markdownlint.yaml
#
# Example: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
# Default state for all rules
default: true
# Path to configuration file to extend
extends: null
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md
MD013: false