Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.

markdownlint_cli2 not working with builtin #1256

Open
5 tasks done
dngray opened this issue Nov 25, 2022 · 3 comments
Open
5 tasks done

markdownlint_cli2 not working with builtin #1256

dngray opened this issue Nov 25, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@dngray
Copy link

dngray commented Nov 25, 2022

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Issues

  • I have checked existing issues and there are no issues with the same problem.

Neovim Version

NVIM v0.8.1

Dev Version?

  • I am using a stable Neovim release version, or if I am using a dev version of Neovim I have confirmed that my issue is reproducible on a stable version.

Operating System

Arch Linux

Minimal Config

-- this template is borrowed from nvim-lspconfig
local on_windows = vim.loop.os_uname().version:match("Windows")

local function join_paths(...)
    local path_sep = on_windows and "\\" or "/"
    local result = table.concat({ ... }, path_sep)
    return result
end

vim.g.loaded_remote_plugins = ""
vim.cmd([[set runtimepath=$VIMRUNTIME]])

local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))

local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")

local null_ls_config = function()
    local null_ls = require("null-ls")
    -- add only what you need to reproduce your issue
    null_ls.setup({
        sources = {null_ls.builtins.diagnostics.markdownlint_cli2},
        debug = true,
    })
end

local function load_plugins()
    -- only add other plugins if they are necessary to reproduce the issue
    require("packer").startup({
        {
            "wbthomason/packer.nvim",
            {
                "jose-elias-alvarez/null-ls.nvim",
                requires = { "nvim-lua/plenary.nvim" },
                config = null_ls_config,
            },
        },
        config = {
            package_root = package_root,
            compile_path = compile_path,
        },
    })
end

if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
    load_plugins()
    require("packer").sync()
else
    load_plugins()
    require("packer").sync()
end

Steps to Reproduce

Use the above built in config. I found when using this config, everything worked fine:

local null_ls_config = function()
    local null_ls = require("null-ls")
    -- add only what you need to reproduce your issue
    null_ls.setup({
       sources = { null_ls.builtins.diagnostics.markdownlint_cli2.with { args = { "$FILENAME" } } },
       debug = true,
    })
end

Reproducibility Check

  • I confirm that my minimal config is based on the minimal_init.lua template and that my issue is reproducible by running nvim --clean -u minimal_init.lua and following the steps above.

Expected Behavior

To see diagnostics in my project

Actual Behavior

No diagnostics show in the buffer.

Debug Log

[TRACE Fri 25 Nov 2022 23:04:51] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:110: starting null-ls client
[TRACE Fri 25 Nov 2022 23:04:51] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method initialize
[DEBUG Fri 25 Nov 2022 23:04:51] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:165: unable to notify client for method textDocument/didOpen (client not active): {
  textDocument = {                                                
    uri = "file:///home/d/src/dngray/pg/privacyguides.org/README.md"
  }
}
[TRACE Fri 25 Nov 2022 23:04:51] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method initialized
[TRACE Fri 25 Nov 2022 23:04:51] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method textDocument/didOpen
[TRACE Fri 25 Nov 2022 23:04:51] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN
[DEBUG Fri 25 Nov 2022 23:04:51] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:320: spawning command "markdownlint-cli2" at /home/d/src/dngray/pg/privacyguides.org with args {}
[TRACE Fri 25 Nov 2022 23:04:52] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:204: error output: markdownlint-cli2 v0.5.1 (markdownlint v0.26.2)
https://github.com/DavidAnson/markdownlint-cli2
    
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN]
        markdownlint-cli2-fix glob0 [glob1] [...] [globN]
        markdownlint-cli2-config config-file glob0 [glob1] [...] [globN]

Glob expressions (from the globby library):
- * matches any number of characters, but not /
- ? matches a single character, but not /
- ** matches any number of characters, including /
- {} allows for a comma-separated list of "or" expressions
- ! or # at the beginning of a pattern negate the match
- : at the beginning identifies a literal file path
    
Dot-only glob:
- The command "markdownlint-cli2 ." would lint every file in the current directory tree which is probably not intended
- Instead, it is mapped to "markdownlint-cli2 *.{md,markdown}" which lints all Markdown files in the current directory
- To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead

Configuration via:
- .markdownlint-cli2.jsonc
- .markdownlint-cli2.yaml
- .markdownlint-cli2.cjs or .markdownlint-cli2.mjs
- .markdownlint.jsonc or .markdownlint.json
- .markdownlint.yaml or .markdownlint.yml
- .markdownlint.cjs or .markdownlint.mjs
    
Cross-platform compatibility:
- UNIX and Windows shells expand globs according to different rules; quoting arguments is recommended
- Some Windows shells don't handle single-quoted (') arguments well; double-quote (") is recommended
- Shells that expand globs do not support negated patterns (!node_modules); quoting is required here
- Some UNIX shells parse exclamation (!) in double-quotes; hashtag (#) is recommended in these cases
- The path separator is forward slash (/) on all platforms; backslash (\) is automatically converted

The most compatible syntax for cross-platform support:
$ markdownlint-cli2 "**/*.md" "#node_modules"

[TRACE Fri 25 Nov 2022 23:04:52] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:205: output: nil
[TRACE Fri 25 Nov 2022 23:04:52] ...ck/packer/start/null-ls.nvim/lua/null-ls/diagnostics.lua:181: received diagnostics from source 1
[TRACE Fri 25 Nov 2022 23:04:52] ...ck/packer/start/null-ls.nvim/lua/null-ls/diagnostics.lua:182: {}

Help

No

Implementation Help

No response

Requirements

  • I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
@SichangHe
Copy link

Something like this would work.

local null_ls = require('null-ls')
null_ls.setup {
    sources = {
        null_ls.builtins.diagnostics.markdownlint_cli2.with {
            args = { "$FILENAME" },
        },
    },
}

@jose-elias-alvarez
Copy link
Owner

^ While this does work, I think the right solution is the one I mentioned in #1257. The config file itself should specify which files to lint, and we should mention that in the documentation.

dngray added a commit to dngray/dotfiles that referenced this issue Feb 18, 2023
- Change to Nord theme
- Convert to LunarVim
- Stop using gpg-agent and use ssh-agent
- Only Silverblue has Gnome Terminal
- Fix profiles path for Flatpak and use correct profile id
- Hide Firefox View Button/List
- Fix arkenfox script and add prefsCleaner.sh
- Update Weechat configs
- Fix mistake in limits.conf
- Use markdownlint_cli2 for linting
- Readd Third git user
- Use drill instead of bind https://archlinux.org/todo/dnsutils-to-ldns-migration/
- Temporary fix for markdownlint_cli2 not working on files with spaces jose-elias-alvarez/null-ls.nvim#1256
- Switch back to Rofi
- Add nnn config
- Update mutt-wizard template
dngray added a commit to dngray/dotfiles that referenced this issue Feb 18, 2023
- Change to Nord theme
- Convert to LunarVim
- Stop using gpg-agent and use ssh-agent
- Only Silverblue has Gnome Terminal
- Fix profiles path for Flatpak and use correct profile id
- Hide Firefox View Button/List
- Fix arkenfox script and add prefsCleaner.sh
- Update Weechat configs
- Fix mistake in limits.conf
- Use markdownlint_cli2 for linting
- Readd Third git user
- Use drill instead of bind https://archlinux.org/todo/dnsutils-to-ldns-migration/
- Temporary fix for markdownlint_cli2 not working on files with spaces jose-elias-alvarez/null-ls.nvim#1256
- Switch back to Rofi
- Add nnn config
- Update mutt-wizard template
@dngray
Copy link
Author

dngray commented Apr 24, 2023

I can confirm #1256 (comment) does work. @jose-elias-alvarez if there is a better way to do it as you suggest could this be added to the documentation so people like me know what to do?

dngray added a commit to dngray/dotfiles that referenced this issue Jul 10, 2023
- Change to Nord theme
- Convert to LunarVim
- Stop using gpg-agent and use ssh-agent
- Only Silverblue has Gnome Terminal
- Fix profiles path for Flatpak and use correct profile id
- Hide Firefox View Button/List
- Fix arkenfox script and add prefsCleaner.sh
- Update Weechat configs
- Fix mistake in limits.conf
- Use markdownlint_cli2 for linting
- Readd Third git user
- Use drill instead of bind https://archlinux.org/todo/dnsutils-to-ldns-migration/
- Temporary fix for markdownlint_cli2 not working on files with spaces jose-elias-alvarez/null-ls.nvim#1256
- Switch back to Rofi
- Add nnn config
- Update mutt-wizard template

zfs-load-key

Updates, cleanup

.
dngray added a commit to dngray/dotfiles that referenced this issue Jul 10, 2023
- Change to Nord theme
- Convert to LunarVim
- Stop using gpg-agent and use ssh-agent
- Only Silverblue has Gnome Terminal
- Fix profiles path for Flatpak and use correct profile id
- Hide Firefox View Button/List
- Fix arkenfox script and add prefsCleaner.sh
- Update Weechat configs
- Fix mistake in limits.conf
- Use markdownlint_cli2 for linting
- Readd Third git user
- Use drill instead of bind https://archlinux.org/todo/dnsutils-to-ldns-migration/
- Temporary fix for markdownlint_cli2 not working on files with spaces jose-elias-alvarez/null-ls.nvim#1256
- Switch back to Rofi
- Add nnn config
- Update mutt-wizard template

zfs-load-key

Updates, cleanup

.

.
dngray added a commit to dngray/dotfiles that referenced this issue Jul 10, 2023
- Change to Nord theme
- Convert to LunarVim
- Stop using gpg-agent and use ssh-agent
- Only Silverblue has Gnome Terminal
- Fix profiles path for Flatpak and use correct profile id
- Hide Firefox View Button/List
- Fix arkenfox script and add prefsCleaner.sh
- Update Weechat configs
- Fix mistake in limits.conf
- Use markdownlint_cli2 for linting
- Readd Third git user
- Use drill instead of bind https://archlinux.org/todo/dnsutils-to-ldns-migration/
- Temporary fix for markdownlint_cli2 not working on files with spaces jose-elias-alvarez/null-ls.nvim#1256
- Switch back to Rofi
- Add nnn config
- Update mutt-wizard template

zfs-load-key

Updates, cleanup

.

.

.
dngray added a commit to dngray/dotfiles that referenced this issue Jul 14, 2023
- Change to Nord theme
- Convert to LunarVim
- Stop using gpg-agent and use ssh-agent
- Only Silverblue has Gnome Terminal
- Fix profiles path for Flatpak and use correct profile id
- Hide Firefox View Button/List
- Fix arkenfox script and add prefsCleaner.sh
- Update Weechat configs
- Fix mistake in limits.conf
- Use markdownlint_cli2 for linting
- Readd Third git user
- Use drill instead of bind https://archlinux.org/todo/dnsutils-to-ldns-migration/
- Temporary fix for markdownlint_cli2 not working on files with spaces jose-elias-alvarez/null-ls.nvim#1256
- Switch back to Rofi
- Add nnn config
- Update mutt-wizard template
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants