none-ls.nvim

repository·main·Indexed 25 days ago

https://github.com/nvimtools/none-ls.nvim

A community-maintained fork of null-ls.nvim that allows Neovim to use non-LSP sources, such as CLI tools, as LSP servers. It provides diagnostics, code actions, formatting, hover, and completion via pure Lua. It supports built-in sources and custom source creation by parsing buffer content or CLI program output.

Tokens
26.2K
Snippets
246
Records
278
Agent score
85%

What's inside none-ls.nvim

  1. Understand the core concepts of null-ls Sources

    main

    The fundamental unit of operation in null-ls is a source. A source consists of:

    • Method: Defines when the source runs (e.g., formatting, diagnostics).
    • Generator: The logic that runs in response to a method request.
    • Filetypes: A list determining which buffers activate the source.

    You can check which sources are currently active for your buffer by running the command :NullLsInfo in Neovim.

  2. Register sources using setup or register

    main

    You can add sources to null-ls using either setup (for user configuration) or register (for integrations).

    Both methods accept:

    1. A single source.
    2. A list of sources.
    3. A table containing multiple sources with shared configuration.

    Dynamically registering a diagnostic source will automatically refresh diagnostics for affected buffers.

    local null_ls = require("null-ls")
    
    -- 1. Using setup (standard user config)
    null_ls.setup({ sources = my_sources })
    
    -- 2. Using register (for integrations)
    -- Single source
    null_ls.register({ my_source })
    
    -- List of independent sources
    null_ls.register({ my_source, my_other_source })
    
    -- Multiple sources with shared configuration
    null_ls.register({
        name = "my-sources", 
        filetypes = { "lua" }, 
        sources = { my_source, my_other_source }
    })