README.md

March 4, 2023 ยท View on GitHub

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

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.

C# (omnisharp)

  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

ShortcutModeDescription
F2NormalReplace word under cursor
F2VisualRename selection
F5NormalOpen telescope.nvim module reloader
F10NormalToggle spellcheck
F11NormalToggle warp
F12NormalToggle paste mode
\\tNormalOpen windows terminal at cwd
\\eNormalOpen explorer at cwd
\\cNormalOpen current file in VSCode
\\nNormalOpen current file in notepad
tfNormalOpen telescope.nvim find files
trNormalOpen telescope.nvim recent files
tsNormalOpen telescope.nvim session browser
\qNormalToggle quickfix
\hNormalDisable search highlight
\vNormal/InsertPaste from system clipboard in paste mode
\wNormalClose buffer (will discard changes if not saved)
\uNormalOpen URL under cursor in browser
\sNormalSearch word under cursor in browser
\nNormalOpen dashboard
fNormalSearch buffer using 1 chars
SNormalSearch buffer using 2 chars
TabNormalMove to next buffer
Shift TabNormalMove to previous buffer
TabInsertExpand trigger or jump to next tab stop
Shift TabInsertJump to previous tab stop
Ctrl j(k)CommandMove between completion items
Ctrl j(k)InsertMove between completion items
Alt dNormalDuplicate current line below
Alt j(k)Normal/VisualMove line (block) up or down
Alt ]NormalIncrease indent
Alt [NormalDecrease indent
Ctrl /Normal/Visual/InsertComment current (selected) line(s)
EnterInsertSelect completion item
Ctrl SpaceInsertForce completion menu to open
Ctrl cInsertForce completion menu to close
Ctrl eInsertSelect first completion item
Ctrl tInsertOpen omni-func completion
Ctrl BackspaceInsertDelete previous word
Ctrl DeleteInsertDelete next word
Ctrl bNormalToggle nvim-tree
Ctrl fNormalFormat document
Ctrl h(jkl)NormalMove to window to the left (down, up, right)
Ctrl sNormalSave current file
Ctrl Shift sNormalSave and reload module (current file)
Ctrl vInsertPaste from system clipboard
Ctrl zInsertCorrect preceding misspelt word
Ctrl zNormalCorrect misspelt word under cursor
gDNormalLSP: Goto function declaration
giNormalLSP: Goto function implementation
ghNormalLSP: Preview documentation
gdNormalLSP: Preview function definition
gsNormalLSP: Preview signature help
grNormalLSP: Rename instance
glNormalLSP: Show line diagnostic
gRNormalLSP: Show references
gaNormalLSP: Trigger code action
\liNormalVimTeX: Info
\lTNormalVimTeX: TOC toggle
\lqNormalVimTeX: Log
\lvNormalVimTeX: View pdf
\lrNormalVimTeX: Reverse search
\llNormalVimTeX: Compile
\lkNormalVimTeX: Stop
\leNormalVimTeX: Errors
\lCNormalVimTeX: Clean full
\lxNormalVimTeX: Reload
\lXNormalVimTeX: Reload state
\tNormalPython, Lua, C#: Run code in external terminal
\rNormalPython, Lua: Run code without terminal output
\ltNormalLua (Lร–VE2D): Run game in external terminal
\lrNormalLua (Lร–VE2D): Run game without terminal output

Todo โœ”

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