Re-learning Vim (8)

Date: 2024/06/04 (initial publish), 2024/06/14 (last update)

Source: en/note-00074.md

Previous Post Top Next Post

TOC

Nvim configuration retrospective

I have been updating Nvim configuration with LazyVim as described in Re-learning Vim (7) to make it behave as close as plain Nvim.

I made further changes to my forked LazyVim starter.

Vim configuration touch-ups

In order to make my Vim experience to match my LazyVim/Nvim configuration as much, I also updated my ~/.vimrc.

Folding of markdown file

I have always used gq under visual line mode to rewrap range of lines within 'textwidth. Since LazyVim sets 'formatexpr, it doesn’t work as expected any more for some 'filetype such as markdown.

Easy workaround is to use gw instead.

Basics around quickfix list

Command summary

I feel I need to revisit some key baseline Vim operation techniques beyond the use of keyboard MACRO.

Let’s look into “Quickfix list” and “location list”.

“Quickfix list” and “location list” are essentially a jump table data generated by:

“quickfix list” “location list” functionality
:vim[grep] :lv[imgrep] Vim internal search
:gr[ep] :lgr[ep] Vim external search
:helpg[rep] :lh[elpgrep] Help message search
:mak[e] :lmak[e] Run makeprg
:cex[pr] {expr} :lex[pr] {expr} Run {expr}
:cope[n] :lop[en] Open list of errors/matches
:ccl[ose] :lcl[ose] Close list of errors/matches
:cdo {cmd} :ld[o] {cmd} Execute {cmd} for all errors/matches
:cc [nr] :ll [nr] Display nr-th error/match
:cn[ext] :ln[ext] Display next error/match
:cp[revious] or :cN :lp[revious] or :lN Display previous error/match
:cfir[st] :lfir[st] Display first error/match
:cla[st] :lla[st] Display last error/match
:cli[st] :lli[st] List all errors/matches
:col[der] :lol[der] Open older list of errors/matches
:cne[wer] :lne[wer] Open newer list of errors/matches

Here, {cmd} in the above for :cdo is Ex-command like s/foo/bar/gc. {cmd} can contain | to concatenate several commands in Ex-mode.

LazyVim and my updated ~/.vimrc map [q and ]q to :cprevious<cr> and :cnext<cr> for easy navigation based on quickfix list.

Unless I get to do very complicated things, I should be OK just using global quickfix list.

I normally set hidden and autowrite, so forcing some command to jump to different buffer is safe.

For customizing :make behavior, see:

For customizing :cexpr {expr} behavior, see:

For customizing :grep behavior, see:

Ex-mode command line

There are special characters for EX-mode command line.

If the faster rg (ripgrep package) is used for :grep, it can easily offer optimal recursive tree search from the current working tree by not-specifying the target file in Ex-mode command line.

The wildcard expression such as *, *.txt, **.md, …, parsed by the underlining shell (Bash) may also be useful.

Use case (manual changes)

Use case (automatic changes)

Filter quickfix list contents

Use exclude_pattern and include_pattern (vim internal regex).

(I updated ~/.vimrc and ~/.config/nvim/lua/config/lazy.lua)

This is quite handy to trim down quickfix list to run :cdo {cmd} script.

:col and :cnew are handy for this type of operation.

Regex dialects around quickfix list

All modern platforms, such as Perl, Python, Rust, …, support POSIX 1003.2 regular expressions. So be careful for Vim RE.

Since I use rg or Vim internal regex, I decided to keep their default to be smart case and set them as needed to be specific ones.

Lua in Nvim basics

There are 4 ways to print the value of an internal variable var in NORMAL-mode.

Here are tutorials:

“Lua-guide” in the above is based on “nvim-lua-guide” and supersede it now.

Nvim logging

Invoke with option: nvim -V10logfile.txt file1 file2

:=_G should dump code to log. Other variables can be inspected, too.

Basic modules in LazyVim

I went through LazyVim’s keymap page to check available non-extra modules and functionalities.

I found a few interesting ones which I overlooked.

noice.nvim

I now realize noice.nvim offers a nice UI for recalling messages from the message history, etc. (Updated keymap.)

todo-comments.nvim

Interesting search UI with quickfix. Keyword are followed by a colon:

trouble.nvim

Interesting diagnostic and LSP UI with quickfix and telescope.

conform.nvim and nvim-lint

These packages seem to replace functionality previously available through null-ls/none-ls.

bufferline.nvim

LazyVim uses buffers with top tab line indicator.

Additional plugins

precognition.nvim

I added precognition with its feature disabled as started.

Changes of LazyVim and extras

In order to understand historical context of LazyVim development, I checked:

These gave me decent perspective.

Then, I realize lua/lazyvim/util/plugin.lua has interesting summary of reasons of existences for some extras – deprecated/renamed/… .

Previous Post Top Next Post