kickstart.nvim icon indicating copy to clipboard operation
kickstart.nvim copied to clipboard

LSP Setup, or: I don't get it. (Conflated issues?)

Open jwdevantier opened this issue 1 year ago • 5 comments

Describe the bug

I think this part of the config (arguably the most important?) is both confusing and under-documented. I'll use my attempts to get a Nix LSP (nixd and/or nil, both in PATH) as an example of the things I find confusing and/or under-documented.

Given my background as a daily Doom Emacs user (some customization, not much) and the owner of a home-built and shabby neovim config with multiple plugins and LSP servers configured, I'd expect I was the target audience.

To Reproduce

(Be on a Linux System (NixOS) with nixd and nil (two Nix LSPs) already installed)

  1. :e $MYVIMRC
  2. find LSP config section, find the local servers definition.
  3. Add an entry, added nil_ls = {}, based on what I saw in the list from :help lspconfig-all
  4. Re-start neovim with a .nix file open. I get nil: failed to install in the minibuffer(?)
    • How to see more information?
    • Why is nil, which is on $PATH, not found?
  5. Read :help lspconfig-all again, grep for the nix section. See something like require'lspconfig'.nil_ls.setup()
    • Realize the closest to that is is a handler function inside of 'mason-lspconfig' (again, why?).. Give up

Questions:

  • Why mason?
  • Is mason smart enough to not do something if the relevant LSP binary is already on PATH?
    • If so, why am I getting an error? How to investigate? And perhaps document this in the config. This the part of the config most likely to cause trouble. Nearly everyone needs to add one or more LSPs, a broad user-base will want different LSPs for different languages. Some of those users will definitely encounter trouble similar to what I have.
  • Could the config please have an example of hand-configuring an LSP entry ? Like I want nixd called on editing .nix files - I don't want mason or any other magic - the OS provides. How would I do that ? Could a commented entry be included in the base config?

Desktop

  • OS: NixOS Stable, 23.11
  • Terminal: Konsole

Neovim Version

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1693350652

   system vimrc file: "$VIM/sysinit.vim"
   fall-back for $VIM: "/nix/store/bjqr6vi3q0f8iy4ncv1z8vl81bzkjq0r-neovim-unwrapped-0.9.4/share/nvim"

jwdevantier avatar Mar 27 '24 05:03 jwdevantier

Hi there.

I'm going to hold aside your critique of the choices that went into creating kickstart.nvim.

The whole point of the project is to make some reaosnable configuration choices for new users. If you want different choices, you are more than welcome to either create a fork or ignore kickstart and create your very own emacs-ish custom configuration out of whole cloth!

To the actual issue at hand: configuring for Nix.

In Mason, I see no fewer that 3 entries around Nix and Nix format. Why not install one and see how it works out? And then add that rather than null_ls, which is now abandonware?

In stock kickstart.nvim just start Neovim, type :Mason, and type /nix.

When you see something you like, hit i.

feoh avatar Mar 27 '24 14:03 feoh

My critique isn't necessarily about the choice of using mason. My critique is centered on the idea that the resulting setup is quite complicated exactly around the point which most people will need to adjust first: installing and managing LSPs.

As I understand it, the point of kickstart is to bring in new users. As a potential user (existing user of neovim, regular Emacs user) I should be better positioned to understand what to do than the average Vs Code convert - yet I'm lost. I'm assuming that if I am lost, a fair number of other people would be too.

Hence my suggestion of better documenting

  • how to debug, when I get an error like nil: cannot be installed -- what can I do to see more ? Can I get a LSP configured without mason attempting to install it ? And please show how.

That's my concrete suggestion. This part of the config is by far the most complicated bit, it deserves a bit more documentation.

If not, then be fair and admit that kickstart is really not for new users, but powerusers of neovim and lua who want a cool base for a new, better config. But as advertised, I'd say it needs some documentation.


Regarding my actual problem I tried to install something using mason. nil_ls (got that from :help lspconfig-all), I got the error listed above. Hence the issue. It doesn't work. Mason says it fails to install something, I don't know where to get more information on why that is, much less how I could configure the setup to maybe just use the binary which is already present on my system.

Using :Mason I see different offerings. But nixpkgs-fmt is just a formatter - not what I want/need and the other offering, rnix-lsp I've heard is the oldest and least capable of the 3 LSPs available (rnix, nil, nixd). Again, shouldn't it be easy to translate the instructions from :help lspconfig-all on (for example) nil_ls to something I can do in the kickstart config ?

jwdevantier avatar Mar 27 '24 20:03 jwdevantier

So, you're saying you insist on installing an abandoned language server because none of the offerings kickstart puts easily at your disposal work for you.

OK. That's fine. I'll let others in the community see if they can be helpful. Good luck!

feoh avatar Mar 27 '24 21:03 feoh

I don't see any mention of nil being abandoned ( https://github.com/oxalica/nil ). And fwiw, opening a nix file in lunarvim immediately launched nil.

The wider point stands, I think if kickstart wants to bill itself as a user-friendly on-ramp for neovim, then the LSP section needs a bit more documentation. Namely on how to debug when mason won't/can't install some requested package and how one might configure an LSP entry without having mason attempt to install it (such as when your environment already has the right version).

I'll leave this here as a suggestion

jwdevantier avatar Mar 27 '24 22:03 jwdevantier

Mason says it fails to install something, I don't know where to get more information (...)

looks like you should find the answer on the Mason side.

It does not feel realistic, and IMO it can be even wasteful to document, and maintain all the unhappy-path recipes for all the external dependencies properly in scope of this project.

ro0gr avatar Mar 28 '24 00:03 ro0gr

I don't think so. As it stands, this setup will literally break for every NixOS user who will try it.

Anyway. I'm not smart enough to do the right thing and provide a fallback/override mechanism for entries which you don't want mason to install. But I did manage to remove mason and use lsp-zero. I'm putting a link to that for others to find if they encounter the same issue.

https://github.com/jwdevantier/kickstart.nvim.no-mason (Not going to start an actual fork or maintain it. But the last commit outlines what can be done to manage LSPs without mason).

jwdevantier avatar Mar 28 '24 14:03 jwdevantier