Skip to content

Instantly share code, notes, and snippets.

@AlanJui
Last active February 5, 2021 07:45
Show Gist options
  • Select an option

  • Save AlanJui/da7a80c0604da133cab5d7e7cd09d77e to your computer and use it in GitHub Desktop.

Select an option

Save AlanJui/da7a80c0604da133cab5d7e7cd09d77e to your computer and use it in GitHub Desktop.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Alan Jui : alanjui.1960@gmail.com
"
" Version:
" V 0.4.0 2019/07/01 00:14
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"==============================================================
" Vim 附加套件
"
" 暫停附加套件:
"
" Plug 'foo/bar', { 'on': [] }
"==============================================================
call plug#begin('~/.local/share/nvim/plugged')
"--------------------------------------------------------------
" 使用者操作介面
" Color Scheme
Plug 'morhetz/gruvbox'
Plug 'joshdick/onedark.vim'
Plug 'dracula/vim', { 'commit': '147f389f4275cec4ef43ebc25e2011c57b45cc00' }
Plug 'chriskempson/tomorrow-theme', { 'rtp': 'vim' }
" Color Scheme for syntax
Plug 'sheerun/vim-polyglot'
" Status Bar
Plug 'vim-airline/vim-airline'
" Switch vim-airlinetheme
Plug 'vim-airline/vim-airline-themes'
" Add file type glyphs/icons to popular Vim plugins: NERDTree, vim-airline
Plug 'ryanoasis/vim-devicons'
"--------------------------------------------------------------
" 檔案操作
" MRU: Most Recently Used
Plug 'vim-scripts/mru.vim'
" File managing and exploration
Plug 'scrooloose/nerdtree'
" Want to use tabs
Plug 'jistr/vim-nerdtree-tabs'
" Plugin for NERDTree showing git status flags
Plug 'xuyuanp/nerdtree-git-plugin'
" Code jump: jump to definition of class and method
Plug 'davidhalter/jedi-vim'
" 模糊化檔案搜尋
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
"--------------------------------------------------------------
" 視覺導引
" Code folding
Plug 'tmhedberg/SimpylFold'
" Displaying thin vertical lines
Plug 'Yggdroot/indentLine'
"--------------------------------------------------------------
" 語法檢查(Syntax Check)
" Check syntax (linting) and fix files asynchronously, with Language
" Server Protocol (LSP) integration in Vim
Plug 'w0rp/ale'
"--------------------------------------------------------------
" 自動完成(Autocomplete)
" Automatic quote and bracket completion
Plug 'jiangmiao/auto-pairs'
" " A set of mappings for HTML, XML, PHP, ASP, eRuby, JSP, and more
" Plug 'tpope/vim-ragtag'
" NCM2 (nvim-completion-manager v2) is a fast, extensible, async completion
" framework for neovim.
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
" NOTE: you need to install completion sources to get completions. Check
" our wiki page for a list of sources: https://github.com/ncm2/ncm2/wiki
" Gerenal purpose
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
" Syntax
Plug 'ncm2/ncm2-syntax' | Plug 'Shougo/neco-syntax'
" Web Development
Plug 'ncm2/ncm2-html-subscope'
Plug 'ncm2/ncm2-tagprefix'
" Plug 'ncm2/ncm2-markdown-subscope'
" Python completion for ncm2 via the great jedi library.
Plug 'ncm2/ncm2-jedi'
" Neosnippet integration for ncm2.
" - snippet completion source
" - trigger dynamic snippet of completed item, e.g. parameter expansion.
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'ncm2/ncm2-neosnippet'
" Emmet for vim
Plug 'mattn/emmet-vim'
" Snippets
"--------------------------------------------------------------
" 程式排版
" Code auto-format
Plug 'Chiel92/vim-autoformat'
Plug 'google/yapf'
"--------------------------------------------------------------
" 程式編輯
" Comment code
Plug 'scrooloose/nerdcommenter'
" Multiple cursor editting
Plug 'terryma/vim-multiple-cursors'
" Auto-pairs
Plug 'tpope/vim-surround'
"--------------------------------------------------------------
" 其它
" 終端機
Plug 'sollidsnake/vterm'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim 設定
" 使用者可客製化
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"==============================================================
" 通用設定
"==============================================================
"--------------------------------------------------------------
" 作業系統層級設定
" Python for NeoVim (PyNvim)
let g:python3_host_prog='/Users/alanjui/.pyenv/versions/neovim3/bin/python'
" 與作業系統共用 Clipboard
" 欲將系統剪貼簿的內容貼入 Vim 前,需先按 <F2> 鍵。
set clipboard=unnamed
set undolevels=700
" no temp or backup files
set noswapfile
set nobackup
set nowritebackup
"--------------------------------------------------------------
" 應用系統層級設定
set nocompatible " Disable compatibility to old-time vi
set encoding=UTF-8
set backspace=2
"set backspace=indent,start,eol
set mouse=a
set hidden
set noshowmode
set showmatch " Show matching brackets.
set nolazyredraw
set showcmd
" 倒刪鍵不刪 EOL
" 標示多餘空白【務必放在 ColorScheme 設定之前】
"autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
"autocmd InsertLeave * match ExtraWhitespace /\s\+$/
" 設定 Leader 鍵
let mapleader = ","
set timeout timeoutlen=1500
" 進入「貼上(Paste)」模式
set pastetoggle=<F2>
" 滑䑕指標可切換 tab
" 離開插入模式,回返一般模式
imap II <Esc>
imap jj <Esc>
imap <silent> <leader><leader> <C-O>l,
" 退出
noremap <Leader>e :quit<CR> " Quit current window
noremap <Leader>E :qa!<CR> " Quit all windows
"--------------------------------------------------------------
" 檔案作業
" 停用 backup 與 swap 功能
set nobackup
set nowritebackup
set noswapfile
" 儲存檔案
nmap <Leader>w :update<CR>
imap <Leader>w <C-O>:update<CR>
vmap <Leader>w <C-C>:update<CR>
" 設定檔作業
" 編輯設定檔
nmap <leader>i :tabnew ~/.config/nvim/init.vim<CR>
" 依據設定檔重啟設定
nmap <leader>I :source ~/.config/nvim/init.vim<CR>
"==============================================================
" 操作介面
"==============================================================
"--------------------------------------------------------------
" 佈景、配色與字體
" gruvbox: Vim color scheme
colorscheme gruvbox
set background=dark
" one-dark
let g:lightline = {
\ 'colorscheme': 'onedark',
\ }
" 檔案內容,以「紀錄檔」配色顯示
nmap <leader>l :set filetype=journal<CR>
"--------------------------------------------------------------
" 圖示 DevIcons
set guifont=DroidSansMono\ Nerd\ Font:h16
"let g:airline_powerline_fonts=1
"--------------------------------------------------------------
" 狀態列: Airline & AirlineTheme
"let g:airline_powerline_fonts = 1
"set guifont=DejaVuSansMono\ Nerd\ Font:h16
"set guifont=DejaVu\ Sans\ Mono\ Nerd\ Font\ Complete:h16
set guifont=Hack\ Nerd\ Font\:h16
let g:airline_theme='luna'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'default'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.dirty= '⚡'
"--------------------------------------------------------------
" 視窗管理
set splitbelow " 水平切割時,在下產生新視窗
set splitright " 垂直切割時,在右產生新視窗
" 切割視窗指令:
" - 水平切割: :sp ==> :10sp [FileName]10+
" - 垂直切割: :vsp ==> :vsp [FileName]
"<C-w>_ :視窗高度最大化(適用於水平切割視窗)
"<C-w>| :視窗寬度最大化(適用於垂直切割視窗)
"<C-w>= :視窗寬高平均化(適用於任何切割視窗)
" <C-w>r: Swap top/bottom or left/right splitjj
" <C-w>t: Break out current window into a new tabview
" <C-w>o: Close every window in the current tabview but the current one
"map <c-j> <c-w>j
"map <c-k> <c-w>k
"map <c-l> <c-w>l
"map <c-h> <c-w>h
" 在 Tab 視窗移動
map <Leader>p <esc>:tabprevious<CR>
map <Leader>n <esc>:tabnext<CR>
"==============================================================
" 程式碼排版
"==============================================================
" 令程式碼檔案可有語法(Syntax)高亮標示
filetype off
filetype plugin indent on
syntax on
" 程式碼排版規範
set colorcolumn=80 " 設定每行能放 80 個字元
set nowrap " 不用依據 colorcolumn 的規範,在自動換行
set autoindent " indent a new line the same amount as the line just typed
" 行號顯示
set nu " 顯示行號
set relativenumber " 在遊標所在處顯示相對行號
set cursorline
" Tabs and spaces handling
set tabstop=4
set shiftwidth=4
set softtabstop=4
set shiftround
set expandtab
" 設定〔行號〕顯示模式
map <leader>nr :set relativenumber<CR>
map <leader>nn :set norelativenumber<CR>
" 文字搜尋:Serach configuration
set ignorecase " 搜尋時怱略英文字母的大小寫
set smartcase " turn on smartcase
set incsearch
set hlsearch " highlight search results
" 清除搜尋完後的醒目提示
noremap <F12> :nohl<CR>
vnoremap <F12> :nohl<CR>
inoremap <F12> :nohl<CR>
"--------------------------------------------------------------
" 遊標操作
" 合併兩行
nmap <leader>j :join!<CR>
imap <leader>j <Esc>:join<CR>
" 在一般模式,置入空白行:
" (1) 在遊標上一行,插入空白行
nmap <leader>O O<Esc>
" (2) 在遊標下一行,插入空白行
nmap <leader>o o<Esc>
"--------------------------------------------------------------
" Python
" 內縮格式
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
" 排版格式:PEP-008
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |
\ let b:comment_leader='#'
" 自動去除不必要的空白
highlight BadWhitespace ctermbg=red guibg=darkred
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /^\t\+/
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
"--------------------------------------------------------------
" Web
" 內縮格式
autocmd FileType javascript setlocal ts=2 sts=2 sw=2
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType xml setlocal shiftwidth=2 tabstop=2 softtabstop=2
" 排版格式
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2
" 註解格式
au BufNewFile,BufRead *.js let b:comment_leader='//'
au BufNewFile,BufRead *.html let b:comment_leader='<!--'
au BufNewFile,BufRead *.css let b:comment_leader='/*'
"--------------------------------------------------------------
" Django
autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType htmldjango inoremap {{ {{ }}<left><left><left>
autocmd FileType htmldjango inoremap {% {% %}<left><left><left>
autocmd FileType htmldjango inoremap {# {# #}<left><left><left>
" 判別是否適用 htmldjango 檔案格式
augroup filetypedetect
" removes current htmldjango detection located at $VIMRUNTIME/filetype.vim
au! BufNewFile,BufRead *.html
au BufNewFile,BufRead *.html call FThtml()
func! FThtml()
let n = 1
while n < 10 && n < line("$")
if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml
return
endif
if getline(n) =~ '{%\|{{\|{#'
setf htmldjango
return
endif
let n = n + 1
endwhile
setf html
endfunc
augroup END
"--------------------------------------------------------------
" 程式碼重新排版: chiel92/vim-autoformat
"
" let g:autoformat_verbosemode=1
au BufWrite *.py :Autoformat
noremap <F3> :Autoformat<CR>
"--------------------------------------------------------------
" 程式碼開展與折疊操作:SimplyFold
"
" - zo: Open fold in current cursor postion
" - zO: Open fold and sub-fold in current cursor postion recursively
" - zc: Close the fold in current cursor position
" - zC: Close the fold and sub-fold in current cursor position recursively
" Set the default to unfolded when a file is opened
set foldmethod=indent
set foldlevel=99
autocmd BufRead * normal zR
" Preview docstring in fold textd
let g:SimpylFold_docstring_preview = 0
" Fold docstrings 1
let g:SimpylFold_fold_docstring = 0
" Fold docstrings (buffer local) 1
let b:SimpylFold_fold_docstring = 0
" Fold imports 1
let g:SimpylFold_fold_import = 0
" Fold imports (buffer local) 1
let b:SimpylFold_fold_import = 0
nmap <space> za
"==============================================================
" 檔案瀏覽、尋找等操作
"==============================================================
"--------------------------------------------------------------
" 列示最近有過用的檔案(MRU: Most Recently Used)
" :MRU
"--------------------------------------------------------------
" 列示所有檔案
nmap <leader>f :Files<CR>
"--------------------------------------------------------------
" 瀏覽目錄與檔案: NERDTree
" - To open file navigation window: [:NERDTree]
" - To open a file in the file explorer to the right window: <o>
" - To switch between file window and nerdtree file navigation window:
" <Ctrl+w><Ctrl+w>; <Ctrl+w><L>
" - To exit or close file explorer window: <q>; [:NERDTreeClose]
" o: 在已有窗口中打開文件、目錄或書籤,並跳到該窗口
" go: 在已有窗口 中打開文件、目錄或書籤,但不跳到該窗口
" t: 在新 Tab 中打開選中文件/書籤,並跳到新 Tab
" T: 在新 Tab 中打開選中文件/書籤,但不跳到新 Tab
" i: split 一個新窗口打開選中文件,並跳到該窗口
" gi: split 一個新窗口打開選中文件,但不跳到該窗口
" s: vsplit 一個新窗口打開選中文件,並跳到該窗口
" gs: vsplit 一個新 窗口打開選中文件,但不跳到該窗口
" !: 執行當前文件
" O: 遞歸打開選中 結點下的所有目錄
" m: 文件操作:複製、刪除、移動等
" 自動展開
"autocmd vimenter * NERDTree
" 啟動 Vim 時,未指定檔案,則自動展開
autocmd vimenter * if !argc() |NERDTree | endif
" NERDTree 若為僅存之唯一視窗,則自動關閉
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" 要顯示隱藏文件
let g:NERDTreeHidden=1
" 需過濾,不用顯示之目錄及檔案
let NERDTreeIgnore = [
\ '\.pyc$',
\ '\~$',
\ '\.vscode',
\ '__pycache__',
\ 'node_modules',
\ ]
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" 目錄與檔案瀏覽
nmap <leader>q :NERDTreeToggle<CR>
nmap \ <leader>q
"--------------------------------------------------------------
" 標示 Git 檔案狀態:nerdtree-git
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
let g:NERDTreeShowIgnoredStatus=1
"==============================================================
" 文字與程式編輯
"==============================================================
"--------------------------------------------------------------
" 輸入自動配對:jiangmiao/auto-pairs
let g:AutoPairsFlyMode = 1
let g:AutoPairsShortcutBackInsert = '<M-b>'
let g:AutoPairs = {
\'(':')',
\'[':']',
\'{':'}',
\"'":"'",
\'"':'"',
\"`":"`",
\'```':'```',
\'"""':'"""',
\"'''":"'''"
\}
autocmd FileType html let b:AutoPairs = AutoPairsDefine({'{%' : '%}'})
"--------------------------------------------------------------
" 多遊標操作:vim-multiple-cursors => Multiple cursor editting
"
" In normal mode...
" - move the cursor to a variable, press <Ctrl+n>, <c>
" - want to skip a certain occurance: <Ctrl+x>
"--------------------------------------------------------------
" Snippets: vim-snippets
" SnipMate
let g:UltiSnipsExpandTrigger = "<c-j>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-p>"
let g:UltiSnipsListSnippets = "<c-k>" "List possible snippets based on current file
"--------------------------------------------------------------
" Tag 快速輸入:Emmet
"let g:user_emmet_install_global=0
"autocmd FileType html,css EmmetInstall
"let g:user_emmet_leader_key='C-Y'
" Selet mode can enable Emmet
" let g:user_emmet_mode='n' "only enable normal mode functions.
" let g:user_emmet_mode='inv' "enable all functions, which is equal to
" let g:user_emmet_mode='a' "enable all function in all mode.
" Enable just for html/css
"let g:user_emmet_install_global = 0
"autocmd FileType html,css EmmetInstall
" To remap the default <C-Y> leader:
let g:user_emmet_leader_key = ','
"--------------------------------------------------------------
" 程式碼語法檢查:Ale
let g:ale_lint_on_enter = 0
let g:ale_lint_on_text_changed = 'never'
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_linters = {'python': ['flake8']}
" "--------------------------------------------------------------
" " 程式碼輸入提示:NCM2
"
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" IMPORTANT: :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
" augroup NCM2
" autocmd!
" " enable ncm2 for all buffers
" autocmd BufEnter * call ncm2#enable_for_buffer()
" " :help Ncm2PopupOpen for more information
" set completeopt=noinsert,menuone,noselect
" " When the <Enter> key is pressed while the popup menu is visible, it only
" " hides the menu. Use this mapping to close the menu and also start a new line.
" inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
"
" " Use <TAB> to select the popup menu:
" inoremap <expr> <Tab> pumvisible() ? "\<C-N>" : "\<Tab>"
" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
"
" " wrap existing omnifunc
" " Note that omnifunc does not run in background and may probably block the
" " editor. If you don't want to be blocked by omnifunc too often, you could
" " add 180ms delay before the omni wrapper:
" " 'on_complete': ['ncm2#on_complete#delay', 180,
" " \ 'ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
" au User Ncm2Plugin call ncm2#register_source({
" \ 'name' : 'css',
" \ 'priority': 9,
" \ 'subscope_enable': 1,
" \ 'scope': ['css','scss'],
" \ 'mark': 'css',
" \ 'word_pattern': '[\w\-]+',
" \ 'complete_pattern': ':\s*',
" \ 'on_complete': ['ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
" \ })
" augroup END
" shougo/neosnippet
let g:deoplete#enable_at_startup = 1
" " <C-k> to select-and-expand a snippet from the deoplete popup
" " (Use <C-n> and <C-p> to select it). <C-k> can also be used to jump
" " to the next field in the snippet.
" "
" " <Tab> to select the next field to fill in the snippet.
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <expr><TAB>
\ pumvisible() ? "\<C-n>" :
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" " For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
"
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
"let g:neosnippet#snippets_directory='~/.vim/vim-addons/vim-snippets/snippets'
let g:neosnippet#snippets_directory='~/.local/share/nvim/snippets'
" ncm2-neosnippet
" " Press enter key to trigger snippet expansion
" " The parameters are the same as `:help feedkeys()`
"inoremap <silent> <expr> <CR> ncm2_neosnippet#expand_or("\<CR>", 'n')
"--------------------------------------------------------------
" 註解標示:scrooloose/nerdcommenter
" nerdcommenter: Comment code
" https://vimawesome.com/plugin/nerdcommenter-may-fear-less
"
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
"let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
" (1) Comment out the current line or text selected in visual mode.
" : [count]<leader>cc
"nmap <leader>cc :NERDCommenterComment<CR>
" (2) Uncomments the selected line(s). ==> [count]<leader>cu
"nmap <leader>cu :NERDCommenterUncomment<CR>
"==============================================================
" 軟體開發輔助工具
"==============================================================
"--------------------------------------------------------------
" 終端機操作:Builtin terminal
"
" - Open terminal: [:terminal]
" - Open new v-window for terminal: [:vnew term://zsh]
" - Open new h-window for terminal: [:new term://zsh]
" - Close terminal: <Ctrl+\><Ctrl+n>
" - Close terminal: 'exit'<Enter>
" 產生「終端機」視窗
nmap <leader>th <C-w>s<C-w>j:terminal<CR>
nmap <leader>tv <C-w>v<C-w>l:terminal<CR>
" noremap <F5> :new term://zsh<CR>
" noremap <F6> :vnew term://zsh<CR>
" 執行 Python 程式碼
nmap <F5> <C-W>v<C-W>l:ter python %<CR>i
"nmap <F5> :vnew term://python %<CR>i
nmap <F6> <C-W>s<C-W>j:ter python %<CR>i
"--------------------------------------------------------------
" ipdb 除錯器
"
func! s:SetBreakpoint()
cal append('.', repeat(' ', strlen(matchstr(getline('.'), '^\s*'))) . 'import ipdb; ipdb.set_trace()')
endf
func! s:RemoveBreakpoint()
exe 'silent! g/^\s*import\sipdb\;\?\n*\s*ipdb.set_trace()/d'
endf
func! s:ToggleBreakpoint()
if getline('.')=~#'^\s*import\sipdb' | cal s:RemoveBreakpoint() | el | cal s:SetBreakpoint() | en
endf
nnoremap <F6> :call <SID>ToggleBreakpoint()<CR>
"==============================================================
" 客製用 Vim Scripts
"==============================================================
" Dracula Mode (Dark)
function! ColorDracula()
color dracula
let g:airline_theme=''
IndentLinesEnable
endfunction
" Forgotten Mode (Light)
function! ColorForgotten()
" Light airline themes: tomorrow, silver, alduin
" Light colors: forgotten-light, nemo-light
let g:airline_theme='tomrrow'
color forgotten-light
IndentLinesDisable
endfunction
" Zazen Mode (Black & White)
function! ColorZazen()
let g:airline_theme='badcat'
color zazen
IndentLinesEnable
endfunction
"--------------------------------------------------------------
" 程式碼編輯
" Python 專用
imap :: <ESC>A:<ESC>
imap EE <C-O>oelse:<C-O>o
imap <Enter><Enter> <ESC>o
" 搬移文字
nnoremap <M-j> :m .+1<CR>==
nnoremap <M-k> :m .-2<CR>==
inoremap <M-j> <Esc>:m .+1<CR>==gi
inoremap <M-k> <Esc>:m .-2<CR>==gi
vnoremap <M-j> :m '>+1<CR>gv=gv
vnoremap <M-k> :m '<-2<CR>gv=gv
" nnoremap ∆ :m .+1<CR>== " <M-j>
" nnoremap ˚ :m .-2<CR>== " <M-k>
"
" inoremap ∆ <Esc>:m .+1<CR>==gi
" inoremap ˚ <Esc>:m .-2<CR>==gi
"
" vnoremap ∆ :m '>+1<CR>gv=gv
" vnoremap ˚ :m '<-2<CR>gv=gv
"--------------------------------------------------------------
" Help
" Plugins need to be added to runtimepath before helptags can be generated.
packloadall
" Load all of the helptags now, after plugins have been loaded.
" All messages and errors will be ignored.
silent! helptags ALL
"--------------------------------------------------------------
" 使用 Python 3 客製 VIM Plugin
if !has('python3')
echo 'Error: Required vim compild with +python3'
finish
endif
function! MyPlugin()
python << EOF
print('Hello MyPlugin!')
EOF
endfunction
@AlanJui
Copy link
Copy Markdown
Author

AlanJui commented Jun 30, 2019

加入 htmldjango 辨視判斷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment