Neovim from scratch

So, after playing around with lazyvim and getting quite frustrated with all sorts of weirdness due to mismatched versions and suchlike, I thought I’d dig into the fundamentals and build my own setup, install various plugins manually, maybe setup an LSP from scratch.

This is not a beginner tutorial – if you’ve never used vim or neovim before then there plenty of videos, blogs and even books to help you get started. Also, if you have a working installation of [neo]vim, then you can also start it and type: :Tutor (including the colon) and press enter and follow the instructions.

Anyway, lets dig in. First port of call, as always, is the manual.

:help

I wont’ reproduce the whole help file here, but this first page is super useful, as it tells you how to find specific information, like on a specific command or option:

help.txt        Nvim

                        VIM - main help file
                                                                         k  
      Move around:  Use the cursor keys, or "h" to go left,            h   l
                    "j" to go down, "k" to go up, "l" to go right.       j
Close this window:  Use ":q<Enter>".                                        
   Get out of Vim:  Use ":qa!<Enter>" (careful, all changes are lost!).
        
Jump to a subject:  Position the cursor on a tag (e.g. bars) and hit CTRL-].
   With the mouse:  Double-click the left mouse button on a tag, e.g. bars.
        Jump back:  Type CTRL-O.  Repeat to go further back.
                                                
Get specific help:  It is possible to go directly to whatever you want help
                    on, by giving an argument to the :help command. 
                    Prepend something to specify the context:  help-context   
        
                          WHAT                  PREPEND    EXAMPLE
                      Normal mode command                  :help x
                      Visual mode command         v_       :help v_u
                      Insert mode command         i_       :help i_<Esc>
                      Command-line command        :        :help :quit
                      Command-line editing        c_       :help c_<Del>
                      Vim command argument        -        :help -r
                      Option                      '        :help 'textwidth'
                      Regular expression          /        :help /[
                    See help-summary for more contexts and an explanation.

We can make the help full screen with :only.

Before we start adding our own stuff, lets have a quick look at what gets included by default. :help initialization shows a serious list of stuff that goes on under the hood when Neovim is started.

Item 4. mentions default-mappings and default-autocmds, take a quick look at those to see what’s going on.

One little note, if you’re going to get deep into Neovim, I recommend you get used to Lua. This means that the mapping functions end up looking different. Instead of adding :noremap F3 i to your init.vim, you put vim.keymap.set('F3','i') in your init.lua.

On the subject of key mappings, there are a few useful tools to keep in mind:

:help indexShows the default key list
:mapShows a list of all the mappings currently in effect
:help map-which-keysSome advice from the manual about which keys to use for mappings

Leave a Reply

Your email address will not be published. Required fields are marked *