Giter Club home page Giter Club logo

Comments (7)

amtoine avatar amtoine commented on May 30, 2024 1

ooooh wow, of course, now it works 🀩

thanks a ton 😌
maybe you can just pin this and mention it in the README, no need to make it a whole README section probably, i did just not know all that about null-ls πŸ˜‹

from nu-ls.nvim.

zioroboco avatar zioroboco commented on May 30, 2024

I'm not familiar with the setup you've used to bootstrap your neovim config, but I can give an answer which starts from more basic principles, which will hopefully make debugging this make more sense.

(Also if you don't have null-ls working by default from your bootstrapped config, everything I'm about to say should generalise to installing that as well.)

There are two broader concepts here which might be getting mixed up, so I'll try to clear them up:

first concept: resolving the nu-ls lua module (from... somewhere on your neovim runtime path)

The statement require("nu-ls") is asking lua to load the nu-ls module, and to substitute the module's return value. In this case, the return value is a null-ls source (i.e. a thing from which null-ls knows how to request completions etc.), which can be registered as per the snippet in the README.

To resolve the requested "nu-ls" name, lua searches a list of known paths for particular files β€” either lua/nu-ls.lua or lua/nu-ls/init.lua (in this case we're expecting it to find the latter). This file will then be interpreted as the entrypoint for that module β€” i.e. the first file of that module's code which lua runs as a result of the require call (modulo some caching, which we can ignore).

The paths that lua will search will be different in different contexts, but in neovim specifically, you can get the full list by running :echo nvim_list_runtime_paths(). This will return all locations on your filesystem where you could (in principle) manually copy the lua/nu-ls directory from this repo to make the require("nu-ls") line work.

Typically, these paths will include your main neovim config directory (usually ~/.config/nvim), so copying the lua/nu-ls directory from this repo to ~/.config/nvim/lua/nu-ls should allow you to require("nu-ls") as per the README.

second concept: installing the zioroboco/nu-ls.nvim package (so that this lua module can be required)

However... you might not want to copy random lua code around in your config, and you also probably have a package manager set up β€” I'd expect one of folke/lazy.nvim or wbthomason/packer.nvim depending on when you bootstrapped your config from the kickstarter project. In this case, you can add "zioroboco/nu-ls.nvim" as a "package" (scare quotes to indicate that neovim packages are generally just repos full of config) by following the instructions of the package manager. It will probably look something like:

-- if using lazy:
require("lazy").setup({
  "zioroboco/nu-ls.nvim",
  -- ...
})

-- if using packer:
require("packer").startup(function(use)
  use "zioroboco/nu-ls.nvim"
  -- ...
})

You will then need to source your neovim config (just restart neovim if you're not sure what I mean) and then install packages with your package manager (I think lazy might do this automatically, and for packer you would run :PackerInstall).

This will fetch this repo from GitHub and install it onto the neovim runtime path just as if you'd installed it yourself, but will also maintain the contents as this repo changes.

So beware if you do this: I'm kinda just stuffing around for now (I was impatient to try out the new --ide-* flags! 😊), and there's a chance I might break the module API to include a config function for adding additional sources (I'm thinking I want to to source completions for external commands using carapace for example). I might also just break things by accident. So using a package manager means that you might automatically pull in those broken changes during an update. 🀷

(You can get around this by pinning to a particular commit, or using a lockfile... I won't go into these, but you can look up the details for your package manager)

Also probably worth saying that the --ide-* flags that this is using is based on unreleased commits to the nushell repo. You'll need to build nu from source from a recent state of the main branch, and we shouldn't expect the API of those flags to remain stable before the next release (and even beyond that, who knows).

Anyway, I hope this helps!

(I'll leave this open for discoverability, and as a reminder that I should add docs, maybe, at some point...)

from nu-ls.nvim.

amtoine avatar amtoine commented on May 30, 2024

@zioroboco
thanks for the detailed answer 🀩

i've been able to remove the error by adding

-- lua/custom/plugins/nu-ls.lua
return {
  "zioroboco/nu-ls.nvim"
}

next to my

-- lua/custom/plugins/null-ls.lua
return {
  "jose-elias-alvarez/null-ls.nvim",
  config = function ()
    require("null-ls").setup {
      sources = {
        require("nu-ls"),
      },
    }
  end
}

πŸ‘Œ

now i need to attach nu-ls to any .nu buffer πŸ€”

:NullLsInfo
	null-ls
	https://github.com/jose-elias-alvarez/null-ls.nvim
	
	Supported source(s)
	
	* Note: current buffer has no sources attached

from nu-ls.nvim.

amtoine avatar amtoine commented on May 30, 2024

yeah i have to admit i do not get the documentation of null-ls, it's installed, nu-ls too, but i can't where i can attach all this to .nu files πŸ€”

from nu-ls.nvim.

zioroboco avatar zioroboco commented on May 30, 2024

Ah, this source is configured to automatically attach to any buffers with the nu filetype (see: lua/nu-ls/init.lua).

You can make neovim associate any files with a .nu extension with the nu filetype by adding the following to your neovim config:

vim.filetype.add({
    extension = {
        nu = "nu",
    },
})

I think you're very close πŸ˜„

from nu-ls.nvim.

zioroboco avatar zioroboco commented on May 30, 2024

I've added an installation guide to the README in cf8b0d8, so I'll close this now.

Thanks for opening this @amtoine β€” you helped me to identify the bits that needed docs ☺️

from nu-ls.nvim.

amtoine avatar amtoine commented on May 30, 2024

amazing, that's just perfect πŸ₯³

from nu-ls.nvim.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.