Skip to content

Configuration for Neovim with some personal hacks.

License

Notifications You must be signed in to change notification settings

AnthonyK213/nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neovim Configuration

Configuration for Neovim with some personal hacks.

Requirements

Installation

  • Clone repository
    • Windows
      git clone --depth=1 https://github.com/AnthonyK213/nvim.git `
                          "$env:LOCALAPPDATA\nvim"
    • GNU/Linux
      git clone --depth=1 https://github.com/AnthonyK213/nvim.git \
                          "${XDG_DATA_HOME:-$HOME/.config}"/nvim
  • Start Neovim and wait for the installation to complete
  • Customize with nvimrc
    • In the home|config directory, named .nvimrc (also can be _nvimrc on Windows)
    • Example
      {
        // When PC is not able to connect to the Internet to download the plus-in
        "offline": false,
        // Dependencies
        "dep": {
          // (string|array) Shell
          "sh": ["pwsh", "-nologo"],
          // (string) C compiler
          "cc": "clang",
          // (string) Python3 executable path
          "py3": "python3/executable/path",
          // (string) Proxy
          "proxy": "http://127.0.0.1:7890"
        },
        // Paths
        "path": {
          // (string) Home directory
          "home": "$HOME",
          // (string) Cloud drive directory
          "cloud": "$HOME/cloud",
          // (string) Desktop directory
          "desktop": "$HOME/Desktop",
          // (string) Binaries directory
          "bin": "$HOME/bin"
        },
        // Terminal UI
        "tui": {
          // ("onedark"|"tokyonight"|"gruvbox"|"nightfox"|"onenord") Color scheme
          "scheme": "nightfox",
          // ("dark"|"light") Tui background theme
          "theme": "dark",
          // (string) Style of color scheme
          "style": "nord",
          // (boolean) Make background transparent
          "transparent": false,
          // (boolean) Global statusline
          "global_statusline": false,
          // (string) Floating window border style
          "border": "single",
          // (boolean) nvim-cmp ghost text
          "cmp_ghost": false,
          // (boolean) Dim inactive window automatically
          "auto_dim": false,
          // (boolean) Animation effects
          "animation": false,
          // (boolean) Show current context by indent line
          "show_context": false,
          // (boolean) Enable devicons
          "devicons": false,
          // (string|array) Welcome page title
          "welcome_header": "NEOVIM",
          // (string|array) Bufferline style
          "bufferline_style": "thin"
        },
        // GUI (neovim-qt, fvim, neovide)
        "gui": {
          // ("auto"|"dark"|"light") GUI background theme
          "theme": "auto",
          // (number) Window opacity
          "opacity": 0.98,
          // (boolean) Render ligatures
          "ligature": false,
          // (boolean) Use GUI popup menu
          "popup_menu": false,
          // (boolean) Use GUI tabline
          "tabline": false,
          // (boolean) Use GUI scroll bar
          "scroll_bar": false,
          // (number) Line space
          "line_space": 0.0,
          // (boolean) Cursor blink
          "cursor_blink": false,
          // (number) GUI font size
          "font_size": 13,
          // (string) See `guifont`
          "font_half": "Monospace",
          // (string) See `guifontwide`
          "font_wide": "Monospace"
        },
        // Language Server Protocol
        "lsp": {
          // (boolean|object) https://github.com/clangd/clangd
          "clangd": false,
          // (boolean|object) https://github.com/LuaLS/lua-language-server
          "lua_ls": {
            "load": false,
            "settings": {
              "Lua": {
                "runtime": {
                  "version": "LuaJIT"
                },
                "diagnostics": {
                  "globals": [ "vim" ]
                },
                "workspace": {
                  // "${lua_expression}" is allowed.
                  "library": "${vim.api.nvim_get_runtime_file('', true)}",
                  "checkThirdParty": false
                },
                "telemetry": {
                  "enable": false
                },
                "format": {
                  "defaultConfig": {
                    "indent_style": "space",
                    "indent_size": "2"
                  }
                }
              }
            }
          },
          // (boolean|object) https://github.com/OmniSharp/omnisharp-roslyn
          "omnisharp": {
            "load": false,
            // Some LSPs' semantic tokens are not usable
            "disable_semantic_tokens": true
          },
          // (boolean|object) https://github.com/microsoft/pyright
          "pyright": {
            "load": false,
            // Extra settings, depends on the LSP
            "settings": {
              "python": {
                "analysis": {
                  "autoSearchPaths": true,
                  "diagnosticMode": "workspace",
                  "useLibraryCodeForTypes": true,
                  "stubPath": "stubPath",
                  "typeCheckingMode": "off"
                }
              }
            }
          },
          // (boolean|object) https://github.com/rust-analyzer/rust-analyzer
          "rust_analyzer": false,
          // (boolean|object) https://github.com/iamcco/vim-language-server
          "vimls": false
          // And so on...
        },
        // Treesitter
        "ts": {
          // (array) Parsers to install automatically
          "ensure_installed": [],
          // (array) File type to disable treesitter highlight
          "highlight_disable": [],
          // (array) File type to disable vim-matchup
          "matchup_disable": []
        },
        // Debug Adapter Protocol
        "dap": {
          // (boolean) https://github.com/llvm/llvm-project
          "lldb": false,
          // (boolean) https://github.com/Samsung/netcoredbg
          "netcoredbg": false,
          // (boolean) https://github.com/microsoft/debugpy
          "debugpy": false
        },
        // Disabled built-in plugins
        "disable": [
          "matchit",
          "matchparen",
          "netrwPlugin"
        ]
      }
  • Install LSP servers via mason.nvim
  • Set .vimrc for Vim (optional)
    • Windows
      Copy-Item "$env:LOCALAPPDATA\nvim\viml\vimrc.vim" `
                -Destination "$env:HOMEPATH\_vimrc"
    • GNU/Linux
      cp "${XDG_DATA_HOME:-$HOME/.config}"/nvim/viml/vimrc.vim \
         "${XDG_DATA_HOME:-$HOME}"/.vimrc
  • Set mailboxes (optional)
    • In the home|config directory, named .mail.json (also can be _mail.json on Windows)
    • Example
      {
        "archive": "/path/to/email/archive/directory/",
        "providers": [
          {
            "label": "A unique label for the mailbox provider",
            "smtp": "SMTP server address",
            "imap": "IMAP server address",
            "port": 993,
            "user_name": "User name",
            "password": "Password"
          }
        ]
      }

Key bindings

  • Ctrl
    • in: C-S -> Save.
    • n: C-Arrow -> Adjust window size.
  • Meta
    • in: M-a -> Select all.
    • v: M-c -> Copy to system clipboard.
    • t: M-d -> Close the terminal.
    • n: M-e -> nvim-tree.lua, nvim-tree find file.
    • nv: M-g -> Find and replace.
    • nv: M-h -> Jump to the window left.
    • nv: M-j -> Jump to the window below.
    • nv: M-k -> Jump to the window above.
    • nv: M-l -> Jump to the window right.
    • nv: M-n -> Move line(s) down.
    • nv: M-p -> Move line(s) up.
    • inv: M-v -> Paste from system clipboard.
    • inv: M-w -> Jump to the window in turns.
    • v: M-x -> Cut to system clipboard.
    • n: M-, -> Open nvimrc.
    • i: M-CR -> Begin a new line below the cursor and insert bullet.
    • in: M-Nr -> Jump to tab (Number: 1, 2, 3, ..., 9, 0).
    • in: M-B -> Markdown/LaTeX bold.
    • in: M-I -> Markdown/LaTeX italic.
    • in: M-M -> Markdown bold_italic; LaTeX Roman Family.
    • in: M-P -> Markdown block.
    • inv: M-U -> Markdown underscore.
  • Emacs
    • inv: C-N -> Cursor down.
    • inv: C-P -> Cursor up.
    • ci: C-B -> Cursor left.
    • ci: C-F -> Cursor right.
    • ci: C-A -> To the first character of the screen line.
    • ci: C-E -> To the last character of the screen line.
    • i: C-K -> Kill text until the end of the line.
    • cin: M-b -> Cursor one word left.
    • cin: M-f -> Cursor one word right.
    • i: M-d -> Kill text until the end of the word.
    • in: M-x -> Command-line mode.
  • Leader

    leader is mapped to SPACE.

    • leader-b- -> Buffer.
      • n: b -> bufferline.nvim, BufferPick.
      • n: c -> Set directory to the current buffer.
      • n: d -> Delete buffer.
      • n: g -> Toggle background.
      • n: h -> Stop the search highlighting.
      • n: n -> Next buffer.
      • n: p -> Previous buffer.
    • leader-c- -> Check.
      • nv: c -> Chinese characters count.
      • n: s -> Toggle spell check.
    • leader-d- -> Debug.
      • n: b -> nvim-dap, toggle break point.
      • n: c -> nvim-dap, clear break point.
      • n: l -> nvim-dap, run last.
      • n: n -> nvim-dap-ui, toggle dap-ui.
      • n: r -> nvim-dap, toggle REPL window.
      • n: t -> nvim-dap, terminate.
    • leader-e- -> Evaluate.
      • n: v -> Evaluate lua chunk surrounded by backquote.
      • n: l -> Evaluate lisp chunk(math) surrounded by backquote.
    • leader-f- -> Find.
      • n: b -> telescope.nvim, buffers.
      • n: f -> telescope.nvim, find_files.
      • n: g -> telescope.nvim, live_grep.
    • leader-g- -> Git.
      • n: b -> gitsigns.nvim, blame line.
      • n: n -> diffview.nvim, open diffview in tab.
      • n: h -> diffview.nvim, open diffview file history in tab.
      • n: j -> gitsigns.nvim, next hunk.
      • n: k -> gitsigns.nvim, previous hunk.
      • n: l -> toggleterm.nvim, open lazygit.
      • n: p -> gitsigns.nvim, preview hunk.
      • n: s -> Git status.
    • leader-h- -> Search cword/selection with ....
      • nv: b -> Baidu.
      • nv: d -> DuckDuckGo.
      • nv: g -> Google.
      • nv: h -> StarDict (requires local dictionary).
      • nv: y -> Youdao.
    • leader-j- -> Jieba.
      • n: m -> Toggle jieba-mode.
    • leader-k- -> Comment.
      • nv: c -> Comment current/selected line(s).
      • nv: u -> Uncomment current/selected line(s).
    • leader-l- -> LSP
      • n: 0 -> Document symbol.
      • n: a -> Code action.
      • n: d -> Jump to declaration.
      • n: f -> Jump to definition.
      • n: h -> Signature help.
      • n: i -> Implementation.
      • n: k -> Show diagnostics in a floating window.
      • n: m -> Format.
      • n: n -> Rename.
      • n: r -> References.
      • n: t -> Type definition.
      • n: w -> Work space symbol.
      • n: [ -> Jump to previous diagnostic mark.
      • n: ] -> Jump to next diagnostic mark.
    • leader-m- -> Markdown, Mail, Misc
      • n: f -> Fetch recently unseen mails from IMAP server.
      • n: l -> Regenerate list bullets.
      • n: n -> Create a new mail(.eml file).
      • n: s -> Send current buffer as an e-mail.
      • n: v -> aerial.nvim/VimTeX, Toc toggle.
      • n: t -> markdown-preview.nvim, toggle markdown preview; toggle marp preview (requires marp); LaTeX project pdf preview; toggle glsl preview (requires glslViewer).
      • n: i -> glslViewer input.
    • leader-n- -> GTD.
      • n: d -> Append the weekday after a date(yyyy-mm-dd).
      • n: s -> Insert timestamp after cursor.
      • n: t -> Print TODO list.
    • leader-o- -> Open.
      • n: b -> Open file of buffer with system default browser.
      • n: e -> Open system file manager.
      • n: t -> Open terminal.
      • n: p -> nvim-tree.lua, nvim-tree toggle.
      • n: u -> Open path or url under the cursor.
    • leader-s- -> Surrounding.
      • nv: a -> Surrounding add.
      • n: c -> Surrounding change.
      • n: d -> Surrounding delete.
    • leader-t- -> Table mode.
      • n: a -> vim-table-mode, Add formula.
      • n: c -> vim-table-mode, Evaluate formula.
      • n: f -> vim-table-mode, Re-align.
    • leader-v- -> Visual
      • n: s -> Show highlight information.
    • leader-w- -> Vimwiki.
    • leader-z- -> Misc.
      • v: bd -> Base64 decode selection.
      • v: be -> Base64 encode selection.
  • Miscellanea
    • v: */# -> Search for the visual selection.
    • n: F5 -> nvim-dap, continue debugging; presenting.vim, presenting view
    • n: S-F5 -> CodeRun.
    • n: C-S-F5 -> CodeRun test.
    • invt:F8 -> Toggle mouse status.
    • n: F10 -> nvim-dap, step over.
    • n: S-F11 -> nvim-dap, step into.
    • n: C-S-F11 -> nvim-dap, step out.

Commands

  • CodeRun -> Run or compile the code.
  • BuildDylibs -> Build crates in $config/rust/ directory.
  • GlslViewer -> Open glslViewer.
  • NvimUpgrade -> Upgrade neovim by channel input.
  • PushAll -> Just push everything to the remote origin.
    • -b -> branch (default: current branch).
    • -m -> commit (default: date).
    • -r -> remote (default: origin).
  • SshConfig -> Open and edit ~/.ssh/config
  • Time -> Print date and time.

Packages

API

collections

futures

utility

About

Configuration for Neovim with some personal hacks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages