vim 8 advance configuration
The ddc | deoplete GitHub
ddc github repo
deoplete github repo
vim 使用筆記
目的:
- Linux環境設定通用性的vim環境
- 可參考的介紹 vim 的使用
The vim-plug for vim-8
Pros.
- Easy to set up: Single file. No boilerplate code required.
- Easy to use: Concise, intuitive syntax
- Super-fast parallel installation/update (with any of +job, +python, +python3, +ruby, or Neovim)
- Creates shallow clones to minimize disk space usage and download time
- On-demand loading for faster startup time
- Can review and rollback updates
- Branch/tag/commit support
- Post-update hooks
- Support for externally managed plugins
Install vim-plug for vim
https://github.com/junegunn/vim-plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
VIM-Plug Usage
Add a vim-plug section to your ~/.vimrc (or stdpath('config') . '/init.vim' for Neovim)
Begin the section with call plug#begin([PLUGIN_DIR])call plug#begin('~/.vim/plugged')
List the plugins with Plug commands
call plug#end() to update &runtimepath and initialize plugin system
Automatically executes filetype plugin indent on and syntax enable. You can revert the settings after the call. e.g. filetype indent off, syntax off, etc.
My define vimrc file
set encoding=utf8
set pyxversion=3
" Switch buffer
nnoremap <C-j> :bprevious<CR>
nnoremap <C-k> :bnext<CR>
set hidden
" Switch TabPage
nnoremap <C-h> :tabprevious<CR>
nnoremap <C-l> :tabnext<CR>
" 在插件管理器中,比如vim-plug中,加入如下:
call plug#begin('~/vim/plugged')
" Plug 'rust-lang/rls'
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'prabirshrestha/vim-lsp'
let g:deoplete#enable_at_startup = 1
call plug#end()
let g:LanguageClient_serverCommands = {
\ 'rut': ['rust-analyzer'],
\ }
if executable('rust-analyzer')
au User lsp_setup call lsp#register_server({
\ 'name': 'Rust Language Server',
\ 'cmd': {server_info->['rust-analyzer']},
\ 'whitelist': ['rust'],
\ 'initialization_options': {
\ 'cargo': {
\ 'buildScripts': {
\ 'enable': v:true,
\ },
\ },
\ 'procMacro': {
\ 'enable': v:true,
\ },
\ },
\ })
endif
" deoplete configuration
let g:deoplete#enable_ignore_case=1
call deoplete#custom#option({
\ 'auto_complete_delay': 500,
\ 'smart_case': v:true,
\ })
How to open files in tab page
Opening and closing tabs
When starting Vim, the -p option opens each specified file in a separate tab (up to the value of the 'tabpagemax' option). Examples:
vim -p first.txt second.txt
gvim -p *.txt
Once Vim has been launched, there are many commands that directly create or close tabs:
:tabedit {file} edit specified file in a new tab
:tabfind {file} open a new tab with filename given, searching the 'path' to find it
:tabnew {file} open a new tab with filename
:tabclose close current tab
:tabclose {i} close i-th tab
:tabonly close all other tabs (show only the current tab)
The :tabfind command uses Vim's 'path' option to determine which directories should be searched when opening the specified file. For example, the following tells Vim to look in the directory containing the current file (.), then the current directory (empty text between two commas), then each directory under the current directory ('**').
:set path=.,,**
Remember, as with any Vim commands, you only need type enough characters in the command for Vim to be able to unambiguously identify it. For example, you could use :tabe and :tabf instead of :tabedit and :tabfind.
In addition to these commands, because Vim already has a plethora of commands for working with split windows, Vim provides the :tab command-line modifier, to use a new tab instead of a new window for commands that would normally split a window. For example:
:tab ball show each buffer in a tab (up to 'tabpagemax' tabs)
:tab help open a new help window in its own tab page
:tab drop {file} open {file} in a new tab, or jump to a window/tab containing the file if there is one
:tab split copy the current window to a new tab of its own
A command like :sp myfile.txt creates a new window in the current tab editing the specified file. That window can be moved to a new tab by pressing Ctrl-W T, and can be copied to a new tab with the command :tab sp (split the current window, but open the split in a new tab).
You can type Ctrl-W c to close the current window. If that window is the last window visible in a tab, the tab is also closed (if another tab page is currently open).
If the file you are editing contains the name of another file, you can put the cursor on the name and type gf to edit the file (goto file). If you type Ctrl-W gf the file is displayed in a new tab.
In gvim, you can right click the tab label bar for a popup menu with Close, New Tab, and Open Tab... items.
Navigation
:tabs list all tabs including their displayed windows
:tabm 0 move current tab to first
:tabm move current tab to last
:tabm {i} move current tab to position i+1
:tabm +{i} move current tab right to current position+i
:tabm -{i} move current tab left to current position-i
:tabn go to next tab
:tabp go to previous tab
:tabfirst go to first tab
:tablast go to last tab
In normal mode, you can type:
gt go to next tab
gT go to previous tab
{i}gt go to tab in position i
Advance option for development
rust auto-completion pluggin
Rust auto-completion source for Rust via Racer, but no supported New Rust langange server support
vim-lsp vim-lsp is installed by following the plugin instructions. It can be as simple as adding this line to your .vimrc:
''' Plug 'prabirshrestha/vim-lsp' ''' Next you need to register the rust-analyzer binary. If it is available in $PATH, you may want to add this to your .vimrc:
There is no dedicated UI for the server configuration, so you would need to send any options as a value of the initialization_options field, as described in the Configuration section. Here is an example of how to enable the proc-macro support:
if executable('rust-analyzer')
au User lsp_setup call lsp#register_server({
\ 'name': 'Rust Language Server',
\ 'cmd': {server_info->['rust-analyzer']},
\ 'whitelist': ['rust'],
\ 'initialization_options': {
\ 'cargo': {
\ 'buildScripts': {
\ 'enable': v:true,
\ },
\ },
\ 'procMacro': {
\ 'enable': v:true,
\ },
\ },
\ })
endif
Ghost CMS theme project edit
mustache and handlebars mode for vim
vim plugin for working with mustache and handlebars templates. It has: syntax highlighting
matchit support
mustache abbreviations (optional)
section movement mappings [[ and ]]
text objects ie (inside element) and ae (around element)
This plugin contributes to vim-polyglot language pack.
The Ghost CMS blog add table of contents