Closed amtoine closed 1 year ago
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 require
d)
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...)
@zioroboco thanks for the detailed answer :star_struck:
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
}
:ok_hand:
now i need to attach nu-ls
to any .nu
buffer :thinking:
:NullLsInfo
null-ls
https://github.com/jose-elias-alvarez/null-ls.nvim
Supported source(s)
* Note: current buffer has no sources attached
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 :thinking:
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 π
ooooh wow, of course, now it works :star_struck:
thanks a ton :relieved:
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
:yum:
I've added an installation guide to the README in https://github.com/zioroboco/nu-ls.nvim/commit/cf8b0d8f586f1a5cf75f815c08451c6791437a9e, so I'll close this now.
Thanks for opening this @amtoine β you helped me to identify the bits that needed docs βΊοΈ
amazing, that's just perfect :partying_face:
hello there :wave: :yum:
i wanted to install this plugin to try it out and give you some feedback, but i'm having some trouble :open_mouth:
i've tried to use the snippet you give in the
README
, i.e.in my
lua/custom/plugins/null-ls.lua
(my config is based on thekickstart
framework for neovim)i've also tried
but i get the same error
i probably just don't know and understand how to install a
null-ls
plugin, but am i missing something?cheers :sparkles: