/nvim-config

Personal neovim configuration⚑πŸͺŸ - Fully configured for LaTeX, Python, Lua, C#, HTML, CSS, and Javascript - Neovim version: v0.9+

Primary LanguageLuaMIT LicenseMIT

nvim-config

Just another opinionated, visually appealing Neovim IDE.
Configured for Windows, supports LaTeX, Python, Lua, C#, HTML, CSS, and Javascript.

license stars forks

Table of Contents

Screenshots πŸ“·

start time file explorer file navigation latex latex python

Installation ⚑

The following instructions are for Windows (powershell). An admin prompt is required.

  1. Install chocolatey.

    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  2. Install main dependencies.

    choco install -y git.install --params "/GitAndUnixToolsOnPath /NoGitLfs /SChannel /NoShellIntegration";
    choco install -y neovim python SumatraPDF.install miktex.install;
    # Needed for various plugins
    choco install -y universal-ctags strawberryperl make SQLite ripgrep fd golang; refreshenv; exit
    
  3. Install python dependencies.

    pip install pynvim neovim-remote
    
  4. Clone the repository and open nvim-qt or nvim.

    For fresh installation:

    git clone https://github.com/Neelfrost/nvim-config.git "$HOME\Appdata\Local\nvim"; nvim-qt.exe
    

    For existing config:

    ren "$HOME\Appdata\Local\nvim" 'nvim-old'; git clone https://github.com/Neelfrost/nvim-config.git "$HOME\Appdata\Local\nvim"; nvim-qt.exe
    

LaTeX

Formatting (latexindent)

latexindent is now included with miktex, so downloading it separately is no longer necessary. Moreover, null-ls is pre-configured to run latexindent on save for tex files. Global formatting rules can be changed by:

  1. Creating $HOME/indentconfig.yaml:

    paths:
      - C:\Users\<username>\defaultSettings.yaml
  2. Creating $HOME/defaultSettings.yaml, followed by copying and overriding defaultSettings.

For further reading refer: docs.

Viewing PDF

To launch SumatraPDF using VimTeX (\lv), ensure SumatraPDF.exe is added to environment path.

Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path + ";" + "$HOME\AppData\Local\SumatraPDF" + ";"); refreshenv; exit

Inverse Search

For inverse search, open SumatraPDF then go to Settings -> Options and set inverse search command-line to:

cmd /c start /min nvim --headless -c "PackerLoad vimtex" -c "VimtexInverseSearch %l '%f'"

Use :checkhealth to check for errors if any.

Language Servers

Python (pyright)

  1. Install npm.

    choco install -y nodejs.install; refreshenv; exit
    
  2. Install pyright.

    npm install -g pyright
    
  3. Install black, isort, and flake for formatting and linting.

    pip install flake8 black isort
    
  4. Use :checkhealth to check for errors if any.

Lua (LuaLs)

  1. Install dependencies.

    choco install -y 7zip.install; refreshenv; exit
    
  2. cd into install directory. For example:

    cd C:\tools
    
  3. Install LuaLs.

    curl.exe -L $(curl.exe -s https://api.github.com/repos/LuaLS/lua-language-server/releases/latest | findstr.exe "win32-x64" | %{"$($_.Split('"')[3])"} | findstr.exe "github") -o luals.zip; 7z.exe x .\luals.zip -olua-language-server; rm luals.zip
  4. Add LuaLs to environment path.

    Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path + ";" + "C:\tools\lua-language-server\bin" + ";"); refreshenv; exit
  5. Install stylua for formatting.

    curl.exe -L $(curl.exe -s https://api.github.com/repos/JohnnyMorganz/StyLua/releases/latest | findstr.exe "win64.zip" | %{"$($_.Split('"')[3])"} | findstr.exe "github") -o stylua-win64.zip; 7z.exe x -oC:\tools\stylua .\stylua-win64.zip; rm .\stylua-win64.zip;
    # Add stylua to environment path:
    Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $((Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path + ";" + "C:\tools\stylua" + ";"); refreshenv; exit
  6. Use :checkhealth to check for errors if any.

  1. Install dotnet-sdk.

    choco install dotnet-sdk -y
    
  2. Install omnisharp-roslyn.

    curl.exe -L $(curl.exe -s https://api.github.com/repos/OmniSharp/omnisharp-roslyn/releases/latest | findstr.exe "omnisharp-win-x64-net6.0.zip" | %{"$($_.Split('"')[3])"} | findstr.exe "github") -o omnisharp-win-x64-net6.0.zip; 7z.exe x -oC:\tools\omnisharp .\omnisharp-win-x64-net6.0.zip; rm .\omnisharp-win-x64-net6.0.zip;
    
  3. Use :checkhealth to check for errors if any.

HTML, CSS, Javascript (vscode-langservers-extracted)

  1. Install dependencies.

    npm i -g vscode-langservers-extracted
    
  2. Install prettierd for formatting.

    npm i -g @fsouza/prettierd
    
  3. Use :checkhealth to check for errors if any.

Update πŸš€

  1. Pull changes.

    cd "$HOME\Appdata\Local\nvim"; git pull
    
  2. Open nvim-qt or nvim and update plugins:

    :PackerSync
    

Features πŸ“ƒ

General

  • Smart display line movement.
  • Resume cursor position when re-opening a file.
  • Auto update file if changed outside of neovim.
  • Fix mixed indents (tabs are converted to spaces).
  • Persistent cursor positions when switching buffers.
  • Ability to search custom directories in telescope.nvim.
  • Ability to reload specific modules using telescope.nvim.
  • Automatically trim trailing whitespaces and newlines on save.
  • Search and replace selection (automatically escape special chars).
  • Open windows terminal, vscode, explorer at current directory using \\t, \\c, \\e respectively.

LaTeX

Compile status on statusline Compile not started Compile not started Compile running Compile running Compile success Compile success Compile failed Compile failed
  • Extensive snippets for LaTeX.
  • Better auxiliary file cleaner.
  • Null-ls: latexindent, chktex support.
  • Automatically substitute \ in imports (include, input) with / on save.
  • Keybinds for bold, underline, math, chemical formula environments.
  • Start newline with \item (or \task) if inside a list environment when pressing Enter, o or O.

Folder Structure

nvim
β”œβ”€β”€ after
β”‚   └── ftplugin         # filetype specific options, settings, mappings
β”œβ”€β”€ lua                  # .lua config files
β”‚   └── user
β”‚       └── mappings.lua # keybinds
β”‚       └── options.lua  # vim options
β”‚       └── utils.lua    # utility functions
β”‚       └── plugins
β”‚           β”œβ”€β”€ config   # plugin config
β”‚           └── init.lua # plugin definition file
β”œβ”€β”€ ultisnips            # snippets
β”‚   └── tex              # latex snippets
└── viml                 # .vim config files

Plugins

LSP

File navigation

Code completion

LaTeX

Looks

Buffer, Status

QOL

Mappings

Shortcut Mode Description
F2 Normal Replace word under cursor
F2 Visual Rename selection
F5 Normal Open telescope.nvim module reloader
F10 Normal Toggle spellcheck
F11 Normal Toggle warp
F12 Normal Toggle paste mode
\\t Normal Open windows terminal at cwd
\\e Normal Open explorer at cwd
\\c Normal Open current file in VSCode
\\n Normal Open current file in notepad
tf Normal Open telescope.nvim find files
tr Normal Open telescope.nvim recent files
ts Normal Open telescope.nvim session browser
\q Normal Toggle quickfix
\h Normal Disable search highlight
\v Normal/Insert Paste from system clipboard in paste mode
\w Normal Close buffer (will discard changes if not saved)
\u Normal Open URL under cursor in browser
\s Normal Search word under cursor in browser
\n Normal Open dashboard
f Normal Search buffer using 1 chars
S Normal Search buffer using 2 chars
Tab Normal Move to next buffer
Shift Tab Normal Move to previous buffer
Tab Insert Expand trigger or jump to next tab stop
Shift Tab Insert Jump to previous tab stop
Ctrl j(k) Command Move between completion items
Ctrl j(k) Insert Move between completion items
Alt d Normal Duplicate current line below
Alt j(k) Normal/Visual Move line (block) up or down
Alt ] Normal Increase indent
Alt [ Normal Decrease indent
Ctrl / Normal/Visual/Insert Comment current (selected) line(s)
Enter Insert Select completion item
Ctrl Space Insert Force completion menu to open
Ctrl c Insert Force completion menu to close
Ctrl e Insert Select first completion item
Ctrl t Insert Open omni-func completion
Ctrl Backspace Insert Delete previous word
Ctrl Delete Insert Delete next word
Ctrl b Normal Toggle nvim-tree
Ctrl f Normal Format document
Ctrl h(jkl) Normal Move to window to the left (down, up, right)
Ctrl s Normal Save current file
Ctrl Shift s Normal Save and reload module (current file)
Ctrl v Insert Paste from system clipboard
Ctrl z Insert Correct preceding misspelt word
Ctrl z Normal Correct misspelt word under cursor
gD Normal LSP: Goto function declaration
gi Normal LSP: Goto function implementation
gh Normal LSP: Preview documentation
gd Normal LSP: Preview function definition
gs Normal LSP: Preview signature help
gr Normal LSP: Rename instance
gl Normal LSP: Show line diagnostic
gR Normal LSP: Show references
ga Normal LSP: Trigger code action
\li Normal VimTeX: Info
\lT Normal VimTeX: TOC toggle
\lq Normal VimTeX: Log
\lv Normal VimTeX: View pdf
\lr Normal VimTeX: Reverse search
\ll Normal VimTeX: Compile
\lk Normal VimTeX: Stop
\le Normal VimTeX: Errors
\lC Normal VimTeX: Clean full
\lx Normal VimTeX: Reload
\lX Normal VimTeX: Reload state
\t Normal Python, Lua, C#: Run code in external terminal
\r Normal Python, Lua: Run code without terminal output
\lt Normal Lua (LΓ–VE2D): Run game in external terminal
\lr Normal Lua (LΓ–VE2D): Run game without terminal output

Todo βœ”

  • Improve mappings table
  • Document snippets
  • Automatic install script
  • Create video to showcase snippets