diff --git a/config/fish/config.fish b/config/fish/config.fish index f3f0de4..504511d 100644 --- a/config/fish/config.fish +++ b/config/fish/config.fish @@ -25,6 +25,7 @@ end source-file-if-exists /usr/share/autojump/autojump.fish source-file-if-exists /usr/local/share/autojump/autojump.fish append-path-if-exists ~/.local/bin +append-path-if-exists ~/Programs/bin append-path-if-exists ~/.yarn/bin source-file-if-exists ~/.cargo/env append-path-if-exists /usr/local/bin diff --git a/tex.vimrc b/tex.vimrc new file mode 100644 index 0000000..ef37679 --- /dev/null +++ b/tex.vimrc @@ -0,0 +1,102 @@ +function! MathAndLiquid() + "" Define certain regions + " Block math. Look for "$$[anything]$$" + syn region math start=/\$\$/ end=/\$\$/ + " inline math. Look for "$[not $][anything]$" + syn match math_block '\$[^$].\{-}\$' + + " Liquid single line. Look for "{%[anything]%}" + syn match liquid '{%.*%}' + " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}" + syn region highlight_block start='{% highlight .*%}' end='{%.*%}' + " Fenced code blocks, used in GitHub Flavored Markdown (GFM) + syn region highlight_block start='```' end='```' + + "" Actually highlight those regions. + hi link math Statement + hi link liquid Statement + hi link highlight_block Function + hi link math_block Function +endfunction + +" Call everytime we open a Markdown file +"autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid() + +" \vm 2 4\ +" \begin{vmatrix} +" <++> & <++> & <++> & <++> \\ +" <++> & <++> & <++> & <++ > \\ +" \end{vmatrix}<++> +" +function! Tex() + let mark = '\' + let sepr = ' ' + let tags = {'vm': 'vmatrix', 'bm': 'bmatrix', 'mt': 'matrix', 'cs': 'cases', 'ad': 'aligned', 'al': 'align', 'ar': 'array'} + let text = getline('.') + let end = col('.') + let start = strridx(text, mark, end) + if start > -1 + let params = strpart(text, start+1, end - start - 1) + let params = split(params, sepr) + let abbr = params[0] + if strlen(abbr) == 0 || !has_key(tags, abbr) + return + endif + let rc = params[1] + if !(rc>0) + return + endif + if len(params)>2 + let cc = params[2] + if !(cc>0) + return + endif + else + let cc = 1 + end + + let prefix = repeat(' ', start) + + let thecols = [] + let i = 0 + while i < cc + call add(thecols, '<++>') + let i += 1 + endwhile + let columnsText = prefix . ' '. join(thecols, ' & ') . ' \\' + + let lines = [] + let i = 0 + while i < rc + call add(lines, columnsText) + let i += 1 + endwhile + call add(lines, prefix . '\end{' . tags[abbr] . '}<++>') + + let leftPart = strpart(text, 0, start) + let rightPart = strpart(text, end) + if strlen(rightPart) > 0 + call add(lines, prefix . rightPart) + endif + call setline(line('.'), leftPart . '\begin{' . tags[abbr] . '}') + call append(line('.'), lines) + "call append(line('.'), lines) + endif +endfunction + +" autocmd FileType markdown +inoremap :call Tex()a +" Navigating with guides +inoremap /<++>"_c4l +vnoremap /<++>"_c4l +map /<++>"_c4l +nmap NERDCommenterToggle +vmap NERDCommenterTogglegv + +" Markdown setup +autocmd FileType markdown inoremap \cs \begin{cases}\end{cases}<++>F\i +autocmd FileType markdown inoremap \fr \frac{<++>}{<++>}<++>F\i +autocmd FileType markdown inoremap ` `$$`<++>F$i +autocmd FileType markdown inoremap $ $$$$<++>kO +autocmd FileType markdown inoremap \{ \{\}<++>F{a +autocmd FileType markdown vnoremap b c__"__ diff --git a/vimrc b/vimrc index 2417cfd..a28fb4b 100644 --- a/vimrc +++ b/vimrc @@ -37,50 +37,44 @@ else source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim endif -Plug 'terryma/vim-multiple-cursors' -Plug 'jiangmiao/auto-pairs' -"Plug 'scrooloose/syntastic' -"Plug 'w0rp/ale' -Plug 'scrooloose/nerdtree' -Plug 'alvan/vim-closetag' -"Plug 'AndrewRadev/tagalong.vim' -Plug 'tpope/vim-repeat' -Plug 'tpope/vim-fugitive' " git 功能 -Plug 'tpope/vim-surround' -"Plug 'vim-airline/vim-airline' -"Plug 'vim-airline/vim-airline-themes' -Plug 'scrooloose/nerdcommenter' -Plug 'editorconfig/editorconfig-vim' + +" searching and formatting Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '(GrepperOperator)'] } Plug 'ctrlpvim/ctrlp.vim' +Plug 'godlygeek/tabular' " align text by specified pattern :Tabularize / +Plug 'editorconfig/editorconfig-vim' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-repeat' +Plug 'alvan/vim-closetag' +Plug 'jiangmiao/auto-pairs' + +" ide like +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'mgedmin/coverage-highlight.vim' +"Plug 'klesh/vim-fakeclip' +Plug 'scrooloose/nerdcommenter' +Plug 'tpope/vim-fugitive' " git 功能 +Plug 'scrooloose/nerdtree' + +" color themes +Plug 'morhetz/gruvbox' + +" syntax +Plug 'peitalin/vim-jsx-typescript' +Plug 'pangloss/vim-javascript' Plug 'lunaru/vim-less' Plug 'posva/vim-vue' Plug 'othree/html5.vim' -Plug 'mtscout6/syntastic-local-eslint.vim' -Plug 'pangloss/vim-javascript' -Plug 'klesh/vim-fakeclip' Plug 'dag/vim-fish' -Plug 'digitaltoad/vim-pug' -"Plug 'ludovicchabant/vim-gutentags' -Plug 'godlygeek/tabular' -Plug 'plasticboy/vim-markdown' -Plug 'triglav/vim-visual-increment' -Plug 'jvirtanen/vim-octave' Plug 'vim-python/python-syntax' -Plug 'mgedmin/coverage-highlight.vim' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} -Plug 'morhetz/gruvbox' -Plug 'peitalin/vim-jsx-typescript' +Plug 'plasticboy/vim-markdown' +"Plug 'digitaltoad/vim-pug' + +" statusline +Plug 'liuchengxu/eleline.vim' call plug#end() -" coc configuration, may need to run `yarn` in ~/.vim/coc-python folder -" $ pip install --user python-language-server jedi rope - - - -" Remap keys for gotos +" ==== coc configuration ==== nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) @@ -89,9 +83,6 @@ nmap gr (coc-references) " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') -" Use K to show documentation in preview window -nnoremap K :call show_documentation() - " Remap for rename current word nmap rn (coc-rename) @@ -99,305 +90,45 @@ nmap rn (coc-rename) xmap f (coc-format-selected) nmap f (coc-format-selected) +" Use K to show documentation in preview window function! s:show_documentation() + " s:f makes function f local, use f() to call it, ! replaces existing + " function quitely if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction +nnoremap K :call show_documentation() -" markdown +" ==== markdown configuration ==== let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_math = 1 -" nerdtree + +" ==== nerdtree configuration ==== let NERDTreeDirArrowExpandable = "+" let NERDTreeDirArrowCollapsible = "-" +let NERDTreeIgnore = ['\.pyc$', '__pycache__'] -" python + +" ==== python configuration ==== let g:python_highlight_all = 1 -" airline -let g:airline_theme='bubblegum' -let g:airline_left_sep = '' -let g:airline_right_sep = '' -"let g:airline_left_sep = ' ' -"let g:airline_right_sep = ' ' -let g:airline_symbols#crypt = '🔒' -let g:airline_symbols#linenr = '¶' -let g:airline_symbols#maxlinenr = '☰' -let g:airline_symbols#branch = '' -"let g:airline_symbols#paste = 'ρ' -let g:airline_symbols#paste = 'Þ' -"let g:airline_symbols#paste = '∥' -"let g:airline_symbols#spell = 'Ꞩ' -"let g:airline_symbols#notexists = '∄' -"let g:airline_symbols#whitespace = 'Ξ' -" -"let g:airline_theme='luna' -" CtrlP +" ==== ctrlp configuration ==== let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard'] -"let g:ctrlp_map = '' -" NERDTree -let NERDTreeIgnore = ['\.pyc$', '__pycache__'] -" syntastic -" let g:syntastic_javascript_checkers = ['eslint'] -"let g:ale_python_pylint_change_directory = 0 -let g:ale_linters = { - \ 'python': ['flake8'] - \} - -" vue-vim -" 解决跳到尾部时语法高亮不正常的问题 +" ==== vue configuration ==== +" syntax highlighting not working correctly occasionally for vue autocmd FileType vue syntax sync fromstart -" 利用现有的插件对语法进行高亮 -"autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html5.javascript.less autocmd BufRead,BufNewFile *.vue setlocal filetype=vue -" vim -set ts=4 -set sw=4 -set listchars=eol:$,tab:->,extends:>,precedes:<,space:., -set list -set nu -set expandtab -set hidden -set autoindent -set confirm -set noundofile -set nobackup -set ruler " 开启游标右下角行、列显示 -set noswapfile " 关闭临时文件 -set hlsearch -set lazyredraw -set noshowmatch -set laststatus=2 -let html_no_rendering=1 -set fillchars=vert:\ ,fold:- -"highlight VertSplit guibg=Orange guifg=Black ctermbg=None ctermfg=033 -hi StatusLine cterm=NONE -" keybindings -" 从系统剪贴板复制/粘贴 -"inoremap "+pa -"nnoremap "+p -"vnoremap "+p -"vnoremap "+y -vmap (fakeclip-y) -inoremap ::wa -nnoremap ::w - -"nnoremap :CtrlP -nnoremap n :NERDTreeToggle -nnoremap g :Grepper -tool git - -nnoremap :noh -nnoremap o :only -nnoremap w -nnoremap q :qall -vnoremap p "_dP -nnoremap e :%s/\s\+$//g -nnoremap s :syntax sync fromstart -nnoremap c ::set cursorcolumn! - -nnoremap h h -nnoremap j j -nnoremap k k -nnoremap l l -nnoremap m :vertical resize +5 -nnoremap , :vertical resize -5 -nnoremap . :resize +5 -nnoremap / :resize -5 -nnoremap d :vs -nnoremap [ :lprev -nnoremap ] :lnext - -vnoremap m c=trim(@") . '=' . trim(system('math ' . shellescape(@"))) - -" 行尾空格高亮 -highlight ExtraWhitespace ctermbg=red guibg=red -au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red -au Syntax * match ExtraWhitespace /\s\+$/ - -" iterm2 插入模式时backspace不works -set backspace=indent,eol,start - -function! ReadClipboardWsl() - let text = system('powershell.exe -Command Get-Clipboard') - let text = substitute(text, "\r\n", '', 'g') - return text -endfunction - -function! TabNewFromClipboard() - exec ':tabnew ' . ReadClipboardWsl() -endfunction - -function! Jsonpp() - "exec ':%!python -m json.tool' - exec ':%!json_pp' -endfunction - -function! DecodeHtml() - exec ':%s/
/```\r/g'
-  exec ':%s/<\/pre>/\r```/g'
-  exec ':%s/<//g'
-  exec ':%s/&/\&/g'
-endfunction
-
-cnoremap  
-cnoremap  
-cnoremap  
-cnoremap  
-cnoremap  
-cnoremap  
-cnoremap  
-
-inoremap  
-inoremap  
-inoremap  
-inoremap  
-inoremap  
-inoremap  
-inoremap  
-
-noremap  
-noremap  
-noremap  
-noremap  
-noremap  
-noremap  
-
-function! MathAndLiquid()
-  "" Define certain regions
-  " Block math. Look for "$$[anything]$$"
-  syn region math start=/\$\$/ end=/\$\$/
-  " inline math. Look for "$[not $][anything]$"
-  syn match math_block '\$[^$].\{-}\$'
-
-  " Liquid single line. Look for "{%[anything]%}"
-  syn match liquid '{%.*%}'
-  " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
-  syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
-  " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
-  syn region highlight_block start='```' end='```'
-
-  "" Actually highlight those regions.
-  hi link math Statement
-  hi link liquid Statement
-  hi link highlight_block Function
-  hi link math_block Function
-endfunction
-
-" Call everytime we open a Markdown file
-"autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
-
-" \vm 2 4\
-" \begin{vmatrix}
-" <++> & <++> & <++> & <++> \\
-" <++> & <++> & <++> & <++ > \\
-" \end{vmatrix}<++>
-"
-function! Tex()
-  let mark = '\'
-  let sepr = ' '
-  let tags = {'vm': 'vmatrix', 'bm': 'bmatrix', 'mt': 'matrix', 'cs': 'cases', 'ad': 'aligned', 'al': 'align', 'ar': 'array'}
-  let text = getline('.')
-  let end = col('.')
-  let start = strridx(text, mark, end)
-  if start > -1
-    let params = strpart(text, start+1, end - start - 1)
-    let params = split(params, sepr)
-    let abbr = params[0]
-    if strlen(abbr) == 0 || !has_key(tags, abbr)
-      return
-    endif
-    let rc = params[1]
-    if !(rc>0)
-      return
-    endif
-    if len(params)>2
-      let cc = params[2]
-      if !(cc>0)
-        return
-      endif
-    else
-      let cc = 1
-    end
-
-    let prefix = repeat(' ', start)
-
-    let thecols = []
-    let i = 0
-    while i < cc
-      call add(thecols, '<++>')
-      let i += 1
-    endwhile
-    let columnsText = prefix . '  '. join(thecols, ' & ') . ' \\'
-
-    let lines = []
-    let i = 0
-    while i < rc
-      call add(lines, columnsText)
-      let i += 1
-    endwhile
-    call add(lines, prefix . '\end{' . tags[abbr] . '}<++>')
-
-    let leftPart = strpart(text, 0, start)
-    let rightPart = strpart(text, end)
-    if strlen(rightPart) > 0
-      call add(lines, prefix . rightPart)
-    endif
-    call setline(line('.'), leftPart . '\begin{' . tags[abbr] . '}')
-    call append(line('.'), lines)
-    "call append(line('.'), lines)
-  endif
-endfunction
-
-" autocmd FileType markdown
-inoremap  :call Tex()a
-" Navigating with guides
-inoremap  /<++>"_c4l
-vnoremap  /<++>"_c4l
-map  /<++>"_c4l
-nmap    NERDCommenterToggle
-vmap    NERDCommenterTogglegv
-
-" Markdown setup
-autocmd FileType markdown inoremap \cs \begin{cases}\end{cases}<++>F\i
-autocmd FileType markdown inoremap \fr \frac{<++>}{<++>}<++>F\i
-autocmd FileType markdown inoremap ` `$$`<++>F$i
-autocmd FileType markdown inoremap $ $$$$<++>kO
-autocmd FileType markdown inoremap \{ \{\}<++>F{a
-autocmd FileType markdown vnoremap b c__"__
-autocmd FileType json nnoremap f %!json_pp
-
-function! HTML5()
-  let html = []
-  call setline(1, '')
-  call add(html, '')
-  call add(html, ' ')
-  call add(html, '   ')
-  call add(html, '   <++>')
-  call add(html, ' ')
-  call add(html, ' ')
-  call add(html, ' <++>')
-  call add(html, ' ')
-  call add(html, '')
-  call append(1, html)
-endfunction
-
-color gruvbox
-set background=dark
-highlight Normal ctermbg=None
-
-" closetag
-" dict
+" ==== closetag configuration ====
 " Disables auto-close if not in a "valid" region (based on filetype)
 let g:closetag_regions = {
     \ 'typescript.tsx': 'jsxRegion,tsxRegion',
@@ -405,9 +136,10 @@ let g:closetag_regions = {
     \ }
 let g:closetag_shortcut = '>'
 let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.vue,*.tsx"
-"
-"let g:tagalong_additional_filetypes = ['typescript.tsx']
 
+
+" ==== nerdcommenter configuration ====
+" fixing vue commenting problem
 fu! NERDCommenter_before()
   if &ft == 'vue'
     let b:isvue = 1
@@ -427,13 +159,93 @@ fu! NERDCommenter_after()
     let b:isvue = 0
   endif
 endfu
-"
-
-"fu! NERDCommenter_before()
-  "setf javascript
-"endfu
 
 
-"fu! NERDCommenter_after()
-  "setf vue
-"endfu
+" ==== general configuration ====
+set ts=4
+set sw=4
+set listchars=eol:$,tab:->,extends:>,precedes:<,space:.,
+set list
+set nu
+set expandtab
+set hidden
+set autoindent
+set confirm
+set noundofile
+set nobackup
+set ruler                                                           " 开启游标右下角行、列显示
+set noswapfile                                                      " 关闭临时文件
+set hlsearch
+set lazyredraw
+set noshowmatch
+set laststatus=2
+let html_no_rendering=1
+set fillchars=vert:\ ,fold:-
+set showcmd
+hi StatusLine cterm=NONE
+
+" 行尾空格高亮
+highlight ExtraWhitespace ctermbg=red guibg=red
+au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
+au Syntax * match ExtraWhitespace /\s\+$/
+
+" theme
+try
+    color gruvbox
+catch
+    color delek
+endtry
+set background=dark
+highlight Normal ctermbg=None
+
+" ==== keybinding configuration ====
+"vmap  (fakeclip-y)
+inoremap  ::wa
+nnoremap  ::w
+
+vnoremap p "_dP
+nnoremap  :noh
+nnoremap n :NERDTreeToggle
+nnoremap g :Grepper -tool git
+nnoremap o :only
+nnoremap q :qall
+nnoremap e :%s/\s\+$//g
+nnoremap s :syntax sync fromstart
+nnoremap c ::set cursorcolumn!
+autocmd FileType json nnoremap f %!json_pp
+
+"nnoremap m :vertical resize +5
+"nnoremap , :vertical resize -5
+"nnoremap . :resize +5
+"nnoremap / :resize -5
+"nnoremap d :vs
+"nnoremap [ :lprev
+"nnoremap ] :lnext
+"vnoremap  m c=trim(@") . '=' . trim(system('math ' . shellescape(@")))
+
+" iterm2 插入模式时backspace不works
+set backspace=indent,eol,start
+
+
+function! DecodeHtml()
+  exec ':%s/
/```\r/g'
+  exec ':%s/<\/pre>/\r```/g'
+  exec ':%s/<//g'
+  exec ':%s/&/\&/g'
+endfunction
+
+function! HTML5()
+  let html = []
+  call setline(1, '')
+  call add(html, '')
+  call add(html, ' ')
+  call add(html, '   ')
+  call add(html, '   <++>')
+  call add(html, ' ')
+  call add(html, ' ')
+  call add(html, ' <++>')
+  call add(html, ' ')
+  call add(html, '')
+  call append(1, html)
+endfunction