/nvim-config-packer

My Neovim config No_01 (My OLD config, Windows OS, plugin manager Packer.nvim )

Primary LanguageLuaMIT LicenseMIT

INTRODUCTION

This is my old Neovim configuration for Windows (See: Neovim Github repo).
Here I used the Packer.nvim, plugin manager for Neovim.
Info: neovim/projects ==> @bfredl, @tjdevries, @mfussenegger, @folke, ...

init.lua is the config entry point for terminal Nvim, and ginit.vim is the additional config file for GUI client of Nvim.
My GUI client of Nvim is neovim-qt. You can find Neovim plugins on these sites: plugins

This config is only maintained for the latest nvim stable release. A starting point for my configuration is nvim-lua/kickstart.nvim.


FOLDERS AND FILES

nvim
├── after
│   └── plugin
│       ├── autocmd.lua
│       ├── commands.lua
│       ├── keymaps.lua
│       └── options.lua
│
├── doc\INSTALL.md
│
├── lua
│   ├── custom
│   │  ├── config\bufferline.lua, todocomments.lua, ...
│   │  └── plugins.lua
│   │
│   └── 
│
├── plugin\packer_compiled.lua
│
├── templates\HowToTemplate.txt, py.tpl, ...
│
├── ginit.vim
├── init.lua
├── README.md

init.lua: Main configuration file that call lua modules

nvim\lua\ Folder of lua modules, here reside all the Lua modules that needed.
See: where-to-put-lua-files


INSTALL AND SETUP

See doc here on how to install Neovim and Neovim dependencies.

Check where the config folder is:

:echo stdpath("config")
==>  C:\Users\userName\AppData\Local\nvim

:echo stdpath("data")
==>  C:\Users\userName\AppData\Local\nvim-data

Windows command shell:
echo %userprofile%
==>  C:\Users\userName

echo %localappdata%
==>  C:\Users\userName\AppData\Local

Neovim config and plugins installation

Windows command shell: help XCOPY
/S Copy folders and subfolders
/H Copy hidden and system files and folders (default=N)

  1. Backup your previous configuration (show hidden files and folders)
    XCOPY %LOCALAPPDATA%\nvim\* nvim\ /S /H
    and (if you want) archive "nvim-data" folder with zip archiver
    ( or XCOPY %LOCALAPPDATA%\nvim-data\* nvim-data\ /S /H )

  2. Delete folders "nvim" and "nvim-data"
    ( Delete file "packer_compiled.lua": DEL %LOCALAPPDATA%\nvim\plugin\packer_compiled.lua )
    Delete folder "nvim": RD %LOCALAPPDATA%\nvim\
    Delete folder "nvim-data": RD %LOCALAPPDATA%\nvim-data\

  3. Download this repo with git
    git clone https://github.com/mlabrkic/dotfiles.git

  4. Copy the "nvim" folder of this repo into %LOCALAPPDATA%
    XCOPY nvim\* %LOCALAPPDATA%\ /S /H

  5. Start (1.) Neovim (nvim)
    Ignore any error message about missing plugins!
    ==> Wait for: "packer.nvim - finished in" 463s (7,7 min)
    Quit Neovim - :q(uit) (press Enter)

  6. Start (2.) Neovim (nvim)
    " ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'help', 'vim' },"
    ==> Wait for nvim-treesitter parsers to compile ( 1/9, 2/9, ... , 9/9).
    ...
    [4/9] Treesitter parser fo lua has been installed.
    ...
    Quit Neovim - :q(uit) (press Enter)

If you want, install manually
:TSInstall java
:TSInstallInfo
Windows-support#troubleshooting


CHECK IT OUT

Various checks

LSP check

Open a source file of one of the supported languages with Neovim, and run command "LspInfo" for testing the LSP support.
:LspInfo

Keymaps check

:echo mapcheck('<F4>', 'n')
:echo hasmapto('set relativenumber!<CR>', 'n')

Configuration check

Open nvim and run command "checkhealth", you should not see any error in the output (except for the one related to the Python 2 interpreter if don't have it):
:checkhealth


FINALLY, install these plugins ONE BY ONE

  -- Uncomment No_ 01:
  -- use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', }

  -- Uncomment No_ 02:
  -- use { "folke/todo-comments.nvim",
  --   requires = "nvim-lua/plenary.nvim",
  --   config = [[require('plugins.todocomments')]], }

  -- Uncomment No_ 03:
  -- use {
  --   "iamcco/markdown-preview.nvim", ft = { "markdown" },
  --   run = "cd app && npm install",
  --   config = [[require('plugins.v_markdown-preview')]],
  -- }

Plugins can have post-install/update hooks (Packer.nvim.)
It is best to install them one by one!

Packer info:
-- You must run this (or PackerSync) whenever you make changes to your plugin configuration:
-- Regenerate compiled loader file   :PackerCompile

-- Remove any disabled or unused plugins   :PackerClean
-- Clean, then install missing plugins   :PackerInstall

-- Show list of installed plugins   :PackerStatus
-- Loads opt plugin immediately   :PackerLoad trouble.nvim

h packer.compile()

init.lua :

  -- INFO: First install other plugins. After that uncomment this:
  use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', }

To get fzf-native working, you need to build it with either cmake or make:

  • CMake, and the Microsoft C++ Build Tools, or
  • Make, and MinGW (gcc)(my choice)
    ( See doc here on how to install C compiler. )

Check this after installation:

Windows Command shell:
cd %LOCALAPPDATA%\nvim-data\site\pack\packer\start\telescope-fzf-native.nvim\
cd build
dir
==> libfzf.dll exist?
If libfzf.dll does not exist ...

A) Check for "make" (in Neovim):
:echo executable("make")
or
:lua print(vim.fn.executable('make'))

Windows Command shell:
make -v
make -h

B) If you have "make":

Windows Command shell:
cd %LOCALAPPDATA%\nvim-data\site\pack\packer\start\telescope-fzf-native.nvim\
dir

make

C) If you don't have a "make":

Windows Command shell:
cd %LOCALAPPDATA%\nvim-data\site\pack\packer\start\telescope-fzf-native.nvim\

mkdir build
gcc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll

-->
telescope-fzf-native.nvim\build\libfzf.dll

NOTE: If you want to uninstall this plugin later ...

  • First delete the "build" folder:
    cd %LOCALAPPDATA%\nvim-data\site\pack\packer\start\telescope-fzf-native.nvim\
    RD build\

  • Uninstall this plugin (Comment plugin in "init.lua", PackerCompile, PackerClean)

--------------

nvim\lua\plugins.lua :

  -- Please make sure that you have installed node.js .
  -- INFO: First install other plugins. After that uncomment this:

  use {
    "iamcco/markdown-preview.nvim", ft = { "markdown" },
    run = "cd app && npm install",
    -- requires = { "zhaozg/vim-diagram", "aklt/plantuml-syntax" },
    config = [[require('plugins.v_markdown-preview')]],
  }
  • Open some markdown file.
  • :MarkdownPreview ( nnoremap <A-m> :<C-U>MarkdownPreview<CR> )
  • Wait cca 15 s.
If nothing happened after "MarkdownPreview" command ...

Nothing happened after "MarkdownPreview" command. No page opened in browser.
Check for errors :messages

Please make sure that you have installed node.js ( node --version ).
If there are errors, then uninstall the plugin, and repeat everything.

--------------


FEATURES

I use these plugins

REFERENCES

https://github.com/jdhao/nvim-config
https://github.com/brainfucksec/neovim-lua

:help lua-guide (large part taken from https://github.com/nanotee/nvim-lua-guide)

Lua in Y minutes - https://learnxinyminutes.com/docs/lua/
Lua Quick Guide - https://github.com/medwatt/Notes/blob/main/Lua/Lua_Quick_Guide.ipynb
( Lua 5.1 Reference Manual )

Windows Command shell info

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands
https://ss64.com/nt/