dankelley / nvim

basic lazyvim setup, with added R support
Apache License 2.0
0 stars 0 forks source link

markdown files show annoying long line warnings #3

Open dankelley opened 1 month ago

dankelley commented 1 month ago

I know there is a way to turn off individual warnings, but my web searches are not turning anything up. It is mode-specific. Files ending in .md get this warning but files ending in Rmd do not. @richardsc has also noted this problem but I'm making an issue because it's nice to refer to issues in making commits.

dankelley commented 1 month ago

This is an example of the warning

MD013/line-length Line length [Expected: 80; Actual: 447] markdownlint  [5, 81]
dankelley commented 1 month ago

This seems to be a feasible entry for learning more: https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md

dankelley commented 1 month ago

To be explicit, the solution is to put the following into a file, perhaps named .config/nvim/lua/plugins/lint.lua. (You can put multiple items after the "MD013". I guess the -- line is how it designates the end of the list.)

return {
    "mfussenegger/nvim-lint",
    opts = {
        linters_by_ft = { "markdownlint" },
        markdown = { "markdownlint" },
    },
    config = function()
        local markdownlint = require("lint").linters.markdownlint
        markdownlint.args = {
            "--disable",
            "MD013",
            "--", -- Required
        }
    end
}
dankelley commented 1 month ago

@richardsc reported that this didn't work. I tested, and it didn't. The update at commit 7570a9298e34775d0b71f68779717dfdcd0831a7 seems to fix it, though.

dankelley commented 1 month ago

Here is the new .config/nvim/lua/plugins/lint.lua contents:

if true then return {} end
return {
    "mfussenegger/nvim-lint",
    opts = {
        --linters_by_ft = { "markdownlint" },
        markdown = { "markdownlint" },
    },
    config = function()
        local markdownlint = require("lint").linters.markdownlint
        markdownlint.args = {
            "--disable",
            "MD013",
            "--", -- Required
        }
    end
}
richardsc commented 1 month ago

Hm, that doesn't work for me either -- same as before, I get no linting using the above code. TBH, I don't understand what the first line is doing (but then again, I don't know lua ...).

I'm going to have to noodle with it later. I also notice, that even when I do get the mardown warnings, if I do cf I get a "No formatter available" pop-up, and no reformatting.

image

richardsc commented 1 month ago

Sorry, using the above I do get linting, but still get the "long line" error ... (I had a nvim window open in a different tab when I was testing).

dankelley commented 1 month ago

There's a solution: use comments in the file. This might mess up latex output -- I really wish markdown had an official commenting scheme -- and so the better solution will be to figure out the lua. But that's a bit of a guessing game.

The attached video shows how to do this. Going offline now for the day.

https://github.com/user-attachments/assets/513ccbb8-4944-48fe-8522-db7c53bd2f40

richardsc commented 1 month ago

Yeah, I guess that works. I don't like it though ... 😄

dankelley commented 1 month ago

As I note in the README.md file, if you put the following into a local file named .markdownlint.yaml then the linter won't complain about long lines for any .md file in the same directory.

MD013: false

I also have some notes in README.md about a method that supposedly should work for any files in the system, but I couldn't get that to work. For me, adding a local file is a good solution, so I can have different linting instructions in different directories. That's pretty common for other linters, but a lot of them default to a global one, and I wish that were the case here, too.