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.editor.aerial",
"lazyvim.plugins.extras.formatting.prettier", "lazyvim.plugins.extras.formatting.prettier",
"lazyvim.plugins.extras.lang.go", "lazyvim.plugins.extras.lang.go",
"lazyvim.plugins.extras.lang.markdown",
"lazyvim.plugins.extras.lang.tailwind", "lazyvim.plugins.extras.lang.tailwind",
"lazyvim.plugins.extras.lang.yaml" "lazyvim.plugins.extras.lang.yaml"
], ],

View File

@@ -11,57 +11,58 @@ vim.cmd([[command! -nargs=0 GoToCommand :Telescope commands]])
vim.cmd([[command! -nargs=0 Grep :Telescope live_grep]]) vim.cmd([[command! -nargs=0 Grep :Telescope live_grep]])
require("lazy").setup({ require("lazy").setup({
spec = { spec = {
-- add LazyVim and import its plugins -- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" }, { "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here -- import any extras modules here
{ import = "lazyvim.plugins.extras.coding.codeium" }, { import = "lazyvim.plugins.extras.coding.codeium" },
{ import = "lazyvim.plugins.extras.coding.copilot" }, { import = "lazyvim.plugins.extras.coding.copilot" },
{ import = "lazyvim.plugins.extras.coding.mini-surround" }, { import = "lazyvim.plugins.extras.coding.mini-surround" },
{ import = "lazyvim.plugins.extras.dap.core" }, { import = "lazyvim.plugins.extras.dap.core" },
{ import = "lazyvim.plugins.extras.editor.aerial" }, { import = "lazyvim.plugins.extras.editor.aerial" },
{ import = "lazyvim.plugins.extras.editor.harpoon2" }, { import = "lazyvim.plugins.extras.editor.harpoon2" },
{ import = "lazyvim.plugins.extras.formatting.prettier" }, { import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.lang.go" }, { import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.json" }, { import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.ruby" }, { import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.tailwind" }, { import = "lazyvim.plugins.extras.lang.ruby" },
{ import = "lazyvim.plugins.extras.lang.typescript" }, { import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.lang.yaml" }, { import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.linting.eslint" }, { import = "lazyvim.plugins.extras.lang.yaml" },
{ import = "lazyvim.plugins.extras.test.core" }, { import = "lazyvim.plugins.extras.linting.eslint" },
{ import = "lazyvim.plugins.extras.ui.mini-animate" }, { import = "lazyvim.plugins.extras.test.core" },
-- import/override with your plugins { import = "lazyvim.plugins.extras.ui.mini-animate" },
{ import = "plugins" }, -- import/override with your plugins
}, { import = "plugins" },
defaults = { },
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. defaults = {
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
lazy = false, -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning, lazy = false,
-- have outdated releases, which may break your Neovim install. -- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
version = false, -- always use the latest git commit -- have outdated releases, which may break your Neovim install.
-- version = "*", -- try installing the latest stable version for plugins that support semver version = false, -- always use the latest git commit
}, -- version = "*", -- try installing the latest stable version for plugins that support semver
install = { colorscheme = { "tokyonight", "habamax" } }, },
checker = { install = { colorscheme = { "tokyonight", "habamax" } },
enabled = true, checker = {
notify = false, enabled = true,
frequency = 86400, notify = false,
}, frequency = 86400,
performance = { },
rtp = { performance = {
-- disable some rtp plugins rtp = {
disabled_plugins = { -- disable some rtp plugins
"gzip", disabled_plugins = {
-- "matchit", "gzip",
-- "matchparen", -- "matchit",
-- "netrwPlugin", -- "matchparen",
"tarPlugin", -- "netrwPlugin",
"tohtml", "tarPlugin",
"tutor", "tohtml",
"zipPlugin", "tutor",
}, "zipPlugin",
}, },
}, },
},
}) })

View File

@@ -1,56 +1,74 @@
-- Lightweight yet powerful formatter plugin for Neovim -- Lightweight yet powerful formatter plugin for Neovim
-- https://github.com/stevearc/conform.nvim -- https://github.com/stevearc/conform.nvim
return { return {
"stevearc/conform.nvim", "stevearc/conform.nvim",
event = { "BufWritePre", "BufNewFile" }, event = { "BufWritePre", "BufNewFile" },
keys = { keys = {
{ {
"<leader>mp", "<leader>mp",
mode = { "n", "v" }, mode = { "n", "v" },
function() function()
require("conform").format({ require("conform").format({
lsp_fallback = true, lsp_fallback = true,
async = false, async = false,
timeout_ms = 500, timeout_ms = 500,
}) })
end, end,
desc = "Format file or range (in visual mode)", desc = "Format file or range (in visual mode)",
}, },
}, },
opts = { opts = {
formatters = { formatters = {
eslint_d = { ["eslint_d"] = {
command = "eslint_d", command = "eslint_d",
args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" }, args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" },
stdin = true, stdin = true,
}, },
nixpkgs_fmt = { ["markdown-toc"] = {
command = "nixpkgs-fmt", condition = function(_, ctx)
}, for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do
}, if line:find("<!%-%- toc %-%->") then
formatters_by_ft = { return true
-- ["*"] = { "codespell" }, end
["_"] = { "trim_whitespace" }, end
astro = { { "prettierd", "prettier" } }, end,
css = { { "prettierd", "prettier" }, "stylelint" }, },
fish = { "fish_indent" }, ["markdownlint-cli2"] = {
go = { "goimports", "gofumpt" }, condition = function(_, ctx)
graphql = { { "prettierd", "prettier" } }, local diag = vim.tbl_filter(function(d)
html = { { "prettierd", "prettier" } }, return d.source == "markdownlint"
javascript = { { "prettierd", "prettier" }, "eslint_d" }, end, vim.diagnostic.get(ctx.buf))
javascriptreact = { { "prettierd", "prettier" }, "eslint_d" }, return #diag > 0
json = { { "prettierd", "prettier" } }, end,
lua = { "stylua" }, },
markdown = { { "prettierd", "prettier" } }, ["nixpkgs_fmt"] = {
mdx = { { "prettierd", "prettier" } }, command = "nixpkgs-fmt",
nix = { "nixpkgs_fmt" }, },
python = { "isort", "black" }, },
ruby = { "rubyfmt", "rubocop" }, formatters_by_ft = {
eruby = { "htmlbeautifier" }, -- ["*"] = { "codespell" },
svelte = { { "prettierd", "prettier" } }, ["_"] = { "trim_whitespace" },
typescript = { { "prettierd", "prettier" }, "eslint_d" }, ["astro"] = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" }, "eslint_d" }, ["css"] = { { "prettierd", "prettier" }, "stylelint" },
yaml = { { "prettierd", "prettier" } }, ["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,34 +1,43 @@
-- Linting -- Linting
-- https://github.com/mfussenegger/nvim-lint -- https://github.com/mfussenegger/nvim-lint
local HOME = os.getenv("HOME")
return { return {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
event = { event = {
"BufWritePre", "BufWritePre",
"BufNewFile", "BufNewFile",
}, },
keys = { keys = {
{ {
"<leader>L", "<leader>L",
mode = { "n" }, mode = { "n" },
function() function()
require("lint").try_lint() require("lint").try_lint()
end, end,
desc = "Trigger linting for current file", desc = "Trigger linting for current file",
}, },
}, },
opts = { opts = {
events = { "BufEnter", "BufWritePost", "BufReadPost", "InsertLeave" }, events = { "BufEnter", "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = { linters = {
["*"] = { "codespell" }, -- https://github.com/LazyVim/LazyVim/discussions/4094#discussioncomment-10178217
astro = { "eslint_d", "cspell" }, ["markdownlint-cli2"] = {
fish = { "fish" }, args = { "--config", HOME .. "/.markdownlint.yaml", "--" },
javascript = { "eslint_d", "cspell" }, },
javascriptreact = { "eslint_d", "cspell" }, },
python = { "pylint" }, linters_by_ft = {
ruby = { "rubocop" }, ["*"] = { "codespell" },
svelte = { "eslint_d" }, ["astro"] = { "eslint_d", "cspell" },
typescript = { "eslint_d", "cspell" }, ["fish"] = { "fish" },
typescriptreact = { "eslint_d", "cspell" }, ["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 { return {
"MeanderingProgrammer/render-markdown.nvim", "MeanderingProgrammer/render-markdown.nvim",
opts = { 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" }, dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" },
} }

View File

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