├── .gitignore ├── README.md ├── UltiSnips ├── all.snippets ├── asciidoc.snippets ├── asciidoc_blocks.snippets ├── asciidoc_replacements.snippets ├── asciidoc_revealjs.snippets ├── behave.snippets ├── c.snippets ├── cabal.snippets ├── cpp.snippets ├── cpp_guard.snippets ├── cpp_unittest.snippets ├── dockerfile.snippets ├── haskell.snippets ├── haskell_hspec.snippets ├── html.snippets ├── impressjs.snippets ├── javascript.snippets ├── javascript_node.snippets ├── lilypond.snippets ├── lilypond_additional.snippets ├── lilypond_template.snippets ├── make.snippets ├── markdown.snippets ├── markdown_blocks.snippets ├── markdown_jekyll.snippets ├── markdown_mermaid.snippets ├── markdown_revealjs.snippets ├── markdown_skel.snippets ├── markdown_tex_math.snippets ├── python.snippets ├── python_behave.snippets ├── python_click.snippets ├── python_import.snippets ├── python_routine.snippets ├── python_skel.snippets ├── revealjs.snippets ├── sh.snippets ├── sml.snippets ├── tex.snippets ├── tex_math.snippets ├── toml.snippets ├── vim.snippets └── yaml.snippets ├── autoload ├── SpaceVim │ └── layers │ │ └── lang │ │ └── lilypond.vim ├── myspacevim.vim └── myspacevim │ └── colorscheme.vim ├── ftplugin ├── c_path_settings.vim └── cpp.vim ├── init.toml ├── nogui.sh ├── offline.sh └── templates └── pydocstring └── google ├── arg.txt ├── comment.txt ├── multi.txt └── oneline.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .netrwhist 2 | tags 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is my custom configuratin for [SpaceVim][]. Feel free to clone and modified. 2 | 3 | You can put host dependent code into a ``vim`` file: ``~/.spacevim.local``, it will be source at the begin of ``bootstrap_before`` function. 4 | 5 | For example, I disable all the programming related plugins in my FreeBSD Jail: 6 | 7 | ```vim 8 | " vim: filetype=vim fileencoding=utf-8 foldmethod=marker foldlevel=0: 9 | 10 | for l in [ 'VersionControl', 'lang#c', 'lang#clojure', 11 | \ 'lang#go', 'lang#haskell', 'lang#haskell', 12 | \ 'lang#java', 'lang#javascript', 'lang#python', 13 | \ 'lang#lilypond', 'leaderf', 'lsp', 'tags'] 14 | call SpaceVim#layers#disable(l) 15 | endfor 16 | ``` 17 | 18 | ## Offline usage 19 | 20 | You can use ``offline.sh`` to disable ``checkupdate`` to be used at an offline environment. 21 | 22 | You can use ``nogui.sh`` to be used in an terminal without nerd-font. 23 | 24 | ## Dependencies 25 | 26 | ```sh 27 | pip install pynvim neovim 28 | ``` 29 | 30 | * ``lang#markdown`` depends on ``remark`` 31 | 32 | ```sh 33 | npm install --global remark-cli remark-html remark-preset-lint-markdown-style-guide 34 | ``` 35 | 36 | * ``lang#c`` depends on 37 | 38 | ```sh 39 | pip install clang 40 | ``` 41 | 42 | * ``lang#python`` depends on 43 | 44 | ```sh 45 | pip install jedi 46 | ``` 47 | 48 | * `lang#javascript` depends on 49 | 50 | ```sh 51 | npm install -g typescript typescript-language-server 52 | ``` 53 | 54 | ## Work with pyenv for neovim 55 | 56 | * Create the neovim virtualenvs 57 | 58 | * 59 | 60 | * python2 61 | 62 | ```sh 63 | pyenv install 2.7.15 64 | pyenv virtualenv 2.7.15 neovim2 65 | pyenv activate neovim2 66 | pip install pynvim neovim 67 | pyenv which python # Note the path 68 | ``` 69 | 70 | * python3 71 | 72 | ```py 73 | pyenv install 3.7.3 74 | pyenv virtualenv 3.7.3 neovim3 75 | pyenv activate neovim3 76 | pip install clang jedi neovim pynvim 77 | pyenv which python # Note the path 78 | ``` 79 | 80 | * Set environment 81 | 82 | * using vim script 83 | 84 | ```py 85 | let g:python_host_prog = '/full/path/to/neovim2/bin/python' 86 | let g:python3_host_prog = '/full/path/to/neovim3/bin/python' 87 | ```py 88 | 89 | * using shell 90 | 91 | ```sh 92 | export PYTHON_HOST_PROG="$(pyenv root)/neovim2/bin/python" 93 | export PYTHON3_HOST_PROG="$(pyenv root)/neovim3/bin/python" 94 | F 95 | ``` 96 | 97 | [SpaceVim]: https://spacevim.org 98 | -------------------------------------------------------------------------------- /UltiSnips/all.snippets: -------------------------------------------------------------------------------- 1 | snippet datew "YYYY-MM-DD with weekday" w 2 | `!v strftime("%Y-%m-%d %A")` 3 | endsnippet 4 | 5 | snippet datey "YYYY-MM-DD and weekday for yesterday" w 6 | `!v strftime("%Y-%m-%d %A", localtime() - 24*3600)` 7 | endsnippet 8 | 9 | snippet md// "Markdown comment" 10 | [//]: # (${VISUAL}$1) 11 | $0 12 | endsnippet 13 | -------------------------------------------------------------------------------- /UltiSnips/asciidoc.snippets: -------------------------------------------------------------------------------- 1 | snippet skel 2 | // vim: set filetype=asciidoc fileencoding=utf-8: 3 | = ${1:`!v expand("%:t:r")`} 4 | :numbered: 5 | :encoding: UTF-8 6 | :toc: macro 7 | :toc-title: `!v "\u76ee\u5f55"` 8 | :icons: font 9 | :data-uri: 10 | 11 | toc::[] 12 | 13 | ${0} 14 | endsnippet 15 | 16 | snippet src "source list" b 17 | [source,${1}] 18 | ---- 19 | ${VISUAL}${2} 20 | ---- 21 | ${0} 22 | endsnippet 23 | 24 | snippet -- "open block" b 25 | -- 26 | ${VISUAL}$1 27 | -- 28 | ${0} 29 | endsnippet 30 | 31 | snippet table "table" b 32 | [cols="${1:${2:2}*}", options="${3:header}"] 33 | |=== 34 | |${VISUAL/\n\s*/\n|/g}${4} 35 | |=== 36 | ${0} 37 | endsnippet 38 | 39 | snippet quote "Quote Block" b 40 | [quote${1:,${2:author}${3:,${4:source}}}] 41 | ____ 42 | ${VISUAL}$5 43 | ____ 44 | ${0} 45 | endsnippet 46 | 47 | snippet verse "Verse Block" b 48 | [verse,${1:author},${2:source}] 49 | ____ 50 | ${VISUAL}$3 51 | ____ 52 | ${0} 53 | endsnippet 54 | 55 | snippet comment "Comment Block" b 56 | //// 57 | ${VISUAL}$1 58 | //// 59 | ${0} 60 | endsnippet 61 | 62 | snippet passthrough "Passthrough Block" b 63 | ++++ 64 | ${VISUAL}$1 65 | ++++ 66 | ${0} 67 | endsnippet 68 | 69 | snippet listing "Listing Block" b 70 | ---- 71 | ${VISUAL}$1 72 | ---- 73 | ${0} 74 | endsnippet 75 | 76 | snippet literal "Literal Block" b 77 | .... 78 | ${VISUAL}$1 79 | .... 80 | ${0} 81 | endsnippet 82 | 83 | snippet sidebar "Sidebar Block" b 84 | **** 85 | ${VISUAL}$1 86 | **** 87 | ${0} 88 | endsnippet 89 | 90 | snippet example "Example Block" b 91 | ==== 92 | ${VISUAL}$1 93 | ==== 94 | ${0} 95 | endsnippet 96 | 97 | snippet note "Note admonition" b 98 | [NOTE] 99 | .${1:Title} 100 | ==== 101 | ${VISUAL}$2 102 | ==== 103 | ${0} 104 | endsnippet 105 | 106 | snippet style "text with style (class, like red/red-background/big/small/underline/overline/line-through)" 107 | [${1:red}]#${VISUAL}$2#${0} 108 | endsnippet 109 | 110 | snippet footnote "Footnote" 111 | footnote:[${1:${VISUAL:text}}]${0} 112 | endsnippet 113 | 114 | snippet anchor-macro "Hypertext link target" 115 | anchor:${1:${VISUAL:id}}[${2:label}]${0} 116 | endsnippet 117 | 118 | snippet anchor "Hypertext link target" 119 | [[${1:id}${2:,label}]]`!p snip.rv='#'+snip.v.text+'#' if snip.v.text else ''`${0} 120 | endsnippet 121 | 122 | snippet [[ "Hypertext link target" 123 | [[${1:id}${2:,label}]]`!p snip.rv='#'+snip.v.text+'#' if snip.v.text else ''`${0} 124 | endsnippet 125 | 126 | snippet xref-macro "Link to hypertext anchor" 127 | xref:${1:${VISUAL:id}}[${2:caption}]${0} 128 | endsnippet 129 | 130 | snippet xref "Link to hypertext anchor" 131 | <<${1:id}${2:,caption}>>${0} 132 | endsnippet 133 | 134 | snippet << "Link to hypertext anchor" 135 | <<${1:id}${2:,caption}>>${0} 136 | endsnippet 137 | 138 | snippet image-inline "Inline Image" 139 | image:${1:url}[${2:alt="${VISUAL:$3}"}]${0} 140 | endsnippet 141 | 142 | snippet image-block "Block Image" 143 | image::${1:url}[${2:alt="${VISUAL:$3}"}]${0} 144 | endsnippet 145 | 146 | snippet img "Block Image" 147 | image::${1:url}[${2:alt="${VISUAL:$3}"}]${0} 148 | endsnippet 149 | 150 | snippet link "Link to URL" 151 | link:${1:url}[${2:${VISUAL:title}}]${0} 152 | endsnippet 153 | 154 | snippet amb "asciimath block" b 155 | [asciimath] 156 | ---- 157 | ${0} 158 | ---- 159 | endsnippet 160 | 161 | snippet am "asciimath inline" 162 | asciimath:[${0}] 163 | endsnippet 164 | 165 | snippet stemb "stem block" b 166 | [stem] 167 | ---- 168 | ${0} 169 | ---- 170 | 171 | endsnippet 172 | 173 | snippet stem "stem inline" 174 | stem:[${0}] 175 | endsnippet 176 | 177 | snippet uml "plantuml block" b 178 | [plantuml, "${1:filename}", ${2:svg}] 179 | ---- 180 | ${0} 181 | ---- 182 | 183 | endsnippet 184 | 185 | snippet erd "plantuml block for ERD" b 186 | [plantuml, "${1:filename}", ${2:svg}] 187 | ---- 188 | !define Table(name) entity name as "name" << (T,#FFAAAA) >> 189 | !define Table(name,desc) entity name as "name\n desc" << (T,#FFAAAA) >> 190 | !define primary_key(x) x 191 | !define foreign_key(x) x 192 | !define unique(x) x 193 | !define not_null(x) x 194 | hide empty members 195 | hide stereotypes 196 | 197 | ${0} 198 | ---- 199 | 200 | endsnippet 201 | -------------------------------------------------------------------------------- /UltiSnips/asciidoc_blocks.snippets: -------------------------------------------------------------------------------- 1 | snippet cpp "cpp code block" b 2 | [source,cpp] 3 | ---- 4 | ${VISUAL}${1} 5 | ---- 6 | ${0} 7 | endsnippet 8 | 9 | snippet css "css code block" b 10 | [source,css] 11 | ---- 12 | ${VISUAL}${1} 13 | ---- 14 | ${0} 15 | endsnippet 16 | 17 | snippet python "python code block" b 18 | [source,python] 19 | ---- 20 | ${VISUAL}${1} 21 | ---- 22 | ${0} 23 | endsnippet 24 | 25 | snippet haskell "ruby code block" b 26 | [source,haskell] 27 | ---- 28 | ${VISUAL}${1} 29 | ---- 30 | ${0} 31 | endsnippet 32 | 33 | snippet html "html code block" b 34 | [source,html] 35 | ---- 36 | ${VISUAL}${1} 37 | ---- 38 | ${0} 39 | endsnippet 40 | 41 | snippet js "javascript code block" b 42 | [source,javascript] 43 | ---- 44 | ${VISUAL}${1} 45 | ---- 46 | ${0} 47 | endsnippet 48 | 49 | snippet markdown "markdown code block" b 50 | [source,markdown] 51 | ---- 52 | ${VISUAL}${1} 53 | ---- 54 | ${0} 55 | endsnippet 56 | 57 | snippet racket "racket code block" b 58 | [source,racket] 59 | ---- 60 | ${VISUAL}${1} 61 | ---- 62 | ${0} 63 | endsnippet 64 | 65 | snippet ruby "ruby code block" b 66 | [source,ruby] 67 | ---- 68 | ${VISUAL}${1} 69 | ---- 70 | ${0} 71 | endsnippet 72 | 73 | snippet sh "sh code block" b 74 | [source,sh] 75 | ---- 76 | ${VISUAL}${1} 77 | ---- 78 | ${0} 79 | endsnippet 80 | 81 | snippet sml "sml code block" b 82 | [source,sml] 83 | ---- 84 | ${VISUAL}${1} 85 | ---- 86 | ${0} 87 | endsnippet 88 | 89 | -------------------------------------------------------------------------------- /UltiSnips/asciidoc_replacements.snippets: -------------------------------------------------------------------------------- 1 | # to esay convert some character to asciidoc replacements 2 | snippet nbsp "{nbsp}" i 3 | {nbsp} 4 | endsnippet 5 | 6 | snippet zwsp "{zwsp} - zero width space" i 7 | {zwsp} 8 | endsnippet 9 | 10 | snippet wj "{wj} - word joiner" i 11 | {wj} 12 | endsnippet 13 | 14 | snippet apos "{apos} - '" i 15 | {apos} 16 | endsnippet 17 | 18 | snippet ' "{apos} - '" 19 | {apos} 20 | endsnippet 21 | 22 | 23 | snippet quot "{quot} - double quote" i 24 | {quot} 25 | endsnippet 26 | 27 | snippet lsquo "{lsquo} - ‘" i 28 | {lsquo} 29 | endsnippet 30 | 31 | snippet ‘ "{lsquo} - ‘" 32 | {lsquo} 33 | endsnippet 34 | 35 | 36 | snippet rsquo "{rsquo} - ’" i 37 | {rsquo} 38 | endsnippet 39 | 40 | snippet ’ "{rsquo} - ’" 41 | {rsquo} 42 | endsnippet 43 | 44 | 45 | snippet ldquo "{ldquo} - “" i 46 | {ldquo} 47 | endsnippet 48 | 49 | snippet “ "{ldquo} - “" 50 | {ldquo} 51 | endsnippet 52 | 53 | 54 | snippet rdquo "{rdquo} - ”" i 55 | {rdquo} 56 | endsnippet 57 | 58 | snippet ” "{rdquo} - ”" 59 | {rdquo} 60 | endsnippet 61 | 62 | 63 | snippet deg "{deg} - °" i 64 | {deg} 65 | endsnippet 66 | 67 | snippet ° "{deg} - °" 68 | {deg} 69 | endsnippet 70 | 71 | 72 | snippet plus "{plus} - +" i 73 | {plus} 74 | endsnippet 75 | 76 | snippet + "{plus} - +" 77 | {plus} 78 | endsnippet 79 | 80 | 81 | snippet brvbar "{brvbar} - ¦" i 82 | {brvbar} 83 | endsnippet 84 | 85 | snippet ¦ "{brvbar} - ¦" 86 | {brvbar} 87 | endsnippet 88 | 89 | 90 | snippet vbar "{vbar} - |" i 91 | {vbar} 92 | endsnippet 93 | 94 | snippet | "{vbar} - |" 95 | {vbar} 96 | endsnippet 97 | 98 | 99 | snippet amp "{amp} - &" i 100 | {amp} 101 | endsnippet 102 | 103 | snippet & "{amp} - &" 104 | {amp} 105 | endsnippet 106 | 107 | 108 | snippet lt "{lt} - <" i 109 | {lt} 110 | endsnippet 111 | 112 | snippet < "{lt} - <" 113 | {lt} 114 | endsnippet 115 | 116 | 117 | snippet gt "{gt} - >" i 118 | {gt} 119 | endsnippet 120 | 121 | snippet > "{gt} - >" 122 | {gt} 123 | endsnippet 124 | 125 | 126 | snippet startsb "{startsb} - [" i 127 | {startsb} 128 | endsnippet 129 | 130 | snippet [ "{startsb} - [" 131 | {startsb} 132 | endsnippet 133 | 134 | 135 | snippet endsb "{endsb} - ]" i 136 | {endsb} 137 | endsnippet 138 | 139 | snippet ] "{endsb} - ]" 140 | {endsb} 141 | endsnippet 142 | 143 | 144 | snippet caret "{caret} - ^" i 145 | {caret} 146 | endsnippet 147 | 148 | snippet ^ "{caret} - ^" 149 | {caret} 150 | endsnippet 151 | 152 | 153 | snippet asterisk "{asterisk} - *" i 154 | {asterisk} 155 | endsnippet 156 | 157 | snippet * "{asterisk} - *" 158 | {asterisk} 159 | endsnippet 160 | 161 | 162 | snippet tilde "{tilde} - ~" i 163 | {tilde} 164 | endsnippet 165 | 166 | snippet ~ "{tilde} - ~" 167 | {tilde} 168 | endsnippet 169 | 170 | 171 | snippet backslash "{backslash} - \" i 172 | {backslash} 173 | endsnippet 174 | 175 | snippet \ "{backslash} - \" 176 | {backslash} 177 | endsnippet 178 | 179 | 180 | snippet backtick "{backtick} - `" i 181 | {backtick} 182 | endsnippet 183 | 184 | snippet ` "{backtick} - `" 185 | {backtick} 186 | endsnippet 187 | 188 | snippet two-colons "{two-colons} - ::" i 189 | {two-colons} 190 | endsnippet 191 | 192 | snippet :: "{two-colons} - ::" 193 | {two-colons} 194 | endsnippet 195 | 196 | snippet two-semicolons "{two-semicolons} - ;;" i 197 | {two-semicolons} 198 | endsnippet 199 | 200 | snippet ;; "{two-semicolons} - ;;" 201 | {two-semicolons} 202 | endsnippet 203 | 204 | 205 | snippet c++ "{cpp} - C++" i 206 | {cpp} 207 | endsnippet 208 | 209 | -------------------------------------------------------------------------------- /UltiSnips/asciidoc_revealjs.snippets: -------------------------------------------------------------------------------- 1 | snippet reveal "Reveal.js" b 2 | // vim: set filetype=asciidoc fileencoding=utf-8: 3 | = ${1:`expand("%:t:r")`} 4 | :imagesdir: images 5 | 6 | ${0} 7 | == 双列1 8 | 9 | [width="400",float="left"] 10 | image::https://upload.wikimedia.org/wikipedia/commons/b/b2/Hausziege_04.jpg[] 11 | 12 | -- 13 | * 第一项 14 | * 第二项 15 | * 第三项 16 | -- 17 | 18 | == 递进 19 | [%step] 20 | * First point 21 | * Second point 22 | * Final point 23 | 24 | [%notitle] 25 | == No title slide 26 | 27 | Using `[%notitle]` 28 | 29 | [background-color="yellow"] 30 | == Slide Three 31 | 32 | 黄色背景 33 | 34 | [%notitle] 35 | 36 | [transition=zoom, %notitle] 37 | == Zoom zoom 38 | 39 | This slide will override the presentation transition and zoom! 40 | 41 | [transition-speed=fast, %notitle] 42 | == Speed 43 | 44 | Choose from three transition speeds: default, fast or slow! 45 | 46 | == Speaker View 47 | 48 | Hello World - Good Bye Cruel World 49 | 50 | [NOTE.speaker] 51 | -- 52 | Actually things aren't that bad 53 | -- 54 | endsnippet 55 | 56 | snippet ifbackend "ifdef::backend" b 57 | ifdef::backend-${1:revealjs}[${2:=== !}] 58 | 59 | ${0} 60 | endsnippet 61 | -------------------------------------------------------------------------------- /UltiSnips/behave.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "框架" b 2 | # language: zh-CN 3 | 功能: ${1:`!p snip.rv=re.sub(r'\.[^.]*$', '', snip.fn)`} 4 | 5 | 场景: $2 6 | 假如$3 7 | 当$4 8 | 那么$5 9 | 10 | $0 11 | endsnippet 12 | 13 | snippet background "背景" b 14 | 背景: $1 15 | 假如$2 16 | $0 17 | endsnippet 18 | 19 | snippet feature "功能" b 20 | 功能: $0 21 | endsnippet 22 | 23 | snippet scenario "场景" b 24 | 场景: $1 25 | 假如$2 26 | 当$3 27 | 那么$4 28 | 29 | $0 30 | endsnippet 31 | 32 | snippet scenario_outline "场景大纲" b 33 | 场景大纲: $1 34 | 假如$2 35 | 当$3 36 | 那么$4 37 | 38 | 例子: ${5:Name} 39 | | ${6:col1} | ${7:col2} | 40 | | ${8:val1} | ${9:val2} | 41 | $0 42 | endsnippet 43 | 44 | snippet given "假如" b 45 | 假如$0 46 | endsnippet 47 | 48 | snippet when "当" b 49 | 当$0 50 | endsnippet 51 | 52 | snippet then "那么" b 53 | 那么$0 54 | endsnippet 55 | 56 | snippet and "而且" b 57 | 而且$0 58 | endsnippet 59 | 60 | snippet but "但是" b 61 | 但是$0 62 | endsnippet 63 | 64 | snippet example "Example" b 65 | 例子: ${1:Name} 66 | | ${2:col1} | ${3:col2} | 67 | | ${4:val1} | ${5:val2} | 68 | 69 | $0 70 | endsnippet 71 | -------------------------------------------------------------------------------- /UltiSnips/c.snippets: -------------------------------------------------------------------------------- 1 | snippet if 2 | if (${1}) 3 | { 4 | ${0} 5 | } 6 | endsnippet 7 | 8 | snippet else 9 | else 10 | { 11 | ${0} 12 | } 13 | endsnippet 14 | 15 | snippet elseif 16 | else if (${1}) 17 | { 18 | ${0} 19 | } 20 | endsnippet 21 | 22 | snippet ifelse 23 | if (${1}) 24 | { 25 | ${2} 26 | } 27 | else 28 | { 29 | ${3} 30 | } 31 | endsnippet 32 | 33 | snippet for 34 | for (${1} = 0; $1 < ${2}; ++$1) 35 | { 36 | ${0} 37 | } 38 | endsnippet 39 | 40 | snippet while 41 | while (${1}) 42 | { 43 | ${0} 44 | } 45 | endsnippet 46 | 47 | snippet do 48 | do 49 | { 50 | ${0} 51 | } 52 | while (${1}); 53 | endsnippet 54 | 55 | snippet switch 56 | switch (${1}) 57 | { 58 | case ${2}: 59 | ${0} 60 | break; 61 | } 62 | endsnippet 63 | 64 | snippet func 65 | ${1:void} ${2}(${3}) 66 | { 67 | ${0} 68 | } 69 | endsnippet 70 | 71 | snippet struct 72 | struct ${1} 73 | { 74 | ${0} 75 | }; 76 | endsnippet 77 | 78 | # Typedef struct 79 | snippet struct_typedef 80 | typedef struct ${1} 81 | { 82 | ${0} 83 | }; 84 | endsnippet 85 | 86 | snippet enum 87 | enum ${1} 88 | { 89 | ${0} 90 | }; 91 | endsnippet 92 | 93 | # hard-tab is necessary; C indent doesn't support this. 94 | snippet main 95 | int main(int argc, char const* argv[]) 96 | { 97 | ${0} 98 | return 0; 99 | } 100 | endsnippet 101 | 102 | -------------------------------------------------------------------------------- /UltiSnips/cabal.snippets: -------------------------------------------------------------------------------- 1 | snippet pkg "Package properties" 2 | name : `!v vim2hs#cabal#name()` 3 | version : 0.1.0 4 | license : BSD3 5 | cabal-version : >= 1.10 6 | build-type : Simple 7 | 8 | endsnippet 9 | 10 | snippet repo "Source-Repository" 11 | source-repository ${1:head} 12 | type : ${2:`!v vim2hs#cabal#vcs()`} 13 | location : $3 14 | endsnippet 15 | 16 | snippet gh "Source-Repository: GitHub" 17 | homepage : https://github.com/$1/$2 18 | 19 | source-repository head 20 | type : git 21 | location : git://github.com/${1:`!v $USER`}/${2:`!v vim2hs#cabal#name()`}.git 22 | endsnippet 23 | 24 | snippet den "Source-Repository: darcsden" 25 | homepage : http://darcsden.com/$1/$2 26 | 27 | source-repository head 28 | type : darcs 29 | location : http://darcsden.com/${1:`!v $USER`}/${2:`!v vim2hs#cabal#name()`} 30 | endsnippet 31 | 32 | snippet hub "Source-Repository: hub.darcs.net" 33 | homepage : http://hub.darcs.net/$1/$2 34 | 35 | source-repository head 36 | type : darcs 37 | location : http://hub.darcs.net/${1:`!v $USER`}/${2:`!v vim2hs#cabal#name()`} 38 | endsnippet 39 | 40 | snippet pt "Source-Repository: Patch-Tag" 41 | homepage : http://patch-tag.com/r/$1/$2 42 | 43 | source-repository head 44 | type : darcs 45 | location : http://patch-tag.com/r/${1:`!v $USER`}/${2:`!v vim2hs#cabal#name()`} 46 | endsnippet 47 | 48 | snippet test "Test-Suite" 49 | test-suite test-${1:`!v vim2hs#cabal#name()`} 50 | type : exitcode-stdio-1.0 51 | main-is : ${2:test-$1.hs} 52 | hs-source-dirs : test bin 53 | default-language : Haskell2010 54 | ghc-options : -Wall 55 | other-modules : $3 56 | build-depends : base == 4.*, 57 | `!v vim2hs#cabal#name()`, 58 | checkers, 59 | HUnit, 60 | QuickCheck, 61 | quickcheck-instances, 62 | quickcheck-properties, 63 | test-framework, 64 | test-framework-hunit, 65 | test-framework-quickcheck2, 66 | test-framework-th 67 | endsnippet 68 | 69 | snippet bench "Benchmark" 70 | benchmark bench-${1:`!v vim2hs#cabal#name()`} 71 | type : exitcode-stdio-1.0 72 | main-is : ${2:bench-$1.hs} 73 | hs-source-dirs : bench bin 74 | default-language : Haskell2010 75 | ghc-options : -Wall 76 | other-modules : $3 77 | build-depends : base == 4.*, 78 | `!v vim2hs#cabal#name()`, 79 | criterion 80 | endsnippet 81 | 82 | snippet exe "Executable" 83 | executable ${1:`!v vim2hs#cabal#name()`} 84 | main-is : ${2:$1.hs} 85 | hs-source-dirs : bin 86 | default-language : Haskell2010 87 | ghc-options : -Wall 88 | -threaded -rtsopts -with-rtsopts=-N 89 | build-depends : base == 4.*, 90 | `!v vim2hs#cabal#name()`, 91 | $0 92 | endsnippet 93 | 94 | snippet lib "Library" 95 | library 96 | hs-source-dirs : src 97 | default-language : Haskell2010 98 | ghc-options : -Wall 99 | exposed-modules : $1 100 | build-depends : base == 4.*, 101 | $0 102 | endsnippet 103 | -------------------------------------------------------------------------------- /UltiSnips/cpp.snippets: -------------------------------------------------------------------------------- 1 | ########################################################################### 2 | # Global functions # 3 | ########################################################################### 4 | 5 | global !p 6 | 7 | def write_docstring_args(arglist, snip): 8 | args = str(arglist).split(',') 9 | 10 | if len(args) > 1: 11 | c = 0 12 | for arg in args: 13 | if c == 0: 14 | snip.rv += arg 15 | c = 1 16 | else: 17 | snip += '* : %s' % arg.strip() 18 | else: 19 | snip.rv = args[0] 20 | 21 | 22 | endglobal 23 | 24 | ########################################################################### 25 | # Snippets # 26 | ########################################################################### 27 | snippet try 28 | try 29 | { 30 | ${VISUAL}${1} 31 | } 32 | catch (${2:...}) 33 | { 34 | ${3} 35 | } 36 | endsnippet 37 | 38 | snippet fori 39 | for (${1:size_t} ${2:i}=${3:0}; $2 < ${4}; ++$2) 40 | { 41 | ${VISUAL}${0} 42 | } 43 | endsnippet 44 | 45 | # range based for ( C++11 feature ) 46 | snippet fore 47 | for (${1:auto} ${2:i} : ${3:container}) 48 | { 49 | ${VISUAL}${4} 50 | } 51 | endsnippet 52 | 53 | snippet namespace 54 | namespace ${1:#:name} 55 | { 56 | 57 | ${VISUAL}${0} 58 | 59 | } // namespace $1 60 | endsnippet 61 | 62 | snippet mfun 63 | ${4:void} ${1:`substitute(substitute(expand("%:t:r"), "^\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")`}::${2:MemberFunction}(${3}) 64 | { 65 | ${VISUAL}${0} 66 | } 67 | endsnippet 68 | 69 | snippet skel 70 | #include 71 | using namespace std; 72 | 73 | int main(int argc, char const* argv[]) 74 | { 75 | ${0:cout << "hello, world!" << endl;} 76 | 77 | return 0; 78 | } 79 | endsnippet 80 | 81 | snippet log 82 | LOG_${1:INFO}( 83 | ${2:kInfo}, 84 | format(translate(${3})) 85 | % ${4}, 86 | ${5:""}); 87 | 88 | ${0} 89 | endsnippet 90 | 91 | snippet fnc "Basic c++ doxygen function template" b 92 | /** 93 | * @brief: ${4:brief} 94 | * 95 | * @param: `!p write_docstring_args(t[3],snip)` 96 | * 97 | * @return: `!p snip.rv = t[1]` 98 | */ 99 | ${1:ReturnType} ${2:FunctionName}(${3:param}) 100 | { 101 | ${0:FunctionBody} 102 | } 103 | endsnippet 104 | -------------------------------------------------------------------------------- /UltiSnips/cpp_guard.snippets: -------------------------------------------------------------------------------- 1 | global !p 2 | import os 3 | import sys 4 | import re 5 | import itertools 6 | from glob import glob 7 | 8 | def split_path(relpath): 9 | return os.path.abspath(relpath).split(os.sep) 10 | 11 | def fqn_to_guard(fqn): 12 | return ('_' + re.sub(r'[.-]', '_', '_'.join(fqn)) + '_').upper() 13 | 14 | def fqn_to_namespaces(fqn): 15 | return '::'.join(fqn[:-1]) 16 | 17 | def fqn_to_classname(fqn): 18 | classname = re.sub( 19 | r'(?:^|_)([^_])', 20 | lambda m: m.group(1).upper(), 21 | os.path.splitext(fqn[-1])[0]) 22 | 23 | return classname 24 | 25 | def fqn_to_full_classname(fqn): 26 | return '::'.join((fqn_to_namespaces(fqn), fqn_to_classname(fqn))) 27 | 28 | def path_to_fqn(relpath, base='', depth=-1): 29 | if base: 30 | relpath = os.path.relpath(relpath, base) 31 | 32 | ret = [] 33 | if snip.v.text: 34 | ret = [v for v in re.split(r'::|/|\\', snip.v.text) if v] 35 | 36 | if not relpath: 37 | return ret 38 | 39 | paths = [ 40 | x 41 | for x in os.path.normpath(relpath).split(os.sep) 42 | if x not in ('src','')] 43 | 44 | start = len(paths) - depth - 1 45 | if depth < 0 or start < 0: 46 | start = 0 47 | 48 | ret += paths[start:] 49 | return ret 50 | 51 | def header_fqn(path, depth=''): 52 | depth = int(depth) if depth else 0 53 | 54 | abspath = os.path.abspath(path) 55 | parent = os.path.dirname(abspath) 56 | while parent: 57 | if os.path.basename(parent) in ['include', 'lib', 'libs', '3rd']: 58 | return path_to_fqn(abspath, parent) 59 | 60 | new_parent = os.path.dirname(parent) 61 | if new_parent == parent: 62 | break 63 | 64 | parent = new_parent 65 | 66 | return path_to_fqn(abspath, depth=depth) 67 | 68 | def find_header(path, filename, recursive=False): 69 | path = os.path.abspath(path) 70 | HEADER_EXTS = ('.h', '.hpp', '.hh') 71 | 72 | root_name = os.path.splitext(filename)[0] 73 | 74 | for ext in HEADER_EXTS: 75 | header = root_name + ext 76 | pathname = os.path.join(path, '**', header) if recursive else os.path.join(path, header) 77 | result = glob(pathname, recursive=recursive) 78 | if result: 79 | return result 80 | 81 | return [] 82 | 83 | 84 | def rank_file(lpath, rpath): 85 | def rank(lhs, rhs): 86 | if len(lhs) == 0: 87 | return 0 88 | 89 | for i in range(0, len(rhs)): 90 | if lhs[0] == rhs[i]: 91 | return max(1+rank(lhs[1:], rhs[i+1:]), rank(lhs[1:], rhs)) 92 | 93 | return rank(lhs[1:], rhs) 94 | 95 | lhs = lpath.split(os.sep) 96 | rhs = rpath.split(os.sep) 97 | 98 | return max(rank(lhs, rhs), rank(rhs, lhs)) 99 | 100 | 101 | def best_match(src_file, headers): 102 | print(sorted(headers, key=len)) 103 | print(sorted( 104 | sorted(headers, key=len), 105 | key=lambda f: rank_file(src_file, f), 106 | reverse=True)) 107 | 108 | return sorted( 109 | sorted(headers, key=len), 110 | key=lambda f: rank_file(src_file, f), 111 | reverse=True)[0] 112 | 113 | def source_fqn(src_file, depth=''): 114 | depth = int(depth) if depth else 0 115 | 116 | src_file = os.path.abspath(src_file) 117 | parent = os.path.dirname(src_file) 118 | filename = os.path.basename(src_file) 119 | 120 | headers = find_header(parent, filename) 121 | if headers: 122 | return header_fqn(headers[0]) 123 | 124 | include_path = '' 125 | 126 | while parent: 127 | if os.path.basename(parent) in ['lib', 'libs', '3rd']: 128 | include_path = parent 129 | break 130 | 131 | for d in ('include', ): 132 | if os.path.exists(os.path.join(parent, d)): 133 | include_path = os.path.join(parent, d) 134 | break 135 | 136 | if include_path: 137 | break 138 | 139 | new_parent = os.path.dirname(parent) 140 | if new_parent == parent: 141 | break 142 | 143 | parent = new_parent 144 | 145 | if include_path: 146 | headers = find_header(include_path, filename, recursive=True) 147 | if len(headers) > 0: 148 | header = best_match(src_file, headers) 149 | return path_to_fqn(header, include_path, depth=depth) 150 | elif src_file.startswith(include_path): 151 | return path_to_fqn(os.path.splitext(src_file)[0] + '.h', include_path, depth=depth) 152 | 153 | return path_to_fqn(os.path.splitext(src_file)[0] + '.h', depth=depth) 154 | 155 | def source_include(src_file, depth=-1): 156 | sqn = source_fqn(src_file, depth) 157 | if len(sqn) > 1: 158 | return '<' + '/'.join(sqn) + '>' 159 | 160 | return '"' + '/'.join(sqn) + '"' 161 | endglobal 162 | 163 | # Include-Guard,适用于目录层次中有include目录的头文件 164 | # 可以选中额外的namespace(如foo:bar)后再扩展 165 | snippet "header(\d*)" "header for include/*, header2 for 2 level dirs" br 166 | /** 167 | * @file 168 | * @brief `!p snip.rv = fqn_to_classname(header_fqn(path, depth=match.group(1)))`类的声明 169 | * @author `!v $USER` 170 | */ 171 | #ifndef `!p snip.rv = fqn_to_guard(header_fqn(path, depth=match.group(1)))` 172 | #define `!p snip.rv = fqn_to_guard(header_fqn(path, depth=match.group(1)))` 173 | `!p snip.rv = '' if match.group(1)=='0' else '\n' + '\n'.join('namespace ' + n + ' {' for n in header_fqn(path, depth=match.group(1))[:-1]) + '\n'` 174 | /** 175 | * @brief ${1} 176 | */ 177 | class `!p snip.rv = fqn_to_classname(header_fqn(path, depth=match.group(1)))` 178 | { 179 | public: 180 | ${0} 181 | }; 182 | `!p snip.rv = '\n'.join('} // namespace ' + n + ' {' for n in reversed(header_fqn(path, depth=match.group(1))[:-1]))` 183 | #endif // `!p snip.rv = fqn_to_guard(header_fqn(path, depth=match.group(1)))` 184 | endsnippet 185 | 186 | # C++源文件框架,适用于目录层次中有src目录,头文件放在src同层的include下的情况。会自动从include下找到与本文件同名的头文件,按其目录确定最终的名字空间 187 | snippet "src(\d*)" "src for src/*, src2 for 2 level dirs" br 188 | /** 189 | * @file 190 | * @brief `!p snip.rv = fqn_to_classname(source_fqn(path, depth=match.group(1)))`类的定义 191 | * @author `!v $USER` 192 | */ 193 | #include `!p snip.rv = source_include(path, depth=match.group(1))` 194 | `!p snip.rv = '' if match.group(1)=='0' else '\n' + '\n'.join('namespace ' + n + ' {' for n in source_fqn(path, depth=match.group(1))[:-1])` 195 | 196 | ${0} 197 | `!p snip.rv = '\n'.join('} // namespace ' + n for n in reversed(source_fqn(path, depth=match.group(1))[:-1]))` 198 | endsnippet 199 | -------------------------------------------------------------------------------- /UltiSnips/cpp_unittest.snippets: -------------------------------------------------------------------------------- 1 | # Boost.Test,必须放在unittest目录下,且与unittest同层有include目录 2 | snippet ut "unittest skel" b 3 | #include 4 | #include 5 | #include 6 | #include <`!v substitute(findfile(substitute(expand("%:t:r"), "^test_\\?", "", "") . ".h", substitute(expand("%:p"), "\\ 7 | 8 | using namespace `!v substitute(substitute(fnamemodify(substitute(findfile(substitute(expand("%:t:r"), "^test_\\?", "", "") . ".h", substitute(expand("%:p"), "\\ 31 | #include 32 | #include 33 | #include "../src/`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`.h" 34 | 35 | using namespace sscc`!v substitute(substitute(substitute(substitute(expand("%:p:h"), "/unittest\\>", "", ""), "[.-]", "_", "g"), "^.*\\(\\(/[^/]\\+\\)\\{1}\\)$", "\\1", ""), "/", "::", "g")`; 36 | using boost::system::error_code; 37 | 38 | BOOST_AUTO_TEST_SUITE(test_`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`); 39 | 40 | struct Fixture 41 | { 42 | `!v substitute(substitute(expand("%:t:r"), "^test_\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")` ${1:`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`}; 43 | 44 | Fixture() 45 | : $1(${2}) 46 | { 47 | } 48 | }; 49 | 50 | ${0} 51 | 52 | BOOST_AUTO_TEST_SUITE_END() 53 | endsnippet 54 | 55 | # Boost.Test 56 | snippet sut2 "sscc::*::*" b 57 | #include 58 | #include 59 | #include 60 | #include "../src/`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`.h" 61 | 62 | using namespace sscc`!v substitute(substitute(substitute(substitute(expand("%:p:h"), "/unittest\\>", "", ""), "[.-]", "_", "g"), "^.*\\(\\(/[^/]\\+\\)\\{2}\\)$", "\\1", ""), "/", "::", "g")`; 63 | using boost::system::error_code; 64 | 65 | BOOST_AUTO_TEST_SUITE(test_`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`); 66 | 67 | struct Fixture 68 | { 69 | `!v substitute(substitute(expand("%:t:r"), "^test_\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")` ${1:`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`}; 70 | 71 | Fixture() 72 | : $1(${2}) 73 | { 74 | } 75 | }; 76 | 77 | ${0} 78 | 79 | BOOST_AUTO_TEST_SUITE_END() 80 | endsnippet 81 | 82 | # Boost.Test 83 | snippet sut3 "sscc::*::*::*" b 84 | #include 85 | #include 86 | #include 87 | #include "../src/`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`.h" 88 | 89 | using namespace sscc`!v substitute(substitute(substitute(substitute(expand("%:p:h"), "/unittest\\>", "", ""), "[.-]", "_", "g"), "^.*\\(\\(/[^/]\\+\\)\\{3}\\)$", "\\1", ""), "/", "::", "g")`; 90 | using boost::system::error_code; 91 | 92 | BOOST_AUTO_TEST_SUITE(test_`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`); 93 | 94 | struct Fixture 95 | { 96 | `!v substitute(substitute(expand("%:t:r"), "^test_\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")` ${1:`!v substitute(expand("%:t:r"), "^test_\\?", "", "")`}; 97 | 98 | Fixture() 99 | : $1(${2}) 100 | { 101 | } 102 | }; 103 | 104 | ${0} 105 | 106 | BOOST_AUTO_TEST_SUITE_END() 107 | endsnippet 108 | 109 | # Comment for Test Case 110 | snippet tc "unittest for any class" b 111 | /** 112 | * @class `!v substitute(substitute(fnamemodify(substitute(findfile(substitute(expand("%:t:r"), "^test_\\?", "", "") . ".h", substitute(expand("%:p"), "\\输入数据: ${2}\n 115 | * 预期输出: ${3} 116 | */ 117 | BOOST_FIXTURE_TEST_CASE(Test${4}, ${5:Fixture}) 118 | { 119 | ${0} 120 | } 121 | endsnippet 122 | 123 | snippet tc "data-driven unittest" b 124 | /** 125 | * @class `!v substitute(substitute(fnamemodify(substitute(findfile(substitute(expand("%:t:r"), "^test_\\?", "", "") . ".h", substitute(expand("%:p"), "\\输入数据: ${2}\n 128 | * 预期输出: ${3} 129 | */ 130 | BOOST_DATA_TEST_CASE(Test${4}, ${5:dataset}, ${6:param}) 131 | { 132 | ${0} 133 | } 134 | endsnippet 135 | 136 | snippet tc "data-driven unittest with fixture" b 137 | /** 138 | * @class `!v substitute(substitute(fnamemodify(substitute(findfile(substitute(expand("%:t:r"), "^test_\\?", "", "") . ".h", substitute(expand("%:p"), "\\输入数据: ${2}\n 141 | * 预期输出: ${3} 142 | */ 143 | BOOST_DATA_TEST_CASE_F(${4:Fixture}, Test${5}, ${6:dataset}, ${7:param}) 144 | { 145 | ${0} 146 | } 147 | endsnippet 148 | 149 | # Comment for Sscc Test Case 150 | snippet stc1 "unittest for sscc::*" b 151 | /** 152 | * @class sscc::`!v substitute(substitute(substitute(substitute(expand("%:p:h"), "/unittest\\>", "", ""), "[.-]", "_", "g"), "^.*/\\([^/]\\+\\)$", "\\1", ""), "/", "::", "g")`::`!v substitute(substitute(expand("%:t:r"), "^test_\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")` 153 | * @test ${1}\n 154 | * 输入数据: ${2}\n 155 | * 预期输出: ${3} 156 | */ 157 | BOOST_FIXTURE_TEST_CASE(Test${4}, Fixture) 158 | { 159 | ${0} 160 | } 161 | endsnippet 162 | 163 | # Comment for Sscc Test Case 164 | snippet stc2 "unittest for sscc::*::*" b 165 | /** 166 | * @class sscc::`!v substitute(substitute(substitute(substitute(expand("%:p:h"), "/unittest\\>", "", ""), "[.-]", "_", "g"), "^.*/\\([^/]\\+/[^/]\\+\\)$", "\\1", ""), "/", "::", "g")`::`!v substitute(substitute(expand("%:t:r"), "^test_\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")` 167 | * @test ${1}\n 168 | * 输入数据: ${2}\n 169 | * 预期输出: ${3} 170 | */ 171 | BOOST_FIXTURE_TEST_CASE(Test${4}, Fixture) 172 | { 173 | ${0} 174 | } 175 | endsnippet 176 | 177 | # Comment for Sscc Test Case 178 | snippet stc3 "unittest for sscc::*::*::*" b 179 | /** 180 | * @class sscc::`!v substitute(substitute(substitute(substitute(expand("%:p:h"), "/unittest\\>", "", ""), "[.-]", "_", "g"), "^.*/\\([^/]\\+/[^/]\\+/[^/]\\+\\)$", "\\1", ""), "/", "::", "g")`::`!v substitute(substitute(expand("%:t:r"), "^test_\\(.\\)", "\\u\\1", ""),"_\\(.\\)","\\u\\1","g")` 181 | * @test ${1}\n 182 | * 输入数据: ${2}\n 183 | * 预期输出: ${3} 184 | */ 185 | BOOST_FIXTURE_TEST_CASE(Test${4}, Fixture) 186 | { 187 | ${0} 188 | } 189 | endsnippet 190 | 191 | -------------------------------------------------------------------------------- /UltiSnips/dockerfile.snippets: -------------------------------------------------------------------------------- 1 | snippet skel 2 | FROM ${1:base} 3 | 4 | ARG BUILD_DATE 5 | ARG VCS_REF 6 | 7 | LABEL org.label-schema.build-date=$BUILD_DATE \ 8 | org.label-schema.vcs-url="https://github.com/${2:repo}.git" \ 9 | org.label-schema.vcs-ref=$VCS_REF \ 10 | org.label-schema.schema-version="1.0.0-rc1" 11 | 12 | WORKDIR ${3:/documents} 13 | 14 | ${0} 15 | 16 | ENTRYPOINT ["${4:/bin/sh}"] 17 | endsnippet 18 | -------------------------------------------------------------------------------- /UltiSnips/haskell.snippets: -------------------------------------------------------------------------------- 1 | # vim: foldmethod=marker 2 | 3 | # Pragmas {{{ 4 | 5 | snippet pragma "Compiler pragma" !b 6 | {-# $1 #-} 7 | endsnippet 8 | 9 | snippet lang "LANGUAGE pragma" !b 10 | {-# LANGUAGE $1 #-} 11 | endsnippet 12 | 13 | snippet ghcopt "GHC options" !b 14 | {-# OPTIONS_GHC $1 #-} 15 | endsnippet 16 | 17 | snippet preproc "Preprocessor" !b 18 | {-# OPTIONS_GHC -F -pgmF ${1:executable} #-} 19 | endsnippet 20 | 21 | snippet trhsx "HSP/HSX Preprocessor (trhsx)" !b 22 | {-# OPTIONS_GHC -F -pgmF trhsx #-} 23 | endsnippet 24 | 25 | snippet hsx "HSP/HSX Preprocessor (hsx2hs)" !b 26 | {-# OPTIONS_GHC -F -pgmF hsx2hs #-} 27 | endsnippet 28 | 29 | snippet inline "INLINE pragma" !b 30 | {-# INLINE ${1:name} #-} 31 | endsnippet 32 | 33 | snippet inlinable "INLINABLE pragma" !b 34 | {-# INLINABLE ${1:name} #-} 35 | endsnippet 36 | 37 | snippet noinline "NOINLINE pragma" !b 38 | {-# NOINLINE ${1:name} #-} 39 | endsnippet 40 | 41 | snippet specialize "SPECIALIZE pragma" !b 42 | {-# SPECIALIZE ${1:name} :: ${2:type} #-} 43 | endsnippet 44 | 45 | snippet rules "RULES pragma" !b 46 | {-# RULES "${1:name}" ${2:rule} #-} 47 | endsnippet 48 | 49 | snippet unpack "UNPACK pragma" !w 50 | {-# UNPACK #-} 51 | endsnippet 52 | 53 | snippet nounpack "NOUNPACK pragma" !w 54 | {-# NOUNPACK #-} 55 | endsnippet 56 | 57 | # }}} Pragmas 58 | 59 | # Statements {{{ 60 | 61 | global !p 62 | def last_module(mod): 63 | return mod.rstrip('.').rsplit('.', 1)[-1] 64 | 65 | def space_if(p): 66 | return " " if p else "" 67 | endglobal 68 | 69 | snippet module "Module declaration" !b 70 | module `!v substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` 71 | ( ${1} 72 | ) where 73 | 74 | `!v expand('%') =~ 'Main' ? "\nmain :: IO ()\nmain = undefined" : ""`$0 75 | endsnippet 76 | 77 | snippet mod "Module declaration" !b 78 | module `!v substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` where 79 | 80 | `!v expand('%') =~ 'Main' ? "\nmain :: IO ()\nmain = undefined" : ""`$0 81 | endsnippet 82 | 83 | snippet main "Main module" !b 84 | module Main (main) where 85 | 86 | main :: IO () 87 | main = ${1:error "undefined: \`main' in `!v expand('%')`"} 88 | endsnippet 89 | 90 | snippet imp "Import module" !b 91 | import ${1:Module} ( $2 ) 92 | $0 93 | endsnippet 94 | 95 | snippet qual "Qualified import, name by last module" !b 96 | import qualified ${1:Module} as ${2:`!p snip.rv = last_module(t[1])`} 97 | endsnippet 98 | 99 | snippet as "Qualified import, name by first character of last module" !b 100 | import qualified ${1:Module} as ${2:`!p snip.rv = last_module(t[1])[0]`} 101 | endsnippet 102 | 103 | snippet containers "Import modules for data structures, qualified" !b 104 | import qualified Data.HashMap.Lazy as HashMap 105 | import qualified Data.HashSet as HashSet 106 | import qualified Data.IntMap as IntMap 107 | import qualified Data.IntSet as IntSet 108 | import qualified Data.IxSet as IxSet 109 | import qualified Data.Map as Map 110 | import qualified Data.Sequence as Seq 111 | import qualified Data.Set as Set 112 | endsnippet 113 | 114 | snippet data "Algebraic data type" !b 115 | data ${1:Type} ${2:variables}`!p snip.rv = space_if(t[2])`= ${3:Constructor} | ${0:Constructor} 116 | endsnippet 117 | 118 | snippet rec "Data record" !b 119 | data ${1:Type} = $1 120 | { ${3:field} :: ${4:Type} 121 | } deriving (${5:Classes}) 122 | endsnippet 123 | 124 | snippet new "Newtype" !b 125 | newtype ${1:Type} ${2:variables}`!p snip.rv = space_if(t[2])`= $1 ${3:Oldtype} 126 | endsnippet 127 | 128 | snippet cls "Type class definition" !b 129 | class ${1:Name} where 130 | $0 131 | endsnippet 132 | 133 | snippet in "Instance definition" !b 134 | instance ${1:Class} ${2:Type} where 135 | $0 136 | endsnippet 137 | 138 | # }}} Statements 139 | 140 | # Definitions {{{ 141 | 142 | snippet :: "Type signature" !b 143 | ${1:name} :: ${2:Type} 144 | endsnippet 145 | 146 | snippet => "Class constraint" !w 147 | ${1:Class} ${2:variable} => $2 148 | endsnippet 149 | 150 | snippet fun "Function definition" !b 151 | -- | ${5:Documentation for '$1'} 152 | $1 :: ${3:Type} -> ${4:Type} 153 | ${1:name} ${2:args} = ${6:error "undefined: \`$1' in `!v expand('%')`"} 154 | endsnippet 155 | 156 | snippet fun[] "Function definition for list patterns" !b 157 | -- | ${3:Documentation for $1} 158 | ${1:name} :: [${2:Type}] 159 | $1 [] = ${3:undefined} 160 | $1 ${4:(x:xs)} = ${5:error "undefined: \`$1' in `!v expand('%')`"} 161 | endsnippet 162 | 163 | snippet def "Value definition" !b 164 | -- | ${4:Documentation for $1} 165 | $1 :: ${2:Type} 166 | ${1:name} = ${5:error "undefined: \`$1' in `!v expand('%')`"} 167 | endsnippet 168 | 169 | snippet = "Function clause" !b 170 | ${1:name} ${2:pattern} = ${3:undefined} 171 | endsnippet 172 | 173 | snippet 2= "Function clause" !b 174 | ${1:name} ${2:pattern} = ${3:undefined} 175 | $1 ${4:pattern} = ${5:undefined} 176 | endsnippet 177 | 178 | snippet 3= "Function clause" !b 179 | ${1:name} ${2:pattern} = ${3:undefined} 180 | $1 ${4:pattern} = ${5:undefined} 181 | $1 ${6:pattern} = ${7:undefined} 182 | endsnippet 183 | 184 | snippet | "Guard" !b 185 | | ${1:predicate} = ${2:undefined} 186 | endsnippet 187 | 188 | # }}} Definitions 189 | 190 | # Expressions {{{ 191 | 192 | snippet \ "Lambda" !w 193 | \\ ${1:args} -> ${2:expression} 194 | endsnippet 195 | 196 | snippet if "Boolean conditional" !w 197 | if ${1:condition} 198 | then ${2:expression} 199 | else ${3:expression} 200 | endsnippet 201 | 202 | snippet case "Pattern match" !w 203 | case ${1:scrutinee} of 204 | ${2:pattern} -> ${3:expression} 205 | endsnippet 206 | 207 | snippet qq "Quasi quote" !w 208 | [${1:quoter}|${2:content}|] 209 | endsnippet 210 | 211 | snippet [|] "List comprehension" !w 212 | [${3:foo }$1 | ${1:x} <- ${2:xs} ] 213 | endsnippet 214 | 215 | snippet let "let ... in ..." !b 216 | let 217 | ${1:name} = ${2:expression} 218 | in ${3:expression} 219 | endsnippet 220 | # }}} Expressions 221 | 222 | snippet impqq "Import raw-string-qq" 223 | {-# LANGUAGE QuasiQuotes #-} 224 | 225 | import Text.RawString.QQ 226 | $0 227 | endsnippet 228 | -------------------------------------------------------------------------------- /UltiSnips/haskell_hspec.snippets: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # UltiSnips snippets for Hspec - http://hspec.github.io/ 3 | # 4 | # Many triggers modeled on RSpec triggers. 5 | #------------------------------------------------------------------------------- 6 | 7 | priority 0 8 | 9 | extends haskell 10 | 11 | # See: http://hspec.github.io/hspec-discover.html 12 | snippet hdisc "Hspec: discovery magic preproc comment" b 13 | {-# OPTIONS_GHC -F -pgmF hspec-discover #-} 14 | $0 15 | endsnippet 16 | 17 | 18 | # This can be used as a standalone main suite, or a single file when using 19 | # discovery. The main method then allows it to be individually tested from GHCi. 20 | snippet spec "Hspec: new suite" b 21 | module ${1:`!v substitute(substitute(expand('%:r'), '\C^\%(tests\?[/\\]\)\(.*\)Spec$\|.*', '\1', ''), '[/\\]', '.', 'g')`}Spec (main, spec) where 22 | 23 | import Test.Hspec 24 | import Test.QuickCheck 25 | import $1 26 | 27 | main :: IO () 28 | main = hspec spec 29 | 30 | spec :: Spec 31 | spec = do 32 | describe "${2:$1}" $ do 33 | $0 34 | endsnippet 35 | 36 | 37 | snippet hspec "Hspec: begin suite" 38 | hspec $ do 39 | des$0 40 | endsnippet 41 | 42 | 43 | snippet bef "Hspec: suite with before hook" 44 | hspec $ before ${1:ioAction} $ do 45 | des$0 46 | endsnippet 47 | 48 | 49 | snippet aft "Hspec: suite with after hook" 50 | hspec $ after ${1:ioAction} $ do 51 | des$0 52 | endsnippet 53 | 54 | 55 | snippet around "Hspec: suite with around hook" 56 | hspec $ around ${1:ioWrapper} $ do 57 | des$0 58 | endsnippet 59 | 60 | 61 | snippet pw "Hspec: pendingWith" b 62 | pendingWith "${1:explanation}" 63 | endsnippet 64 | 65 | 66 | snippet des "Hspec: describe block" b 67 | describe "${1:subject}" $ do 68 | $0 69 | endsnippet 70 | 71 | 72 | snippet con "Hspec: context block" b 73 | context "${1:context}" $ do 74 | $0 75 | endsnippet 76 | 77 | 78 | snippet it "Hspec: it block" b 79 | it "${1:does something}" $ do 80 | ${0:pending} 81 | endsnippet 82 | 83 | 84 | # Prefer active voice, but for some this is an ingrained habit. 85 | snippet its "Hspec: it should" b 86 | it "should ${1:do something}" $ do 87 | $0 88 | endsnippet 89 | 90 | 91 | snippet itr "Hspec: it with resource loaner pattern" b 92 | it "${1:does something}" $ ${2:withResource} $ \\${3:rs} -> do 93 | $0 94 | endsnippet 95 | 96 | #------------------------------------------------------------------------------- 97 | # Expectations 98 | # 99 | # TODO: has this behavior broken in UltiSnips? Doesn't seem to work for me anymore 100 | # http://fueledbylemons.com/blog/2011/07/27/why-ultisnips/#different-beginning-of-line-snippet 101 | #------------------------------------------------------------------------------- 102 | 103 | snippet shb "Hspec: shouldBe" 104 | \`shouldBe\` ${1:result} 105 | endsnippet 106 | 107 | 108 | priority 1 109 | snippet shb "Hspec: shouldBe" !b 110 | ${1:subject} \`shouldBe\` ${2:result} 111 | endsnippet 112 | priority 0 113 | 114 | 115 | snippet shret "Hspec: shouldReturn" 116 | \`shouldReturn\` ${1:result} 117 | endsnippet 118 | 119 | 120 | priority 1 121 | snippet shret "Hspec: shouldReturn" !b 122 | ${1:subject} \`shouldReturn\` ${2:result} 123 | endsnippet 124 | priority 0 125 | 126 | 127 | snippet shs "Hspec: shouldSatisfy" 128 | \`shouldSatisfy\` ${1:(${2:not . null})} 129 | endsnippet 130 | 131 | 132 | priority 1 133 | snippet shs "Hspec: shouldSatisfy" !b 134 | ${1:subject} \`shouldSatisfy\` ${2:(${3:not . null})} 135 | endsnippet 136 | priority 0 137 | 138 | 139 | snippet sht "Hspec: shouldThrow" 140 | \`shouldThrow\` ${1:anyException} 141 | endsnippet 142 | 143 | 144 | priority 1 145 | snippet sht "Hspec: shouldThrow" !b 146 | ${1:evaluate (${2:subject})} \`shouldThrow\` ${3:anyException} 147 | endsnippet 148 | priority 0 149 | 150 | #------------------------------------------------------------------------------- 151 | # Hspec with QuickCheck 152 | #------------------------------------------------------------------------------- 153 | 154 | snippet itp "Hspec: it with QuickCheck property" b 155 | it "${1:does something}" $ property $ 156 | \\${3:subj} -> $0 157 | endsnippet 158 | 159 | -------------------------------------------------------------------------------- /UltiSnips/html.snippets: -------------------------------------------------------------------------------- 1 | snippet script " 5 | endsnippet 6 | 7 | snippet script "HTML inline 11 | endsnippet 12 | 13 | snippet script "HTML 15 | endsnippet 16 | 17 | -------------------------------------------------------------------------------- /UltiSnips/impressjs.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "impress.js template" b 2 | 3 | 4 | 5 | 6 | 7 | ${1:幻灯标题} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

您正在使用的浏览器不支持impress.js需要的功能,因此只能看到简化版本。

18 |

请使用最新版本的ChromeSafariFirefox浏览器以取得最佳效果。

19 |
20 | 21 |
22 | 23 | 24 |
25 |

${2:$1}

26 |

${3:`!v $USER`}

27 |

${4:`!v strftime("%Y-%m-%d")`}

28 |
29 | 30 |
31 | ${0:输入需要的内容} 32 |
33 | 34 |
35 |
36 |

Powered by impress.js*

37 |
38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | endsnippet 56 | 57 | snippet modeline "vim modeline" b 58 | 59 | endsnippet 60 | 61 | snippet step "impress.js step" b 62 |
63 |

$1

64 | $0 65 |
66 | 67 | endsnippet 68 | 69 | snippet slide "impress.js slide" b 70 |
71 |

$1

72 | $0 73 |
74 | 75 | endsnippet 76 | 77 | snippet markdown "impress.js markdown slide" bs 78 |
79 | 84 |
85 | 86 | endsnippet 87 | 88 | snippet markdown "impress.js markdown block" b 89 |
90 | 93 |
94 | endsnippet 95 | 96 | snippet section "impress section slide" b 97 |
98 |

$1

99 |
100 | 101 | endsnippet 102 | 103 | snippet v2 "split into two part vertically" b 104 |
105 |
106 | $0 107 |
108 |
109 |
110 |
111 | 112 | endsnippet 113 | 114 | snippet h2 "split into two part horizontally" b 115 |
116 |
117 | $0 118 |
119 |
120 |
121 |
122 | 123 | endsnippet 124 | 125 | snippet notes "insert notes" b 126 |
127 | $0 128 |
129 | endsnippet 130 | 131 | snippet goto "goto-key" 132 | data-goto-key-list="${1:ArrowRight}" data-goto-next-list="${2:SlideId}" 133 | endsnippet 134 | 135 | snippet rel-to "data-rel-to" 136 | data-rel-to="${1:slideId}" data-rel-reset data-rel-x="1w" 137 | endsnippet 138 | 139 | snippet reset "data-rel-reset" 140 | data-rel-reset data-rel-${1:x}="${2:1w}" 141 | endsnippet 142 | -------------------------------------------------------------------------------- /UltiSnips/javascript.snippets: -------------------------------------------------------------------------------- 1 | snippet r "require" b 2 | var ${1:module} = require('${2:$1}') 3 | $0 4 | endsnippet 5 | snippet gur "require gulp" b 6 | var ${1:gulp} = require('gulp${2:-$1}') 7 | $0 8 | endsnippet 9 | snippet gut "gulp task" b 10 | gulp.task('${1:default}', ${2:['${3:dependency}'], }function(${4:callback}) { 11 | $0 12 | }) 13 | endsnippet 14 | snippet guw "gulp watch" b 15 | gulp.watch('$1', ['${2:task}']) 16 | endsnippet 17 | snippet gus "gulp src" b 18 | return gulp.src('$1') 19 | $0 20 | endsnippet 21 | snippet gup "gulp pipe with string arg" b 22 | .pipe($1(${2:'$3'})) 23 | $0 24 | endsnippet 25 | snippet gupo "gulp pipe with object arg" b 26 | .pipe($1(${2:{$3: ${4:‘$5‘}}})) 27 | $0 28 | endsnippet 29 | snippet gud "gulp destination" b 30 | .pipe(gulp.dest('$1')) 31 | endsnippet 32 | snippet us "use strict" b 33 | 'use strict' 34 | $0 35 | endsnippet 36 | snippet me "module exports" b 37 | module.exports = function($1) { 38 | $0 39 | } 40 | endsnippet 41 | snippet cl "console.log" b 42 | console.log(${1:'${2:message}'}) 43 | $0 44 | endsnippet 45 | snippet imp "import module" b 46 | import ${1:module} from '${2:$1}' 47 | $0 48 | endsnippet 49 | snippet RC "React Class Component" b 50 | class ${1:MyCmponent} extends React.Component { 51 | render() { 52 | return $0 53 | } 54 | } 55 | endsnippet 56 | snippet iife "immediatelly invoced function expression" b 57 | (function($1){ 58 | $0 59 | })($2) 60 | endsnippet 61 | 62 | -------------------------------------------------------------------------------- /UltiSnips/javascript_node.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "file handle skel" b 2 | #!/usr/bin/env node 3 | 4 | const path = require('path'); 5 | const glob = require('glob'); 6 | const fs = require('fs'); 7 | 8 | var files = glob.sync('*/index.html'); 9 | var outPath = path.resolve('dist'); 10 | 11 | if (!fs.existsSync(outPath)){ 12 | fs.mkdirSync(outPath); 13 | } 14 | 15 | for (var i in presentations) { 16 | var name = path.basename(path.dirname(presentations[i])); 17 | 18 | process.stdout.write(` Processing ${i*1+1}/${count}: ${name}...`); 19 | process.stdout.write(`done.\n`); 20 | } 21 | 22 | process.stdout.write(` All done.\n`); 23 | endsnippet 24 | 25 | snippet arg "yargs" b 26 | const argv = require('yargs') 27 | .option('times', { 28 | alias: 't', 29 | description: 'The argument', 30 | type: 'number' 31 | }) 32 | .default({ 33 | 'times': 3 34 | }) 35 | .help() 36 | .strict() 37 | .demandCommand(0) 38 | .example('\$0 -a 15', 'help string') 39 | .check((argv, options) => { 40 | return true; 41 | }) 42 | .parse(); 43 | 44 | for (var i=0; i 75 | console.log(`GitGraph server listening on port ${port}!`) 76 | ); 77 | endsnippet 78 | -------------------------------------------------------------------------------- /UltiSnips/lilypond.snippets: -------------------------------------------------------------------------------- 1 | snippet ver "\version" b 2 | \version "${1:2.23.2}" 3 | endsnippet 4 | 5 | snippet paper "Paper setting" b 6 | \paper { 7 | #(set-paper-size "${2:a4}") 8 | two-sided = ##${3:t} 9 | 10 | binding-offset = ${4:10}\mm % scaled to paper-size 11 | indent = ${5:15}\mm % scaled to paper-size 12 | 13 | scoreTitleMarkup = \markup { 14 | \fill-line { 15 | \null 16 | \fontsize #4 \bold \fromproperty #'header:piece 17 | \fromproperty #'header:composer 18 | } 19 | } 20 | } 21 | ${0} 22 | endsnippet 23 | 24 | snippet book "bookpart" b 25 | \bookpart { 26 | \header { 27 | subtitle = "${1}" 28 | } 29 | $0 30 | } 31 | endsnippet 32 | 33 | snippet score "score" b 34 | \score { 35 | \header { 36 | piece = "${1:title}" 37 | % opus = "" 38 | % composer = "" 39 | } 40 | 41 | ${0:relative} 42 | } 43 | endsnippet 44 | 45 | snippet relative "Relative notes" 46 | \relative ${2:c'} 47 | { 48 | \clef "treble" 49 | \key ${3:c} ${4:\major} 50 | \time ${5:4/4} 51 | % \tempo 4 = 96 52 | 53 | ${0} 54 | } 55 | endsnippet 56 | 57 | snippet absolute "Absolute notes" 58 | \absolute 59 | { 60 | \clef "treble" 61 | \key ${2:c} ${3:\major} 62 | \time ${4:4/4} 63 | % \tempo 4. = 96 64 | 65 | ${0} 66 | } 67 | endsnippet 68 | 69 | snippet key "Key" b 70 | \key ${1:c} ${2:\major} 71 | endsnippet 72 | 73 | snippet bar "Bar" 74 | \bar "${1:||}" ${0} 75 | endsnippet 76 | 77 | snippet tuplet "Tuplet连音" 78 | \tuplet ${1:3/2} { ${2} } ${0} 79 | endsnippet 80 | 81 | snippet barc "barNumberCheck" 82 | \barNumberCheck #${0:number} 83 | endsnippet 84 | 85 | snippet barcheck "barNumberCheck" 86 | \barNumberCheck #${0:number} 87 | endsnippet 88 | 89 | snippet octc "octaveCheck" 90 | \octaveCheck ${0:c'} 91 | endsnippet 92 | 93 | snippet octavecheck "octaveCheck" 94 | \octaveCheck ${0:c'} 95 | endsnippet 96 | 97 | snippet transpose "transpose" 98 | \transpose ${1:c} ${2:f} { 99 | ${0} 100 | } 101 | endsnippet 102 | 103 | snippet toc "TOC" b 104 | \markuplist \table-of-contents 105 | endsnippet 106 | 107 | snippet toci "tocItem" b 108 | \tocItem \markup \\"${1}" 109 | endsnippet 110 | 111 | snippet melody "xxMelody" b 112 | "${1:`!v expand("%:t:r")`}Melody" = 113 | { 114 | \key ${2:\\"${1:`!v expand("%:t:r")`}Key"} ${3:\major} 115 | \transpose c $2 { 116 | ${4:\tempo 4 = ${5:60}} 117 | \melody 118 | } 119 | } 120 | endsnippet 121 | 122 | snippet inote "include note" 123 | \\pageBreak 124 | 125 | \\include "../${1:notes}/${2:name}.ily" 126 | 127 | \\tocItem \markup \concat { \\"${3:$2}Piece" "" } 128 | \\score { 129 | \\transpose c ${4:\\"$2Key"} { 130 | \\chooseMusic "a4" \\"$3NotesC" \\"$3MelodyC" 131 | } 132 | \\header { 133 | piece = \\"$3Piece" 134 | opus = \\"$3Opus" 135 | composer = \\"$3Composer" 136 | } 137 | } 138 | ${0} 139 | endsnippet 140 | 141 | snippet repeat "repeat" b 142 | \repeat volta ${1:2} 143 | { 144 | ${0} 145 | } 146 | endsnippet 147 | 148 | snippet repeat "repeat with alternative" b 149 | \repeat volta 2 150 | { 151 | ${0} 152 | } 153 | \alternative 154 | { 155 | { 156 | } 157 | { 158 | } 159 | } 160 | endsnippet 161 | 162 | snippet repeat "repeat with volta alternative" b 163 | \repeat volta 3 164 | { 165 | ${0} 166 | } 167 | \alternative 168 | { 169 | \volta 1,2 { 170 | } 171 | \volta 3 { 172 | } 173 | } 174 | endsnippet 175 | 176 | snippet partial 177 | \partial ${1:duration} 178 | endsnippet 179 | 180 | snippet func "define music functin" b 181 | ${1:funcname} = 182 | #(define-music-function 183 | (parser location ${2:note}) 184 | (${3:ly:music?}) 185 | #{ 186 | ${0} 187 | #}) 188 | endsnippet 189 | 190 | snippet parallel "parallelMusic" b 191 | \parallelMusic #'(${1:melody} ${2:harmony}) { 192 | % Bar 1 193 | ${0} | 194 | | 195 | 196 | % Bar 2 197 | | 198 | | 199 | } 200 | \new StaffGroup << 201 | \new Staff \\$1 202 | \new Staff \\$2 203 | >> 204 | endsnippet 205 | 206 | snippet color "override colors" 207 | \override Accidental.color = #(x11-color '${1:gray50}) 208 | \override Beam.color = #(x11-color '$1) 209 | \override Dots.color = #(x11-color '$1) 210 | \override NoteHead.color = #(x11-color '$1) 211 | \override Rest.color = #(x11-color '$1) 212 | \override Stem.color = #(x11-color '$1) 213 | \override Tie.color = #(x11-color '$1) 214 | ${0} 215 | endsnippet 216 | 217 | snippet merge "Merge two Voice into one Staff" 218 | \new Staff << 219 | ${1:\tempo 4 = ${2:108}} 220 | 221 | \relative c'' { 222 | ${3:\melody} 223 | } 224 | \\\\ 225 | \relative c' { 226 | ${4:\harmony} 227 | } 228 | >> 229 | endsnippet 230 | 231 | snippet skip "skip some notes" 232 | \repeat unfold ${1:note_count} { \skip 1 } 233 | ${0} 234 | endsnippet 235 | 236 | snippet segno "segno" 237 | \mark \markup { \fontsize #-2 \musicglyph "scripts.segno" } 238 | endsnippet 239 | 240 | snippet coda "Coda sign" 241 | \mark \markup { \fontsize #-2 \musicglyph "scripts.coda" } 242 | endsnippet 243 | 244 | snippet coda "Coda" 245 | \mark \markup { \fontsize #-2 \line { \musicglyph "scripts.coda" "Coda" } } 246 | endsnippet 247 | 248 | snippet coda "To Coda" 249 | \mark \markup { \fontsize #-2 \line { "To Coda " \musicglyph "scripts.coda" } } 250 | endsnippet 251 | 252 | snippet ds "D.S. al Coda" 253 | \bar "||" 254 | \mark \markup \line { "D.S. al" \raise #1 \musicglyph #"scripts.coda" } 255 | endsnippet 256 | 257 | snippet ds "D.S." 258 | \bar "||" 259 | \mark \markup { \fontsize #-2 "D.S." } 260 | endsnippet 261 | 262 | snippet ds "D.C. D.S." 263 | \bar "||" 264 | \mark \markup { \fontsize #-2 \column { "D.C." "D.S." } } 265 | endsnippet 266 | 267 | snippet ds "上coda,下D.S." 268 | \bar "||" 269 | \once \override Score.RehearsalMark.extra-offset = #'(0 . -8.5) 270 | \once \override Score.RehearsalMark.baseline-skip = #9 271 | \mark \markup \center-column { \fontsize #-2 {\musicglyph "scripts.coda"} "D.S." } 272 | endsnippet 273 | 274 | snippet rest "long Rests" 275 | \override MultiMeasureRest.expand-limit = #3 276 | \compressEmptyMeasures 277 | endsnippet 278 | 279 | snippet grace "装饰音" 280 | \grace { $1 } $0 281 | endsnippet 282 | 283 | snippet grace "短倚音" 284 | \acciaccatura { $1 } $0 285 | endsnippet 286 | 287 | snippet acci "短倚音" 288 | \acciaccatura { $1 } $0 289 | endsnippet 290 | 291 | snippet grace "长倚音" 292 | \appoggiatura { $1 } $0 293 | endsnippet 294 | 295 | snippet appo "长倚音" 296 | \appoggiatura { $1 } $0 297 | endsnippet 298 | 299 | snippet grace "后装饰音" 300 | \afterGrace $1 { $2 } $0 301 | endsnippet 302 | 303 | snippet 装饰音 "装饰音" 304 | \grace { $1 } $0 305 | endsnippet 306 | 307 | snippet 装饰音 "短倚音" 308 | \acciaccatura { $1 } $0 309 | endsnippet 310 | 311 | snippet 装饰音 "长倚音" 312 | \appoggiatura { $1 } $0 313 | endsnippet 314 | 315 | snippet 装饰音 "后装饰音" 316 | \afterGrace $1 { $2 } $0 317 | endsnippet 318 | 319 | snippet score "带高低音部和和弦" b 320 | \score { 321 | \header { 322 | piece = "${1:示例曲谱}" 323 | } 324 | 325 | \new GrandStaff << 326 | \chords { 327 | % 和弦功能 328 | \set noChordSymbol = "" 329 | 330 | ${0} 331 | } 332 | \new Staff { 333 | \relative c' { 334 | \clef "treble" 335 | \key c \major 336 | \time 4/4 337 | % 高音部 338 | 339 | \bar "|." 340 | } 341 | } 342 | \new Staff { 343 | \relative c { 344 | \clef "bass" 345 | \key c \major 346 | \time 4/4 347 | % 低音部 348 | 349 | \bar "|." 350 | } 351 | } 352 | >> 353 | } 354 | endsnippet 355 | -------------------------------------------------------------------------------- /UltiSnips/lilypond_additional.snippets: -------------------------------------------------------------------------------- 1 | snippet toc "目录" b 2 | \markuplist \table-of-contents 3 | endsnippet 4 | 5 | snippet transexec "十二大调转调练习" b 6 | \version "2.23.2" 7 | 8 | \include "../global.ily" 9 | 10 | \header { 11 | title = "转调练习-${2:`!v substitute(expand("%:t:r"), "转调练习-", "", "")`}" 12 | } 13 | 14 | \include "../notes/$2.ily" 15 | 16 | Notes = \transpose c c { 17 | \"$2Pitches" 18 | } 19 | 20 | \tocItem \markup "C" 21 | \score { 22 | \transpose c c { 23 | \"Notes" 24 | } 25 | \header { 26 | piece = "C" 27 | } 28 | } 29 | 30 | \tocItem \markup "F" 31 | \score { 32 | \transpose c f${3:,} { 33 | \"Notes" 34 | } 35 | \header { 36 | piece = "F" 37 | } 38 | } 39 | 40 | \pageBreak 41 | 42 | \tocItem \markup "Bb" 43 | \score { 44 | \transpose c bes, { 45 | \"Notes" 46 | } 47 | \header { 48 | piece = "Bb" 49 | } 50 | } 51 | 52 | \tocItem \markup "Eb" 53 | \score { 54 | \transpose c es { 55 | \"Notes" 56 | } 57 | \header { 58 | piece = "Eb" 59 | } 60 | } 61 | 62 | \pageBreak 63 | 64 | \tocItem \markup "Ab" 65 | \score { 66 | \transpose c aes, { 67 | \"Notes" 68 | } 69 | \header { 70 | piece = "Ab" 71 | } 72 | } 73 | 74 | \tocItem \markup "Db" 75 | \score { 76 | \transpose c des { 77 | \"Notes" 78 | } 79 | \header { 80 | piece = "Db" 81 | } 82 | } 83 | 84 | \pageBreak 85 | 86 | \tocItem \markup "Gb/F#" 87 | \score { 88 | \transpose c ges$3 { 89 | \"Notes" 90 | } 91 | \header { 92 | piece = "Gb/F#" 93 | } 94 | } 95 | 96 | \tocItem \markup "B" 97 | \score { 98 | \transpose c b, { 99 | \"Notes" 100 | } 101 | \header { 102 | piece = "B" 103 | } 104 | } 105 | 106 | \pageBreak 107 | 108 | \tocItem \markup "E" 109 | \score { 110 | \transpose c e { 111 | \"Notes" 112 | } 113 | \header { 114 | piece = "E" 115 | } 116 | } 117 | 118 | \tocItem \markup "A" 119 | \score { 120 | \transpose c a, { 121 | \"Notes" 122 | } 123 | \header { 124 | piece = "A" 125 | } 126 | } 127 | 128 | \pageBreak 129 | 130 | \tocItem \markup "D" 131 | \score { 132 | \transpose c d { 133 | \"Notes" 134 | } 135 | \header { 136 | piece = "D" 137 | } 138 | } 139 | 140 | \tocItem \markup "G" 141 | \score { 142 | \transpose c g, { 143 | \"Notes" 144 | } 145 | \header { 146 | piece = "G" 147 | } 148 | } 149 | 150 | \pageBreak 151 | 152 | endsnippet 153 | 154 | snippet break "\\break" 155 | \break 156 | endsnippet 157 | 158 | snippet break "\\breakFor a4" 159 | \\breakFor "${1:a4}" 160 | endsnippet 161 | 162 | snippet break "\\breakFor #'(a4 a5)" 163 | \\breakFor #'(${1:"a4" "a5"}) 164 | endsnippet 165 | 166 | snippet break "\\noBreak" 167 | \noBreak 168 | endsnippet 169 | 170 | snippet break "\\noBreakFor a4" 171 | \\noBreakFor "${1:a4}" 172 | endsnippet 173 | 174 | snippet break "\\noBreakFor #'(a4 a5)" 175 | \\noBreakFor #'(${1:"a4" "a5"}) 176 | endsnippet 177 | 178 | snippet break "\\pageBreak" 179 | \pageBreak 180 | endsnippet 181 | 182 | snippet break "\\pageBreakFor a4" 183 | \\pageBreakFor "${1:a4}" 184 | endsnippet 185 | 186 | snippet break "\\pageBreakFor #'(a4 a5)" 187 | \\pageBreakFor #'(${1:"a4" "a5"}) 188 | endsnippet 189 | -------------------------------------------------------------------------------- /UltiSnips/lilypond_template.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "简单嵌入模板" b 2 | \version "2.23.2" 3 | \paper { 4 | ragged-right = ##t 5 | } 6 | \relative c'' { 7 | \time 4/4 8 | $0 9 | } 10 | endsnippet 11 | 12 | snippet skel "非复调 普通钢琴作品通用模板" b 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % 非复调 普通钢琴作品通用模板 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | \version "2.23.2" 17 | 18 | showTN = { \override TupletNumber #'transparent = ##f } 19 | hideTN = { \override TupletNumber #'transparent = ##t } 20 | 21 | staffDown = { \change Staff = "down" } %staff down 22 | staffUp = { \change Staff = "up" } %staff up 23 | 24 | mbreak = \break 25 | 26 | %%%%%%%%%%%%%% 27 | % 右手部分 % 28 | %%%%%%%%%%%%%% 29 | RH = \relative c'' 30 | { 31 | \clef treble 32 | \key c \major 33 | \time 4/4 34 | \override Score.MetronomeMark #'transparent = ##t 35 | \tempo 4=132 36 | %TODO: 下面开始写右手部分 37 | 38 | } 39 | 40 | %%%%%%%%%%%%%% 41 | % 左手部分 % 42 | %%%%%%%%%%%%%% 43 | LH = \relative c 44 | { 45 | \clef bass 46 | \key c \major 47 | \time 4/4 48 | %TODO: 下面开始写左手部分 49 | 50 | } 51 | 52 | \score 53 | { 54 | \context PianoStaff 55 | << 56 | %\set PianoStaff.connectArpeggios = ##t 57 | %\set PianoStaff.instrumentName = \markup { \fontsize #+3 \bold "1." } 58 | \new Staff = "up" \RH 59 | \new Staff = "down" \LH 60 | >> 61 | 62 | \layout { } 63 | 64 | \midi 65 | { 66 | \context 67 | { 68 | \Voice 69 | \remove Dynamic_performer 70 | } 71 | } 72 | } 73 | endsnippet 74 | 75 | snippet skel "复调钢琴作品模板" b 76 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 77 | % 复调模板 78 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 79 | \version "2.23.2" 80 | 81 | showTN = { \override TupletNumber #'transparent = ##f } 82 | hideTN = { \override TupletNumber #'transparent = ##t } 83 | 84 | staffDown = { \change Staff = "down" } %staff down 85 | staffUp = { \change Staff = "up" } %staff up 86 | 87 | mbreak = \break 88 | 89 | %%%%%%%%%%%%%% 90 | % up % 91 | %%%%%%%%%%%%%% 92 | A = \relative c' 93 | { 94 | \clef treble 95 | \key c \major 96 | \time 4/4 97 | \override Score.MetronomeMark #'transparent = ##t 98 | \tempo 4=132 99 | 100 | } 101 | 102 | B = \relative c' 103 | { 104 | 105 | } 106 | 107 | %%%%%%%%%%%%%% 108 | % down % 109 | %%%%%%%%%%%%%% 110 | C = \relative c 111 | { 112 | \clef bass 113 | \key c \major 114 | 115 | } 116 | 117 | D = \relative c 118 | { 119 | 120 | } 121 | 122 | \score 123 | { 124 | \context PianoStaff 125 | << 126 | %\set PianoStaff.connectArpeggios = ##t 127 | %\set PianoStaff.instrumentName = \markup { \fontsize #+3 \bold "1." } 128 | \new Staff = "up" 129 | << 130 | \new Voice = "A" \A 131 | \new Voice = "B" \B 132 | >> 133 | \new Staff = "down" 134 | << 135 | \new Voice = "C" \C 136 | \new Voice = "D" \D 137 | >> 138 | >> 139 | 140 | \layout { } 141 | 142 | \midi 143 | { 144 | \context 145 | { 146 | \Voice 147 | \remove Dynamic_performer 148 | } 149 | } 150 | } 151 | endsnippet 152 | 153 | snippet skel "Notes" b 154 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 155 | "$1Opus" = "" 156 | "$1Composer" = "" 157 | "$1Singer" = "" 158 | "$1Key" = \\Key${3:C} 159 | 160 | "$1Pitches" = \relative ${4:c''} 161 | { 162 | \time ${5:4/4} 163 | \key `!p snip.rv = re.sub("[,']+", "", t[8])` ${9:\major} 164 | 165 | ${0} 166 | 167 | \fine 168 | } 169 | 170 | "$1NotesC" = 171 | { 172 | ${6:\tempo 4 = ${7:60}} 173 | 174 | \transpose ${8:c} c { 175 | \"$1Pitches" 176 | } 177 | } 178 | 179 | "$1Notes" = 180 | { 181 | \transpose c \\"$1Key" { 182 | \"$1NotesC" 183 | } 184 | } 185 | 186 | "$1MelodyC" = \"$1NotesC" 187 | "$1Melody" = \"$1Notes" 188 | endsnippet 189 | 190 | snippet skel "Notes with lyric" b 191 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 192 | "$1Opus" = "" 193 | "$1Composer" = "" 194 | "$1Singer" = "" 195 | "$1Key" = \\Key${3:C} 196 | 197 | melody = \relative ${4:c''} 198 | { 199 | \time ${5:4/4} 200 | \key `!p snip.rv = re.sub("[,']+", "", t[8])` ${9:\major} 201 | 202 | ${0} 203 | 204 | \fine 205 | } 206 | 207 | verse = \lyricmode { 208 | } 209 | 210 | "$1Pitches" = 211 | { 212 | << 213 | \new Voice = "melody" { 214 | ${6:\tempo 4 = ${7:60}} 215 | 216 | \melody 217 | } 218 | \new Lyrics = "verse" \lyricsto "melody" { 219 | \verse 220 | } 221 | >> 222 | } 223 | 224 | "$1NotesC" = 225 | { 226 | \transpose ${8:c} c { 227 | \"$1Pitches" 228 | } 229 | } 230 | 231 | "$1Notes" = 232 | { 233 | \transpose c \\"$1Key" { 234 | \"$1NotesC" 235 | } 236 | } 237 | 238 | "$1MelodyC" = 239 | { 240 | \transpose $8 c { 241 | $6 242 | \melody 243 | } 244 | } 245 | 246 | "$1Melody" = 247 | { 248 | \transpose c \\"$1Key" { 249 | \"$1MelodyC" 250 | } 251 | } 252 | endsnippet 253 | 254 | snippet skel "Parallel Notes (one staff)" b 255 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 256 | "$1Opus" = "" 257 | "$1Composer" = "" 258 | "$1Singer" = "" 259 | "$1Key" = \\Key${3:C} 260 | 261 | \parallelMusic #'(melody harmony) { 262 | 263 | \time ${3:4/4} 264 | 265 | ${0} 266 | 267 | \fine 268 | } 269 | 270 | "$1Pitches" = 271 | { 272 | \new Staff << 273 | ${4:\tempo 4 = ${5:108}} 274 | 275 | \relative c'' \melody 276 | \\\\ 277 | \relative c' \harmony 278 | >> 279 | } 280 | 281 | "$1Notes" = 282 | { 283 | \transpose c ${6:c} { 284 | \key ${7:c} ${8:\major} 285 | \"$1Pitches" 286 | } 287 | } 288 | 289 | "$1Melody" = \"$1Notes" 290 | endsnippet 291 | 292 | snippet skel "Parallel Notes (1 staffs with lyric)" b 293 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 294 | "$1Opus" = "" 295 | "$1Composer" = "" 296 | "$1Singer" = "" 297 | "$1Key" = \\Key${3:C} 298 | 299 | \parallelMusic #'(preludeM preludeH) { 300 | 301 | \time $3 302 | 303 | ${0} 304 | 305 | } 306 | 307 | \parallelMusic #'(melody harmony) { 308 | 309 | \time ${3:4/4} 310 | 311 | 312 | \fine 313 | } 314 | 315 | grayVoice = { 316 | \override Accidental.color = #(x11-color 'gray50) 317 | \override Beam.color = #(x11-color 'gray50) 318 | \override Dots.color = #(x11-color 'gray50) 319 | \override NoteHead.color = #(x11-color 'gray50) 320 | \override Rest.color = #(x11-color 'gray50) 321 | \override Stem.color = #(x11-color 'gray50) 322 | \override Tie.color = #(x11-color 'gray50) 323 | } 324 | 325 | "$1Pitches" = 326 | { 327 | << 328 | \new Voice = "melody" { 329 | ${4:\tempo 4 = ${5:60}} 330 | 331 | << 332 | \new Voice { 333 | \voiceThree 334 | \relative c'' { 335 | \preludeM 336 | } 337 | } 338 | \new Voice { 339 | \voiceFour 340 | \grayVoice 341 | \relative c' { 342 | \preludeH 343 | } 344 | } 345 | { 346 | \voiceOne 347 | \relative c'' { 348 | \melody 349 | } 350 | } 351 | \new Voice { 352 | \voiceTwo 353 | \grayVoice 354 | \relative c' { 355 | \harmony 356 | } 357 | } 358 | >> 359 | } 360 | 361 | \new Lyrics="firstVerse" \lyricsto "melody" { 362 | } 363 | \new Lyrics="secondVerse" \lyricsto "melody" { 364 | \repeat unfold 4 { \skip 1 } 365 | } 366 | >> 367 | } 368 | 369 | "$1Notes" = 370 | { 371 | \transpose c ${6:c} { 372 | \key ${7:c} ${8:\major} 373 | \"$1Pitches" 374 | } 375 | } 376 | 377 | "$1Melody" = 378 | { 379 | << 380 | \new Voice = "melody" { 381 | $4 382 | 383 | << 384 | \new Voice { 385 | \voiceThree 386 | \relative c'' { 387 | \preludeM 388 | } 389 | } 390 | { 391 | \voiceOne 392 | \relative c'' { 393 | \melody 394 | } 395 | } 396 | >> 397 | } 398 | \new Lyrics \lyricsto "melody" { 399 | \verse 400 | } 401 | >> 402 | } 403 | endsnippet 404 | 405 | snippet skel "Parallel Notes (two staffs)" b 406 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 407 | "$1Opus" = "" 408 | "$1Composer" = "" 409 | "$1Singer" = "" 410 | "$1Key" = \\Key${3:C} 411 | 412 | \parallelMusic #'(melody harmony) { 413 | 414 | \time ${3:4/4} 415 | 416 | ${0} 417 | 418 | \fine 419 | } 420 | 421 | "$1Pitches" = 422 | { 423 | \new Staff << 424 | ${4:\tempo 4 = ${5:108}} 425 | 426 | \relative c'' { 427 | \melody 428 | } 429 | \\\\ 430 | \relative c' { 431 | \grayNotes 432 | 433 | \harmony 434 | } 435 | >> 436 | } 437 | 438 | "$1Notes" = 439 | { 440 | \transpose c ${6:c} { 441 | \key ${7:c} ${8:\major} 442 | \"$1Pitches" 443 | } 444 | } 445 | 446 | "$1Melody" = \"$1Notes" 447 | endsnippet 448 | 449 | snippet skel "Parallel Notes (two staffs separated)" b 450 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 451 | "$1Opus" = "" 452 | "$1Composer" = "" 453 | "$1Singer" = "" 454 | "$1Key" = \\Key${3:C} 455 | 456 | \parallelMusic #'(melody harmony) { 457 | 458 | \time ${3:4/4} 459 | 460 | ${0} 461 | 462 | \fine 463 | } 464 | 465 | "$1Pitches" = 466 | { 467 | \new StaffGroup << 468 | \new Staff { 469 | ${4:\tempo 4 = ${5:108}} 470 | 471 | \relative c'' \melody 472 | } 473 | \new Staff { 474 | \relative c' \harmony 475 | } 476 | >> 477 | } 478 | 479 | "$1Notes" = 480 | { 481 | \transpose c ${6:c} { 482 | \key ${7:c} ${8:\major} 483 | \"$1Pitches" 484 | } 485 | } 486 | 487 | "$1Melody" = \"$1Notes" 488 | endsnippet 489 | 490 | snippet skel "普通高低音部,带和弦和歌词" b 491 | "${1:`!v expand("%:t:r")`}Piece" = "${2:$1}" 492 | "$1Opus" = "" 493 | "$1Composer" = "" 494 | "$1Singer" = "" 495 | "$1Key" = \\Key${3:C} 496 | 497 | "$1Up" = \relative ${4:c''} 498 | { 499 | \time ${5:4/4} 500 | \key `!p snip.rv = re.sub("[,']+", "", t[9])` ${10:\major} 501 | 502 | ${0} 503 | 504 | \fine 505 | } 506 | 507 | "$1Down" = \relative ${6:c} 508 | { 509 | \time $5 510 | \key `!p snip.rv = re.sub("[,']+", "", t[8])` $9 511 | 512 | ${0} 513 | 514 | \fine 515 | } 516 | 517 | 518 | "$1Pitches" = 519 | { 520 | \new StaffGroup << 521 | \new Staff { 522 | ${7:\tempo 4 = ${8:108}} 523 | 524 | \relative c'' \"$1Up" 525 | } 526 | \new Staff { 527 | \relative c' \"$1Down" 528 | } 529 | >> 530 | } 531 | 532 | "$1NotesC" = 533 | { 534 | \transpose ${9:c} c { 535 | \"$1Pitches" 536 | } 537 | } 538 | 539 | "$1Notes" = 540 | { 541 | \transpose c \\"$1Key" { 542 | \"$1NotesC" 543 | } 544 | } 545 | 546 | "$1Melody" = \"$1Notes" 547 | endsnippet 548 | 549 | -------------------------------------------------------------------------------- /UltiSnips/make.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "C base Makefile" bt 2 | TARGET = ${1:target} 3 | 4 | # Listing all sources 5 | SOURCES = $(wildcard *.c) 6 | 7 | # depended libraries 8 | LFLAGS = $0 9 | 10 | all: $(TARGET) 11 | 12 | .PHONY : clean distclean cscope run 13 | clean: 14 | rm -f $(TARGET) $(SOURCES:.c=.o) 15 | 16 | distclean: 17 | rm -f $(TARGET) $(SOURCES:.c=.o) $(SOURCES:.c=.d) 18 | 19 | run: $(TARGET) 20 | @-./$(TARGET) 21 | 22 | # TARGET depends on ".o"s, where every .cpp metioned in SOURCES are substituted into a .o 23 | $(TARGET): $(SOURCES:.c=.o) 24 | $(CC) -g -o $@ $^ $(LFLAGS) 25 | 26 | # Every .d contains the header files which the correspending .c depends on 27 | # In gnu make, as of a sub makefile, this rule will automatic checked on the next include command 28 | %.d: %.c 29 | @set -e; rm -f $@; \ 30 | $(CC) -MM $< > $@.$$$$; \ 31 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 32 | rm -f $@.$$$$ 33 | 34 | # Include ".d"s for each .c 35 | -include $(SOURCES:.c=.d) 36 | endsnippet 37 | 38 | snippet skel "C++ base Makefile" bt 39 | TARGET = ${1:target} 40 | 41 | # Listing all sources 42 | SOURCES = $(wildcard *.cpp) 43 | 44 | CXXFLAGS = -std=c++11 45 | # depended libraries 46 | LFLAGS = $0 47 | 48 | all: $(TARGET) 49 | 50 | .PHONY : clean distclean cscope run 51 | clean: 52 | rm -f $(TARGET) $(SOURCES:.cpp=.o) 53 | 54 | distclean: 55 | rm -f $(TARGET) $(SOURCES:.cpp=.o) $(SOURCES:.cpp=.d) 56 | 57 | run: $(TARGET) 58 | @-./$(TARGET) 59 | 60 | # TARGET depends on ".o"s, where every .cpp metioned in SOURCES are substituted into a .o 61 | $(TARGET): $(SOURCES:.cpp=.o) 62 | $(CXX) -g -o $@ $^ $(LFLAGS) 63 | 64 | # Every .d contains the header files which the correspending .cpp depends on 65 | # In gnu make, as of a sub makefile, this rule will automatic checked on the next include command 66 | %.d: %.cpp 67 | @set -e; rm -f $@; \ 68 | $(CC) -MM $(CXXFLAGS) $< > $@.$$$$; \ 69 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 70 | rm -f $@.$$$$ 71 | 72 | # Include ".d"s for each .cpp 73 | -include $(SOURCES:.cpp=.d) 74 | endsnippet 75 | 76 | snippet skel "Python base Makefile" bt 77 | # If the first argument is "run"... 78 | ifeq (run,$(firstword $(MAKECMDGOALS))) 79 | # use the rest as arguments for "run" 80 | RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) 81 | endif 82 | 83 | all: lint test 84 | 85 | %: 86 | @: 87 | 88 | .PHONY: run 89 | run: 90 | python -m log_analyzer $(RUN_ARGS) 91 | 92 | .PHONY: lint 93 | lint: 94 | flake8 95 | 96 | .PHONY: test 97 | test: 98 | pytest 99 | 100 | #.PHONY: release 101 | #release: 102 | # python setup.py sdist bdist_wheel upload 103 | 104 | .PHONY: clean 105 | clean: 106 | find . -type f -name *.pyc -delete 107 | find . -type d -name __pycache__ -delete 108 | endsnippet 109 | 110 | snippet skel "Python venv based Makefile" bt 111 | # system python interpreter, used to create virtual environment 112 | PY = python3 113 | VENV = venv 114 | BIN = $(VENV)/bin 115 | 116 | # make it work on windows too 117 | ifeq ($(OS), Windows_NT) 118 | BIN = $(VENV)/Scripts 119 | PY = python 120 | endif 121 | 122 | # If the first argument is "run"... 123 | ifeq (run,$(firstword $(MAKECMDGOALS))) 124 | # use the rest as arguments for "run" 125 | RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) 126 | endif 127 | 128 | all: lint test 129 | 130 | %: 131 | @: 132 | 133 | $(VENV): requirements.txt requirements-dev.txt 134 | $(PY) -m venv $(VENV) 135 | $(BIN)/pip install --upgrade -r requirements.txt 136 | $(BIN)/pip install --upgrade -r requirements-dev.txt 137 | #$(BIN)/pip install -e . 138 | touch $(VENV) 139 | 140 | .PHONY: run 141 | run: $(VENV) 142 | $(BIN)/python -m log_analyzer $(RUN_ARGS) 143 | 144 | .PHONY: lint 145 | lint: $(VENV) 146 | $(BIN)/flake8 --exclude $(VENV) 147 | 148 | .PHONY: test 149 | test: $(VENV) 150 | $(BIN)/pytest 151 | 152 | #.PHONY: release 153 | #release: $(VENV) 154 | # $(BIN)/python setup.py sdist bdist_wheel upload 155 | 156 | .PHONY: clean 157 | clean: 158 | rm -rf $(VENV) 159 | find . -type f -name *.pyc -delete 160 | find . -type d -name __pycache__ -delete 161 | endsnippet 162 | 163 | snippet skel "Go package Makefile" bt 164 | include $(GOROOT)/src/Make.inc 165 | 166 | TARG=${1:package} 167 | GOFILES=\ 168 | $1.go\ 169 | $0 170 | 171 | include $(GOROOT)/src/Make.pkg 172 | endsnippet 173 | 174 | snippet skel "Go program Makefile" bt 175 | include $(GOROOT)/src/Make.inc 176 | TARG=${1:program} 177 | GOFILES=\ 178 | $1.go\ 179 | $0 180 | 181 | include $(GOROOT)/src/Make.cmd 182 | endsnippet 183 | -------------------------------------------------------------------------------- /UltiSnips/markdown.snippets: -------------------------------------------------------------------------------- 1 | snippet skel 2 | # ${1:`!v expand("%:t:r")`} 3 | 4 | ${0} 5 | endsnippet 6 | 7 | snippet design "设计报告" b 8 | # ${1:`!v expand("%:t:r")`} 9 | 10 | ## 背景 11 | 12 | ${0} 13 | 14 | ## 目标 15 | 16 | ### 需求 17 | 18 | ### 约束 19 | 20 | ## 方案 21 | 22 | ### 要点 23 | 24 | ### 优点 25 | 26 | ### 缺点 27 | 28 | ## 建议 29 | 30 | ## 实现 31 | 32 | endsnippet 33 | 34 | snippet modeline "vim modeline" b 35 | [modeline]: # ( vim: set fenc=utf-8 ft=markdown: ) 36 | endsnippet 37 | 38 | snippet meta "inline meta-data" b 39 | Title: ${1:title} 40 | Authors: ${2:authors} 41 | Summary: ${3:summary} 42 | 43 | ${0} 44 | endsnippet 45 | 46 | snippet toc "GitLab ToC" b 47 | [[_TOC_]] 48 | endsnippet 49 | 50 | snippet toc "kramdown ToC" b 51 | * ToC 52 | {:toc} 53 | 54 | endsnippet 55 | 56 | snippet toc "vim-markdown-toc" b 57 | ## 目录 58 | 59 |
60 | 61 | 62 | 63 | 64 |
65 | 66 | ${0} 67 | endsnippet 68 | 69 | snippet -[ "- [ ] todo" 70 | - [${1: }] ${0} 71 | endsnippet 72 | 73 | snippet *[ "* [ ] todo" 74 | * [${1: }] ${0} 75 | endsnippet 76 | 77 | snippet // "comment" 78 | [//]: # (${1}) 79 | ${0} 80 | endsnippet 81 | 82 | snippet meeting "会议纪要" b 83 | * **时间**:${1} 84 | * **地点**:${2} 85 | * **人员**:${3} 86 | * **内容**: 87 | - ${4} 88 | * **问题**: 89 | - ${5} 90 | * **结论**: 91 | - ${6} 92 | endsnippet 93 | 94 | snippet refl "Reference Link" w 95 | [${1:${VISUAL:Text}}][${2:id}]$0 96 | 97 | [`!p snip.rv = t[2] if t[2] else t[1]`]: ${3:url}${5: "${4:$3}"} 98 | endsnippet 99 | 100 | snippet src "code block" b 101 | \`\`\`${1} 102 | ${VISUAL}${2} 103 | \`\`\` 104 | ${0} 105 | endsnippet 106 | 107 | -------------------------------------------------------------------------------- /UltiSnips/markdown_blocks.snippets: -------------------------------------------------------------------------------- 1 | snippet cpp "cpp code block" b 2 | \`\`\`cpp 3 | ${VISUAL}${1} 4 | \`\`\` 5 | ${0} 6 | endsnippet 7 | 8 | snippet css "css code block" b 9 | \`\`\`css 10 | ${VISUAL}${1} 11 | \`\`\` 12 | ${0} 13 | endsnippet 14 | 15 | snippet haskell "ruby code block" b 16 | \`\`\`haskell 17 | ${VISUAL}${1} 18 | \`\`\` 19 | ${0} 20 | endsnippet 21 | 22 | snippet html "html code block" b 23 | \`\`\`html 24 | ${VISUAL}${1} 25 | \`\`\` 26 | ${0} 27 | endsnippet 28 | 29 | snippet js "javascript code block" b 30 | \`\`\`javascript 31 | ${VISUAL}${1} 32 | \`\`\` 33 | ${0} 34 | endsnippet 35 | 36 | snippet lilypond "lilypond code block" b 37 | \`\`\`lilypond 38 | ${VISUAL}${1} 39 | \`\`\` 40 | ${0} 41 | endsnippet 42 | 43 | snippet markdown "markdown code block" b 44 | \`\`\`markdown 45 | ${VISUAL}${1} 46 | \`\`\` 47 | ${0} 48 | endsnippet 49 | 50 | snippet python "python code block" b 51 | \`\`\`python 52 | ${VISUAL}${1} 53 | \`\`\` 54 | ${0} 55 | endsnippet 56 | 57 | snippet racket "racket code block" b 58 | \`\`\`racket 59 | ${VISUAL}${1} 60 | \`\`\` 61 | ${0} 62 | endsnippet 63 | 64 | snippet ruby "ruby code block" b 65 | \`\`\`ruby 66 | ${VISUAL}${1} 67 | \`\`\` 68 | ${0} 69 | endsnippet 70 | 71 | snippet sh "sh code block" b 72 | \`\`\`sh 73 | ${VISUAL}${1} 74 | \`\`\` 75 | ${0} 76 | endsnippet 77 | 78 | snippet sml "sml code block" b 79 | \`\`\`sml 80 | ${VISUAL}${1} 81 | \`\`\` 82 | ${0} 83 | endsnippet 84 | 85 | snippet anchor "anchor" b 86 | ${0} 87 | endsnippet 88 | 89 | -------------------------------------------------------------------------------- /UltiSnips/markdown_jekyll.snippets: -------------------------------------------------------------------------------- 1 | # vim:ft=snippets: 2 | snippet post "Jekyll post header" b 3 | --- 4 | title: ${1:title} 5 | layout: single 6 | guid: `!p 7 | import uuid 8 | if not snip.c: 9 | try: 10 | guid = uuid.uuid4().hex 11 | except: 12 | guid = uuid.uuid4().get_hex() 13 | snip.rv = guid 14 | ` 15 | date: `!v strftime("%Y-%m-%d %H:%M:%S")` 16 | categories: 17 | - ${3} 18 | tags: 19 | - ${4} 20 | --- 21 | 22 | ${0} 23 | endsnippet 24 | 25 | snippet /img "jekyll image path completion" 26 | /${1:images}/`!p 27 | parts = snip.fn.split('-') 28 | rv = '' 29 | if len(parts) >= 3: 30 | rv = '/'.join(parts[:3]) 31 | snip.rv=rv`/${2:file.png} 32 | endsnippet 33 | 34 | -------------------------------------------------------------------------------- /UltiSnips/markdown_mermaid.snippets: -------------------------------------------------------------------------------- 1 | snippet class "Class Diagram" b 2 | \`\`\`mermaid 3 | classDiagram$0 4 | Animal <|-- Duck 5 | Animal : -int age 6 | Animal : -String gender 7 | Animal: +isMammal() 8 | Animal: +mate() 9 | class Duck\{ 10 | -String beakColor 11 | +swim() 12 | +quack() 13 | } 14 | \`\`\` 15 | endsnippet 16 | 17 | snippet seq "Sequence Diagram" b 18 | \`\`\`mermaid 19 | sequenceDiagram$0 20 | actor Alice 21 | participant Bob 22 | Alice->>John: Hello John, how are you? 23 | loop Healthcheck 24 | John->>John: Fight against hypochondria 25 | end 26 | Note right of John: Rational thoughts
prevail... 27 | John-->>Alice: Great! 28 | John->>Bob: How about you? 29 | Bob-->>John: Jolly good! 30 | \`\`\` 31 | endsnippet 32 | 33 | snippet flow "Flow Chart Diagram" b 34 | \`\`\`mermaid 35 | flowchart ${1:LR}$0 36 | A((Start)) --> B\{Is it?}; 37 | B -- Yes --> C[OK]; 38 | C --> D[Rethink]; 39 | D --> B; 40 | B -- No ----> E((End)); 41 | \`\`\` 42 | endsnippet 43 | 44 | -------------------------------------------------------------------------------- /UltiSnips/markdown_revealjs.snippets: -------------------------------------------------------------------------------- 1 | extends revealjs 2 | 3 | -------------------------------------------------------------------------------- /UltiSnips/markdown_skel.snippets: -------------------------------------------------------------------------------- 1 | snippet digest "文摘模板" b 2 | # ${1:标题} 3 | 4 | [//]: # (读前提问题、阅后作总结,才能提升知识营养的吸收效果) 5 | 6 | ## #**思考or困惑or问题** 7 | 8 | [//]: # (A-对文章中表述的核心主题要提出自己的联想、思考、问题、矛盾点、困惑) 9 | 10 | 11 | 12 | ## #**认知or原理or规律or原则** 13 | 14 | [//]: # (B-Know Why类) 15 | 16 | 17 | 18 | ## #**观点or道理or逻辑or建议** 19 | 20 | [//]: # (B-主观思考类) 21 | 22 | 23 | 24 | ## #**概念or数据or信息or案例or实证** 25 | 26 | [//]: # (B-Know What类) 27 | 28 | 29 | 30 | ## #**方法or工具or流程** 31 | 32 | [//]: # (B-Know How类) 33 | 34 | 35 | 36 | ## #**体验or感知or金句** 37 | 38 | [//]: # (B-语句修辞类) 39 | 40 | 41 | 42 | ## #**总结or启示or应用** 43 | 44 | [//]: # (C-总结回顾全文核心内容说了什么,把自己的思考和问题与作者的观点两相对应,看看是否解决了问题或者提升了认知。并把值得记住的知识点重读几遍加深印象) 45 | 46 | 47 | 48 | ## #**来源** 49 | endsnippet 50 | 51 | -------------------------------------------------------------------------------- /UltiSnips/markdown_tex_math.snippets: -------------------------------------------------------------------------------- 1 | extends tex_math 2 | -------------------------------------------------------------------------------- /UltiSnips/python.snippets: -------------------------------------------------------------------------------- 1 | snippet attr "attribute with sphinx docstring" b 2 | #: ${3:type: TODO} 3 | self.${1:attr} = ${2:$1} 4 | ${0} 5 | endsnippet 6 | 7 | snippet catch-keyboard "Catch KeyboardInterrupt" b 8 | try: 9 | ${VISUAL}${0} 10 | 11 | except KeyboardInterrupt: 12 | pass 13 | 14 | finally: 15 | pass 16 | endsnippet 17 | 18 | #! header 19 | snippet #! "Shebang header for python scripts" b 20 | #!/usr/bin/env python${1:} 21 | # -*- coding: utf-8 -*- 22 | 23 | $0 24 | endsnippet 25 | 26 | snippet modeline "VIM modeline for python scripts" b 27 | # vim: set fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4: 28 | endsnippet 29 | 30 | snippet context 31 | import os 32 | import sys 33 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 34 | 35 | import ${1:sample} 36 | endsnippet 37 | 38 | snippet nulllogger "set null logger" 39 | # Set default logging handler to avoid "No handler found" warnings. 40 | import logging 41 | 42 | logging.getLogger(__name__).addHandler(logging.NullHandler()) 43 | 44 | endsnippet 45 | 46 | snippet logger "get logger for module" 47 | logger = logging.getLogger(__name__) 48 | 49 | endsnippet 50 | 51 | snippet main "if __name__ == '__main__'" b 52 | if __name__ == '__main__': 53 | $0 54 | endsnippet 55 | 56 | snippet "#\s*\.\.\." "# doctest:+ELLIPSIS" r 57 | # doctest:+ELLIPSIS 58 | endsnippet 59 | 60 | snippet currdir "dir of script" 61 | os.path.dirname(os.path.realpath(__file__)) 62 | endsnippet 63 | 64 | snippet defi "def __init__" b 65 | def __init__(self, ${1:args}): 66 | ${2:super().__init__()} 67 | endsnippet 68 | 69 | snippet input "handle file input" b 70 | import fileinput 71 | 72 | for line in fileinput.input(encoding="utf-8"): 73 | process(line) 74 | endsnippet 75 | -------------------------------------------------------------------------------- /UltiSnips/python_behave.snippets: -------------------------------------------------------------------------------- 1 | snippet step "Behave step_impl" b 2 | @${1:given}(u'${2:content}') 3 | def step_impl(context): 4 | $0 5 | endsnippet 6 | 7 | snippet behave "behave steps skel" b 8 | # vim: set fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4: 9 | from behave import * 10 | 11 | $0 12 | endsnippet 13 | 14 | snippet step_table "Behave step_impl with table" b 15 | @${1:given}(u'${2:content}') 16 | def step_impl(context): 17 | for row in context.table: 18 | $0 19 | endsnippet 20 | 21 | snippet step_match "Behave step_impl with matching" b 22 | @${1:given}(u'${2:matching {text}}') 23 | def step_impl(context, ${3:text}): 24 | $0 25 | endsnippet 26 | 27 | -------------------------------------------------------------------------------- /UltiSnips/python_click.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "Skel using click for command line parsing" b 2 | #!/usr/bin/env python 3 | # -*- coding: utf-8 -*- 4 | 5 | import logging 6 | import os 7 | import sys 8 | 9 | import click 10 | 11 | VERSION = u'`!v strftime("%Y%m%d")`' 12 | 13 | logger = logging.getLogger() 14 | 15 | def setup_logger(quiet=False, verbose=False): 16 | """日志初始化 17 | Args: 18 | quiet (bool): 静默模式 19 | verbose (bool): 打印调试日志 20 | """ 21 | log_format = u'%(asctime)s %(levelname)s %(message)s' 22 | 23 | if quiet: 24 | logging.basicConfig(level=logging.WARNING, format=log_format) 25 | elif verbose: 26 | logging.basicConfig(level=logging.DEBUG, format=log_format) 27 | else: 28 | logging.basicConfig(level=logging.INFO, format=log_format) 29 | 30 | 31 | @click.command() 32 | @click.version_option(version=VERSION) 33 | @click.option('--quiet', '-q', is_flag=True, help='Quiet mode.') 34 | @click.option('--verbose', '-v', is_flag=True, help='Verbose mode.') 35 | @click.argument('argument') 36 | def cli( 37 | argument, 38 | help=False, 39 | quiet=False, 40 | verbose=False 41 | ): 42 | setup_logger(quiet=quiet, verbose=verbose) 43 | 44 | 45 | if __name__ == '__main__': 46 | cli() 47 | endsnippet 48 | 49 | snippet skel "Skel using click with sub-commands" b 50 | #!/usr/bin/env python 51 | # -*- coding: utf-8 -*- 52 | 53 | import logging 54 | import os 55 | import sys 56 | import functools 57 | 58 | import click 59 | 60 | VERSION = u'`!v strftime("%Y%m%d")`' 61 | 62 | logger = logging.getLogger() 63 | 64 | class Context(object): 65 | def __init__(self): 66 | self.quiet = False 67 | self.verbose = False 68 | 69 | pass_context = click.make_pass_decorator(Context, ensure=True) 70 | 71 | 72 | def init_common_params(func): 73 | """Used to inject common params to sub-command 74 | """ 75 | 76 | @click.option('--quiet', '-q', is_flag=True, default=False, help="Quiet mode.") 77 | @click.option('--verbose', '-v', is_flag=True, default=False, help="Verbose mode.") 78 | @pass_context 79 | @functools.wraps(func) 80 | def wrapper(context, *args, **kwargs): 81 | context.quiet = kwargs['quiet'] 82 | context.verbose = kwargs['verbose'] 83 | 84 | del kwargs['quiet'] 85 | del kwargs['verbose'] 86 | 87 | return func(context, *args, **kwargs) 88 | 89 | return wrapper 90 | 91 | 92 | def common_params(func): 93 | """Merge common params and do some common initilize 94 | """ 95 | 96 | @init_common_params 97 | @functools.wraps(func) 98 | def wrapper(context, *args, **kwargs): 99 | setup_logger(quiet=context.quiet, verbose=context.verbose) 100 | 101 | return func(context, *args, **kwargs) 102 | 103 | return wrapper 104 | 105 | 106 | def setup_logger(quiet=False, verbose=False): 107 | """日志初始化 108 | Args: 109 | args (Dict[string, string]): 命令行参数 110 | """ 111 | log_format = u'%(asctime)s %(levelname)s %(message)s' 112 | 113 | if quiet: 114 | logging.basicConfig(level=logging.WARNING, format=log_format) 115 | elif verbose: 116 | logging.basicConfig(level=logging.DEBUG, format=log_format) 117 | else: 118 | logging.basicConfig(level=logging.INFO, format=log_format) 119 | 120 | 121 | @click.group() 122 | @click.version_option(version=VERSION) 123 | @init_common_params 124 | def cli( 125 | context, 126 | ): 127 | pass 128 | 129 | 130 | @cli.command() 131 | @click.argument('input', type=click.File('rb')) 132 | @common_params 133 | def command1( 134 | context, 135 | input): 136 | pass 137 | 138 | 139 | if __name__ == '__main__': 140 | cli() 141 | endsnippet 142 | 143 | 144 | # Directory structure: 145 | # 146 | # yourscript.py 147 | # setup.py 148 | # 149 | snippet setup "setup.py using setuptools" b 150 | #!/usr/bin/env python 151 | # -*- coding: utf-8 -*- 152 | 153 | from setuptools import setup 154 | 155 | setup( 156 | name='${1:yourscript}', 157 | version='0.1.0', 158 | py_modules=['${2:$1}'], 159 | install_requires=[ 160 | 'Click', 161 | ], 162 | entry_points={ 163 | 'console_scripts': [ 164 | '$1 = $2:cli', 165 | ], 166 | }, 167 | ) 168 | endsnippet 169 | 170 | # Directory structure: 171 | # 172 | # project/ 173 | # yourpackage/ 174 | # __init__.py 175 | # main.py 176 | # utils.py 177 | # scripts/ 178 | # __init__.py 179 | # yourscript.py 180 | # setup.py 181 | # 182 | snippet setup "setup.py with package using setuptools" b 183 | #!/usr/bin/env python 184 | # -*- coding: utf-8 -*- 185 | 186 | from setuptools import setup, find_packages 187 | 188 | setup( 189 | name='${1:yourpackage}', 190 | version='0.1.0', 191 | packages=find_packages(), 192 | include_package_data=True, 193 | install_requires=[ 194 | 'Click', 195 | ], 196 | entry_points={ 197 | 'console_scripts': [ 198 | '${2:$1} = $1.scripts.$2:cli', 199 | ], 200 | }, 201 | ) 202 | endsnippet 203 | 204 | snippet option "click option" b 205 | @click.option('--${1:long-name}', '-${2:short-name}'${3:, type=${4:int}}) 206 | endsnippet 207 | 208 | snippet option "click option flag: --verbose" b 209 | @click.option('--${1:verbose}', '-${2:v}', is_flag=True, help='${3:help}') 210 | endsnippet 211 | 212 | snippet option "click option flag pair: --flag/--no-flag" b 213 | @click.option('--${1:flag}/--no-$1', '-${2:f}/-${3:F}', default=False, help='${4:help}') 214 | endsnippet 215 | 216 | snippet option "click option count: -v/-vv/-vvv" b 217 | @click.option('--${1:verbose}', '-${2:v}', count=True, help='${3:help}') 218 | endsnippet 219 | 220 | snippet option "click option optional value: -v/-v2" b 221 | @click.option('--${1:verbose}', '-${2:v}', is_flag=False, flag_value=${3:2}, help='${4:help}') 222 | endsnippet 223 | 224 | snippet option "click feature switch" b 225 | @click.option('--${2:feature1}', '${1:feature_name}', flag_value='$2', default=True) 226 | @click.option('--${3:feature2}', '$1', flag_value='$3') 227 | endsnippet 228 | 229 | snippet option "click option choice" b 230 | @click.option('--${1:name}', '-${2:n}', case_sensitive=False, 231 | type=click.Choice([${3:'MD5', 'SHA1'}])) 232 | endsnippet 233 | 234 | snippet option "click option range" b 235 | @click.option('--${1:name}', '-${2:n}', type=click.IntRange(${3:0}, ${4:10}${5:, clamp=True})) 236 | endsnippet 237 | 238 | snippet option "click password option" b 239 | @click.option('--${1:password}', '-${2:p}', prompt=True, hide_input=True, confirmation_prompt=True)) 240 | endsnippet 241 | 242 | snippet option "click infile option" b 243 | @click.option('${1:input}', type=click.File('rb')) 244 | endsnippet 245 | 246 | snippet option "click outfile option" b 247 | @click.option('${1:output}', type=click.File('wb')) 248 | endsnippet 249 | 250 | snippet option "click path option" b 251 | @click.option('${1:filename}', type=click.Path(${2:exists=True})) 252 | endsnippet 253 | 254 | snippet argument "click 1 argument" b 255 | @click.argument('${1:argument}') 256 | endsnippet 257 | 258 | snippet argument "click * arguments" b 259 | @click.argument('${1:argument}', nargs=-1) 260 | endsnippet 261 | 262 | snippet argument "click infile arguments" b 263 | @click.argument('${1:input}', type=click.File('rb'), nargs=-1) 264 | endsnippet 265 | 266 | snippet argument "click outfile arguments" b 267 | @click.argument('${1:output}', type=click.File('wb')) 268 | endsnippet 269 | 270 | snippet argument "click path arguments" b 271 | @click.argument('${1:filename}', type=click.Path(${2:exists=True})) 272 | endsnippet 273 | -------------------------------------------------------------------------------- /UltiSnips/python_import.snippets: -------------------------------------------------------------------------------- 1 | snippet numpy "import numpy" b 2 | import numpy as np 3 | 4 | endsnippet 5 | 6 | snippet streamlit "import streamlit" b 7 | import streamlit as st 8 | 9 | endsnippet 10 | 11 | snippet pandas "import pandas" b 12 | import pandas as pd 13 | 14 | endsnippet 15 | 16 | -------------------------------------------------------------------------------- /UltiSnips/python_routine.snippets: -------------------------------------------------------------------------------- 1 | snippet mapreduce "Sync and Async map/reduce" 2 | import functools 3 | import itertools 4 | import multiprocessing 5 | 6 | 7 | def map_reduce(mapper, reducer, inputs, process_count='auto'): 8 | """把inputs通过mapper和reducer处理为结果 9 | 10 | Args: 11 | mapper (Function): 单参数的函数,依次对inputs进行处理 12 | reducer (Function): 接受两个参数,返回一个结果 13 | inputs (Sequence): 要处理的数据列表 14 | process_count: 数字表示指定了进程数,''或'auto'使用CPU核数 15 | 16 | Returns: 最终的结果 17 | 18 | """ 19 | # 确定进程数 20 | if process_count == '' or process_count == 'auto': 21 | # 如果只有一个核就直接用当前进程即可 22 | if multiprocessing.cpu_count() > 1: 23 | process_count = multiprocessing.cpu_count() 24 | else: 25 | process_count = 0 26 | else: 27 | process_count = int(process_count) 28 | 29 | if process_count > 1: 30 | try: 31 | input_count = len(inputs) 32 | if process_count > input_count: 33 | process_count = input_count 34 | except TypeError: # Can't get len 35 | pass 36 | 37 | pool = multiprocessing.Pool(process_count) 38 | 39 | result = functools.reduce( 40 | reducer, pool.imap(mapper, inputs)) 41 | 42 | pool.close() 43 | pool.join() 44 | else: 45 | result = functools.reduce( 46 | reducer, 47 | itertools.imap(mapper, inputs)) 48 | 49 | return result 50 | endsnippet 51 | 52 | snippet ip_in_network "Check if an ip is in network" 53 | import socket 54 | import struct 55 | 56 | def ip_in_network(ip, net): 57 | """Is an address in a network 58 | Args: 59 | ip: socket.inet_aton格式或x.x.x.x格式的字符串 60 | net: 192.168.0.0/24格式的字符串 61 | 62 | Returns (Bool): ip是否在net中 63 | """ 64 | if len(ip) > 4: 65 | ip = socket.inet_aton(ip) 66 | 67 | ipaddr = struct.unpack('L', ip)[0] 68 | netaddr, bits = net.split('/') 69 | netmask = struct.unpack('L',socket.inet_aton(netaddr))[0] & ((2L< 0: 60 | logging.basicConfig(level=logging.DEBUG, format=log_format) 61 | else: 62 | logging.basicConfig(level=logging.INFO, format=log_format) 63 | 64 | main(**vars(args)) 65 | endsnippet 66 | 67 | snippet skel "minimal skel with argparse for python3" b 68 | #!/usr/bin/env python3 69 | # -*- coding: utf-8 -*- 70 | 71 | # Imports 72 | import argparse 73 | import codecs 74 | import logging 75 | 76 | VERSION=u'`!v strftime("%Y%m%d")`' 77 | 78 | logger = logging.getLogger() 79 | 80 | def main(**args): 81 | ${0:pass} 82 | 83 | if __name__ == '__main__': 84 | parser = argparse.ArgumentParser( 85 | description=u'''\ 86 | ${1:description}''') 87 | 88 | parser.add_argument('-v', '--verbose', action='count', dest='verbose', help=u'Be moderatery verbose') 89 | parser.add_argument('-q', '--quiet', action='store_true', dest='quiet', default=False, help=u'Only show warning and errors') 90 | parser.add_argument('--version', action='version', version=VERSION, help=u'Show version and quit') 91 | parser.add_argument('gateway_id', nargs=1, help=u'Gateway ID') 92 | 93 | args = parser.parse_args() 94 | 95 | if not args.verbose: 96 | args.verbose = 0 97 | 98 | # 日志初始化 99 | log_format = u'%(asctime)s %(levelname)s %(message)s' 100 | 101 | if args.quiet: 102 | logging.basicConfig(level=logging.WARNING, format=log_format) 103 | elif args.verbose > 0: 104 | logging.basicConfig(level=logging.DEBUG, format=log_format) 105 | else: 106 | logging.basicConfig(level=logging.INFO, format=log_format) 107 | 108 | main(**vars(args)) 109 | endsnippet 110 | 111 | snippet skel "full skel with argparse for python2/3" b 112 | #!/usr/bin/env python 113 | # -*- coding: utf-8 -*- 114 | 115 | """{0:描述本程序的作用} 116 | """ 117 | 118 | # Imports 119 | import argparse 120 | import logging 121 | import os 122 | import sys 123 | from distutils.dir_util import mkpath 124 | 125 | if sys.version_info[0] < 3: 126 | import cPickle as pickle 127 | import codecs 128 | import locale 129 | else: 130 | import pickle 131 | 132 | 133 | VERSION = u'`!v strftime("%Y%m%d")`' 134 | SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) 135 | # 存放结果的目录 136 | DEFAULT_OUTPUT_DIR = 'result' 137 | 138 | logger = logging.getLogger() 139 | 140 | 141 | def parse(args): 142 | """解释输入文件 143 | 144 | Args: 145 | args (Dict[string, string]): 命令行参数 146 | 147 | Returns (Dict[string, pd.DataFrame]): 解释结果 148 | """ 149 | return dict() 150 | 151 | 152 | def analyze(result, args): 153 | """分析解释结果 154 | 155 | Args: 156 | result (Dict[string, pd.DataFrame]): 解释结果 157 | args (Dict[string, string]): 命令行参数 158 | """ 159 | pass 160 | 161 | 162 | def load_result(pickle_file): 163 | """载入解释结果 164 | 165 | Args: 166 | pickle_file (string): pickle文件路径 167 | 168 | Returns (Dict[string, pd.DataFrame]): 解释结果 169 | """ 170 | logger.info(u'Loading Pickle file "%s"...', pickle_file) 171 | 172 | with open(pickle_file, 'r') as _: 173 | return pickle.load(_) 174 | 175 | logger.info(u' Done.') 176 | 177 | 178 | def export_result(pickle_file, result): 179 | """导出解释结果 180 | 181 | Args: 182 | pickle_file (string): pickle文件路径 183 | result (Dict[string, pd.DataFrame]): 解释结果 184 | """ 185 | logger.info(u'Exporting to "%s"...', pickle_file) 186 | 187 | if not os.path.exists(os.path.dirname(pickle_file)): 188 | logger.info(u' Creating "%s"...', os.path.dirname(pickle_file)) 189 | mkpath(os.path.dirname(pickle_file)) 190 | 191 | with open(pickle_file, 'w') as _: 192 | pickle.dump(result, _, pickle.HIGHEST_PROTOCOL) 193 | 194 | logger.info(u' Done.') 195 | 196 | 197 | def init_locale(): 198 | """初始化locale信息""" 199 | if sys.version_info[0] < 3: 200 | reload(sys) 201 | sys.setdefaultencoding('utf8') 202 | 203 | encoding = locale.getpreferredencoding() 204 | sys.stdout = codecs.getwriter(encoding)(sys.stdout) 205 | sys.stderr = codecs.getwriter(encoding)(sys.stderr) 206 | 207 | 208 | def locale_args(args): 209 | """对解释出来的命令行参数进行编码转换 210 | 211 | Args: 212 | args (Dict[string, string]): 解释结果 213 | 214 | Returns (Dict[string, string]): 转换为unicode的解释结果 215 | """ 216 | # 对解释出来的参数进行编码转换 217 | for key in args: 218 | value = args[key] 219 | if isinstance(value, str): 220 | args[key] = unicode(value, locale.getpreferredencoding()).strip() 221 | elif isinstance(value, list): 222 | args[key] = [ 223 | unicode(s, locale.getpreferredencoding()).strip() 224 | if isinstance(s, str) else s for s in value 225 | ] 226 | 227 | return args 228 | 229 | 230 | def init_logger(args): 231 | """日志初始化 232 | 233 | Args: 234 | args (Dict[string, string]): 命令行参数 235 | """ 236 | log_format = u'%(asctime)s %(levelname)s %(message)s' 237 | 238 | if args['quiet']: 239 | logging.basicConfig(level=logging.WARNING, format=log_format) 240 | elif args['verbose']: 241 | logging.basicConfig(level=logging.DEBUG, format=log_format) 242 | else: 243 | logging.basicConfig(level=logging.INFO, format=log_format) 244 | 245 | 246 | def main(argv): 247 | """程序主入口 248 | 249 | Args: 250 | args (Dict[string, string]): 命令行参数 251 | """ 252 | init_locale() 253 | args = init_args(argv) 254 | init_logger(args) 255 | 256 | if 'load' in args and args['load']: 257 | result = load_result(args['load']) 258 | else: 259 | result = parse(args) 260 | 261 | if 'export' in args and args['export']: 262 | export_result(args['export'], result) 263 | 264 | analyze(result, args) 265 | 266 | 267 | def init_args(argv): 268 | """解释命令行参数 269 | 270 | Args: 271 | argv (List[string]): 命令行参数(sys.argv[1:]) 272 | 273 | Returns (Dict[string, string]): 解释结果 274 | """ 275 | parser = argparse.ArgumentParser( 276 | description=u'''\ 277 | ${1:description}''') 278 | 279 | parser.add_argument( 280 | '-v', '--verbose', action='store_true', dest='verbose', default=False, 281 | help=u'显示调试日志') 282 | parser.add_argument( 283 | '-q', '--quiet', action='store_true', dest='quiet', default=False, 284 | help=u'只显示警告以上级别的日志') 285 | parser.add_argument( 286 | '--version', action='version', version=VERSION, 287 | help=u'显示程序版本号后退出') 288 | parser.add_argument( 289 | '-o', '--output', action='store', dest='output_dir', 290 | default=DEFAULT_OUTPUT_DIR, help=u'结果存放目录') 291 | parser.add_argument( 292 | '--load', action='store', dest='load', metavar='PICKLE_FILE', 293 | help=u'从pickle文件中载入数据而不是从日志中分析') 294 | parser.add_argument( 295 | '--export', action='store', dest='export', default=False, 296 | help=u'保存各结果为pickle文件') 297 | parser.add_argument( 298 | '-c', '--concurrent', action='store', default='auto', 299 | help=u'并发数') 300 | # parser.add_argument( 301 | # 'logfile', nargs='*', help=u'日志文件路径') 302 | 303 | args = vars(parser.parse_args(argv)) 304 | 305 | if sys.version_info[0] < 3: 306 | args = locale_args(args) 307 | 308 | return args 309 | 310 | 311 | if __name__ == '__main__': 312 | main(sys.argv[1:]) 313 | endsnippet 314 | 315 | -------------------------------------------------------------------------------- /UltiSnips/revealjs.snippets: -------------------------------------------------------------------------------- 1 | snippet skel "reveal.js template" b 2 | 3 | 4 | 5 | 6 | 7 | 8 | ${1:幻灯标题} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
21 |

${2:$1}

22 |
23 |
24 | ${0:输入需要的内容} 25 |
26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 44 | 45 | 46 | endsnippet 47 | 48 | snippet markdown "reveal.js markdown section w/ script" b 49 |
50 | 53 |
54 | endsnippet 55 | 56 | snippet markdown "reveal.js markdown section w/ textarea" b 57 |
58 | 61 |
62 | endsnippet 63 | 64 | snippet markdown "reveal.js markdown w/ external file" b 65 |
66 |
67 | endsnippet 68 | 69 | snippet .elem "reveal.js markdown element attributes" 70 | $0 71 | endsnippet 72 | 73 | snippet .elem "reveal.js markdown element class attributes (prepend elem)" 74 | ­$0 75 | endsnippet 76 | 77 | snippet .slide "reveal.js markdown slide attributes" 78 | $0 79 | endsnippet 80 | 81 | snippet .slide "reveal.js markdown title slide" 82 | $0 83 | endsnippet 84 | 85 | snippet notes "reveal.js HTML notes" b 86 | $0 89 | endsnippet 90 | 91 | snippet notes "reveal.js Markdown notes" b 92 | notes: ${1:speak notes} 93 | endsnippet 94 | -------------------------------------------------------------------------------- /UltiSnips/sh.snippets: -------------------------------------------------------------------------------- 1 | snippet cwd "Resolve current path and filename" 2 | SOURCE="${BASH_SOURCE[0]}" 3 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink 4 | DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" 5 | SOURCE="$(readlink "$SOURCE")" 6 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located 7 | done 8 | DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" 9 | endsnippet 10 | 11 | snippet temp "Tempfile" b 12 | ${1:TMPFILE}="$(mktemp -t ${3:--suffix=${4:.SUFFIX}} ${2:`!p 13 | snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" 14 | `}.XXXXXX)" 15 | ${5:${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'}${6/(.+)/" 0 # EXIT\n/}${7/(.+)/trap "/}${7:rm -f '$${1/.*\s//}'; exit 1}${7/(.+)/" 2 # INT\n/}${8/(.+)/trap "/}${8:rm -f '$${1/.*\s//}'; exit 1}${8/(.+)/" 1 15 # HUP TERM\n/}} 16 | 17 | endsnippet 18 | 19 | snippet temp "TempDir" 20 | ${1:TMPDIR}="$(mktemp -d ${2:`!p 21 | snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" 22 | `}.XXXXXX)" 23 | trap "rm -rf '\$$1'" 0 # EXIT 24 | trap "rm -rf '\$$1'; exit 1" 2 # INT 25 | trap "rm -rf '\$$1'; exit 1" 1 15 # HUP TERM 26 | $0 27 | endsnippet 28 | 29 | snippet #! "shebang" 30 | #!/usr/bin/env bash 31 | 32 | $0 33 | endsnippet 34 | 35 | snippet skel "Basic skel using getopt, not work in macOS" 36 | #!/usr/bin/env bash 37 | 38 | function EchoUsage() 39 | { 40 | echo " 41 | Usage: $(basename "\$0") [options] 42 | 43 | Options: 44 | -h [ --help ] show this screen 45 | -V [ --version ] show program version 46 | -v [ --verbose= ] Set log level. 0: trace, 1: debug, 2:info ... 47 | " >&2 48 | } 49 | 50 | TEMP=$(getopt -o h,V,v:: --long help,version,verbose:: -- "$@") 51 | 52 | if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi 53 | 54 | # Note the quotes around $TEMP: they are essential! 55 | eval set -- "$TEMP" 56 | 57 | show_version= 58 | args= 59 | 60 | while true ; do 61 | case "\$1" in 62 | -h|--help) 63 | EchoUsage 64 | exit 1 65 | ;; 66 | -V|--version) 67 | show_version=1 68 | shift 1 69 | break 70 | ;; 71 | -v|--verbose) 72 | args="${args} --verbose \$2" 73 | shift 2 74 | ;; 75 | --) 76 | shift 1 77 | break 78 | ;; 79 | *) 80 | echo "Unknown parameter '\$1'!" 81 | exit 1 82 | ;; 83 | esac 84 | done 85 | 86 | # 参数个数最少为1 87 | if [ $# -lt 1 ] 88 | then 89 | EchoUsage 90 | exit 1 91 | fi 92 | 93 | module_id=\$1 94 | 95 | # 显示版本 96 | if [ ! -z "${show_version}" ] 97 | then 98 | echo "Version" 99 | exit 0 100 | fi 101 | endsnippet 102 | 103 | snippet skel "Basic skel using bash getopts, work for macOS, not support long option" b 104 | #!/usr/bin/env bash 105 | 106 | EchoUsage() 107 | { 108 | echo " 109 | Usage: $(basename "\$0") [options] [--] 110 | 111 | Options: 112 | -h|help Display this message 113 | -v|verbose Display more verbose log 114 | -t|test A testing argument 115 | " >&2 116 | } 117 | 118 | VERBOSE= 119 | while getopts ":hVvt:" opt; do 120 | case $opt in 121 | h|help) 122 | EchoUsage 123 | exit 0 124 | ;; 125 | v|verbose) 126 | VERBOSE="${VERBOSE}1" 127 | ;; 128 | t|test) 129 | echo "Testing argument: '$OPTARG' at position $OPTIND" 130 | ;; 131 | * ) 132 | echo -e "\n Option does not exist : '$OPTARG' at position $OPTIND\n" 133 | EchoUsage 134 | exit 1 135 | ;; 136 | esac 137 | done 138 | shift $(($OPTIND-1)) 139 | 140 | # 参数个数最少为1 141 | if [ $# -lt 1 ] 142 | then 143 | EchoUsage 144 | exit 1 145 | fi 146 | 147 | $0 148 | endsnippet 149 | 150 | snippet ostype "case OSTYPE" b 151 | case "$OSTYPE" in 152 | "darwin"*) 153 | : "MacOS" 154 | ;; 155 | 156 | "linux"*) 157 | : "Linux" 158 | ;; 159 | 160 | *"bsd"* | "dragonfly" | "bitrig") 161 | : "BSD" 162 | ;; 163 | 164 | "cygwin" | "msys" | "win32") 165 | : "Windows" 166 | ;; 167 | 168 | *) 169 | printf '%s\n' "Unknown OS detected, aborting..." >&2 170 | exit 1 171 | ;; 172 | esac 173 | 174 | # Finally, set the variable. 175 | os="$_" 176 | endsnippet 177 | 178 | snippet die "die function" b 179 | die() { 180 | echo "\${1:-Exiting}" >&2 181 | exit "\${2:--1}" 182 | } 183 | endsnippet 184 | 185 | snippet read "read from command into array" b 186 | IFS=$'\n' read -r -d '' -a ${1:my_array} < <( ${2:command} && printf '\0' ) 187 | $0 188 | endsnippet 189 | 190 | snippet read "readarray from command into array" b 191 | readarray -t ${1:my_array} < <( ${2:command} ) 192 | $0 193 | endsnippet 194 | 195 | snippet read "read from string into array" b 196 | IFS=$'\n' read -r -d '' -a ${1:my_array} <<<${2:$string} 197 | $0 198 | endsnippet 199 | 200 | snippet read "readarray from string into array" b 201 | readarray -t ${1:my_array} <<<${2:$string} 202 | $0 203 | endsnippet 204 | 205 | snippet heredoc "heredoc from string" 206 | << ${1:EOS} 207 | ${2:lines} 208 | $1 209 | $0 210 | endsnippet 211 | 212 | snippet heredoc "heredoc from string, disable special char" 213 | << '${1:EOS}' 214 | ${2:lines} 215 | $1 216 | $0 217 | endsnippet 218 | 219 | snippet heredoc "herestring" 220 | <<< ${1:"string"} 221 | endsnippet 222 | 223 | snippet append "Append new_path to $PATH" 224 | ${1:PATH}=\$$1\${$1:+:${2:new_path}} 225 | endsnippet 226 | 227 | snippet prepend "Prepend new_path to $PATH" 228 | ${1:PATH}=\${$1:+${2:new_path}:}\$$1 229 | endsnippet 230 | 231 | snippet append "Append new_path to $PATH if not existed" 232 | case ":\${${1:PATH}:-}:" in 233 | *:${2:new_path}:*) ;; 234 | *) $1="\${$1:+\$$1:}$2" ;; 235 | esac 236 | endsnippet 237 | 238 | snippet prepend "Prepend new_path to $PATH if not existed" 239 | case ":\${${1:PATH}:-}:" in 240 | *:${2:new_path}:*) ;; 241 | *) $1="$2\${$1:+:\$$1}" ;; 242 | esac 243 | endsnippet 244 | 245 | snippet if "if ... then (if)" b 246 | if ${2:[[ ${1:condition} ]]}; then 247 | ${0:${VISUAL}} 248 | fi 249 | endsnippet 250 | 251 | snippet if "if type ... then (if cmd exists)" b 252 | if ${2:type ${1:cmd} &> /dev/null}; then 253 | ${0:${VISUAL}} 254 | fi 255 | endsnippet 256 | 257 | snippet plugin "dotfiles plugin bootstrap.sh" b 258 | source "$(dirname "$(dirname "${BASH_SOURCE[0]}")")/util.sh" 259 | init_plugin "${1:`!p snip.rv = os.path.basename(os.path.dirname(os.path.abspath(path)))`}" 260 | ${2:env}_file="$(create_plugin_file ${3:$2.sh})" 261 | $0 262 | endsnippet 263 | -------------------------------------------------------------------------------- /UltiSnips/sml.snippets: -------------------------------------------------------------------------------- 1 | # vim: foldmethod=marker 2 | 3 | # Pragmas {{{ 4 | 5 | # Statements {{{ 6 | 7 | global !p 8 | def last_module(mod): 9 | return mod.rstrip('.').rsplit('.', 1)[-1] 10 | 11 | def space_if(p): 12 | return " " if p else "" 13 | endglobal 14 | 15 | snippet datatype "Algebraic data type" !b 16 | datatype ${1:Type} = ${2:Constructor} | ${0:Constructor} 17 | endsnippet 18 | 19 | snippet rec "Data record" !b 20 | type ${1:Type} = 21 | { ${3:field} : ${4:Type} 22 | }$0 23 | endsnippet 24 | 25 | snippet new "Type Synonyms" !b 26 | type ${1:Type} = ${2:Oldtype} 27 | endsnippet 28 | 29 | # snippet cls "Type class definition" !b 30 | # class ${1:Name} where 31 | # $0 32 | # endsnippet 33 | # 34 | # snippet in "Instance definition" !b 35 | # instance ${1:Class} ${2:Type} where 36 | # $0 37 | # endsnippet 38 | 39 | # }}} Statements 40 | 41 | # Definitions {{{ 42 | 43 | # snippet :: "Type signature" !b 44 | # ${1:name} :: ${2:Type} 45 | # endsnippet 46 | # 47 | # snippet => "Class constraint" !w 48 | # ${1:Class} ${2:variable} => $2 49 | # endsnippet 50 | 51 | snippet fun "Function definition" !b 52 | fun ${1:name} ${2:args} = 53 | $0 54 | endsnippet 55 | 56 | snippet fun[] "Function definition for list patterns" !b 57 | fun ${1:name} ${2:[]} = ${3:[]} 58 | | $1 ${4:(x::xs')} = $0 59 | endsnippet 60 | 61 | # snippet def "Value definition" !b 62 | # -- | ${4:Documentation for $1} 63 | # $1 :: ${2:Type} 64 | # ${1:name} = ${5:error "undefined: \`$1' in `!v expand('%')`"} 65 | # endsnippet 66 | # 67 | # snippet = "Function clause" !b 68 | # ${1:name} ${2:pattern} = ${3:undefined} 69 | # endsnippet 70 | # 71 | # snippet 2= "Function clause" !b 72 | # ${1:name} ${2:pattern} = ${3:undefined} 73 | # $1 ${4:pattern} = ${5:undefined} 74 | # endsnippet 75 | # 76 | # snippet 3= "Function clause" !b 77 | # ${1:name} ${2:pattern} = ${3:undefined} 78 | # $1 ${4:pattern} = ${5:undefined} 79 | # $1 ${6:pattern} = ${7:undefined} 80 | # endsnippet 81 | 82 | snippet | "Guard" !b 83 | | ${1:predicate} = ${2:undefined} 84 | endsnippet 85 | 86 | # }}} Definitions 87 | 88 | # Expressions {{{ 89 | 90 | snippet \ "Lambda" !w 91 | \\ ${1:args} -> ${2:expression} 92 | endsnippet 93 | 94 | snippet if "Boolean conditional" !w 95 | if ${1:condition} 96 | then ${2:expression} 97 | else ${3:expression} 98 | endsnippet 99 | 100 | snippet case "Pattern match" !w 101 | case ${1:scrutinee} of 102 | ${2:[]} => ${3:expression} 103 | | ${4:x::xs'} => ${5:expression} 104 | endsnippet 105 | 106 | snippet aux "Aux function for tail cursion" 107 | let fun aux(${1:lst}, acc) = 108 | case $1 of 109 | ${2:[]} => ${3:acc} 110 | | ${4:x::xs} => ${5:aux(xs, ${6:x::acc})} 111 | in 112 | aux($1, []) 113 | end 114 | endsnippet 115 | 116 | # snippet qq "Quasi quote" !w 117 | # [${1:quoter}|${2:content}|] 118 | # endsnippet 119 | # 120 | # snippet [|] "List comprehension" !w 121 | # [${3:foo }$1 | ${1:x} <- ${2:xs} ] 122 | # endsnippet 123 | 124 | snippet let "let ... in ... end" !b 125 | let 126 | ${1:val} ${2:name} = ${3:expression} 127 | in 128 | ${4:expression} 129 | end 130 | endsnippet 131 | # }}} Expressions 132 | 133 | snippet // "comment (* *)" 134 | (* $1 *) 135 | $0 136 | endsnippet 137 | 138 | -------------------------------------------------------------------------------- /UltiSnips/tex.snippets: -------------------------------------------------------------------------------- 1 | snippet template "Basic template" b 2 | \documentclass[a4paper]{article} 3 | 4 | \usepackage[utf8]{inputenc} 5 | \usepackage[T1]{fontenc} 6 | \usepackage{textcomp} 7 | \usepackage[dutch]{babel} 8 | \usepackage{amsmath, amssymb} 9 | 10 | 11 | % figure support 12 | \usepackage{import} 13 | \usepackage{xifthen} 14 | \pdfminorversion=7 15 | \usepackage{pdfpages} 16 | \usepackage{transparent} 17 | \newcommand{\incfig}[1]{% 18 | \def\svgwidth{\columnwidth} 19 | \import{./figures/}{#1.pdf_tex} 20 | } 21 | 22 | \pdfsuppresswarningpagegroup=1 23 | 24 | \begin{document} 25 | $0 26 | \end{document} 27 | endsnippet 28 | 29 | snippet beg "begin{} / end{}" bA 30 | \\begin{$1} 31 | $0 32 | \\end{$1} 33 | endsnippet 34 | 35 | priority 100 36 | snippet ... "ldots" iA 37 | \ldots 38 | endsnippet 39 | 40 | snippet table "Table environment" b 41 | \begin{table}[${1:htpb}] 42 | \centering 43 | \caption{${2:caption}} 44 | \label{tab:${3:label}} 45 | \begin{tabular}{${5:c}} 46 | $0${5/((?<=.)c|l|r)|./(?1: & )/g} 47 | \end{tabular} 48 | \end{table} 49 | endsnippet 50 | 51 | snippet fig "Figure environment" b 52 | \begin{figure}[${1:htpb}] 53 | \centering 54 | ${2:\includegraphics[width=0.8\textwidth]{$3}} 55 | \caption{${4:$3}} 56 | \label{fig:${5:${3/\W+/-/g}}} 57 | \end{figure} 58 | endsnippet 59 | 60 | snippet enum "Enumerate" bA 61 | \begin{enumerate} 62 | \item $0 63 | \end{enumerate} 64 | endsnippet 65 | 66 | snippet item "Itemize" bA 67 | \begin{itemize} 68 | \item $0 69 | \end{itemize} 70 | endsnippet 71 | 72 | snippet desc "Description" b 73 | \begin{description} 74 | \item[$1] $0 75 | \end{description} 76 | endsnippet 77 | 78 | snippet pac "Package" b 79 | \usepackage[${1:options}]{${2:package}}$0 80 | endsnippet 81 | 82 | snippet => "implies" Ai 83 | \implies 84 | endsnippet 85 | 86 | snippet =< "implied by" Ai 87 | \impliedby 88 | endsnippet 89 | 90 | snippet ali "Align" bA 91 | \begin{align*} 92 | ${1:${VISUAL}} 93 | .\end{align*} 94 | endsnippet 95 | 96 | snippet sympy "sympyblock " w 97 | sympy $1 sympy$0 98 | endsnippet 99 | 100 | priority 10000 101 | snippet 'sympy(.*)sympy' "sympy" wr 102 | `!p 103 | from sympy import * 104 | x, y, z, t = symbols('x y z t') 105 | k, m, n = symbols('k m n', integer=True) 106 | f, g, h = symbols('f g h', cls=Function) 107 | init_printing() 108 | snip.rv = eval('latex(' + match.group(1).replace('\\', '').replace('^', '**').replace('{', '(').replace('}', ')') + ')') 109 | ` 110 | endsnippet 111 | 112 | priority 1000 113 | snippet math "mathematicablock" w 114 | math $1 math$0 115 | endsnippet 116 | 117 | priority 10000 118 | snippet 'math(.*)math' "math" wr 119 | `!p 120 | import subprocess 121 | code = match.group(1) 122 | code = 'ToString[' + code + ', TeXForm]' 123 | snip.rv = subprocess.check_output(['wolframscript', '-code', code]) 124 | ` 125 | endsnippet 126 | 127 | snippet == "equals" iA 128 | &= $1 \\\\ 129 | endsnippet 130 | 131 | snippet != "equals" iA 132 | \neq 133 | endsnippet 134 | 135 | snippet pmat "pmat" iA 136 | \begin{pmatrix} $1 \end{pmatrix} $0 137 | endsnippet 138 | 139 | snippet bmat "bmat" iA 140 | \begin{bmatrix} $1 \end{bmatrix} $0 141 | endsnippet 142 | 143 | snippet lr "left( right)" i 144 | \left( ${1:${VISUAL}} \right) $0 145 | endsnippet 146 | 147 | snippet lr( "left( right)" i 148 | \left( ${1:${VISUAL}} \right) $0 149 | endsnippet 150 | 151 | snippet lr| "left| right|" i 152 | \left| ${1:${VISUAL}} \right| $0 153 | endsnippet 154 | 155 | snippet lr{ "left\{ right\}" i 156 | \left\\{ ${1:${VISUAL}} \right\\} $0 157 | endsnippet 158 | 159 | snippet lrb "left\{ right\}" i 160 | \left\\{ ${1:${VISUAL}} \right\\} $0 161 | endsnippet 162 | 163 | snippet lr[ "left[ right]" i 164 | \left[ ${1:${VISUAL}} \right] $0 165 | endsnippet 166 | 167 | snippet lra "leftangle rightangle" iA 168 | \left<${1:${VISUAL}} \right>$0 169 | endsnippet 170 | 171 | snippet sum "sum" w 172 | \sum_{n=${1:1}}^{${2:\infty}} ${3:a_n z^n} 173 | endsnippet 174 | 175 | snippet taylor "taylor" w 176 | \sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1 $0 177 | endsnippet 178 | 179 | snippet lim "limit" w 180 | \lim_{${1:n} \to ${2:\infty}} 181 | endsnippet 182 | 183 | snippet limsup "limsup" w 184 | \limsup_{${1:n} \to ${2:\infty}} 185 | endsnippet 186 | 187 | snippet prod "product" w 188 | \prod_{${1:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}} $0 189 | endsnippet 190 | 191 | snippet part "d/dx" w 192 | \frac{\partial ${1:V}}{\partial ${2:x}} $0 193 | endsnippet 194 | 195 | snippet R0+ "R0+" iA 196 | \\R_0^+ 197 | endsnippet 198 | 199 | snippet plot "Plot" w 200 | \begin{figure}[$1] 201 | \centering 202 | \begin{tikzpicture} 203 | \begin{axis}[ 204 | xmin= ${2:-10}, xmax= ${3:10}, 205 | ymin= ${4:-10}, ymax = ${5:10}, 206 | axis lines = middle, 207 | ] 208 | \addplot[domain=$2:$3, samples=${6:100}]{$7}; 209 | \end{axis} 210 | \end{tikzpicture} 211 | \caption{$8} 212 | \label{${9:$8}} 213 | \end{figure} 214 | endsnippet 215 | 216 | snippet nn "Tikz node" w 217 | \node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$}; 218 | $0 219 | endsnippet 220 | 221 | snippet lll "l" iA 222 | \ell 223 | endsnippet 224 | 225 | priority 100 226 | snippet ** "cdot" iA 227 | \cdot 228 | endsnippet 229 | 230 | snippet >> ">>" iA 231 | \gg 232 | endsnippet 233 | 234 | snippet << "<<" iA 235 | \ll 236 | endsnippet 237 | 238 | 239 | snippet ~~ "~" iA 240 | \sim 241 | endsnippet 242 | 243 | snippet || "mid" iA 244 | \mid 245 | endsnippet 246 | 247 | 248 | snippet notin "not in " iA 249 | \not\in 250 | endsnippet 251 | 252 | snippet NN "n" iA 253 | \N 254 | endsnippet 255 | 256 | snippet Nn "cap" iA 257 | \cap 258 | endsnippet 259 | 260 | snippet UU "cup" iA 261 | \cup 262 | endsnippet 263 | 264 | snippet uuu "bigcup" iA 265 | \bigcup_{${1:i \in ${2: I}}} $0 266 | endsnippet 267 | 268 | snippet nnn "bigcap" iA 269 | \bigcap_{${1:i \in ${2: I}}} $0 270 | endsnippet 271 | 272 | snippet OO "emptyset" iA 273 | \O 274 | endsnippet 275 | 276 | snippet RR "real" iA 277 | \R 278 | endsnippet 279 | 280 | snippet QQ "Q" iA 281 | \Q 282 | endsnippet 283 | 284 | snippet ZZ "Z" iA 285 | \Z 286 | endsnippet 287 | 288 | snippet "hokje" iA 293 | \diamond 294 | endsnippet 295 | 296 | 297 | snippet SI "SI" iA 298 | \SI{$1}{$2} 299 | endsnippet 300 | 301 | snippet bigfun "Big function" iA 302 | \begin{align*} 303 | $1: $2 &\longrightarrow $3 \\\\ 304 | $4 &\longmapsto $1($4) = $0 305 | .\end{align*} 306 | endsnippet 307 | 308 | snippet cvec "column vector" iA 309 | \begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix} 310 | endsnippet 311 | 312 | snippet letw "let omega" iA 313 | Let $\Omega \subset \C$ be open. 314 | endsnippet 315 | 316 | 317 | # vim:ft=snippets 318 | 319 | -------------------------------------------------------------------------------- /UltiSnips/tex_math.snippets: -------------------------------------------------------------------------------- 1 | global !p 2 | texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']] 3 | 4 | texIgnoreMathZones = ['texMathText'] 5 | 6 | texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')") 7 | texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')") 8 | 9 | ignore = texIgnoreMathZoneIds[0] 10 | 11 | def math(): 12 | synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))") 13 | try: 14 | first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds) 15 | return first != ignore 16 | except StopIteration: 17 | return False 18 | endglobal 19 | 20 | snippet mk "Math" wA 21 | $${1}$`!p 22 | if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']: 23 | snip.rv = ' ' 24 | else: 25 | snip.rv = '' 26 | `$2 27 | endsnippet 28 | 29 | snippet dm "Math" wA 30 | \[ 31 | ${1:${VISUAL}} 32 | .\] $0 33 | endsnippet 34 | 35 | context "math()" 36 | snippet iff "iff" Ai 37 | \iff 38 | endsnippet 39 | 40 | context "math()" 41 | snippet iff "iff" Ai 42 | \iff 43 | endsnippet 44 | 45 | context "math()" 46 | snippet / "Fraction" i 47 | \\frac{${VISUAL}}{$1}$0 48 | endsnippet 49 | 50 | context "math()" 51 | snippet // "Fraction" iA 52 | \\frac{$1}{$2}$0 53 | endsnippet 54 | 55 | context "math()" 56 | snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA 57 | \\frac{`!p snip.rv = match.group(1)`}{$1}$0 58 | endsnippet 59 | 60 | priority 1000 61 | context "math()" 62 | snippet '^.*\)/' "() frac" wrA 63 | `!p 64 | stripped = match.string[:-1] 65 | depth = 0 66 | i = len(stripped) - 1 67 | while True: 68 | if stripped[i] == ')': depth += 1 69 | if stripped[i] == '(': depth -= 1 70 | if depth == 0: break; 71 | i-=1 72 | snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}" 73 | `{$1}$0 74 | endsnippet 75 | 76 | context "math()" 77 | snippet '([A-Za-z])(\d)' "auto subscript" wrA 78 | `!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` 79 | endsnippet 80 | 81 | context "math()" 82 | snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA 83 | `!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`} 84 | endsnippet 85 | 86 | context "math()" 87 | snippet ceil "ceil" iA 88 | \left\lceil $1 \right\rceil $0 89 | endsnippet 90 | 91 | context "math()" 92 | snippet floor "floor" iA 93 | \left\lfloor $1 \right\rfloor$0 94 | endsnippet 95 | 96 | context "math()" 97 | snippet () "left( right)" iA 98 | \left( ${1:${VISUAL}} \right) $0 99 | endsnippet 100 | 101 | context "math()" 102 | snippet conj "conjugate" iA 103 | \overline{$1}$0 104 | endsnippet 105 | 106 | context "math()" 107 | snippet sq "\sqrt{}" iA 108 | \sqrt{${1:${VISUAL}}} $0 109 | endsnippet 110 | 111 | context "math()" 112 | snippet sr "^2" iA 113 | ^2 114 | endsnippet 115 | 116 | context "math()" 117 | snippet cb "^3" iA 118 | ^3 119 | endsnippet 120 | 121 | context "math()" 122 | snippet td "to the ... power" iA 123 | ^{$1}$0 124 | endsnippet 125 | 126 | context "math()" 127 | snippet rd "to the ... power" iA 128 | ^{($1)}$0 129 | endsnippet 130 | 131 | context "math()" 132 | snippet __ "subscript" iA 133 | _{$1}$0 134 | endsnippet 135 | 136 | context "math()" 137 | snippet ooo "\infty" iA 138 | \infty 139 | endsnippet 140 | 141 | context "math()" 142 | snippet rij "mrij" i 143 | (${1:x}_${2:n})_{${3:$2}\\in${4:\\N}}$0 144 | endsnippet 145 | 146 | context "math()" 147 | snippet <= "leq" iA 148 | \le 149 | endsnippet 150 | 151 | context "math()" 152 | snippet >= "geq" iA 153 | \ge 154 | endsnippet 155 | 156 | context "math()" 157 | snippet EE "geq" iA 158 | \exists 159 | endsnippet 160 | 161 | context "math()" 162 | snippet AA "forall" iA 163 | \forall 164 | endsnippet 165 | 166 | context "math()" 167 | snippet xnn "xn" iA 168 | x_{n} 169 | endsnippet 170 | 171 | context "math()" 172 | snippet ynn "yn" iA 173 | y_{n} 174 | endsnippet 175 | 176 | 177 | context "math()" 178 | snippet xii "xi" iA 179 | x_{i} 180 | endsnippet 181 | 182 | context "math()" 183 | snippet yii "yi" iA 184 | y_{i} 185 | endsnippet 186 | 187 | context "math()" 188 | snippet xjj "xj" iA 189 | x_{j} 190 | endsnippet 191 | 192 | context "math()" 193 | snippet yjj "yj" iA 194 | y_{j} 195 | endsnippet 196 | 197 | context "math()" 198 | snippet xp1 "x" iA 199 | x_{n+1} 200 | endsnippet 201 | 202 | context "math()" 203 | snippet xmm "x" iA 204 | x_{m} 205 | endsnippet 206 | 207 | context "math()" 208 | snippet mcal "mathcal" iA 209 | \mathcal{$1}$0 210 | endsnippet 211 | 212 | context "math()" 213 | snippet nabl "nabla" iA 214 | \nabla 215 | endsnippet 216 | 217 | context "math()" 218 | snippet xx "cross" iA 219 | \times 220 | endsnippet 221 | 222 | context "math()" 223 | snippet norm "norm" iA 224 | \|$1\|$0 225 | endsnippet 226 | 227 | priority 100 228 | context "math()" 229 | snippet '(? "to" iA 249 | \to 250 | endsnippet 251 | 252 | priority 200 253 | context "math()" 254 | snippet <-> "leftrightarrow" iA 255 | \leftrightarrow 256 | endsnippet 257 | 258 | context "math()" 259 | snippet !> "mapsto" iA 260 | \mapsto 261 | endsnippet 262 | 263 | context "math()" 264 | snippet invs "inverse" iA 265 | ^{-1} 266 | endsnippet 267 | 268 | context "math()" 269 | snippet compl "complement" iA 270 | ^{c} 271 | endsnippet 272 | 273 | context "math()" 274 | snippet \\\ "setminus" iA 275 | \setminus 276 | endsnippet 277 | 278 | context "math()" 279 | snippet set "set" wA 280 | \\{$1\\} $0 281 | endsnippet 282 | 283 | context "math()" 284 | snippet cc "subset" Ai 285 | \subset 286 | endsnippet 287 | 288 | context "math()" 289 | snippet inn "in " iA 290 | \in 291 | endsnippet 292 | 293 | context "math()" 294 | snippet '(?) 31 | endif 32 | endfunction " }}} 33 | 34 | function! myspacevim#after() abort " {{{ 35 | set ignorecase 36 | set smartcase " Depending on 'ignorecase', will override 'ignorecase' if the search pattern contains upper case characters 37 | set wildmode=longest:full,full 38 | set wildmenu 39 | " Fix compatibility of CJK long lines. 40 | set nolinebreak 41 | 42 | set wrap 43 | 44 | call s:setup_plugin_after() 45 | 46 | if filereadable('/usr/share/dict/words') 47 | if &dictionary == '' 48 | set dictionary+=/usr/share/dict/words 49 | endif 50 | endif 51 | 52 | " if executable('chez') 53 | " call SpaceVim#plugins#runner#reg_runner('scheme', 'chez --script %s') 54 | " call SpaceVim#plugins#repl#reg('scheme', ['chez', '--quiet']) 55 | " else 56 | " call SpaceVim#plugins#runner#reg_runner('scheme', 'scheme --script %s') 57 | " call SpaceVim#plugins#repl#reg('scheme', ['scheme', '--quiet']) 58 | " endif 59 | endfunction " }}} 60 | 61 | function! myspacevim#IncludePathHook(config) " {{{ 62 | if has_key(a:config, 'c_include_path') 63 | let include = a:config['c_include_path'] 64 | if type(include) == type("") 65 | let raw_path = has('win32') ? tr(include, '\', '/') : include 66 | let paths = split(raw_path, ':') 67 | let root = SpaceVim#plugins#projectmanager#current_root() 68 | for p in paths 69 | let &l:path .= ',' . root . p 70 | endfor 71 | endif 72 | endif 73 | endfunction " }}} 74 | 75 | function! s:goyo_enter() " {{{ 76 | if executable('tmux') 77 | silent !tmux set status off 78 | silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z 79 | endif 80 | endfunction " }}} 81 | 82 | function! s:goyo_leave() " {{{ 83 | if executable('tmux') 84 | silent !tmux set status on 85 | silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z 86 | endif 87 | endfunction " }}} 88 | 89 | function! s:setup_lsp() " {{{ 90 | let lsp_servers = { 91 | \ 'c' : 'clangd', 92 | \ 'cpp' : 'clangd', 93 | \ 'css' : 'css-languageserver', 94 | \ 'dockerfile' : 'docker-langserver', 95 | \ 'go' : 'gopls', 96 | \ 'haskell' : {'hie':'hie-wrapper'}, 97 | \ 'html' : 'html-languageserver', 98 | \ 'javascript' : {'tsserver': 'typescript-language-server'}, 99 | \ 'javascriptreact' : {'tsserver': 'typescript-language-server'}, 100 | \ 'objc' : 'clangd', 101 | \ 'objcpp' : 'clangd', 102 | \ 'php' : {'':'php', 'phpactor':'phpactor'}, 103 | \ 'purescript' : 'purescript-language-server', 104 | \ 'python' : 'pyls', 105 | \ 'reason' : 'ocaml-language-server', 106 | \ 'ruby' : 'solargraph', 107 | \ 'rust' : 'rustup', 108 | \ 'scala' : 'metals-vim', 109 | \ 'sh' : {'bashls':'bash-language-server'}, 110 | \ 'typescript' : {'tsserver': 'typescript-language-server'}, 111 | \ 'typescriptreact' : {'tsserver': 'typescript-language-server'}, 112 | \ 'vim' : {'vimls':'vim-language-server'}, 113 | \ 'vue' : 'vls' 114 | \ } 115 | 116 | let filetypes = [] " for old version 117 | let enabled_clients = [] " for neovim 0.50 and above 118 | let executables = {} 119 | 120 | for [lang, lsp] in items(lsp_servers) 121 | if type(lsp) == v:t_dict 122 | " lspconfig client name -> executable. empty name means not such lspconfig 123 | for [c, e] in items(lsp) 124 | if (has_key(executables, e) && !executables[e]) 125 | continue 126 | endif 127 | 128 | if ! executable(e) 129 | let executables[e] = 0 130 | continue 131 | endif 132 | 133 | let executables[e] = 1 134 | call add(filetypes, lang) 135 | if c != "" 136 | call add(enabled_clients, c) 137 | endif 138 | endfor 139 | elseif type(lsp) == v:t_list 140 | for e in lsp 141 | if (has_key(executables, e) && !executables[e]) 142 | continue 143 | endif 144 | 145 | if ! executable(e) 146 | let executables[e] = 0 147 | continue 148 | endif 149 | 150 | let executables[e] = 1 151 | 152 | call add(filetypes, lang) 153 | call add(enabled_clients, e) 154 | endfor 155 | else 156 | if (has_key(executables, lsp) && !executables[lsp]) 157 | continue 158 | endif 159 | 160 | if ! executable(lsp) 161 | let executables[lsp] = 0 162 | continue 163 | endif 164 | 165 | let executables[lsp] = 1 166 | 167 | call add(filetypes, lang) 168 | call add(enabled_clients, lsp) 169 | endif 170 | endfor 171 | 172 | let filetypes = uniq(sort(filetypes)) 173 | let enabled_clients = uniq(sort(enabled_clients)) 174 | 175 | call SpaceVim#logger#info('enabled lsp langs: ' . string(filetypes)) 176 | call SpaceVim#logger#info('enabled lsp clients: ' . string(enabled_clients)) 177 | 178 | call SpaceVim#layers#lsp#set_variable({ 179 | \ 'filetypes' : filetypes, 180 | \ 'enabled_clients' : enabled_clients, 181 | \ }) 182 | endfunction " }}} 183 | 184 | function! s:setup_conemu() " {{{ 185 | if &term=='win32' && !empty($ConEmuANSI) 186 | " echom "Running in conemu" 187 | " Should ``chcp 65001`` in console 188 | set termencoding=utf8 189 | set term=xterm 190 | set t_Co=256 191 | let &t_AB="\e[48;5;%dm" 192 | let &t_AF="\e[38;5;%dm" 193 | let g:spacevim_enable_guicolors=0 194 | let g:spacevim_colorscheme_default = "gruvbox" 195 | endif 196 | endfunction 197 | " }}} 198 | 199 | function! s:setup_mapping() " {{{ 200 | nnoremap zJ zjzx 201 | nnoremap zK zkzx 202 | 203 | " use '%/' in cmdline to get current file path. e.g. :e %/ 204 | cmap %/ =escape(expand("%:p:h")."/", ' \') 205 | 206 | "" vim-mark m {{{ 207 | call SpaceVim#custom#LeaderGroupName(['m'], '+vim-mark') 208 | call SpaceVim#custom#leader('nnoremap ', 'mm', 'MarkSet', 'Mark current word') 209 | call SpaceVim#custom#leader('xnoremap ', 'mm', 'MarkSet', 'Mark selected word') 210 | call SpaceVim#custom#leader('nnoremap ', 'mr', 'MarkRegex', 'Mark using regex', 'MarkRegex') 211 | call SpaceVim#custom#leader('xnoremap ', 'mr', 'MarkRegex', 'Mark selection as regex','MarkRegex') 212 | call SpaceVim#custom#leader('nnoremap ', 'mc', 'MarkClear', 'Clear current mark','MarkClear') 213 | call SpaceVim#custom#leader('nnoremap ', 'mM', 'MarkToggle', 'Toggle marks', 'MarkToggle') 214 | call SpaceVim#custom#leader('nnoremap ', 'mC', 'MarkConfirmAllClear', 'Clear ALL marks','MarkAllClear') 215 | 216 | " nmap mn MarkSearchCurrentNext 217 | " nmap mp MarkSearchCurrentPrev 218 | " nmap mN MarkSearchAnyNext 219 | " nmap mP MarkSearchAnyPrev 220 | " nmap IgnoreMarkSearchNext MarkSearchNext 221 | " nmap IgnoreMarkSearchPrev MarkSearchPrev 222 | 223 | " highlight MarkWord1 ctermbg=DarkCyan ctermfg=Black guibg=#8CCBEA guifg=Black | 224 | " highlight MarkWord2 ctermbg=DarkMagenta ctermfg=Black guibg=#FF7272 guifg=Black | 225 | " highlight MarkWord3 ctermbg=DarkYellow ctermfg=Black guibg=#FFDB72 guifg=Black | 226 | " highlight MarkWord4 ctermbg=DarkGreen ctermfg=Black guibg=#FFB3FF guifg=Black | 227 | " highlight MarkWord5 ctermbg=DarkRed ctermfg=Black guibg=#9999FF guifg=Black | 228 | " highlight MarkWord6 ctermbg=DarkBlue ctermfg=Black guibg=#A4E57E guifg=Black 229 | "" }}} 230 | endfunction 231 | " }}} 232 | 233 | function! s:setup_plugin() " {{{ 234 | "" xml syntax {{{ 235 | let g:xml_syntax_folding = 1 236 | augroup myspacevim_xml 237 | autocmd! BufNewFile,BufEnter *.xml 238 | \ setlocal foldmethod=syntax 239 | augroup END 240 | "" }}} 241 | 242 | "" dein.vim {{{ 243 | " Do a shallow clone 244 | let g:dein#types#git#clone_depth = 1 245 | "" }}} 246 | 247 | "" Projectionist {{{ 248 | let g:projectionist_heuristics = { 249 | \ 'Makefile': { 250 | \ '*': {'make': 'make'}, 251 | \ }, 252 | \ 'Jamroot|Jamroot.v2': { 253 | \ '*': {'make': 'b2'}, 254 | \ }, 255 | \ } 256 | "" }}} 257 | 258 | "" clang2 {{{ 259 | let g:clang2_placeholder_next = '' 260 | let g:clang2_placeholder_prev = '' 261 | "" }}} 262 | 263 | "" incsearch {{{ 264 | let g:incsearch#auto_nohlsearch = 0 265 | "" }}} 266 | 267 | "" ultisnips {{{ 268 | let g:UltiSnipsNoPythonWarning = 1 269 | let g:ultisnips_python_quoting_style = "single" 270 | let g:ultisnips_python_triple_quoting_style = "double" 271 | let g:ultisnips_python_style = "google" 272 | "" }}} 273 | 274 | "" vim-pydocstring {{{ 275 | let g:pydocstring_templates_dir = '~/.SpaceVim.d/templates/pydocstring/google' 276 | "" }}} 277 | 278 | "" Tagbar {{{ 279 | let g:tagbar_autofocus = 1 280 | "" }}} 281 | 282 | "" Startify {{{ 283 | let g:startify_custom_header = [' Welcome to SpaceVim!'] 284 | "" }}} 285 | 286 | "" Unite {{{ 287 | if exists('*unite#custom#source') 288 | call unite#custom#source( 289 | \ 'file_rec,file_rec/async,grep', 290 | \ 'ignore_pattern', 291 | \ join([ 292 | \ '\%(^\|/\)\.$', 293 | \ '\~$', 294 | \ '\.\%(o\|a\|exe\|dll\|bak\|DS_Store\|zwc\|pyc\|sw[po]\|class\|gcno\|gcda\|gcov\)$', 295 | \ '\%(^\|/\)gcc-[0-9]\+\%(\.[0-9]\+\)*/', 296 | \ '\%(^\|/\)doc/html/', 297 | \ '\%(^\|/\)stage/', 298 | \ '\%(^\|/\)boost\%(\|_\w\+\)/', 299 | \ '\%(^\|/\)\%(\.hg\|\.git\|\.bzr\|\.svn\|tags\%(-.*\)\?\)\%($\|/\)', 300 | \ ], '\|')) 301 | endif 302 | "" }}} 303 | 304 | "" vim-asciidoc-folding {{{ 305 | let g:asciidoc_fold_style = 'nested' 306 | let g:asciidoc_fold_override_foldtext = 1 307 | "" }}} 308 | 309 | "" vim-markdown {{{ 310 | "let g:markdown_default_mappings = 1 311 | let g:vim_markdown_auto_insert_bullets = 0 312 | "let g:markdown_hi_error = 1 313 | "" }}} 314 | 315 | "" vim-markdown-folding {{{ 316 | let g:markdown_fold_style = 'nested' 317 | let g:markdown_fold_override_foldtext = 1 318 | "" }}} 319 | 320 | "" vim-markdown-toc {{{ 321 | let g:vmt_auto_update_on_save = 0 322 | let g:vmt_dont_insert_fence = 0 323 | let g:vmt_cycle_list_item_markers = 1 324 | "" }}} 325 | 326 | "" vim-bracketed-paste {{{ 327 | let g:bracketed_paste_tmux_wrap = 0 328 | "" }}} 329 | 330 | "" CodeReviewer.vim {{{ 331 | call SpaceVim#mapping#def('nmap ', 'i', 'AddComment', 'Insert code review comment', 'AddComment') 332 | 333 | if $USER != "" 334 | let g:CodeReviewer_reviewer = $USER 335 | elseif $USERNAME != "" 336 | let g:CodeReviewer_reviewer = $USERNAME 337 | else 338 | let g:CodeReviewer_reviewer = "Unknown" 339 | endif 340 | 341 | let g:CodeReviewer_reviewFile="review.rev" 342 | "" }}} 343 | 344 | "" coc.nvim {{{ 345 | if exists('*coc#config') 346 | call coc#config('coc.preferences', { 347 | \ "autoTrigger": "always", 348 | \ "maxCompleteItemCount": 10, 349 | \ "codeLens.enable": 1, 350 | \ "diagnostic.virtualText": 1, 351 | \}) 352 | 353 | let s:coc_extensions = [ 354 | \ 'coc-dictionary', 355 | \ 'coc-json', 356 | \ 'coc-ultisnips', 357 | \ 'coc-tag', 358 | \] 359 | 360 | for extension in s:coc_extensions 361 | call coc#add_extension(extension) 362 | endfor 363 | endif 364 | "" }}} 365 | 366 | "" colorizer {{{ 367 | let g:colorizer_maxlines = 1000 " Disable plugin on large file 368 | "" }}} 369 | 370 | "" indentLine {{{ 371 | let g:indentLine_setColors = 0 372 | let g:indentLine_fileTypeExclude = get(g:, 'indentLine_fileTypeExclude', []) 373 | call add(g:indentLine_fileTypeExclude, 'sml') 374 | "" }}} 375 | 376 | "" neovide (GUI for windows) {{{ 377 | if exists("g:neovide") 378 | let g:neovide_position_animation_length = 0 379 | let g:neovide_cursor_animation_length = 0.00 380 | let g:neovide_cursor_trail_size = 0 381 | let g:neovide_cursor_animate_in_insert_mode = false 382 | let g:neovide_cursor_animate_command_line = false 383 | let g:neovide_scroll_animation_far_lines = 0 384 | let g:neovide_scroll_animation_length = 0.00 385 | endif 386 | "" }}} 387 | endfunction 388 | " }}} 389 | 390 | function! s:setup_autocmd() " {{{ 391 | augroup myspacevim_cpp 392 | autocmd! 393 | autocmd! FileType c,cpp 394 | \ setlocal foldmethod=syntax 395 | \| setlocal foldlevel=99 396 | augroup END 397 | 398 | augroup myspacevim_asciidoc 399 | autocmd! 400 | autocmd! FileType asciidoc 401 | \ :setlocal foldlevel=0 402 | augroup END 403 | 404 | augroup myspacevim_markdown 405 | autocmd! 406 | autocmd! FileType markdown 407 | \ :setlocal foldlevel=1 shiftwidth=2 408 | \| :command! -buffer -range=% ReBullet silent! %s/^\( \( \)*\)\* /\1- / silent! %s/^\(\( \)*\)\- /\1* / 409 | augroup END 410 | 411 | augroup myspacevim_scss 412 | autocmd! 413 | autocmd! FileType scss 414 | \ :setlocal shiftwidth=2 415 | augroup END 416 | 417 | augroup myspacevim_haskell 418 | autocmd! 419 | autocmd! FileType haskell 420 | \ :setlocal shiftwidth=2 expandtab 421 | augroup END 422 | 423 | " surround 424 | augroup myspacevim_surround_markdown 425 | autocmd! 426 | autocmd! FileType markdown :let b:surround_96 = "``\r``" 427 | augroup END 428 | 429 | " Goyo, Distraction-free writing in Vim 430 | augroup myspacevim_goyo 431 | autocmd! 432 | autocmd! User GoyoEnter nested call goyo_enter() 433 | autocmd! User GoyoLeave nested call goyo_leave() 434 | augroup END 435 | 436 | augroup myspacevim_yaml 437 | autocmd! 438 | autocmd! BufNewFile,BufEnter *.ksy 439 | \ :setlocal filetype=yaml 440 | autocmd! FileType yaml :setlocal shiftwidth=2 expandtab 441 | augroup END 442 | 443 | augroup myspacevim_private 444 | autocmd! 445 | autocmd! BufNewFile,BufEnter */private/* 446 | \ :setlocal noswapfile noundofile nobackup writebackup backupdir=. 447 | augroup END 448 | 449 | augroup myspacevim_lilypond 450 | autocmd! 451 | autocmd! FileType lilypond 452 | \ setlocal tabstop=2 453 | \| setlocal softtabstop=2 454 | \| setlocal shiftwidth=2 455 | augroup END 456 | 457 | endfunction 458 | " }}} 459 | 460 | function! s:setup_plugin_after() " {{{ 461 | if exists('*editorconfig#AddNewHook') 462 | call editorconfig#AddNewHook(function('myspacevim#IncludePathHook')) 463 | endif 464 | 465 | "" NERD_commenter.vim {{{ 466 | if SpaceVim#layers#isLoaded('lang#c') 467 | call SpaceVim#custom#SPC('nmap', ['c', 'c'], 'NERDCommenterToggle', 'comment or uncomment lines(aligned)', 0) 468 | endif 469 | "" }}} 470 | 471 | "" unite {{{ 472 | if exists('*unite#filters#matcher_default#use') 473 | call unite#filters#matcher_default#use(['matcher_context']) 474 | endif 475 | 476 | if exists('*unite#custom#profile') 477 | call unite#custom#profile('default', 'context', { 478 | \ 'direction': 'botright', 479 | \ }) 480 | endif 481 | ""}}} 482 | 483 | "" denite {{{ 484 | if exists('*denite#custom#source') 485 | call denite#custom#source('_', 'matchers', ['matcher/regexp']) 486 | call denite#custom#source('_', 'sorters', ['sorter/sublime']) 487 | endif 488 | 489 | if exists('*denite#custom#option') 490 | call denite#custom#option('default', { 491 | \ 'direction' : 'botright', 492 | \ }) 493 | endif 494 | ""}}} 495 | 496 | "" deoplete.vim {{{ 497 | if exists('*deoplete#custom#option') 498 | call deoplete#custom#option("auto_complete_delay", 150) 499 | endif 500 | "" }}} 501 | 502 | "" vim-markdown {{{ 503 | if SpaceVim#layers#isLoaded("lang#latex") 504 | augroup myspacevim_mkdtex 505 | autocmd! 506 | autocmd! FileType markdown 507 | \ syntax include @tex syntax/tex.vim 508 | \| syntax region mkdMath start="\\\@!/src!,' . 548 | \ 'reg:!/include/.*!/src!,' . 549 | \ 'ifrel:!/include\>!../src!,' . 550 | \ 'reg:!/include/\w\+\>!/src!,' . 551 | \ 'reg:!/include\(/\w\+\)\{2}\>!/src!,' . 552 | \ 'reg:!/include\(/\w\+\)\{3}\>!/src!,' . 553 | \ 'reg:!/include\(/\w\+\)\{4}\>!/src!,' . 554 | \ 'reg:!/include/.*!/src/**!,' . 555 | \ 'reg:!^\(.*/\|\)sscc\(/[^/]\+\|\)!\1libs\2/src/**!' . 556 | \ 'reg:!/impl_include\>!/src/impl!,' . 557 | \ 'reg:!/impl_include/.*!/src/impl!,' . 558 | \ 'ifrel:!/impl_include\>!../src/impl!,' . 559 | \ 'reg:!/impl_include/\w\+\>!/src/impl!,' . 560 | \ 'reg:!/impl_include\(/\w\+\)\{2}\>!/src/impl!,' . 561 | \ 'reg:!/impl_include\(/\w\+\)\{3}\>!/src/impl!,' . 562 | \ 'reg:!/impl_include\(/\w\+\)\{4}\>!/src/impl!,' . 563 | \ 'reg:!/impl_include/.*!/src/impl/**!,' 564 | \| let b:fsnonewfiles="on" 565 | autocmd! BufNewFile,BufEnter *.c,*.cpp,cxx,*.ipp 566 | \ let b:fswitchdst='h,hpp' 567 | \| let b:fswitchlocs= 568 | \ 'reg:!/src\>!/include!,' . 569 | \ 'reg:!/src\(/.*\|\)$!/include/**!,' . 570 | \ 'ifrel:!/src\>!../include/!,' . 571 | \ 'reg:!/libs/.*!/**!' . 572 | \ 'reg:!/src/impl\>!/impl_include!,' . 573 | \ 'reg:!/src/impl\(/.*\|\)$!/impl_include/**!,' . 574 | \ 'ifrel:!/src/impl\>!../impl_include/!,' 575 | \| let b:fsnonewfiles="on" 576 | 577 | autocmd! BufNewFile,BufEnter *.xml 578 | \ let b:fswitchdst='rnc' 579 | \| let b:fswitchlocs='./' 580 | autocmd! BufNewFile,BufEnter *.rnc 581 | \ let b:fswitchdst='xml' 582 | \| let b:fswitchlocs='./' 583 | 584 | autocmd! BufNewFile,BufEnter */src/*.hs 585 | \ let b:fswitchdst='hs' 586 | \| let b:fswitchlocs='reg:!/src/!/test/!' 587 | \| let b:fswitchfnames='/$/Spec/' 588 | autocmd! BufNewFile,BufEnter */test/*Spec.hs 589 | \ let b:fswitchdst='hs' 590 | \| let b:fswitchlocs='reg:!/test/!/src/!' 591 | \| let b:fswitchfnames='/Spec$//' 592 | 593 | autocmd! FileType c,cpp,xml,rnc,haskell 594 | command! -buffer A :call FSwitch('%', '') 595 | augroup END 596 | "" }}} 597 | 598 | "" Neomake {{{ 599 | let g:neomake_open_list = 0 " 0: don't auto open 600 | 601 | if ! exists('g:neomake_vim_enabled_makers') 602 | let g:neomake_vim_enabled_makers = [] 603 | endif 604 | if executable('vimlint') 605 | call add(g:neomake_vim_enabled_makers, 'vimlint') 606 | endif 607 | if executable('vint') 608 | call add(g:neomake_vim_enabled_makers, 'vint') 609 | endif 610 | 611 | " 优先使用clang-tidy 612 | if executable('clang-tidy') 613 | let g:neomake_c_enabled_makers = 'clangtidy' 614 | let g:neomake_cpp_enabled_makers = 'clangtidy' 615 | endif 616 | 617 | let g:neomake_markdown_markdownlint_errorformat = 618 | \ '%f:%l:%c %m,' . 619 | \ '%f: %l: %c: %m,' . 620 | \ '%f:%l %m,' . 621 | \ '%f: %l: %m' 622 | "" }}} 623 | 624 | "" Telescope {{{ 625 | if exists(':Telescope') 626 | call SpaceVim#mapping#def('nmap ', 'fs', ':Telescope lsp_dynamic_workspace_symbols', 'Telescope dynamic symbols', 'Find symbols') 627 | 628 | if SpaceVim#layers#isLoaded('lang#c') 629 | for l:lang in ['c', 'cpp'] 630 | call SpaceVim#mapping#gd#add(l:lang, function('s:gotodef')) 631 | call SpaceVim#custom#LangSPC(l:lang, 'nmap', ['x'], ':Telescope lsp_references', 'show-reference', 1) 632 | call SpaceVim#custom#LangSPC(l:lang, 'nmap', ['i'], ':Telescope lsp_implementations', 'implementation', 1) 633 | endfor 634 | endif 635 | endif 636 | "" }}} 637 | 638 | "" build/test mapping for c and cpp {{{ 639 | if SpaceVim#layers#isLoaded('lang#c') 640 | for l:lang in ['c', 'cpp', 'bbv2'] 641 | call SpaceVim#custom#LangSPC(l:lang, 'nmap', ['b'], 'make', 'build project', 1) 642 | call SpaceVim#custom#LangSPC(l:lang, 'nmap', ['B'], 'Make', 'async build project', 1) 643 | call SpaceVim#custom#LangSPC(l:lang, 'nmap', ['t'], 'make unittest', 'run unittest', 1) 644 | call SpaceVim#custom#LangSPC(l:lang, 'nmap', ['T'], 'Make unittest', 'async run unittest', 1) 645 | endfor 646 | endif 647 | "" }}} 648 | 649 | endfunction 650 | " }}} 651 | 652 | function! s:gotodef() abort 653 | if exists(':Telescope') 654 | exec 'Telescope lsp_definitions' 655 | endif 656 | endfunction 657 | 658 | function! s:build_make(program, args) abort " {{{ 659 | if a:program =~# '\$\*' 660 | return substitute(a:program, '\$\*', a:args, 'g') 661 | elseif empty(a:args) 662 | return a:program 663 | else 664 | return a:program . ' ' . a:args 665 | endif 666 | endfunction 667 | " }}} 668 | 669 | function! s:async_make(args) " {{{ 670 | let cmd1 = s:build_make(&makeprg, a:args) 671 | let cmd2 = join(map(split(cmd1, '\ze[<%# "'']'), 'expand(v:val)'), '') 672 | call SpaceVim#plugins#runner#open(cmd2) 673 | endfunction 674 | " }}} 675 | 676 | " command SyntaxId {{{ 677 | function! s:syntax_id() 678 | let s = [] 679 | for id in synstack(line("."), col(".")) 680 | call add(s, synIDattr(id, "name")) 681 | endfor 682 | echo join(s, ' -> ') 683 | endfunction 684 | 685 | command! SyntaxId call s:syntax_id() 686 | " }}} 687 | 688 | -------------------------------------------------------------------------------- /autoload/myspacevim/colorscheme.vim: -------------------------------------------------------------------------------- 1 | function! myspacevim#colorscheme#autoload() 2 | if s:handle_dynamic_colors() 3 | return 4 | endif 5 | 6 | if g:spacevim_colorscheme == '' && g:spacevim_colorscheme_bg != '' 7 | " SpaceVim will not set background with 8 | " g:spacevim_colorscheme_default, so we do it ourself. 9 | let &background=g:spacevim_colorscheme_bg 10 | endif 11 | endfunction 12 | 13 | function s:handle_dynamic_colors() 14 | let dynamic_colors_root = $DYNAMIC_COLORS_ROOT 15 | 16 | if dynamic_colors_root == '' 17 | return 0 18 | endif 19 | 20 | if !isdirectory(dynamic_colors_root) 21 | return 0 22 | endif 23 | 24 | let colorscheme_file = dynamic_colors_root . '/colorscheme' 25 | if !filereadable(colorscheme_file) 26 | return 0 27 | endif 28 | 29 | let dc_colorscheme = readfile(colorscheme_file, '', 1)[0] 30 | 31 | " handle 'solarized-dark'/'solarized-dark-desaturated' 32 | " catch 'solarized' and 'dark' 33 | let m = matchlist(dc_colorscheme, '^\([^-]\+\)\%([-_]\([^-]\+\)\(-.*\)\?\)\?$') 34 | if len(m) == 0 35 | return 0 36 | endif 37 | let name = m[1] 38 | let bg = m[2] 39 | 40 | let colorscheme = g:spacevim_colorscheme 41 | 42 | if name != '' 43 | " Only use dynamic-colors colorscheme when colorscheme is not set in configuration file 44 | if colorscheme == '' 45 | let g:spacevim_colorscheme = name 46 | let colorscheme = g:spacevim_colorscheme 47 | if bg != '' 48 | let g:spacevim_colorscheme_bg = bg 49 | endif 50 | endif 51 | 52 | if name == 'solarized' && colorscheme == 'NeoSolarized' 53 | if g:spacevim_colorscheme_bg != bg 54 | let g:spacevim_colorscheme_bg=bg 55 | endif 56 | endif 57 | endif 58 | 59 | return 1 60 | endfunction 61 | -------------------------------------------------------------------------------- /ftplugin/c_path_settings.vim: -------------------------------------------------------------------------------- 1 | " Only do this when not done yet for this buffer 2 | if exists("b:did_c_path_settings") 3 | finish 4 | endif 5 | let b:did_c_path_settings = 1 6 | 7 | if !exists('s:cpp_include_path') 8 | let s:cpp_include_path_ready = 0 9 | let s:cpp_include_path = [] 10 | let s:proj_includes = {} 11 | let s:path_to_proj_root = {} 12 | endif 13 | 14 | let s:proj_root_stopper = ["Jamroot", "Jamroot.v2", "Jamroot.jam", ".git", ".svn"] 15 | function! s:FindProjectRoot(path) 16 | let l:last = fnamemodify(a:path, ':p') 17 | if has_key(s:path_to_proj_root, l:last) 18 | return s:path_to_proj_root[l:last] 19 | endif 20 | 21 | let l:root = l:last 22 | 23 | let l:curr = fnamemodify(l:last, ':h') 24 | while l:curr != l:last && l:curr != $HOME 25 | for l:name in s:proj_root_stopper 26 | let l:p = l:curr . "/" . l:name 27 | if filereadable(l:p) || isdirectory(l:p) 28 | let l:root = l:curr 29 | break 30 | endif 31 | endfor 32 | 33 | let l:last = l:curr 34 | let l:curr = fnamemodify(l:last, ':h') 35 | endwhile 36 | 37 | return l:root 38 | endfunction 39 | 40 | function! s:GetProjectIncludes(path) 41 | let l:root = s:FindProjectRoot(a:path) 42 | 43 | if ! has_key(s:proj_includes, l:root) 44 | let s:proj_includes[l:root] = [] 45 | for l:p in finddir("include", s:FindProjectRoot(l:root) . '/**', -1) 46 | call add(s:proj_includes[l:root], l:p) 47 | endfor 48 | endif 49 | 50 | return s:proj_includes[l:root] 51 | endfunction 52 | 53 | function! s:AddComponentsToPath(path) 54 | let l:path = fnamemodify(a:path, ':p') 55 | 56 | if index(b:proj_processed_components, l:path) >= 0 57 | return 58 | endif 59 | 60 | call add(b:proj_processed_components, l:path) 61 | 62 | " 把path目录下,两层子目录内的include等目录加入路径中 63 | for l:name in ["include"] 64 | for l:p in finddir(l:name, l:path . "/**2", -1) 65 | call s:AddPath(l:p) 66 | endfor 67 | endfor 68 | 69 | for l:name in ["3rd"] 70 | for l:p in finddir(l:name, l:path . "/**2", -1) 71 | call s:AddComponentsToPath(l:p) 72 | endfor 73 | endfor 74 | 75 | " 把path目录下,两层子目录内的boost/sscc等目录的上一层目录加入路径中 76 | for l:name in ["boost", "sscc"] 77 | for l:p in finddir(l:name, l:path . "/**2", -1) 78 | call s:AddPath(fnamemodify(l:p, ":h")) 79 | endfor 80 | endfor 81 | 82 | " 把path目录下,所有包含头文件的直接子目录include路径中 83 | for l:p in split(glob(l:path . "/*"), "\n") 84 | if findfile("*.h", l:p) || findfile("*.hpp", l:p) 85 | call s:AddPath(l:p) 86 | endif 87 | 88 | if isdirectory(l:p . "/lib") 89 | call s:AddComponentsToPath(l:p . "/lib") 90 | endif 91 | endfor 92 | endfunction 93 | 94 | function! s:AddPath(path) 95 | let l:p = fnamemodify(a:path, ":p:h") 96 | if isdirectory(l:p) && index(b:proj_processed_paths, l:p) < 0 97 | call add(b:proj_processed_paths, l:p) 98 | exec "setlocal path+=" . l:p 99 | endif 100 | endfunction 101 | 102 | function! s:GetCompilerDefaultIncludePath(compiler) 103 | let l:output = system("echo '' | " . a:compiler . " -E -x c++ - -v |& sed -e '1,/#include <.*search starts here/d' -e '/End of search list/,$d'") 104 | return map(split(l:output), 'fnamemodify(v:val, ":p")') 105 | endfunction 106 | 107 | function! s:AddCppDefaultIncludePath() 108 | if !s:cpp_include_path_ready 109 | let s:cpp_include_path_ready = 1 110 | 111 | if executable("sed") 112 | if executable("clang++") 113 | let s:cpp_include_path = extend(s:cpp_include_path, s:GetCompilerDefaultIncludePath("clang++")) 114 | elseif executable("g++") 115 | let s:cpp_include_path = extend(s:cpp_include_path, s:GetCompilerDefaultIncludePath("g++")) 116 | endif 117 | endif 118 | 119 | if empty(s:cpp_include_path) 120 | " 未能从编译器取得include列表,自行查找 121 | let l:cpp_include_path = substitute(substitute(glob("/usr/include/c++/*/"), "^.*\n", "", ""), "/$", "", "") 122 | if isdirectory(l:cpp_include_path) 123 | call add(s:cpp_include_path, l:cpp_include_path) 124 | 125 | " 在/usr/include/c++/4.4.6/x86_64-redhat-linux/bits有需要的文件,因此 126 | " 把/usr/include/c++/4.4.6/x86_64-redhat-linux加入路径中 127 | for l:p in finddir("bits", l:cpp_include_path . '/**2', -1) 128 | call add(s:cpp_include_path, fnamemodify(l:p, ":p:h:h")) 129 | endfor 130 | endif 131 | endif 132 | endif 133 | 134 | for l:p in s:cpp_include_path 135 | call s:AddPath(l:p) 136 | endfor 137 | endfunction 138 | 139 | function! s:SetupEnvironment() 140 | " 使用当前目录 141 | "setlocal path=. 142 | let b:proj_processed_components = [] 143 | let b:proj_processed_paths = [] 144 | 145 | let l:path = expand('%:p:h') 146 | 147 | " 找出到workspace下一层的目录。如/home/user/workspace/proj/dir1/dir2 => 148 | " /home/usr/workspace/proj 149 | let l:curr = l:path 150 | let l:parent = fnamemodify(l:curr, ':h') 151 | 152 | let l:workspace_dir = $HOME 153 | let l:stop_dir = '' 154 | while l:parent != l:curr 155 | " 如果有多个工作区目录,可以加到这个列表中。遇到这些目录中任意一个时,就 156 | " 不会再往上找了。如所有项目都放到$HOME/workspace/下的话,就设置为 157 | " workspace。这样,workspace/cs/*就会只查找workspace/cs/及其子目录,不 158 | " 会找workspace下的其它项目 159 | if index(['workspace', 'program'], fnamemodify(l:parent, ':t')) >= 0 160 | " l:parent目录符合要求的目录名 161 | let l:workspace_dir = l:parent 162 | " 为路径加上结束的/,这样才能在这层停下来。否则将在workspace_dir才 163 | " 停,多了一层 164 | let l:stop_dir = fnamemodify(l:curr, ':p') 165 | break 166 | endif 167 | 168 | let l:curr = l:parent 169 | let l:parent = fnamemodify(l:curr, ':h') 170 | endwhile 171 | 172 | let l:search_path = l:path . ';' . l:stop_dir 173 | 174 | " 加入路径上所有lib/3rd/util/framework目录下的库 175 | for l:d in ["lib", "3rd", "framework", "prod"] 176 | for l:p in finddir(l:d, l:search_path, -1) 177 | call s:AddComponentsToPath(l:p) 178 | endfor 179 | endfor 180 | 181 | " for l:p in s:GetProjectIncludes(l:path) 182 | " call s:AddPath(l:p) 183 | " endfor 184 | 185 | " Boost库 186 | if match(&path, "boost") < 0 " 路径中没有boost库才需要加入 187 | if isdirectory($BOOST_ROOT) 188 | call s:AddPath($BOOST_ROOT) 189 | else 190 | let l:boost_dirs = sort(split(glob(l:workspace_dir . "/boost_*/"), "\n")) 191 | if len(l:boost_dirs) > 0 192 | call s:AddPath(l:boost_dirs[0]) 193 | endif 194 | endif 195 | endif 196 | 197 | " 加入路径上所有Jamroot/Jamfile所在目录,这种目录通常都在include路径中 198 | for l:name in ["Jamfile", "Jamfile.v2", "Jamfile.jam", "Jamroot", "Jamroot.v2", "Jamroot.jam"] 199 | for l:p in findfile(l:name, l:search_path, -1) 200 | call s:AddPath(fnamemodify(l:p, ":p:h")) 201 | endfor 202 | endfor 203 | 204 | " 加入路径上所有include目录 205 | for l:p in finddir('include', l:search_path, -1) 206 | call s:AddPath(l:p) 207 | endfor 208 | 209 | " 如果在Boost目录,则加上boost目录的上一层目录 210 | let l:boost_include = finddir("boost", l:search_path) 211 | if len(l:boost_include) > 0 212 | " 当前在Boost库的目录下 213 | call s:AddPath(fnamemodify(l:boost_include, ":p:h:h")) 214 | endif 215 | 216 | call s:AddPath("/usr/include") 217 | call s:AddCppDefaultIncludePath() 218 | endfunction 219 | 220 | call s:SetupEnvironment() 221 | " vim: filetype=vim fileencoding=utf-8 222 | -------------------------------------------------------------------------------- /ftplugin/cpp.vim: -------------------------------------------------------------------------------- 1 | " We want to keep comments within a column limit, but not code. 2 | " These two options give us that 3 | setlocal formatoptions+=c " Auto-wrap comments using textwidth 4 | setlocal formatoptions+=r " Automatically insert the current comment leader after hitting 5 | " in Insert mode. 6 | setlocal formatoptions+=q " Allow formatting of comments with "gq". 7 | setlocal formatoptions-=t " Do no auto-wrap text using textwidth (does not apply to comments) 8 | 9 | " This makes doxygen comments work the same as regular comments 10 | setlocal comments-=:// 11 | setlocal comments+=:///,:// 12 | 13 | " indentation 14 | setlocal cinoptions= 15 | setlocal cinoptions+=^ " no specific indent for function 16 | setlocal cinoptions+=:0 " case label indent 17 | setlocal cinoptions+=l1 " align with a case label 18 | setlocal cinoptions+=g0 " c++ scope declaration not indent 19 | setlocal cinoptions+=ps " K&R-style parameter declaration indent 20 | setlocal cinoptions+=t0 " function return type declaration indent 21 | setlocal cinoptions+=i2 " C++ base class declarations and constructor initializations 22 | setlocal cinoptions+=+s " continuation line indent 23 | setlocal cinoptions+=c3 " comment line indent 24 | setlocal cinoptions+=(0 " align to first non-white character after the unclosed parentheses 25 | setlocal cinoptions+=us " same as (N, but for one level deeper 26 | setlocal cinoptions+=U0 " do not ignore the indenting specified by ( or u in case that the unclosed parentheses is the first non-white charactoer in its line 27 | setlocal cinoptions+=w1 28 | setlocal cinoptions+=Ws " indent line ended with open parentheses 29 | 30 | " Highlight strings inside C comments 31 | let c_comment_strings=1 32 | 33 | inoremap /** /**/kA@brief 34 | inoremap /**< /**<@brief*/ 35 | vnoremap /**< /**<@brief*/ 36 | inoremap ///< ///< 37 | vnoremap ///< ///< 38 | inoremap /** /**@brief*/ 39 | vnoremap /** /**@brief*/ 40 | 41 | setlocal keywordprg=man\ -S2:3 42 | 43 | -------------------------------------------------------------------------------- /init.toml: -------------------------------------------------------------------------------- 1 | # All SpaceVim option below [option] section 2 | [options] 3 | debug_level = 1 4 | checkinstall = 0 5 | 6 | bootstrap_before = "myspacevim#before" 7 | bootstrap_after = "myspacevim#after" 8 | 9 | # set spacevim theme. by default colorscheme layer is not loaded, 10 | # if you want to use more colorscheme, please load the colorscheme 11 | # layer 12 | # Detect colorscheme used by dynamic-colors and fallback to NeoSolarized 13 | colorscheme = "" 14 | colorscheme_bg = "dark" 15 | colorscheme_default = "gruvbox" 16 | 17 | # Disable guicolors in basic mode, many terminal do not support 24bit 18 | # true colors 19 | enable_guicolors = true 20 | 21 | # guifont = "SauceCodePro NF:h13" 22 | # guifont = "DejaVuSansMono_Nerd_Font:h13:cANSI:qDRAFT,DejaVuSansMono\ Nerd\ Font:h13:cANSI:qDRAFT,DejaVuSansMono\ NF:h13:cANSI:qDRAFT,Consolas:h13:cANSI:qDRAFT" 23 | guifont = "DejaVuSansMono\ Nerd\ Font:h13:cANSI:qDRAFT,DejaVuSansMono_Nerd_Font:h13:cANSI:qDRAFT" 24 | 25 | # Disable statusline separator, if you want to use other value, please 26 | # install nerd fonts 27 | statusline_separator = "arrow" 28 | statusline_inactive_separator = "arrow" 29 | enable_tabline_ft_icon = true 30 | enable_statusline_display_mode = false 31 | enable_os_fileformat_icon = true 32 | 33 | # 0: 1 ➛ ➊ 1: 1 ➛ ➀ 2: 1 ➛ ⓵ 3: 1 ➛ ¹ 4: 1 ➛ 1 34 | buffer_index_type = 4 35 | 36 | # 0: 1 ➛ ➊ 1: 1 ➛ ➀ 2: 1 ➛ ⓵ 3: 1 ➛ 1 37 | windows_index_type = 3 38 | 39 | statusline_unicode_symbols = 1 40 | 41 | # If there is a particular plugin you don't like, you can define this 42 | # variable to disable them entirely: 43 | disabled_plugins=['vim-gutentags'] 44 | 45 | default_indent = 4 46 | # restore to builtin functinal. Or use qr for builtin 47 | #windows_smartclose = '' 48 | 49 | # Wildignore 50 | wildignore = """\ 51 | */tmp/*,*.so,*.swp,*.zip,*.class,tags,\ 52 | *.jpg,*.ttf,*.TTF,*.png,*/target/*,\ 53 | .git,.svn,.hg,.DS_Store,*.svg,.*/,\ 54 | bin*/**/gcc-*/**,*.gcov,*.o""" 55 | 56 | # The default file manager of SpaceVim. Default is 'vimfiler'. 57 | # you can also use nerdtree or defx 58 | #filemanager = 'defx' 59 | 60 | realtime_leader_guide = 0 61 | enable_vimfiler_welcome = 0 62 | 63 | # Disable delimitmate 64 | autocomplete_parens = 0 65 | 66 | # the default nvim-cmp method doesn't have UltiSnips support builtin 67 | autocomplete_method = 'deoplete' 68 | snippet_engine = 'ultisnips' 69 | 70 | src_root = '~/workspace/' 71 | 72 | # 0: disable autochdir 73 | # 1: change to project root automatically 74 | # 2: change to directory of current file automatically 75 | project_rooter_automatically = 1 76 | 77 | project_rooter_outermost = false 78 | 79 | # default layers 80 | [[layers]] 81 | name = 'core' 82 | enable_smooth_scrolling = false 83 | 84 | [[layers]] 85 | name = 'autocomplete' 86 | auto-completion-return-key-behavior = "nil" 87 | auto-completion-tab-key-behavior = "smart" 88 | auto-completion-complete-with-key-sequence = "nil" 89 | 90 | [[layers]] 91 | name = 'shell' 92 | default_position = 'bottom' 93 | default_height = 30 94 | 95 | [[layers]] 96 | name = 'sudo' 97 | enable = true 98 | 99 | # additional layers 100 | [[layers]] 101 | name = 'VersionControl' 102 | 103 | [[layers]] 104 | name = 'colorscheme' 105 | 106 | [[layers]] 107 | name = 'denite' 108 | #enable = 'has("python3")' 109 | enable = false 110 | 111 | [[layers]] 112 | name = 'git' 113 | enable = 'executable("git")' 114 | 115 | [[layers]] 116 | name = 'leaderf' 117 | #enable = false 118 | 119 | [[layers]] 120 | name = 'unite' 121 | enable = '!has("python3")' 122 | 123 | [[layers]] 124 | name = 'ctrlp' 125 | enable = false 126 | 127 | [[layers]] 128 | name = "ctrlspace" 129 | enable = false 130 | 131 | #[[layers]] 132 | # name = 'incsearch' 133 | 134 | [[layers]] 135 | name = 'tools' 136 | 137 | # begin optional layers 138 | [[layers]] 139 | name = 'gtags' 140 | enable = 'executable("global")' 141 | auto_update = 0 142 | # 0: don't open quickfix 143 | # 1: open quickfix 144 | # 2: open quickfix and preserve cursor position 145 | open_quickfix = 2 146 | 147 | [[layers]] 148 | name = 'debug' 149 | enable = 'executable("gdb")' 150 | 151 | [[layers]] 152 | name = 'lang#asciidoc' 153 | enable = true 154 | 155 | [[layers]] 156 | name = 'lang#c' 157 | enable = true 158 | enable_clang_syntax_highlight = false 159 | #[layers.clang_std] 160 | # cpp = 'c++14' 161 | 162 | [[layers]] 163 | name = 'lang#clojure' 164 | enable = 'executable("clojure")' 165 | 166 | [[layers]] 167 | name = 'lang#go' 168 | enable = false 169 | 170 | [[layers]] 171 | name = 'lang#html' 172 | enable = true 173 | emmet_filetyps = ['html'] 174 | 175 | [[layers]] 176 | name = 'lang#haskell' 177 | enable = 'executable("ghc")' 178 | 179 | [[layers]] 180 | name = 'lang#java' 181 | enable = false 182 | 183 | [[layers]] 184 | name = 'lang#javascript' 185 | enable = true 186 | 187 | [[layers]] 188 | name = 'lang#typescript' 189 | enable = true 190 | 191 | [[layers]] 192 | name = 'lang#lua' 193 | enable = true 194 | 195 | [[layers]] 196 | name = 'lang#markdown' 197 | enable = true 198 | enableWcwidth = 1 199 | listItemIndent = 1 200 | listItemChar = '-' 201 | 202 | [[layers]] 203 | name = 'lang#latex' 204 | enable = false 205 | 206 | [[layers]] 207 | name = 'lang#python' 208 | enable = true 209 | enable_typeinfo = true 210 | 211 | [[layers]] 212 | name = 'lang#racket' 213 | enable = 'executable("racket")' 214 | 215 | [[layers]] 216 | name = 'lang#ruby' 217 | enable = 'executable("ruby")' 218 | 219 | [[layers]] 220 | name = 'lang#scheme' 221 | enable = 'executable("guile") || executable("chez")' 222 | scheme_dialect = 'guile' 223 | scheme_interpreter = 'guile' 224 | # dialect = 'chez' 225 | 226 | [[layers]] 227 | name = 'lang#sh' 228 | enable = true 229 | bash-file-head = [ 230 | '#!/usr/bin/env bash', 231 | '# Time: `strftime("%Y-%m-%d %T")`', 232 | '' 233 | ] 234 | 235 | [[layers]] 236 | name = 'lang#sml' 237 | enable = 'executable("sml")' 238 | auto_create_def_use = 'always' 239 | enable_conceal = 1 240 | enable_conceal_show_tick = 1 241 | 242 | [[layers]] 243 | name = 'lang#toml' 244 | enable = true 245 | 246 | [[layers]] 247 | name = 'lang#vim' 248 | enable = true 249 | 250 | [[layers]] 251 | name = 'lang#xml' 252 | enable = true 253 | 254 | [[layers]] 255 | name = 'lsp' 256 | enable = true 257 | # enabled_clients = ['vimls', 'clangd'] 258 | # [layers.override_cmd] 259 | # c = ['ccls', '--log-file=/tmp/ccls.log'] 260 | # cpp = ['ccls', '--log-file=/tmp/ccls.log'] 261 | 262 | [[layers]] 263 | name = 'tmux' 264 | enable = 'executable("tmux")' 265 | 266 | [[layers]] 267 | name = 'telescope' 268 | enable = true 269 | 270 | [[layers]] 271 | name = 'treesitter' 272 | enable = true 273 | 274 | [[layers]] 275 | name = 'lang#lilypond' 276 | lazy = 1 277 | enable = true 278 | on_path = '.*\.(ly|ily)' 279 | 280 | [[custom_plugins]] 281 | # Display colors like: #RRGGBB 282 | name = 'lilydjwg/colorizer' 283 | merged = 0 284 | 285 | [[custom_plugins]] 286 | name ='thawk/vim-asciidoc-folding' 287 | lazy = 1 288 | on_ft = 'asciidoc' 289 | 290 | # [[custom_plugins]] 291 | # name ='masukomi/vim-markdown-folding' 292 | # lazy = 1 293 | # on_ft = 'markdown' 294 | # 295 | # [[custom_plugins]] 296 | # name ='hspec/hspec.vim' 297 | # lazy = 1 298 | # on_ft = 'haskell' 299 | 300 | [[custom_plugins]] 301 | name = 'haya14busa/dein-command.vim' 302 | lazy = 1 303 | on_cmd = ['Dein'] 304 | 305 | # The following plugins is for my personal file formats 306 | [[custom_plugins]] 307 | name = 'thawk/vim-pcet' 308 | lazy = 1 309 | on_path = 'pcet_.*\.xml' 310 | 311 | [[custom_plugins]] 312 | name = 'thawk/bbv2.vim' 313 | 314 | [[custom_plugins]] 315 | name = 'skilstak/vim-abnf-utf8' 316 | lazy = 1 317 | on_path = '.*\.abnf' 318 | 319 | # end optional layers 320 | 321 | [[custom_plugins]] 322 | name = 'ConradIrwin/vim-bracketed-paste' 323 | 324 | [[custom_plugins]] 325 | name = 'thawk/vim-fswitch' 326 | lazy = 1 327 | on_func = ['FSwitch', 'FSReturnReadableCompanionFilename', 'FSReturnCompanionFilenameString'] 328 | on_cmd = ['FSHere','FSRight','FSSplitRight','FSLeft','FSSplitLeft','FSAbove','FSSplitAbove','FSBelow','FSSplitBelow','FSTab'] 329 | 330 | [[custom_plugins]] 331 | name = 'junkblocker/patchreview-vim' 332 | lazy = 1 333 | on_cmd = ['PatchReview','PatchReviewPersist','ReversePatchReview','ReversePatchReviewPersist','DiffReview','DiffReviewPersist'] 334 | 335 | [[custom_plugins]] 336 | name = 'vim-scripts/CodeReviewer.vim' 337 | lazy = 1 338 | on_cmd = ['CheckReview','SortReviewFile'] 339 | [custom_plugins.on_map] 340 | n = 'AddComment' 341 | 342 | [[custom_plugins]] 343 | name = 'inkarkat/vim-ingo-library' 344 | lazy = 1 345 | 346 | [[custom_plugins]] 347 | name = 'inkarkat/vim-mark' 348 | depends = ['inkarkat/vim-ingo-library'] 349 | lazy = 1 350 | on_cmd = [ 351 | 'Mark', 'MarkClear', 'Marks', 'MarkLoad', 'MarkSave', 'MarkYankDefinitions', 352 | 'MarkYankDefinitionsOneLiner', 'MarkPalette', 'MarkName'] 353 | on_map = ['Mark'] 354 | 355 | [[custom_plugins]] 356 | name = 'mhinz/vim-rfc' 357 | lazy = 1 358 | on_path = 'rfc.*\.txt' 359 | on_cmd = ['RFC'] 360 | on_ft = 'rfc' 361 | 362 | [[custom_plugins]] 363 | name = 'AndrewRadev/linediff.vim' 364 | lazy = 1 365 | on_cmd = [ 366 | 'Linediff', 'LinediffAdd', 'LinediffLast', 'LinediffShow', 367 | 'LinediffReset', 'LinediffMerge', 'LinediffPick', ] 368 | 369 | # Color schemes 370 | [[custom_plugins]] 371 | name = 'sickill/vim-monokai' 372 | 373 | [[custom_plugins]] 374 | name = 'artanikin/vim-synthwave84' 375 | 376 | [[custom_plugins]] 377 | name = 'chriskempson/base16-vim' 378 | 379 | [[custom_plugins]] 380 | name = 'dracula/vim' 381 | 382 | -------------------------------------------------------------------------------- /nogui.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Time: 2020-04-21 09:47:27 3 | 4 | sed -E -i "${HOME}/.SpaceVim.d/init.toml" \ 5 | -e 's#^(\s*enable_guicolors\s*=\s*)\w+#\1false#' \ 6 | -e 's#^(\s*statusline_separator\s*=\s*)"\w+"#\1"nil"#' \ 7 | -e 's#^(\s*statusline_inactive_separator\s*=\s*)"\w+"#\1"nil"#' \ 8 | -e 's#^(\s*enable_tabline_ft_icon\s*=\s*)\w+#\1false#' \ 9 | -e 's#^(\s*enable_os_fileformat_icon\s*=\s*)\w+#\1false#' \ 10 | -e 's#^(\s*statusline_unicode_symbols\s*=\s*)\w+#\10#' \ 11 | -e 's#^(\s*buffer_index_type\s*=\s*)\w+#\14#' \ 12 | -e 's#^(\s*window_index_type\s*=\s*)\w+#\14#' 13 | -------------------------------------------------------------------------------- /offline.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Time: 2020-04-21 09:47:27 3 | 4 | sed -E -i "${HOME}/.SpaceVim.d/init.toml" \ 5 | -e "s#^(\s*checkinstall\s*=\s*)\w+#\10#" 6 | -------------------------------------------------------------------------------- /templates/pydocstring/google/arg.txt: -------------------------------------------------------------------------------- 1 | {{_name_}} ({{_type_}}) 2 | -------------------------------------------------------------------------------- /templates/pydocstring/google/comment.txt: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /templates/pydocstring/google/multi.txt: -------------------------------------------------------------------------------- 1 | """{{_header_}} 2 | 3 | {{_indent_}}Args: 4 | {{_nested_indent_}}{{_args_}}: 5 | 6 | Returns ({{_returnType_}}): 7 | """ 8 | -------------------------------------------------------------------------------- /templates/pydocstring/google/oneline.txt: -------------------------------------------------------------------------------- 1 | """{{_header_}}""" 2 | --------------------------------------------------------------------------------