Code Monkey home page Code Monkey logo

lin.vim's Introduction

lin.vim : Lin Rongbin's (Neo)vim Distribution

lin.vim is a highly configured vim/neovim distribution integrated tons of utilities for development, inspired by spf13-vim.

Table of Contents

Introduction

Aim to be out of box, IDE-like editing experience, high performance, light weight and friendly to most users. Focus on and only on editing, no compile/package/debug.

Solve below issues:

  • Time-costing study and configure vim scripts - All behaviors configured follow vim community's best practice or most popular modern editors(just like vscode).
  • Lack of programming language support or IDE-like features - coc.nvim and a set of plugins are installed, with a bunch of language servers embeded.
  • Don't know how to install/choose/configure plugins: All plugins are selected carefully and well cooperated with each other. Provide best performance and user experience, cover most modern editor features(again, just like vscode).
  • Time-costing repeat installation on different machines and OS - All done by one-line command (not on Windows for now), all behaviors are the same(the only difference is use cmd-key on macOS instead of alt-key on Windows/Linux).
  • Naive UI-looking and lack of icons/colorschemes - Pretty colorschemes, icons, opened tabs, file explorer, file status integrated.
  • Special customization - Open and edit ~/.vimrc ~/.vim/plugin.vim ~/.vim/setting.vim, or add a new language server with coc configuration ~/.vim/coc-settings.json.

Screenshots

Simple but pretty UI

edit-markdown.png

Code complete for C++

cplusplus-code-complete.png

Fast cursor movement

fast-cursor-movement.png

Search text

search-text.png

Search files

search-files.png

Markdown preview

markdown-preview.png

Feature

  • One-line command installation (not on windows for now).
  • Work on multiple OS platforms:
    • Windows.
    • macOS.
    • Linux(Ubuntu/Debian/Fedora/Manjaro).
  • Support both vim and neovim, neovim 0.7+ is strongly recommended for best performance and experience.
  • Modern editor UI features:
    • File explorer.
    • Icons.
    • Color schemes (see Color Schemes - Reference) randomly selected on start.
    • Status line.
    • Tab line and buffer explorer.
    • Outline/Tags.
  • IDE-like editing features supported by coc.nvim, a bunch of language servers(see Embeded Language Servers) embeded by default:
    • Code complete.
    • Diagnostic.
    • Lint.
    • Code format.
    • Jump between symbols.
    • Code Actions.
    • Code Lens.
  • Search engine features supported by fzf.vim:
    • Text search on text/lines/tags/search-histories/command-histories/yank-histories.
    • File search on files/buffers/history-files.
    • Git search on commits/uncommit-changes.
    • Coc.nvim integrated search on symbols/outline/diagnostics/yank.
    • Other enhancement search on vim-marks/vim-key-mappings/vim-commands/help-tags.
  • Other editing enhancements (see Editing Enahncement).
  • Custom configuration.

Installation

Before installation, please make sure access of below domains are available:

UNIX/Linux/MacOS

install.sh will automatically install below softwares with system package managers:

For now supported platforms are:

  • Debian/ubuntu based linux: use apt as software installer.
  • Fedora/centos based linux: use dnf as software installer.
  • Archlinux based linux: use pacman as software installer.
  • MacOS: use brew as software installer, please install Xcode and homebrew as pre-requirements.

Other *NIX systems such as gentoo, bsd are not supported yet.

    $ git clone https://github.com/linrongbin16/lin.vim ~/.vim && cd ~/.vim && ./install.sh

Windows

The goal of installation on windows is to install native executable file, no WSL nor MYSY2 for below reasons:

  • Native executable file has better performance, WSL (actually a virtual machine) is quite slow and heavy.
  • Git for Windows already contains MYSY2 and provide Unix/Linux builtin commands, we could leverage that.
  1. Install Visual Studio with below 3 components checked:

    • .NET Desktop Development
    • Visual C++ Desktop Development (Desktop development with C++)
    • Common Windows Platform Development (Universal Windows Platform development)

install-windows-visual-studio.png

  1. Install 64-bit Git for Windows Setup with especially below 3 options checked:

    1. In the Select Components step, check Associate .sh files to be run with Bash.
    2. In the Adjusting your PATH environment step, choose Use Git and optional Unix tools from the Command Prompt.
    3. In the Configuring the terminal emulator to use with Git Bash step, choose Use Windows's default console window.

install-windows-git-step1.png install-windows-git-step2.png install-windows-git-step3.png

This will add both git.exe and linux builtin commands (such as bash.exe, cp.exe, mv.exe, cd.exe, ls.exe, etc) in $env:Path, turn command prompt and powershell to a linux-like shell, thus help (neo)vim plugins running correctly.

  1. Install other dependencies (x64 is preferred):

    • vim-win32-installer: add gvim.exe to $env:Path
    • neovim: add nvim.exe to $env:Path
    • cmake: add cmake.exe to $env:Path
    • make-for-win32: add make.exe to $env:Path
    • python3: since python3 installer don't provide python3.exe and pip3.exe, manually copy python.exe as python3.exe, copy pip.exe as pip3.exe, then add to $env:Path.
    • rust: add rustc.exe, cargo.exe to $env:Path
    • golang: add go.exe to $env:Path
    • nodejs: add node.exe, npm.exe to $env:Path
    • universal-ctags: add ctags.exe, readtags.exe to $env:Path

Use package manager (such as chocolatey and scoop) could be a better choice, just make sure they're available in $env:Path.

  1. Install Hack NF:

    • Hack Bold Nerd Font Complete Mono Windows Compatible.ttf
    • Hack Bold Italic Nerd Font Complete Mono Windows Compatible.ttf
    • Hack Italic Nerd Font Complete Mono Windows Compatible.ttf
    • Hack Regular Nerd Font Complete Mono Windows Compatible.ttf
  2. Finally run below commands in powershell:

    $ git clone https://github.com/linrongbin16/lin.vim $env:UserProfile\.vim
    $ cd $env:UserProfile\.vim
    $ .\install.ps1

Notice

  1. If you are using WSL, C:\Windows\System32\bash.exe could lead you to WSL instead of the bash.exe provided by Git for Windows. Make sure git environment path is ahead of C:\Windows\System32 (wsl.exe could connect to WSL as well, so no need to worry about losing bash.exe), so git bash will be first detected on $env:Path.

install-windows-notice-git-path.png

  1. Python3 version must be compatible with gvim's libpython3.so version, or it will not been loaded. Latest vim 8.2-9 is compiled with python3.10. Please use gvim --version to find its libpython3.so version.

install-windows-notice-python3-version-compatible.png

  1. Don't use old-version vim.exe provided by Git for Windows, use gvim.exe provided by vim-win32-installer. Or you could move gvim.exe environment path ahead of Git for Windows, this could make sure vim.exe from vim-win32-installer be first detected on $env:Path.

install-windows-notice-vim-path.png

  1. Disable Windows App alias python.exe or python3.exe, this could lead you to the wrong python provide by windows application store. Please see: Manage App Execution Aliases on Windows10 and Default app aliases in windows.

User Guide

In this section, vim editing mode are specified with:

  • ๐Ÿ„ฝ - Normal Mode
  • ๐Ÿ…… - Visual Mode
  • ๐Ÿ„ธ - Insert Mode

Vim key are specified with:

  • D - Meta-Key (Command-Key on macOS, Alt-Key on other os).

Hot Key

  • F1 ๐Ÿ„ฝ - toggle(open/close) file explorer, see Simple but pretty UI.
  • F2 ๐Ÿ„ฝ - toggle(open/close) undo tree.
  • F3 ๐Ÿ„ฝ - toggle(open/close) vista outline/tags, see Code complete for C++.
  • F4 ๐Ÿ„ฝ - switch between C/C++ header and source files.
  • F8 ๐Ÿ„ฝ - open markdown preview.
  • F9 ๐Ÿ„ฝ - change color theme randomly, see Screenshots.
  • F10/SHIFT-F10 ๐Ÿ„ฝ - open/close(toggle) opened buffers explorer.

You could configure these keys in ~/.vim/setting.vim.

UI

File Explorer

Navigation:

  • h ๐Ÿ„ฝ - collapse directory.
  • l ๐Ÿ„ฝ - open or expand directory.
  • <CR> ๐Ÿ„ฝ - open file or cd into directory.
  • <BS> ๐Ÿ„ฝ - leave directory and goto upper directory.
  • e ๐Ÿ„ฝ - open file in split.
  • E ๐Ÿ„ฝ - open file in vsplit.
  • t ๐Ÿ„ฝ - open file in new tab.

Create/Delete/Copy/Paste/Cut:

  • a/A ๐Ÿ„ฝ - create new file/directory.
  • m/r ๐Ÿ„ฝ - move/rename file/directory.
  • <C-c> ๐Ÿ„ฝ - copy file/directory into internal clipboard just like in Windows.
  • <C-x> ๐Ÿ„ฝ - cut file/directory into internal clipboard just like in Windows.
  • <C-v> ๐Ÿ„ฝ - paste internal clipboard file/directory to current directory just like in Windows.
  • d ๐Ÿ„ฝ - trash file/directory to system trash-bin, only works on Windows/macOS.
  • D ๐Ÿ„ฝ - force delete file/directory, possiblely implemented with rm.
  • R ๐Ÿ„ฝ - refresh file explorer.

Resize Width:

  • <D-Right>/<D-.> ๐Ÿ„ฝ - make explorer bigger.
  • <D-Left>/<D-,> ๐Ÿ„ฝ - make explorer smaller.

Others:

  • s ๐Ÿ„ฝ - open file in system file manager(such as Finder in macOS).
  • ? ๐Ÿ„ฝ - open/close(toggle) help.

For neovim 0.7+ only:

  • P ๐Ÿ„ฝ - preview file content.
  • I ๐Ÿ„ฝ - preview file info.
  • H ๐Ÿ„ฝ - toggle dotfiles hidden.
  • y ๐Ÿ„ฝ - copy file name string.
  • Y ๐Ÿ„ฝ - copy absolute file path string.

Support by fern.vim (switched to nvim-tree.lua on neovim 0.7+), you could use key mappings on the file explorer left side:

You could editing ~/.vim/setting/lambdalisue/fern.vim.vim (or ~/.vim/setting/kyazdani42/nvim-tree.lua.vim) to customize key mappings. Please refer to fern.vim - wiki - Mappings (or nvim-tree.lua - README) for more key mappings.

Buffers/Tabs

  • <leader><tab>/<D-Right>/<D-.> ๐Ÿ„ฝ - go to next buffer on the right.
  • <leader><s-tab>/<D-Left>/<D-,> ๐Ÿ„ฝ - go to previous buffer on the left(Notice some terminal/GUI could eat Alt+, Alt+. and Command+, Command+.).
  • <leader>bd ๐Ÿ„ฝ - close current buffer (and go to a nearest buffer) without closing vim window.
  • F10/SHIFT-F10 ๐Ÿ„ฝ - open/close(toggle) opened buffers explorer.

Meta-1 ~ Meta-9 (on macOS it's Command-Key, on others it's Alt-Key) are mapped to 1~9 buffers, Meta-0 are mapped to navigate to the last buffer.

  • <D-1> ๐Ÿ„ฝ - go to buffer-1.
  • <D-2> ๐Ÿ„ฝ - go to buffer-2.
  • <D-3> ๐Ÿ„ฝ - go to buffer-3.
  • <D-4> ๐Ÿ„ฝ - go to buffer-4.
  • <D-5> ๐Ÿ„ฝ - go to buffer-5.
  • <D-6> ๐Ÿ„ฝ - go to buffer-6.
  • <D-7> ๐Ÿ„ฝ - go to buffer-7.
  • <D-8> ๐Ÿ„ฝ - go to buffer-8.
  • <D-9> ๐Ÿ„ฝ - go to buffer-9.
  • <D-0> ๐Ÿ„ฝ - go to the last buffer.

For neovim 0.5+ only:

  • <D-S-Right> ๐Ÿ„ฝ - move current buffer to next position(right side).
  • <D-S-Left> ๐Ÿ„ฝ - move current buffer to previous position(left side).
  • <LeftMouse> ๐Ÿ„ฝ - go to target buffer.
  • <MiddleMouse> ๐Ÿ„ฝ - close target buffer.

Support by vim-buffet(switched to barbar.nvim on neovim 0.5+).

Font

lin.vim use Hack Nerd Font by default. Please manually install other nerd fonts and configure in ~/.vim/setting.vim for other options.

IDE-like Editing

Code Complete

  • <c-n>/<down> ๐Ÿ„ธ - navigate to next suggestion.
  • <c-p>/<up> ๐Ÿ„ธ - navigate to previous suggestion.
  • <tab>/<cr> ๐Ÿ„ธ - confirm current suggestion or snippet.
  • <esc>/<c-[> ๐Ÿ„ธ - close suggestion.
  • <c-f> ๐Ÿ„ธ - jump to next snippet position.
  • <c-b> ๐Ÿ„ธ - jump to previous snippet position.
  • <c-k> ๐Ÿ„ธ - force trigger suggestion.

Jumps

  • [d ๐Ÿ„ฝ - go to previous diagnostic location.
  • ]d ๐Ÿ„ฝ - go to next diagnostic location.
  • gd ๐Ÿ„ฝ - go to definition.
  • gy ๐Ÿ„ฝ - go to type(function) definition.
  • gi ๐Ÿ„ฝ - go to implemention.
  • gr ๐Ÿ„ฝ - go to references.

Symbols

  • K ๐Ÿ„ฝ - show hover(symbol definition).
  • <leader>rs ๐Ÿ„ฝ - rename symbol.

Code Format

  • <leader>cf ๐Ÿ„ฝ๐Ÿ…… - format code on current buffer or visual-selected code.

Code Actions

  • <leader>ca ๐Ÿ„ฝ๐Ÿ…… - run code actions on current cursor position or visual-selected code.
  • <leader>qf ๐Ÿ„ฝ - apply quick fix on current line.

Code Lens

  • <leader>cl ๐Ÿ„ฝ - run code lens on current line.

Git

  • ]c ๐Ÿ„ฝ - go to next git chunk in current buffer.
  • [c ๐Ÿ„ฝ - go to previous git chunk in current buffer.
  • <leader>gs ๐Ÿ„ฝ - show git chunk info on current line.
  • <leader>gc ๐Ÿ„ฝ - show git commit info on current line.

For neovim 0.5+ only:

  • <leader>gb ๐Ÿ„ฝ - toggle git blame info on current line.

Search

Search engine use fzf.vim and integrated with coc.nvim with coc-fzf, all fzf commands are configured with prefix Fzf, for example :Files are renamed to :FzfFiles, :Rg are renamed to :FzfRg.

Text Search

  • <space>gr ๐Ÿ„ฝ - search text by :FzfRg.
  • <space>l ๐Ÿ„ฝ - search lines on opened buffers by :FzfLines.
  • <space>t ๐Ÿ„ฝ - search tags by :FzfTags.
  • <space>y ๐Ÿ„ฝ - search yank history by :CocFzfList yank.
  • <space>sh ๐Ÿ„ฝ - search search history by :FzfHistory/.
  • <space>ch ๐Ÿ„ฝ - search vim command history by :FzfHistory:.

File Search

  • <space>f/<c-p> ๐Ÿ„ฝ - search files by :FzfFiles.
  • <space>b ๐Ÿ„ฝ - search opened buffers by :FzfBuffers.
  • <space>hf ๐Ÿ„ฝ - search history files (v:oldfiles) and opened buffers by :FzfHistory.

Git Search

  • <space>gc ๐Ÿ„ฝ - search git commits by :FzfCommits.
  • <space>gf ๐Ÿ„ฝ - search git files rby :FzfGFile.
  • <space>gs ๐Ÿ„ฝ - search git status(also diff files by preview) by :FzfGFiles?.

Other Search

  • <space>mk ๐Ÿ„ฝ - search marks by :FzfMarks.
  • <space>mp ๐Ÿ„ฝ - search normal mode vim key mappings by :FzfMaps.
  • <space>vc ๐Ÿ„ฝ - search vim commands by :FzfCommands.
  • <space>ht ๐Ÿ„ฝ - search help tags by :FzfHelptags.

Coc.nvim Search

Key mappings are configured with prefix char c after <space>.

  • <space>cs ๐Ÿ„ฝ - search symbols by :CocFzfList symbols.
  • <space>cd ๐Ÿ„ฝ - search diagnostics by :CocFzfList diagnostics.
  • <space>co ๐Ÿ„ฝ - search outline/tags by :CocFzfList outline.
  • <space>cc ๐Ÿ„ฝ - search commands by :CocFzfList commands.
  • <space>cl ๐Ÿ„ฝ - search location by :CocFzfList location.

Please visit fzf.vim and coc-fzf for more information.

Editing Enhancement

Enhanced Copy Paste

when you want copy/paste between different vim instances. Use enhanced copy-paste to stored text content in a file cache:

  • <leader>y ๐Ÿ…… - copy visual-selected text to ~/.vim/.enhanced-copy-paste-cache.
  • <leader>p ๐Ÿ„ฝ - paste text saved from ~/.vim/.enhanced-copy-paste-cache.

You could configure these key mappings in ~/.vim/setting/linrongbin16/enhanced-copy-paste.vim.

Fast Cursor Movement

See Fast cursor movement.

  • <leader>f{char} ๐Ÿ„ฝ - move to a single {char}.
  • <leader>s{char}{char} ๐Ÿ„ฝ - move to consequent two {char}{char}.
  • <leader>w ๐Ÿ„ฝ - move to word.
  • <leader>l ๐Ÿ„ฝ - move to line.

Support by vim-easymotion(switched to hop.nvim on neovim 0.5+).

Word Movement

Better word movement enhancement.

  • W ๐Ÿ„ฝ - move forward to a single word.
  • B ๐Ÿ„ฝ - move backward to a single word.
  • E ๐Ÿ„ฝ - move forward to the end of a single word.
  • gE ๐Ÿ„ฝ - move backward to the end of a single word.

Support by vim-wordmotion.

Fast Repeat

Enhancement for . operation.

Support by vim-repeat.

Fast Quotes Operation

Enhancement for add/remove quotes operation.

Support by vim-surround

Match Brackets and HTML Tags

Enhancement for brackets(pairs) and html tags.

Support by vim-matchup.

Auto Close Brackets and HTML Tags

Enhancement for auto close brackets(pairs) and html tags.

Support by auto-pairs (switched to nvim-autopairs on neovim 0.5+) and vim-closetag.

Easy Comment

Normal mode:

  • gcc ๐Ÿ„ฝ - toggle current line using linewise comment.
  • gc{motion} ๐Ÿ„ฝ - toggle from current line with motion (jkhl) using linewise comment.
  • gc<Count>{motion} ๐Ÿ„ฝ - toggle from current line with motion repeat times using linewise comment.

Virual Mode:

  • gc ๐Ÿ…… - toggle visual-selected code using linewise comment.

Support by tcomment_vim (switched to Comment.nvim on neovim).

Customization

Please add plugins in ~/.vim/plugin.vim, add settings in ~/.vim/setting.vim and ~/.vim/coc-settings.json.

Embeded Language Servers

These language servers are installed by default:

  • c/c++
  • python3 (python2 is not supported)
  • rust
  • go
  • html/xml/markdown
  • css/sass/scss/less
  • json
  • javascript/typescript/jsx/tsx

Reference

Contribute

Please open issue/PR for anything about lin.vim.

Like lin.vim? Consider

Buy Me A Coffee

Or

wechat-pay.jpeg ย  ย  ย  ย  alipay.jpeg

lin.vim's People

Contributors

linrongbin16 avatar lokiiart avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.