this post was submitted on 23 Sep 2023
28 points (96.7% liked)

Neovim

2183 readers
1 users here now

founded 1 year ago
MODERATORS
 

I thought switching from vim to neovim would be like switching from a nano+ to a VSCode CLI, but it's far from that. There are so many plugins and it's not as easy as declaring which plugins I want, having one dictionary/mapping/attribute set with keybindings, another with global preferences, and done.

Then there's something about language servers. The list on https://github.com/rockerBOO/awesome-neovim is daunting. I thought LSP support was built into nvim. Why are there so many LSP plugins? And what the hell is treesitter and why do I need it?

I copied some dude's config and suddenly Ctrl+P for completion didn't work like in VIM.

There's just so much unexplained jargon and abbreviations, that it feels like I have to read neovim code before even using it (ain't nobody got time for that). Is neovim actually the right tool to use to have an easy CLI IDE? Is there an easier command-line alternative that just lets me go "oh, this language isn't supported, let me open the package manager and install the $language-plugin", with "Goto Definition", debugging with breakpoints, code formatting, refactoring (rename variable/method/class, extract function, etc.) ? Maybe neovim just isn't the right tool for those without years of time.

Edit: Thanks for the suggestions everybody. Finally went with Lunarvim and it's been a joy!

top 16 comments
sorted by: hot top controversial new old
[–] Kamek_pf 6 points 1 year ago (1 children)

Try Helix, it's another modal (terminal) editor, but it comes with what you'd expect from a usable text editor out of the box to work on software projects. No need to fight with a million plugins all designed independently.

[–] [email protected] 1 points 1 year ago (1 children)

Good choice, however the number of supported languages is limited to things with language server or treesitter support. Meaning languages without this, like asciidoc, is not supported and might never be

[–] Kamek_pf 2 points 1 year ago (1 children)

both of these things are pretty standard tbh, if a language doesn't even have treesitter grammar, its ecosystem is probably laking

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Nim, which I use as my main language, doesn't have usable Treesitter support. Not for a lack of trying, but because its grammar is very complex and has some features that Treesitter doesn't play well with (indentation sensitivity, style insensitivity).

Also, I do a lot of work in my own language which obviously doesn't have any ecosystem at all.

[–] [email protected] 5 points 1 year ago

Some would probably consider it sacrilegious, but you can actually embed Neovim inside VS Code (or Codium, the FOSS soft fork, similar to what Chromium is for Chrome).

https://github.com/vscode-neovim/vscode-neovim

I've been using this for a couple years (after using vim for a few decades). You get the best of both worlds. You can use both VS Code plugins as well as Neovim/Vim extensions too — whatever you prefer.

I still use Neovim on the command line for quick edits, but I'm happy with VS Codium + Neovim for long IDE coding sessions.

[–] [email protected] 5 points 1 year ago (1 children)
[–] hunger 4 points 1 year ago (1 children)

A good choice... another ist astronvim.

Astronvim covers the basic setup and their community repo with its language packs the specifics :-)

[–] onlinepersona 1 points 1 year ago

I'll try astrovim after lunarvim. Thanks.

[–] [email protected] 4 points 1 year ago

I installed lunarvim(.org) and it gave me all the IDE things I needed + easy installation and configuration

[–] DrDeadCrash 3 points 1 year ago

I've been curious about neovim too, I'm planning on biting off too much with this little walkthrough:

https://vonheikemen.github.io/devlog/tools/build-your-first-lua-config-for-neovim/

[–] xchino 3 points 1 year ago

I'll pile on to the lunarvim suggestions for a more out of the box/curated experience.

[–] [email protected] 3 points 1 year ago

I had similar troubles and my neovim config was not where I wanted it to be. But then I tried AstroNvim and it was great out of the box. From there I customized it to my liking. Also great documentation and fast support from the developers.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

It takes a while to create your minimal and perfect experience, so if you don’t have the time for that I’d suggest using a ready to go neovim setup. Others have suggests kickstart and lunavim. I’d suggest LazyVim since it uses lazy.nvim which is an async package manager. https://www.lazyvim.org/

[–] zygo_histo_morpheus 1 points 1 year ago* (last edited 1 year ago) (1 children)

You're propably better of not worrying too much about the awesome-neovim list until you're more familiar with nvim itself

I thought LSP support was built into nvim. Why are there so many LSP plugins?

Most of the plugins seem to be adding bells and whistles to the core LSP functionality and can be safely ignored. The main one that I recomment is nvim-lspconfig which makes it easier to get servers up and running. Neovim itself knows the lsp protocol but isn't aware of any particular lsp servers. lspconfig comes with premade configurations for different servers so that you don't have to e.g. tell neovim where to look for the executable or which servers handle which filetypes and so on. It is doable to use LSP without this plugin as well, it just means more boilerplate in your config file.

And what the hell is treesitter and why do I need it?

Treesitter is a different way of parsing files for e.g. syntax highlighting. Vanilla (neo)vim uses a pile of regular expressions to perform syntax highlighting essentially, while treesitter actually parses the source files in a way that is aware of the way the target language works. Treesitter might know the difference between a macro and a function for example, and can highlight them differently. You can also querry the syntax tree that tressitter has parsed for use in custom scripts or plugins. Also completely optional unless you want to use a plugin that depends on it.

As for plugin manegement, I use vim-plugged (which is a vim plugin but is also compatible with neovim). You basically just list the github/gitlab repos you want in your .vimrc file and run a command to download/update them.

My lsp code in my init.vim file is as follows (taking advantage of nvim-lspconfig): https://pastebin.com/0Wy1ASwk. Adding a new lsp means making sure that the server itself is intalled (e.g. through my package manager) and then adding another line in the langs object, like when i added erlangls i just added erlangls = {}, on line 19.

(EDIT: For some reason the nmap('gd', vim.lsp.buf.definition) line is repeated a bunch of times in the paste bin. That's not on purpose)

Debugging is imo a weak point for both vim and neovim, there's nvim-dap and vimspector which takes advantage of LSPs sister protocol DAP (debug adapter protocol). Setting it up is principaly similar to LSPs. Vim and neovim also have the builtin termdebug plugin which you can load using packadd termdebug in you .vimrc file and allows you to debug using GDB.

[–] RayZ0rr 2 points 1 year ago

This here is also a good starting point for Neovim: https://github.com/nvim-lua/kickstart.nvim

[–] [email protected] 1 points 1 year ago

I recommend to start with kickstart if you prefer to customize https://github.com/nvim-lua/kickstart.nvim or Lunarvim for a full IDE experience to see what's possible and go from there https://www.lunarvim.org/de/

Most works out of the box then. Start there and customize further to your needs