pykeras/neovim

github github
stars 44
issues 0
subscribers 1
forks 5
CREATED

2024-12-29

UPDATED

11 days ago


Neovim Configuration Guide

TODO:

  • Fix issue with mypy doesn't show inline diagnostic messages

This is a starter configuration for Neovim, featuring a curated selection of the most useful plugins for Python and Rust development. It's lightweight and highly customizable, suitable for both beginners and advanced users.

main environment

rust coding

A basic set of key mappings is included and located in lua/keymaps.lua. You can review and customize these mappings to align with your personal preferences.

Prerequisites

Before proceeding, ensure you meet the following requirements:

Neovim Version: v0.11.0 - v.11.2
Operating System: Rocky Linux 9.4, PopOS 22.04, Debian 12.9, Android with termux

Dependencies:

Ensure the following dependencies are installed for a seamless experience:

  • Ripgrep (for Telescope):

    sudo dnf install ripgrep
    
  • Python venv (for Python-based plugins):
    Replace <minor> with your Python minor version:

    sudo dnf install python3.<minor>-venv
    
  • Clipboard provider (e.g., xclip):

    sudo dnf install xclip
    
  • Node.js & npm (for LSP support via nvm):
    Install nvm from GitHub.

  • Prettier (for yaml,js,... formatting)

    npm install -g prettier
    

How to install:

$ cd ~/.config/nvim
$ git clone git@github.com:pykeras/neovim.git .
$ nvim

Useful Commands

  • Check Telescope health:

    :checkhealth telescope
    
  • Save without formatting:

    :noautocmd write
    
  • Install formatters, debuggers, etc. (via Mason):

    :Mason
    

Key Bindings

Leader Key <leader>: The leader key is mapped to the spacebar ().

General

  • Which Key (Help Menu): Press <leader> to see available shortcuts.
  • Copy to clipboard: <leader>y
  • Paste from clipboard: <leader>p
  • Easier switching between splits:
    • Move to the left split: <C-h>
    • Move to the right split: <C-l>
    • Move to the upper split: <C-k>
    • Move to the lower split: <C-j>
  • Toggle relative line numbers: <leader>rl
  • Clear search highlights: Esc
  • Escape insert mode: jj
  • Close all splits except current: <leader>qo

Virtual Environment Selector (Python)

By default if you have .venv in project directory this setup will use that otherwise:

  • Open selector: <leader>vs
  • Select cached venv: <leader>vc

Debugging

For python make sure you run pip install debugpy in the virtualenv detected/selected.

  • Step into: <F2>
  • Step over: <F3>
  • Step out: <F4>
  • Continue/Start debugging: <F5>
  • Toggle breakpoint: <Leader>b
  • Set conditional breakpoint: <F6>
  • Terminate debugger: <F7>
  • Run last debugging session: <F8>

Rustaceanvim

  • Show testable functions: <leader>rdt

Telescope

  • Search files: <leader>ff
  • Live grep files: <leader>fg
  • Show TODOs (Telescope): <leader>tt
  • Show TODOs (loclist): <leader>tl

NeoTree (File Explorer)

  • Open/Close NeoTree: <leader>e
  • Reveal file in NeoTree: <leader>E
  • NeoTree filesystem: <leader>nf
  • Git status NeoTree: <leader>gs

LSP Configuration

  • Hover documentation: K
  • Go to definition: gd
  • Go to definition (vertical split): <leader>gdv
  • Go to definition (horizontal split): <leader>gds
  • Peek definition: <leader>gdp
  • Code actions: <leader>ca
  • Show method signature (Insert mode): <C-k>

None-ls (Formatting)

  • File global formatting: <leader>gf

Bufferline (Tabs)

  • Select buffer: <leader>bs
  • Cycle next buffer: <Tab>
  • Cycle previous buffer: <S-Tab>
  • Move buffer left: <leader>bl
  • Move buffer right: <leader>br
  • Close buffer: <leader>bx
  • Close all other buffers: <leader>bxa

Commenting

  • Single line comment: ctrl+/
  • Multi-line comment (visual selection): ctrl+/

Git Integration

  • Preview hunk (change): <leader>gp
  • Git blame: <leader>gb
  • Git log (oneline graph, custom): <leader>gl
  • Git difference (file): <leader>gfd

Undo Tree

  • Open/Close undo tree: <leader>u

Session Management (Persisted)

  • Save session: <leader>ss
  • List sessions: <leader>sl
  • Delete session: <leader>sd

CodeSnap

  • Save to clipboard: <leader>cc
  • Save to ~/Pictures: <leader>cs

ToggleTerminal

  • Open/Close terminal: ctrl+\
  • Open terminal below: <leader>th
  • Open floating terminal: <leader>tf
  • Send current line to terminal (run command from docs): <leader>tst

UFO (Folding)

  • Fold all: zR
  • Unfold all: zM
  • Toggle fold under cursor: za

Spelling

  • Display suggestions: z=
  • Add word to dictionary: zg

Noice (Message Management)

  • Dismiss message: <leader>nd
  • List messages: <leader>nl

Tabular (CSV/TSV View)

  • View CSV as table: <leader>csv
  • View TSV as table: <leader>tsv

Optional Features

AI Integration (Avante)

  • Ensure LuaJIT is installed.
  • Rename ~/.config/nvim/lua/plugins/avante to avante.lua for Ollama.