├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE ├── README.md ├── add-custom-plugin.md ├── autoload ├── easycomplete.vim └── easycomplete │ ├── action │ ├── completion.vim │ ├── defination.vim │ ├── diagnostics.vim │ ├── documentation.vim │ ├── reference.vim │ ├── rename.vim │ └── signature.vim │ ├── confirm.vim │ ├── input.vim │ ├── installer.vim │ ├── installer │ ├── c#.sh │ ├── cmake.sh │ ├── cpp.sh │ ├── css.sh │ ├── dart.sh │ ├── deno.sh │ ├── go.sh │ ├── go_install.sh │ ├── grvy.sh │ ├── html.sh │ ├── java.sh │ ├── json.sh │ ├── kt.sh │ ├── lua.sh │ ├── nim.sh │ ├── npm_install.sh │ ├── php.sh │ ├── pip_install.sh │ ├── py.sh │ ├── r.sh │ ├── rb.sh │ ├── rust.sh │ ├── sh.sh │ ├── tn.sh │ ├── ts.sh │ ├── vim.sh │ ├── xml.sh │ └── yml.sh │ ├── job.vim │ ├── log.vim │ ├── lsp.vim │ ├── lsp │ ├── callbag.vim │ ├── client.vim │ ├── folding.vim │ ├── utils.vim │ └── utils │ │ ├── location.vim │ │ ├── position.vim │ │ ├── step.vim │ │ └── text_edit.vim │ ├── lua.vim │ ├── popup.vim │ ├── pum.vim │ ├── python.vim │ ├── sign.vim │ ├── sources │ ├── bash.vim │ ├── buf.vim │ ├── cmake.vim │ ├── cpp.vim │ ├── cs.vim │ ├── css.vim │ ├── dart.vim │ ├── deno.vim │ ├── directory.vim │ ├── go.vim │ ├── grvy.vim │ ├── html.vim │ ├── java.vim │ ├── json.vim │ ├── kotlin.vim │ ├── lua.vim │ ├── nim.vim │ ├── php.vim │ ├── py.vim │ ├── r.vim │ ├── ruby.vim │ ├── rust.vim │ ├── snips.vim │ ├── tn.vim │ ├── ts.vim │ ├── vim.vim │ ├── xml.vim │ └── yaml.vim │ ├── tabnine.vim │ ├── ui.vim │ └── util.vim ├── custom-config.md ├── dict ├── cmake.txt ├── css.txt ├── html.txt └── vim.txt ├── doc ├── easycomplete.txt └── tags ├── lua ├── easycomplete.lua └── easycomplete │ ├── autoload.lua │ ├── loading.lua │ ├── tabnine.lua │ └── util.lua ├── my-custom-config.md ├── plugin └── easycomplete.vim ├── pythonx └── EasyCompleteUtil │ ├── __init__.py │ ├── util.py │ └── vimsnippets.py └── snippets ├── _.snippets ├── c.snippets ├── cmake.snippets ├── codeigniter.snippets ├── cpp.snippets ├── cs.snippets ├── css.snippets ├── d.snippets ├── dart-flutter.snippets ├── dart.snippets ├── eelixir.snippets ├── elixir.snippets ├── elm.snippets ├── erlang.snippets ├── eruby.snippets ├── go.snippets ├── haskell.snippets ├── html.snippets ├── htmldjango.snippets ├── htmltornado.snippets ├── java.snippets ├── javascript ├── javascript-react.snippets ├── javascript.node.snippets └── javascript.snippets ├── jinja.snippets ├── kotlin.snippets ├── lua.snippets ├── make.snippets ├── mako.snippets ├── markdown.snippets ├── objc.snippets ├── perl.snippets ├── perl6.snippets ├── php.snippets ├── plsql.snippets ├── python.snippets ├── r.snippets ├── rails.snippets ├── rst.snippets ├── ruby.snippets ├── rust.snippets ├── sass.snippets ├── scala.snippets ├── scss.snippets ├── sh.snippets ├── snippets.snippets ├── sql.snippets ├── tcl.snippets ├── tex.snippets ├── typescript.snippets ├── typescriptreact.snippets ├── ultisnips ├── README ├── ada.snippets ├── all.snippets ├── bib.snippets ├── bindzone.snippets ├── c.snippets ├── coffee-jasmine.snippets ├── coffee-react.snippets ├── coffee.snippets ├── cpp.snippets ├── crystal.snippets ├── cs.snippets ├── css.snippets ├── cuda.snippets ├── d.snippets ├── django.snippets ├── eelixir.snippets ├── ejs.snippets ├── elm.snippets ├── erlang.snippets ├── eruby.snippets ├── go.snippets ├── haskell.snippets ├── help.snippets ├── html.snippets ├── html_minimal.snippets ├── htmldjango.snippets ├── htmljinja.snippets ├── java.snippets ├── javascript-angular.snippets ├── javascript-ember.snippets ├── javascript-jasmine-arrow.snippets ├── javascript-jsdoc.snippets ├── javascript-node.snippets ├── javascript.snippets ├── javascript_react.snippets ├── jinja2.snippets ├── json.snippets ├── julia.snippets ├── ledger.snippets ├── lhaskell.snippets ├── lua.snippets ├── mako.snippets ├── markdown.snippets ├── matlab.snippets ├── objc.snippets ├── ocaml.snippets ├── octave.snippets ├── pandoc.snippets ├── perl.snippets ├── php-laravel.snippets ├── php-phpspec.snippets ├── php-symfony2.snippets ├── php.snippets ├── plsql.snippets ├── proto.snippets ├── puppet.snippets ├── python.snippets ├── r.snippets ├── rails.snippets ├── rnoweb.snippets ├── robot.snippets ├── rst.snippets ├── ruby.snippets ├── rust.snippets ├── sh.snippets ├── snippets.snippets ├── soy.snippets ├── supercollider.snippets ├── svelte.snippets ├── tcl.snippets ├── tex.snippets ├── texmath.snippets ├── typescript.snippets ├── typescript_react.snippets ├── vim.snippets ├── vue.snippets ├── xhtml.snippets ├── xml.snippets └── zsh.snippets ├── vim.snippets ├── vue.snippets ├── xml.snippets └── zsh.snippets /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: easycomplete.CI 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: [ master ] 10 | pull_request: 11 | branches: [ master ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | build: 20 | # The type of runner that the job will run on 21 | runs-on: ubuntu-latest 22 | 23 | # Steps represent a sequence of tasks that will be executed as part of the job 24 | steps: 25 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 26 | - uses: actions/setup-node@v1 27 | 28 | - name: Install yarn 29 | run: | 30 | curl --compressed -o- -L https://yarnpkg.com/install.sh | bash 31 | - uses: actions/checkout@v2 32 | - name: yarn install 33 | run: | 34 | yarn global add typescript 35 | yarn 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .netrwhist 3 | ./bundle/YouCompleteMe 4 | ./bundle/YouCompleteMe/* 5 | pythonx/EasyCompleteUtil/__pycache__/ 6 | pythonx/__pycache__/ 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2026 Jayli 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /add-custom-plugin.md: -------------------------------------------------------------------------------- 1 | ## Add custom completion plugin 2 | 3 | Take snip as an example ([source file](https://github.com/jayli/vim-easycomplete/blob/master/autoload/easycomplete/sources/snips.vim)) without lsp server. 4 | 5 | ```vim 6 | au User easycomplete_custom_plugin call easycomplete#RegisterSource({ 7 | \ 'name': 'snips', 8 | \ 'whitelist': ['*'], 9 | \ 'completor': 'easycomplete#sources#snips#completor', 10 | \ 'constructor': 'easycomplete#sources#snips#constructor', 11 | \ }) 12 | ``` 13 | 14 | Another example with lsp server support is easier. [source file](https://github.com/jayli/vim-easycomplete/blob/master/autoload/easycomplete/sources/py.vim). By the way, you don't have to writing an omnifunc for Vim's omnicomplete. 15 | 16 | You can redefine a completion plugin via `easycomplete_custom_plugin` event with the same name of default lsp plugin. For example. We replace `ts` plugin's lsp server `tsserver` by `typescript-language-server`. Copy this code in your `.vimrc`: 17 | 18 | ```vim 19 | au User easycomplete_custom_plugin call easycomplete#RegisterSource({ 20 | \ 'name': 'ts', 21 | \ 'whitelist': ['javascript','typescript','javascript.jsx', 22 | \ 'typescript.tsx', 'javascriptreact', 'typescriptreact'], 23 | \ 'completor': function('g:Tss_Completor'), 24 | \ 'constructor': function('g:Tss_Constructor'), 25 | \ 'gotodefinition': function('g:Tss_GotoDefinition'), 26 | \ 'command': 'typescript-language-server' 27 | \ }) 28 | 29 | function! g:Tss_Constructor(opt, ctx) 30 | if executable('typescript-language-server') 31 | call easycomplete#lsp#register_server({ 32 | \ 'name': 'typescript-language-server', 33 | \ 'cmd': {server_info->['typescript-language-server', '--stdio']}, 34 | \ 'root_uri':{server_info-> "file://". fnamemodify(expand('%'), ':p:h')}, 35 | \ 'initialization_options': {'diagnostics': 'true'}, 36 | \ 'whitelist': ['javascript','typescript','javascript.jsx','typescript.tsx'], 37 | \ 'workspace_config': {}, 38 | \ 'semantic_highlight': {}, 39 | \ }) 40 | else 41 | call easycomplete#util#log(printf("'typescript-language-server'". 42 | \ "is not avilable, Please install: '%s'", 43 | \ 'npm -g install typescript-language-server')) 44 | endif 45 | endfunction 46 | 47 | function! g:Tss_Completor(opt, ctx) abort 48 | return easycomplete#DoLspComplete(a:opt, a:ctx) 49 | endfunction 50 | 51 | function! g:Tss_GotoDefinition(...) 52 | return easycomplete#DoLspDefinition(["js","ts","jsx","tsx"]) 53 | endfunction 54 | ``` 55 | -------------------------------------------------------------------------------- /autoload/easycomplete/action/completion.vim: -------------------------------------------------------------------------------- 1 | " ---------------------------------------------------------------------- 2 | " LSP 专用工具函数 3 | " 这里把 vim-lsp 整合进来了,做好了兼容,不用再安装外部依赖,这里的 LSP 4 | " 工具函数主要是给 easycomplete 的插件用的通用方法,已经做到了最小依赖 5 | " vim-lsp 源码冗余很大,这里只对源码做了初步精简 6 | " ---------------------------------------------------------------------- 7 | 8 | function! easycomplete#action#completion#do(opt, ctx) 9 | if empty(easycomplete#installer#GetCommand(a:opt['name'])) 10 | call easycomplete#complete(a:opt['name'], a:ctx, a:ctx['startcol'], []) 11 | return v:true 12 | endif 13 | 14 | let l:info = easycomplete#util#FindLspServers() 15 | let l:ctx = easycomplete#context() 16 | if empty(l:info['server_names']) 17 | call easycomplete#complete(a:opt['name'], l:ctx, l:ctx['startcol'], []) 18 | return v:true 19 | endif 20 | call easycomplete#action#completion#LspRequest(l:info, a:opt['name']) 21 | return v:true 22 | endfunction 23 | 24 | " 原 s:send_completion_request(info) 25 | " info: lsp server 信息 26 | " plugin_name: 插件的名字,比如 py, ts 27 | function! easycomplete#action#completion#LspRequest(info, plugin_name) abort 28 | let l:server_name = a:info['server_names'][0] 29 | call easycomplete#lsp#send_request(l:server_name, { 30 | \ 'method': 'textDocument/completion', 31 | \ 'params': { 32 | \ 'textDocument': easycomplete#lsp#get_text_document_identifier(), 33 | \ 'position': easycomplete#lsp#get_position(), 34 | \ 'context': { 'triggerKind': 1 } 35 | \ }, 36 | \ 'on_notification': function('s:HandleLspCallback', [l:server_name, a:plugin_name]) 37 | \ }) 38 | " call s:console('-->', 'lsp request start') 39 | endfunction 40 | 41 | function! s:HandleLspCallback(server_name, plugin_name, data) abort 42 | " call s:console('<--', 'lsp response') 43 | if easycomplete#IsBacking() | return | endif 44 | let l:ctx = easycomplete#context() 45 | if easycomplete#lsp#client#is_error(a:data) || !has_key(a:data, 'response') || 46 | \ !has_key(a:data['response'], 'result') 47 | call easycomplete#complete(a:plugin_name, l:ctx, l:ctx['startcol'], []) 48 | if a:plugin_name == "py" 49 | call s:log('Lsp Error', 'Please delete global pyls `rm /usr/local/bin/pyls` and reinstall pyls.') 50 | else 51 | echom "lsp error response" 52 | endif 53 | return 54 | endif 55 | 56 | let l:result = s:GetLspCompletionResult(a:server_name, a:data, a:plugin_name) 57 | let l:matches = l:result['matches'] 58 | let l:startcol = l:ctx['startcol'] 59 | 60 | let l:matches = s:MatchResultFilterPipe(a:plugin_name, l:matches) 61 | call easycomplete#complete(a:plugin_name, l:ctx, l:startcol, l:matches) 62 | endfunction 63 | 64 | function! s:GetLspCompletionResult(server_name, data, plugin_name) abort 65 | let l:result = a:data['response']['result'] 66 | let l:response = a:data['response'] 67 | 68 | " 这里包含了 info document 和 matches 69 | let l:completion_result = easycomplete#util#GetVimCompletionItems(l:response, a:plugin_name) 70 | return {'matches': l:completion_result['items'], 'incomplete': l:completion_result['incomplete'] } 71 | endfunction 72 | 73 | function! s:MatchResultFilterPipe(plugin_name, matches) 74 | let lsp_ctx = easycomplete#GetCurrentLspContext() 75 | if type(get(lsp_ctx, "constructor")) != type('') 76 | let fn_name = a:plugin_name 77 | let Fun_name = "easycomplete#sources#" . fn_name . "#filter" 78 | else 79 | let constructor_str = lsp_ctx["constructor"] 80 | let Fun_name = substitute(constructor_str, "#constructor$", "#filter", "g") 81 | endif 82 | if !easycomplete#util#FuncExists(Fun_name) 83 | return a:matches 84 | endif 85 | return call(funcref(Fun_name), [a:matches]) 86 | endfunction 87 | 88 | function! s:console(...) 89 | return call('easycomplete#log#log', a:000) 90 | endfunction 91 | 92 | function! s:log(...) 93 | return call('easycomplete#util#log', a:000) 94 | endfunction 95 | -------------------------------------------------------------------------------- /autoload/easycomplete/action/defination.vim: -------------------------------------------------------------------------------- 1 | 2 | function! easycomplete#action#defination#do() 3 | call s:DefinationCalling() 4 | endfunction 5 | 6 | " LSP 的 GoToDefinition 7 | function! easycomplete#action#defination#LspRequest() abort 8 | " typeDefinition => type definition 9 | let l:method = "definition" 10 | let l:operation = substitute(l:method, '\u', ' \l\0', 'g') 11 | let l:servers = easycomplete#util#FindLspServers()['server_names'] 12 | if empty(l:servers) 13 | return v:false 14 | endif 15 | let l:server = easycomplete#util#FindLspServers()['server_names'][0] 16 | let l:plugin_name = easycomplete#GetPluginNameByLspName(l:server) 17 | if empty(easycomplete#installer#GetCommand(l:plugin_name)) 18 | return v:false 19 | endif 20 | let l:ctx = { 'counter': len(l:server), 'list':[], 'jump_if_one': 1, 'mods': '', 'in_preview': 0 } 21 | 22 | let l:params = { 23 | \ 'textDocument': easycomplete#lsp#get_text_document_identifier(), 24 | \ 'position': easycomplete#lsp#get_position(), 25 | \ } 26 | call easycomplete#lsp#send_request(l:server, { 27 | \ 'method': 'textDocument/' . l:method, 28 | \ 'params': l:params, 29 | \ 'on_notification': function('s:HandleLspCallback', [l:ctx, l:server, l:operation]), 30 | \ }) 31 | 32 | echo printf('Retrieving %s ...', l:operation) 33 | return v:true 34 | endfunction 35 | 36 | " 这里 ctx 的格式保留下来 37 | " ctx = {counter, list, last_command_id, jump_if_one, mods, in_preview} 38 | function! s:HandleLspCallback(ctx, server, type, data) abort 39 | if easycomplete#lsp#client#is_error(a:data['response']) || !has_key(a:data['response'], 'result') 40 | call s:log('Failed to retrieve '. a:type . ' for ' . a:server . 41 | \ ': ' . easycomplete#lsp#client#error_message(a:data['response'])) 42 | else 43 | let a:ctx['list'] = a:ctx['list'] + easycomplete#lsp#utils#location#_lsp_to_vim_list( 44 | \ a:data['response']['result'] 45 | \ ) 46 | endif 47 | 48 | if empty(a:ctx['list']) 49 | call easycomplete#lsp#utils#error('No ' . a:type .' found') 50 | else 51 | call easycomplete#util#UpdateTagStack() 52 | let l:loc = a:ctx['list'][0] 53 | if len(a:ctx['list']) == 1 && a:ctx['jump_if_one'] && !a:ctx['in_preview'] 54 | call easycomplete#lsp#utils#location#_open_vim_list_item(l:loc, a:ctx['mods']) 55 | echo 'Retrieved ' . a:type 56 | redraw 57 | elseif !a:ctx['in_preview'] 58 | call setqflist([]) 59 | call setqflist(a:ctx['list']) 60 | echo 'Retrieved ' . a:type 61 | botright copen 62 | else 63 | " do nothing 64 | endif 65 | endif 66 | endfunction 67 | 68 | function! s:DefinationCalling() 69 | if &filetype == "help" 70 | exec "tag ". expand('') 71 | return 72 | endif 73 | let l:ctx = easycomplete#context() 74 | let syntax_going = v:false 75 | let sources = easycomplete#GetAllPlugins() 76 | for item in keys(sources) 77 | if easycomplete#CompleteSourceReady(item) 78 | if has_key(get(sources, item), "gotodefinition") 79 | let syntax_going = s:GotoDefinitionByName(item, l:ctx) 80 | break 81 | endif 82 | endif 83 | endfor 84 | if syntax_going == v:false 85 | try 86 | exec "tag ". expand('') 87 | catch 88 | echom v:exception 89 | endtry 90 | endif 91 | endfunction 92 | 93 | function! s:GotoDefinitionByName(name, ctx) 94 | let sources = easycomplete#GetAllPlugins() 95 | let l:opt = get(sources, a:name) 96 | let b:gotodefinition = get(l:opt, "gotodefinition") 97 | if empty(b:gotodefinition) 98 | return v:false 99 | endif 100 | if type(b:gotodefinition) == 2 " type is function 101 | return b:gotodefinition(l:opt, a:ctx) 102 | endif 103 | if type(b:gotodefinition) == type("string") " type is string 104 | return call(b:gotodefinition, [l:opt, a:ctx]) 105 | endif 106 | return v:false 107 | endfunction 108 | 109 | function! s:log(...) 110 | return call('easycomplete#util#log', a:000) 111 | endfunction 112 | 113 | function! s:console(...) 114 | return call('easycomplete#log#log', a:000) 115 | endfunction 116 | -------------------------------------------------------------------------------- /autoload/easycomplete/action/diagnostics.vim: -------------------------------------------------------------------------------- 1 | " diagnostics 2 | 3 | let s:response_ready = 0 4 | 5 | function! easycomplete#action#diagnostics#do() 6 | " 确保从这里 fire 的 diagnostic 才会被更新渲染 7 | if easycomplete#util#GetLspPluginName() == "ts" 8 | call easycomplete#sources#ts#lint() 9 | return 10 | endif 11 | if !easycomplete#util#LspServerReady() | return | endif 12 | call easycomplete#lsp#notify_diagnostics_update() 13 | let s:response_ready = 0 14 | call easycomplete#lsp#ensure_flush_all() 15 | call s:AsyncRun(function('easycomplete#action#diagnostics#render'), 16 | \ [], g:easycomplete_diagnostics_render_delay) 17 | endfunction 18 | 19 | function! easycomplete#action#diagnostics#HandleCallback(server, response) 20 | if getbufinfo(bufnr())[0].changed == 1 21 | call easycomplete#sign#flush() 22 | endif 23 | call easycomplete#sign#cache(a:response) 24 | let s:response_ready = 1 25 | endfunction 26 | 27 | function! easycomplete#action#diagnostics#render() 28 | if s:response_ready == 1 29 | call easycomplete#sign#render() 30 | else 31 | call timer_start(1000, { -> easycomplete#sign#render() }) 32 | endif 33 | endfunction 34 | 35 | function! s:AsyncRun(...) 36 | return call('easycomplete#util#AsyncRun', a:000) 37 | endfunction 38 | 39 | function! s:console(...) 40 | return call('easycomplete#log#log', a:000) 41 | endfunction 42 | -------------------------------------------------------------------------------- /autoload/easycomplete/confirm.vim: -------------------------------------------------------------------------------- 1 | let s:win_borderchars = ['─', '│', '─', '│', '┌', '┐', '┘', '└'] 2 | function! easycomplete#confirm#pop(title, cb) abort 3 | if g:env_is_vim && exists('*popup_dialog') 4 | try 5 | call popup_dialog(a:title. ' (y/n)?', { 6 | \ 'highlight': 'Pmenu', 7 | \ 'filter': 'popup_filter_yesno', 8 | \ 'callback': {id, res -> a:cb(v:null, res)}, 9 | \ 'borderchars': s:win_borderchars, 10 | \ 'borderhighlight': ['Pmenu'] 11 | \ }) 12 | catch /.*/ 13 | call a:cb(v:exception, 0) 14 | endtry 15 | return 16 | endif 17 | if g:env_is_nvim 18 | let text = ' '. a:title . ' (y/n)? ' 19 | let width = min([&columns - 4, strdisplaywidth(text) + 2]) 20 | let height = 3 21 | let top = ((&lines - height) / 2) - 1 22 | let left = (&columns - width) / 2 23 | let opts = { 24 | \ 'relative': 'editor', 25 | \ 'row': top, 26 | \ 'col': left, 27 | \ 'width': width, 28 | \ 'height': height, 29 | \ 'style': 'minimal', 30 | \ 'focusable': v:false 31 | \ } 32 | 33 | let top = "┌" . repeat("─", width - 2) . "┐" 34 | let mid = "│" . repeat(" ", width - 2) . "│" 35 | let bot = "└" . repeat("─", width - 2) . "┘" 36 | 37 | let lines = [top] + repeat([mid], height - 2) + [bot] 38 | let border_bufnr = nvim_create_buf(v:false, v:true) 39 | call nvim_buf_set_lines(border_bufnr, 0, -1, v:true, lines) 40 | call setbufvar(border_bufnr, '&buftype', "nofile") 41 | call setbufvar(border_bufnr, '&modifiable', 0) 42 | call setbufvar(border_bufnr, '&buflisted', 0) 43 | let s:border_winid = nvim_open_win(border_bufnr, v:true, opts) 44 | let opts.row += 1 45 | let opts.height -= 2 46 | let opts.col += 2 47 | let opts.width -= 4 48 | let opts.focusable = v:true 49 | let text_bufnr = nvim_create_buf(v:false, v:true) 50 | call nvim_buf_set_lines(text_bufnr, 0, -1, v:true, [text]) 51 | call setbufvar(text_bufnr, '&buftype', "nofile") 52 | call setbufvar(text_bufnr, '&modifiable', 0) 53 | call setbufvar(text_bufnr, '&buflisted', 0) 54 | let text_winid = nvim_open_win(text_bufnr, v:true, opts) 55 | let winhl = "Normal:Pmenu" 56 | call setwinvar(s:border_winid, '&winhl', winhl) 57 | call setwinvar(text_winid, '&winhl', winhl) 58 | call setwinvar(s:border_winid, '&list', 0) 59 | call setwinvar(s:border_winid, '&number', 0) 60 | call setwinvar(s:border_winid, '&relativenumber', 0) 61 | call setwinvar(s:border_winid, '&cursorcolumn', 0) 62 | call setwinvar(s:border_winid, '&colorcolumn', 0) 63 | call setwinvar(s:border_winid, '&wrap', 1) 64 | au WinClosed * ++once :q | call nvim_win_close(s:border_winid, v:true) 65 | redraw 66 | while 1 67 | let key = nr2char(getchar()) 68 | if key == "\" 69 | let res = -1 70 | break 71 | elseif key == "\" || key == 'n' || key == 'N' 72 | let res = 0 73 | break 74 | elseif key == 'y' || key == 'Y' || key == "\" 75 | let res = 1 76 | break 77 | endif 78 | endw 79 | call s:close(text_winid) 80 | call timer_start(40, { -> a:cb(v:null, res) }) 81 | elseif exists('*confirm') 82 | let choice = confirm(a:title, "&Yes\n&No") 83 | call a:cb(v:null, choice == 1) 84 | else 85 | echohl MoreMsg 86 | echom a:title.' (y/n)' 87 | echohl None 88 | let confirm = nr2char(getchar()) 89 | redraw! 90 | if !(confirm ==? "y" || confirm ==? "\r") 91 | echohl Moremsg | echo 'Cancelled.' | echohl None 92 | call a:cb(v:null, 0) 93 | end 94 | call a:cb(v:null, 1) 95 | endif 96 | endfunction 97 | 98 | " for nvim only 99 | function! s:close(winid) 100 | call easycomplete#util#execute(a:winid, ["q!"]) 101 | endfunction 102 | 103 | function! s:log(...) 104 | return call('easycomplete#util#log', a:000) 105 | endfunction 106 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/c#.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | os=$(uname -s | tr "[:upper:]" "[:lower:]") 6 | arch="-x64" 7 | 8 | case $os in 9 | linux) ;; 10 | darwin) 11 | os="osx" 12 | arch="" 13 | ;; 14 | *) 15 | printf "%s doesn't supported by bash installer" "$os" 16 | exit 1 17 | ;; 18 | esac 19 | 20 | url="https://github.com/OmniSharp/omnisharp-roslyn/releases/latest/download/omnisharp-$os$arch.tar.gz" 21 | curl -L -o "omnisharp.tar.gz" "$url" 22 | tar -xzvf omnisharp.tar.gz 23 | 24 | chmod +x run 25 | 26 | cat <omnisharp-lsp 27 | #!/usr/bin/env bash 28 | DIR=\$(cd \$(dirname \$0); pwd) 29 | \$DIR/run \$* 30 | EOF 31 | 32 | chmod +x omnisharp-lsp 33 | 34 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/cmake.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/pip_install.sh" cmake-language-server cmake-language-server 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/cpp.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # On MacOS, use clangd in Command Line Tools for Xcode. 6 | if command -v xcrun 2>/dev/null && xcrun --find clangd 2>/dev/null; then 7 | cat <<'EOF' >clangd 8 | #!/usr/bin/env bash 9 | exec xcrun --run clangd "$@" 10 | EOF 11 | chmod +x clangd 12 | exit 13 | fi 14 | 15 | if command -v lsb_release 2>/dev/null; then 16 | distributor_id=$(lsb_release -a 2>&1 | grep 'Distributor ID' | awk '{print $3}') 17 | elif [ -e /etc/fedora-release ]; then 18 | distributor_id="Fedora" 19 | elif [ -e /etc/redhat-release ]; then 20 | distributor_id=$(cat /etc/redhat-release | cut -d ' ' -f 1) 21 | elif [ -e /etc/arch-release ]; then 22 | distributor_id="Arch" 23 | elif [ -e /etc/SuSE-release ]; then 24 | distributor_id="SUSE" 25 | elif [ -e /etc/mandriva-release ]; then 26 | distributor_id="Mandriva" 27 | elif [ -e /etc/vine-release ]; then 28 | distributor_id="Vine" 29 | elif [ -e /etc/gentoo-release ]; then 30 | distributor_id="Gentoo" 31 | else 32 | distributor_id="Unknown" 33 | fi 34 | 35 | filename() { 36 | local distributor_id=$1 37 | local version=$2 38 | 39 | local os 40 | os=$(uname -s | tr "[:upper:]" "[:lower:]") 41 | 42 | case $os in 43 | linux) 44 | local platform="pc-linux-gnu" 45 | ;; 46 | darwin) 47 | local platform="apple-darwin" 48 | ;; 49 | esac 50 | 51 | case $distributor_id in 52 | # Check Ubuntu version 53 | Ubuntu) 54 | local ubuntu_version 55 | ubuntu_version=$(lsb_release -a 2>&1 | grep 'Release' | awk '{print $2}') 56 | case $ubuntu_version in 57 | 14.04 | 16.04 | 18.04 | 20.04) 58 | local platform="linux-gnu-ubuntu-$ubuntu_version" 59 | ;; 60 | esac 61 | ;; 62 | # Check LinuxMint version 63 | LinuxMint) 64 | local linuxmint_version 65 | linuxmint_version=$(lsb_release -a 2>&1 | grep 'Release' | awk '{print $2}') 66 | case $linuxmint_version in 67 | 19 | 19.1 | 19.2 | 19.3) 68 | local platform="linux-gnu-ubuntu-18.04" 69 | ;; 70 | 18 | 18.1 | 18.2 | 18.3) 71 | local platform="linux-gnu-ubuntu-16.04" 72 | ;; 73 | esac 74 | ;; 75 | # Check RedHat OS version 76 | Fedora | Oracle | CentOS) 77 | case $version in 78 | 9.0.0 | 10.0.0) 79 | local platform="linux-sles11.3" 80 | ;; 81 | 11.0.0) 82 | local platform="linux-sles12.4" 83 | ;; 84 | esac 85 | ;; 86 | esac 87 | 88 | # Check Architecture 89 | local arch 90 | arch=$(uname -m) 91 | case $arch in 92 | aarch64) 93 | local platform="linux-gnu" 94 | ;; 95 | esac 96 | 97 | echo "clang+llvm-$version-$arch-$platform" 98 | } 99 | 100 | filename_v9="$(filename "$distributor_id" '9.0.0')" 101 | url_v9="http://releases.llvm.org/9.0.0/$filename_v9.tar.xz" 102 | filename_v10="$(filename "$distributor_id" '10.0.0')" 103 | url_v10="https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/$filename_v10.tar.xz" 104 | filename_v11="$(filename "$distributor_id" '11.0.0')" 105 | url_v11="https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/$filename_v11.tar.xz" 106 | 107 | response_code=$(curl -sIL "${url_v11}" -o /dev/null -w "%{response_code}") 108 | 109 | if [ "${response_code}" == "404" ]; then 110 | response_code=$(curl -sIL "${url_v10}" -o /dev/null -w "%{response_code}") 111 | 112 | if [ "${response_code}" == "404" ]; then 113 | url="${url_v9}" 114 | filename="${filename_v9}" 115 | else 116 | url="${url_v10}" 117 | filename="${filename_v10}" 118 | fi 119 | else 120 | url="${url_v11}" 121 | filename="${filename_v11}" 122 | fi 123 | 124 | echo "Downloading clangd and LLVM..." 125 | curl -L "$url" | unxz | tar x --strip-components=1 "$filename"/ 126 | ln -sf bin/clangd . 127 | ./clangd --version 128 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/css.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" css-languageserver vscode-css-languageserver-bin 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/dart.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | os=$(uname -s | tr "[:upper:]" "[:lower:]") 6 | 7 | case $os in 8 | linux) 9 | platform="linux" 10 | ;; 11 | darwin) 12 | platform="macos" 13 | ;; 14 | esac 15 | 16 | filename="dartsdk-$platform-x64-release.zip" 17 | 18 | curl -o "$filename" "https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-$platform-x64-release.zip" 19 | unzip "$filename" 20 | rm "$filename" 21 | 22 | cat <analysis-server-dart-snapshot 23 | #!/usr/bin/env bash 24 | DIR=\$(cd \$(dirname \$0); pwd)/dart-sdk 25 | \$DIR/bin/dart \$DIR/bin/snapshots/analysis_server.dart.snapshot --lsp \$* 26 | EOF 27 | 28 | chmod +x analysis-server-dart-snapshot 29 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/deno.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | os=$(uname -s | tr "[:upper:]" "[:lower:]") 6 | 7 | case $os in 8 | linux) 9 | filename="deno-x86_64-unknown-linux-gnu.zip" 10 | ;; 11 | darwin) 12 | if [ $(uname -m) == "x86_64" ]; then 13 | filename="deno-x86_64-apple-darwin.zip" 14 | else 15 | filename="deno-aarch64-apple-darwin.zip" 16 | fi 17 | ;; 18 | esac 19 | 20 | curl -L -o "deno-$os.zip" "https://github.com/denoland/deno/releases/latest/download/$filename" 21 | unzip "deno-$os.zip" 22 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/go.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/go_install.sh" golang.org/x/tools/gopls@latest 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/go_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Usage 4 | # $ go_install [GO_GET_URLPATH] 5 | 6 | set -e 7 | 8 | export GOPROXY=https://mirrors.aliyun.com/goproxy/ 9 | GOPATH=$(pwd) GOBIN=$(pwd) GO111MODULE=on go get -v "$1" 10 | GOPATH=$(pwd) GO111MODULE=on go clean -modcache 11 | rm -rf src pkg 2> /dev/null 12 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/grvy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | git clone --depth=1 https://github.com/prominic/groovy-language-server . 6 | ./gradlew build 7 | 8 | cat <groovy-language-server 9 | #!/usr/bin/env bash 10 | DIR=\$(cd \$(dirname \$0); pwd) 11 | java -jar \$DIR/build/libs/groovy-language-server-all.jar \$* 12 | EOF 13 | 14 | cp build/libs/grvy-all.jar build/libs/groovy-language-server-all.jar 15 | chmod +x groovy-language-server 16 | 17 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/html.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" html-languageserver vscode-html-languageserver-bin 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/java.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | curl -L "http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz" | tar zx 6 | curl -o lombok.jar 'https://projectlombok.org/downloads/lombok.jar' 7 | 8 | 9 | osType="$(uname -s)" 10 | case "${osType}" in 11 | Darwin*) configDir=config_mac ;; 12 | Linux*) configDir=config_linux ;; 13 | *) configDir=config_linux ;; 14 | esac 15 | 16 | cat <eclipse-jdt-ls 17 | #!/usr/bin/env bash 18 | DIR=\$(cd \$(dirname \$0); pwd) 19 | LAUNCHER=\$(ls \$DIR/plugins/org.eclipse.equinox.launcher_*.jar) 20 | 21 | java \ 22 | -Declipse.application=org.eclipse.jdt.ls.core.id1 \ 23 | -Dosgi.bundles.defaultStartLevel=4 \ 24 | -Declipse.product=org.eclipse.jdt.ls.core.product \ 25 | -Dlog.level=ALL \ 26 | -noverify \ 27 | -Xmx1G \ 28 | --add-modules=ALL-SYSTEM \ 29 | --add-opens java.base/java.util=ALL-UNNAMED \ 30 | --add-opens java.base/java.lang=ALL-UNNAMED \ 31 | -jar \$LAUNCHER \ 32 | -configuration \$DIR/$configDir \ 33 | -data ./ \ 34 | -javaagent:\$DIR/lombok.jar \ 35 | --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED \ 36 | -XX:+AggressiveOpts \ 37 | -XX:PermSize=512m -XX:MaxPermSize=512m \ 38 | -Xmx2048m \ 39 | -Xms512m \ 40 | -Xmn512m \ 41 | -Xss2m \ 42 | -XX:+UseG1GC \ 43 | -XX:+UseLargePages 44 | EOF 45 | 46 | chmod +x eclipse-jdt-ls 47 | 48 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/json.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" json-languageserver vscode-json-languageserver-bin 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/kt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | version="0.5.2" 6 | curl -L -o server.zip "https://github.com/fwcd/kotlin-language-server/releases/download/$version/server.zip" 7 | unzip server.zip 8 | rm server.zip 9 | 10 | ln -s server/bin/kotlin-language-server . 11 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/lua.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | ## EmmyLua 6 | #version="0.3.6" 7 | #curl -L -o EmmyLua-LS-all.jar "https://github.com/EmmyLua/EmmyLua-LanguageServer/releases/download/$version/EmmyLua-LS-all.jar" 8 | 9 | #cat <emmylua-ls 10 | ##!/usr/bin/env bash 11 | #DIR=\$(cd \$(dirname \$0); pwd) 12 | #java -cp \$DIR/EmmyLua-LS-all.jar com.tang.vscode.MainKt 13 | #EOF 14 | 15 | #chmod +x emmylua-ls 16 | 17 | 18 | # On MacOS, use clangd in Command Line Tools for Xcode. 19 | 20 | # --------------------------------------------------------------write config file 21 | cat <config.json 22 | { 23 | "Lua": { 24 | "workspace.library": { 25 | "/usr/share/nvim/runtime/lua": true, 26 | "/usr/share/nvim/runtime/lua/vim": true, 27 | "/usr/share/nvim/runtime/lua/vim/lsp": true 28 | }, 29 | "diagnostics": { 30 | "globals": [ "vim" , "use" , "use_rocks"] 31 | } 32 | }, 33 | "sumneko-lua.enableNvimLuaDev": true 34 | } 35 | EOF 36 | 37 | echo "write config.json ok." 38 | 39 | user_root=$(echo $(pwd) | sed -e "s/\/.config.*$//g") 40 | nvim_lsp_path="$user_root/.local/share/nvim/lsp_servers/sumneko_lua/extension/server/bin" 41 | 42 | #---------------------------------------------------------------if 43 | if test -x $nvim_lsp_path/lua-language-server; then 44 | echo "nvim_lsp_config detecting is ok." 45 | cat <sumneko-lua-language-server 46 | #!/usr/bin/env bash 47 | $nvim_lsp_path/lua-language-server -E -e LANG=en $nvim_lsp_path/main.lua \$* 48 | EOF 49 | chmod +x sumneko-lua-language-server 50 | echo "install ready!" 51 | exit 52 | 53 | # --------------------------------------------------------------else 54 | else 55 | 56 | os=$(uname -s | tr "[:upper:]" "[:lower:]") 57 | 58 | version="2.6.6" 59 | 60 | case $os in 61 | linux) 62 | platform="linux-x64" 63 | ;; 64 | darwin) 65 | platform="darwin-x64" 66 | ;; 67 | esac 68 | 69 | package_name="vscode-lua-v$version-$platform" 70 | 71 | url="https://github.com/sumneko/vscode-lua/releases/download/v$version/$package_name.vsix" 72 | echo "downloading $url" 73 | 74 | asset="vscode-lua.vsix" 75 | 76 | curl -L "$url" -o "$asset" 77 | unzip "$asset" 78 | rm "$asset" 79 | 80 | chmod +x extension/server/bin/lua-language-server 81 | 82 | cat <sumneko-lua-language-server 83 | #!/usr/bin/env bash 84 | DIR=\$(cd \$(dirname \$0); pwd)/extension/server 85 | \$DIR/bin/lua-language-server -E -e LANG=en \$DIR/main.lua \$* 86 | EOF 87 | 88 | chmod +x sumneko-lua-language-server 89 | 90 | # --------------------------------------------------------------fi 91 | fi 92 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/nim.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if command -v nimlsp > /dev/null; then 6 | echo "install already" 7 | else 8 | echo "nimlsp is installing" 9 | nimble -y --nimbledir=$(pwd) install nimlsp 10 | ln -s $(pwd)/bin/nimlsp . 11 | # nimble install nimlsp 12 | fi 13 | 14 | #cat <nimlsp 15 | ##!/usr/bin/env bash 16 | #DIR=\$(cd \$(dirname \$0); pwd) 17 | #\$DIR/nimlsp \$* 18 | #EOF 19 | 20 | #chmod +x nimlsp 21 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/npm_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Usage 4 | # $ npm_install [EXECUTABLE_NAME] [NPM_NAME] 5 | 6 | set -e 7 | 8 | # Supporting multiple npm packages(e.g. typescript-language-server uses typescript-language-server and tsserver). 9 | # If package.json exists, skip calling npm init. 10 | if [ ! -f package.json ]; then 11 | # Avoid the problem of not being able to install the same package as name in package.json. 12 | # Create an empty package.json. 13 | npm init -y 14 | echo '{"name": ""}' >package.json 15 | fi 16 | 17 | npm install "$2" 18 | ln -s "./node_modules/.bin/$1" . 19 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/php.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" intelephense intelephense 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/pip_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Usage 4 | # $ pip_install [EXECUTABLE_NAME] [PYPI_NAME] 5 | 6 | set -e 7 | 8 | python3 -m venv ./venv 9 | ./venv/bin/pip3 install -U pip 10 | ./venv/bin/pip3 install "$2" 11 | # pip3 install "$2" 12 | ln -s "./venv/bin/$1" . 13 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/py.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/pip_install.sh" pylsp python-lsp-server 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/r.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo 'install.packages("languageserver", repos = "https://mirror.lzu.edu.cn/CRAN")' >install.r 6 | Rscript install.r 7 | 8 | cat <r-languageserver 9 | #!/usr/bin/env bash 10 | R --slave -e 'languageserver::run()' 11 | EOF 12 | 13 | chmod +x r-languageserver 14 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/rb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | git clone --depth=1 https://github.com/castwide/solargraph . 6 | bundle install --without development --path vendor/bundle 7 | 8 | cat <solargraph 9 | #!/usr/bin/env bash 10 | DIR=\$(cd \$(dirname \$0); pwd) 11 | BUNDLE_GEMFILE=\$DIR/Gemfile bundle exec ruby \$DIR/bin/solargraph \$* 12 | EOF 13 | 14 | chmod +x solargraph 15 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/rust.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | os=$(uname -s | tr "[:upper:]" "[:lower:]") 6 | 7 | case $os in 8 | linux) 9 | platform="x86_64-unknown-linux-gnu" 10 | ;; 11 | darwin) 12 | platform="x86_64-apple-darwin" 13 | ;; 14 | esac 15 | 16 | echo "https://github.com/rust-analyzer/rust-analyzer/releases/download/2021-09-27/rust-analyzer-$platform.gz" 17 | 18 | curl -L -o "rust-analyzer-$platform.gz" "https://github.com/rust-analyzer/rust-analyzer/releases/download/2021-09-27/rust-analyzer-$platform.gz" 19 | gzip -d "rust-analyzer-$platform.gz" 20 | 21 | mv rust-analyzer-$platform rust-analyzer 22 | chmod +x rust-analyzer 23 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/sh.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" bash-language-server bash-language-server 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/tn.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Based on https://github.com/codota/TabNine/blob/master/dl_binaries.sh 4 | # Download latest TabNine binaries 5 | set -e 6 | 7 | #version=${version:-$(curl -sS https://update.tabnine.com/bundles/version)} 8 | #4.280.0 9 | 10 | version="3.3.126" 11 | version="4.4.223" 12 | version="3.3.34" 13 | version="4.277.1" 14 | version="4.251.0" 15 | 16 | case $(uname -s) in 17 | "Darwin") 18 | if [ "$(uname -m)" == "arm64" ]; then 19 | platform="aarch64-apple-darwin" 20 | else 21 | platform="$(uname -m)-apple-darwin" 22 | fi 23 | ;; 24 | "Linux") 25 | platform="$(uname -m)-unknown-linux-musl" 26 | ;; 27 | esac 28 | 29 | # we want the binary to reside inside our plugin's dir 30 | cd $(pwd) 31 | path=$version/$platform 32 | echo $path 33 | 34 | curl https://update.tabnine.com/bundles/${path}/TabNine.zip --create-dirs -o binaries/${path}/TabNine.zip 35 | unzip -o binaries/${path}/TabNine.zip -d binaries/${path} 36 | rm -rf binaries/${path}/TabNine.zip 37 | chmod +x binaries/$path/* 38 | # ln -sf $path "binaries/TabNine_$(uname -s)" 39 | 40 | cat <TabNine 41 | #!/usr/bin/env bash 42 | DIR=\$(cd \$(dirname \$0); pwd) 43 | \$DIR/binaries/$path/TabNine \$* 44 | EOF 45 | 46 | cat <version 47 | $version 48 | EOF 49 | 50 | touch tabnine.log 51 | 52 | mkdir binaries/0.0.1 53 | mkdir binaries/0.0.1/$platform 54 | touch binaries/0.0.1/$platform/bundles.lock 55 | touch binaries/0.0.1/$platform/TabNine.zip 56 | 57 | chmod +x TabNine 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/ts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" tsserver typescript 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/vim.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" vim-language-server vim-language-server 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/xml.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | version="0.14.1" 6 | url="https://repo.eclipse.org/content/repositories/lemminx-releases/org/eclipse/lemminx/org.eclipse.lemminx/${version}/org.eclipse.lemminx-${version}-uber.jar" 7 | lemminx_jar="org.eclipse.lemminx-${version}-uber.jar" 8 | 9 | curl -L "$url" -o "${lemminx_jar}" 10 | 11 | cat <lemminx 12 | #!/usr/bin/env bash 13 | DIR=\$(cd \$(dirname \$0); pwd) 14 | java -jar \$DIR/${lemminx_jar} 15 | EOF 16 | 17 | chmod +x lemminx 18 | -------------------------------------------------------------------------------- /autoload/easycomplete/installer/yml.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | "$(dirname "$0")/npm_install.sh" yaml-language-server yaml-language-server 6 | -------------------------------------------------------------------------------- /autoload/easycomplete/lsp/folding.vim: -------------------------------------------------------------------------------- 1 | let s:folding_ranges = {} 2 | let s:textprop_name = 'vim-lsp-folding-linenr' 3 | 4 | function! s:set_textprops(buf) abort 5 | " Use zero-width text properties to act as a sort of "mark" in the buffer. 6 | " This is used to remember the line numbers at the time the request was 7 | " sent. We will let Vim handle updating the line numbers when the user 8 | " inserts or deletes text. 9 | 10 | " Skip if the buffer doesn't exist. This might happen when a buffer is 11 | " opened and quickly deleted. 12 | if !bufloaded(a:buf) | return | endif 13 | 14 | " Create text property, if not already defined 15 | silent! call prop_type_add(s:textprop_name, {'bufnr': a:buf}) 16 | 17 | let l:line_count = s:get_line_count_buf(a:buf) 18 | 19 | " First, clear all markers from the previous run 20 | call prop_remove({'type': s:textprop_name, 'bufnr': a:buf}, 1, l:line_count) 21 | 22 | " Add markers to each line 23 | let l:i = 1 24 | while l:i <= l:line_count 25 | call prop_add(l:i, 1, {'bufnr': a:buf, 'type': s:textprop_name, 'id': l:i}) 26 | let l:i += 1 27 | endwhile 28 | endfunction 29 | 30 | function! s:get_line_count_buf(buf) abort 31 | if !has('patch-8.1.1967') 32 | return line('$') 33 | endif 34 | let l:winids = win_findbuf(a:buf) 35 | return empty(l:winids) ? line('$') : line('$', l:winids[0]) 36 | endfunction 37 | 38 | function! s:has_provider(server_name, ...) abort 39 | let l:value = easycomplete#lsp#get_server_capabilities(a:server_name) 40 | for l:provider in a:000 41 | if empty(l:value) || type(l:value) != type({}) || !has_key(l:value, l:provider) 42 | return 0 43 | endif 44 | let l:value = l:value[l:provider] 45 | endfor 46 | return (type(l:value) == type(v:true) && l:value == v:true) || type(l:value) == type({}) 47 | endfunction 48 | 49 | function! easycomplete#lsp#folding#send_request(server_name, buf, sync) abort 50 | " if !easycomplete#lsp#capabilities#has_folding_range_provider(a:server_name) 51 | " return 52 | " endif 53 | if !s:has_provider(a:server_name, 'foldingRangeProvider') 54 | return 55 | endif 56 | 57 | if has('textprop') 58 | call s:set_textprops(a:buf) 59 | endif 60 | 61 | call easycomplete#lsp#send_request(a:server_name, { 62 | \ 'method': 'textDocument/foldingRange', 63 | \ 'params': { 64 | \ 'textDocument': easycomplete#lsp#get_text_document_identifier(a:buf) 65 | \ }, 66 | \ 'on_notification': function('s:handle_fold_request', [a:server_name]), 67 | \ 'sync': a:sync, 68 | \ 'bufnr': a:buf 69 | \ }) 70 | endfunction 71 | 72 | function! s:handle_fold_request(server, data) abort 73 | if easycomplete#lsp#client#is_error(a:data) || !has_key(a:data, 'response') || !has_key(a:data['response'], 'result') 74 | return 75 | endif 76 | 77 | let l:result = a:data['response']['result'] 78 | 79 | if type(l:result) != type([]) 80 | return 81 | endif 82 | 83 | let l:uri = a:data['request']['params']['textDocument']['uri'] 84 | let l:path = easycomplete#lsp#utils#uri_to_path(l:uri) 85 | let l:bufnr = bufnr(l:path) 86 | 87 | if l:bufnr < 0 88 | return 89 | endif 90 | 91 | if !has_key(s:folding_ranges, a:server) 92 | let s:folding_ranges[a:server] = {} 93 | endif 94 | let s:folding_ranges[a:server][l:bufnr] = l:result 95 | 96 | " Set 'foldmethod' back to 'expr', which forces a re-evaluation of 97 | " 'foldexpr'. Only do this if the user hasn't changed 'foldmethod', 98 | " and this is the correct buffer. 99 | for l:winid in win_findbuf(l:bufnr) 100 | if getwinvar(l:winid, '&foldmethod') ==# 'expr' 101 | call setwinvar(l:winid, '&foldmethod', 'expr') 102 | endif 103 | endfor 104 | endfunction 105 | 106 | function! s:errlog(...) 107 | return call('easycomplete#util#errlog', a:000) 108 | endfunction 109 | -------------------------------------------------------------------------------- /autoload/easycomplete/lsp/utils/position.vim: -------------------------------------------------------------------------------- 1 | " This function can be error prone if the caller forgets to use +1 to vim line 2 | " so use easycomplete#lsp#utils#position#lsp_to_vim instead 3 | " Convert a character-index (0-based) to byte-index (1-based) 4 | " This function requires a buffer specifier (expr, see :help bufname()), 5 | " a line number (lnum, 1-based), and a character-index (char, 0-based). 6 | function! s:to_col(expr, lnum, char) abort 7 | let l:lines = getbufline(a:expr, a:lnum) 8 | if l:lines == [] 9 | if type(a:expr) != v:t_string || !filereadable(a:expr) 10 | " invalid a:expr 11 | return a:char + 1 12 | endif 13 | " a:expr is a file that is not yet loaded as a buffer 14 | let l:lines = readfile(a:expr, '', a:lnum) 15 | endif 16 | let l:linestr = l:lines[-1] 17 | return strlen(strcharpart(l:linestr, 0, a:char)) + 1 18 | endfunction 19 | 20 | " The inverse version of `s:to_col`. 21 | " Convert [lnum, col] to LSP's `Position`. 22 | function! s:to_char(expr, lnum, col) abort 23 | let l:lines = getbufline(a:expr, a:lnum) 24 | if l:lines == [] 25 | if type(a:expr) != v:t_string || !filereadable(a:expr) 26 | " invalid a:expr 27 | return a:col - 1 28 | endif 29 | " a:expr is a file that is not yet loaded as a buffer 30 | let l:lines = readfile(a:expr, '', a:lnum) 31 | endif 32 | let l:linestr = l:lines[-1] 33 | return strchars(strpart(l:linestr, 0, a:col - 1)) 34 | endfunction 35 | 36 | " @param expr = see :help bufname() 37 | " @param position = { 38 | " 'line': 1, 39 | " 'character': 1 40 | " } 41 | " @returns [ 42 | " line, 43 | " col 44 | " ] 45 | function! easycomplete#lsp#utils#position#lsp_to_vim(expr, position) abort 46 | let l:line = easycomplete#lsp#utils#position#lsp_line_to_vim(a:expr, a:position) 47 | let l:col = easycomplete#lsp#utils#position#lsp_character_to_vim(a:expr, a:position) 48 | return [l:line, l:col] 49 | endfunction 50 | 51 | " @param expr = see :help bufname() 52 | " @param position = { 53 | " 'line': 1, 54 | " 'character': 1 55 | " } 56 | " @returns 57 | " line 58 | function! easycomplete#lsp#utils#position#lsp_line_to_vim(expr, position) abort 59 | return a:position['line'] + 1 60 | endfunction 61 | 62 | " @param expr = see :help bufname() 63 | " @param position = { 64 | " 'line': 1, 65 | " 'character': 1 66 | " } 67 | " @returns 68 | " line 69 | function! easycomplete#lsp#utils#position#lsp_character_to_vim(expr, position) abort 70 | let l:line = a:position['line'] + 1 " optimize function overhead by not calling lsp_line_to_vim 71 | let l:char = a:position['character'] 72 | return s:to_col(a:expr, l:line, l:char) 73 | endfunction 74 | 75 | " @param expr = :help bufname() 76 | " @param pos = [lnum, col] 77 | " @returns { 78 | " 'line': line, 79 | " 'character': character 80 | " } 81 | function! easycomplete#lsp#utils#position#vim_to_lsp(expr, pos) abort 82 | return { 83 | \ 'line': a:pos[0] - 1, 84 | \ 'character': s:to_char(a:expr, a:pos[0], a:pos[1]) 85 | \ } 86 | endfunction 87 | 88 | -------------------------------------------------------------------------------- /autoload/easycomplete/lsp/utils/step.vim: -------------------------------------------------------------------------------- 1 | function! s:next(steps, current_index, result) abort 2 | if len(a:steps) == a:current_index 3 | return 4 | endif 5 | let l:Step = a:steps[a:current_index] 6 | let l:ctx = { 7 | \ 'callback': function('s:callback', [a:steps, a:current_index]), 8 | \ 'result': a:result 9 | \ } 10 | call call(l:Step, [l:ctx]) 11 | endfunction 12 | 13 | function! s:callback(steps, current_index, ...) abort 14 | call s:next(a:steps, a:current_index + 1, a:000) 15 | endfunction 16 | 17 | function! easycomplete#lsp#utils#step#start(steps) abort 18 | call s:next(a:steps, 0, []) 19 | endfunction 20 | -------------------------------------------------------------------------------- /autoload/easycomplete/lua.vim: -------------------------------------------------------------------------------- 1 | 2 | 3 | function! easycomplete#lua#test() 4 | echom "test ok" 5 | " lua require('init').api() 6 | endfunction 7 | 8 | function! easycomplete#lua#api() 9 | echom "api" 10 | endfunction 11 | 12 | function! easycomplete#lua#data() 13 | 14 | endfunction 15 | -------------------------------------------------------------------------------- /autoload/easycomplete/python.vim: -------------------------------------------------------------------------------- 1 | " 兼容非 python3 场景,确保不报错 2 | function! s:PreparePythonEnvironment() 3 | if get(g:, 'easycomplete_python3_ready') == 2 4 | return v:true 5 | endif 6 | 7 | if get(g:, 'easycomplete_python3_ready') == 1 8 | return v:false 9 | endif 10 | 11 | if !has("python3") 12 | let g:easycomplete_python3_ready = 1 13 | return v:false 14 | else 15 | py3 import vim 16 | py3 import EasyCompleteUtil.util as EasyCompleteUtil 17 | let g:easycomplete_python3_ready = 2 18 | return v:true 19 | endif 20 | endfunction 21 | 22 | function! easycomplete#python#NormalizeSortPY(items) 23 | if !s:PreparePythonEnvironment() | return a:items | endif 24 | try 25 | py3 vim.command("let ret = %s"% EasyCompleteUtil.normalize_sort(vim.eval("a:items"))) 26 | catch 27 | echom "python -> vim data format parsing error" 28 | echom v:exception 29 | endtry 30 | return ret 31 | endfunction 32 | 33 | " 实测性能不如 VIM 的实现,一般不用 34 | function! easycomplete#python#FuzzySearchPy(needle, haystack) 35 | if !s:PreparePythonEnvironment() | return 0 | endif 36 | let needle = tolower(a:needle) 37 | let haystack = tolower(a:haystack) 38 | py3 needle = vim.eval("needle") 39 | py3 haystack = vim.eval("haystack") 40 | py3 vim.command("let ret = %s"% EasyCompleteUtil.fuzzy_search(needle, haystack)) 41 | return ret 42 | endfunction 43 | 44 | " TODO 45 | function! easycomplete#python#CompleteMenuFilterPy(all_menu, word, maxlength) 46 | if !s:PreparePythonEnvironment() | return a:all_menu | endif 47 | py3 all_menu = vim.eval("a:all_menu") 48 | py3 word = vim.eval("a:word") 49 | py3 maxlength = int(vim.eval("a:maxlength")) 50 | py3 vim.command('let ret = %s'% EasyCompleteUtil.complete_menu_filter(all_menu, word, maxlength)) 51 | echom ret 52 | return ret 53 | endfunction 54 | 55 | function! easycomplete#python#GetSnippetsCodeInfo(snip_object) 56 | if !s:PreparePythonEnvironment() | return "" | endif 57 | py3 filepath = vim.eval("a:snip_object.filepath") 58 | py3 line_number = int(vim.eval("a:snip_object.line_number")) 59 | py3 vim.command('let ret = %s'% EasyCompleteUtil.snippets_code_info(filepath, line_number)) 60 | return ret 61 | endfunction 62 | 63 | function! easycomplete#python#Sha256(str) 64 | if !s:PreparePythonEnvironment() | return a:str | endif 65 | py3 str = vim.eval("a:str") 66 | py3 vim.command('let ret = "%s"'% EasyCompleteUtil.get_sha256(str)) 67 | return ret 68 | endfunction 69 | 70 | function! easycomplete#python#ListDir(path) 71 | if !s:PreparePythonEnvironment() | return [] | endif 72 | py3 path_str = vim.eval("a:path") 73 | py3 vim.command('let ret = %s'% EasyCompleteUtil.listdir(path_str)) 74 | return ret 75 | endfunction 76 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/bash.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#bash#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'bashls', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name']), 'start'], 5 | \ 'root_uri':{ server_info -> easycomplete#util#GetDefaultRootUri() }, 6 | \ 'allowlist': a:opt['whitelist'], 7 | \ 'config': {'refresh_pattern': '\([a-zA-Z0-9_-]\+\|\k\+\)$'}, 8 | \ }) 9 | endfunction 10 | 11 | function! easycomplete#sources#bash#completor(opt, ctx) abort 12 | return easycomplete#DoLspComplete(a:opt, a:ctx) 13 | endfunction 14 | 15 | function! easycomplete#sources#bash#GotoDefinition(...) 16 | return easycomplete#DoLspDefinition(["sh"]) 17 | endfunction 18 | 19 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/cmake.vim: -------------------------------------------------------------------------------- 1 | " TODO 仍未调通,应该是 cmake-languageserver 本身的 bug 2 | " 参考:https://github.com/regen100/cmake-language-server/issues/9 3 | function! easycomplete#sources#cmake#constructor(opt, ctx) 4 | call easycomplete#RegisterLspServer(a:opt, { 5 | \ 'name': 'cmake', 6 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name'])], 7 | \ 'root_uri':{ server_info -> easycomplete#util#GetDefaultRootUri() }, 8 | \ 'initialization_options': {'buildDirectory': 'build'}, 9 | \ 'allowlist': a:opt['whitelist'], 10 | \ }) 11 | endfunction 12 | 13 | function! easycomplete#sources#cmake#completor(opt, ctx) abort 14 | return easycomplete#DoLspComplete(a:opt, a:ctx) 15 | endfunction 16 | 17 | function! easycomplete#sources#cmake#GotoDefinition(...) 18 | return easycomplete#DoLspDefinition(["cmake", "make", "txt"]) 19 | endfunction 20 | 21 | 22 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/cpp.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#cpp#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'clangd', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name'])]}, 5 | \ 'initialization_options':{ 6 | \ 'cache': {'directory': '/tmp/clangd/cache'}, 7 | \ 'completion': {'detailedLabel': v:false } 8 | \ }, 9 | \ 'allowlist': a:opt['whitelist'], 10 | \ }) 11 | endfunction 12 | 13 | function! easycomplete#sources#cpp#completor(opt, ctx) abort 14 | return easycomplete#DoLspComplete(a:opt, a:ctx) 15 | endfunction 16 | 17 | function! easycomplete#sources#cpp#GotoDefinition(...) 18 | return easycomplete#DoLspDefinition(["cpp","c","h","cc","objc","objcpp","m","hpp"]) 19 | endfunction 20 | 21 | function! easycomplete#sources#cpp#filter(matches) 22 | let ctx = easycomplete#context() 23 | let matches = map(copy(a:matches), function("easycomplete#util#FunctionSurffixMap")) 24 | let matches_ret = map(copy(matches), function("s:CppItemPrefixHandling")) 25 | return matches_ret 26 | endfunction 27 | 28 | function! s:CppItemPrefixHandling(key, val) 29 | " `•clockid_t` -> `clockid_t` 30 | " ` std::chrono` -> `std::chrono` 31 | let item = a:val 32 | let first_char = strcharpart(item['abbr'], 0, 1) 33 | let abbr = item['abbr'] 34 | if char2nr(first_char) == 32 " 首字符是空格 35 | let item['abbr'] = substitute(abbr, "^\\s\\+\\(.\\{\-}\\)$","\\1","g") 36 | elseif strlen(first_char) > 1 37 | let item['abbr'] = strcharpart(abbr, 1) 38 | endif 39 | return item 40 | endfunction 41 | 42 | function! s:log(...) 43 | return call('easycomplete#util#log', a:000) 44 | endfunction 45 | 46 | function! s:console(...) 47 | return call('easycomplete#log#log', a:000) 48 | endfunction 49 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/cs.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#cs#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'omnisharp-lsp', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name']), '-lsp'], 5 | \ 'root_uri':{server_info->easycomplete#util#GetDefaultRootUri()}, 6 | \ 'allowlist': a:opt['whitelist'], 7 | \ 'config': {}, 8 | \ }) 9 | endfunction 10 | 11 | function! easycomplete#sources#cs#completor(opt, ctx) abort 12 | return easycomplete#DoLspComplete(a:opt, a:ctx) 13 | endfunction 14 | 15 | function! easycomplete#sources#cs#GotoDefinition(...) 16 | return easycomplete#DoLspDefinition(["cs"]) 17 | endfunction 18 | 19 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/css.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#css#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'cssls', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name']), '--stdio'], 5 | \ 'allowlist': a:opt['whitelist'], 6 | \ 'config': {'refresh_pattern': '\([a-zA-Z0-9_-]\+\)$'}, 7 | \ }) 8 | endfunction 9 | 10 | function! easycomplete#sources#css#completor(opt, ctx) abort 11 | return easycomplete#DoLspComplete(a:opt, a:ctx) 12 | endfunction 13 | 14 | function! easycomplete#sources#css#GotoDefinition(...) 15 | return easycomplete#DoLspDefinition(["css","less","scss","sass"]) 16 | endfunction 17 | 18 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/dart.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#dart#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'dartls', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name'])], 5 | \ 'root_uri':{ server_info -> easycomplete#util#GetDefaultRootUri() }, 6 | \ 'initialization_options': v:null, 7 | \ 'allowlist': a:opt['whitelist'], 8 | \ 'config': {}, 9 | \ 'semantic_highlight': {}, 10 | \ 'workspace_config': { 11 | \ "dart": { 12 | \ "enableSdkFormatter": v:false, 13 | \ "analysisExcludedFolders": v:false, 14 | \ "showTodos": v:false, 15 | \ "enableSnippets": v:false, 16 | \ }, 17 | \ }, 18 | \ }) 19 | endfunction 20 | 21 | function! easycomplete#sources#dart#completor(opt, ctx) abort 22 | return easycomplete#DoLspComplete(a:opt, a:ctx) 23 | endfunction 24 | 25 | function! easycomplete#sources#dart#GotoDefinition(...) 26 | return easycomplete#DoLspDefinition(["dart"]) 27 | endfunction 28 | 29 | 30 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/go.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#go#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'gopls', 4 | \ 'cmd': { server_info->[easycomplete#installer#GetCommand(a:opt['name'])] }, 5 | \ 'root_uri':{ server_info -> easycomplete#util#GetDefaultRootUri() }, 6 | \ 'initialization_options': { 7 | \ 'completeUnimported': v:true, 8 | \ 'matcher': 'fuzzy', 9 | \ 'codelenses': { 10 | \ 'generate': v:true, 11 | \ 'test': v:true, 12 | \ }, 13 | \ }, 14 | \ 'allowlist': a:opt["whitelist"], 15 | \ }) 16 | endfunction 17 | 18 | function! easycomplete#sources#go#completor(opt, ctx) abort 19 | return easycomplete#DoLspComplete(a:opt, a:ctx) 20 | endfunction 21 | 22 | function! easycomplete#sources#go#GotoDefinition(...) 23 | return easycomplete#DoLspDefinition(["go"]) 24 | endfunction 25 | 26 | function! easycomplete#sources#go#filter(matches) 27 | let ctx = easycomplete#context() 28 | let matches = a:matches 29 | let matches = map(copy(matches), function("easycomplete#util#FunctionSurffixMap")) 30 | return matches 31 | endfunction 32 | 33 | function! s:log(...) 34 | return call('easycomplete#util#log', a:000) 35 | endfunction 36 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/grvy.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#grvy#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'groovyls', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name'])]}, 5 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 6 | \ 'allowlist': a:opt["whitelist"], 7 | \ }) 8 | endfunction 9 | 10 | function! easycomplete#sources#grvy#completor(opt, ctx) abort 11 | return easycomplete#DoLspComplete(a:opt, a:ctx) 12 | endfunction 13 | 14 | function! easycomplete#sources#grvy#GotoDefinition(...) 15 | return easycomplete#DoLspDefinition(["groovy","gradle"]) 16 | endfunction 17 | 18 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/html.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#html#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'html', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name']), '--stdio']}, 5 | \ 'initialization_options':{'embeddedLanguages': {'css': v:true, 'javascript': v:true}}, 6 | \ 'allowlist': a:opt["whitelist"], 7 | \ }) 8 | endfunction 9 | 10 | function! easycomplete#sources#html#completor(opt, ctx) abort 11 | return easycomplete#DoLspComplete(a:opt, a:ctx) 12 | endfunction 13 | 14 | function! easycomplete#sources#html#GotoDefinition(...) 15 | return easycomplete#DoLspDefinition(["html","htm","xhtml"]) 16 | endfunction 17 | 18 | function! s:log(...) 19 | return call('easycomplete#util#log', a:000) 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/java.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#java#constructor(opt, ctx) 2 | " 注册 lsp 3 | call easycomplete#RegisterLspServer(a:opt, { 4 | \ 'name': 'jdtls', 5 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name'])]}, 6 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 7 | \ 'allowlist': a:opt["whitelist"], 8 | \ }) 9 | endfunction 10 | 11 | function! easycomplete#sources#java#completor(opt, ctx) abort 12 | return easycomplete#DoLspComplete(a:opt, a:ctx) 13 | endfunction 14 | 15 | function! easycomplete#sources#java#GotoDefinition(...) 16 | return easycomplete#DoLspDefinition(["java"]) 17 | endfunction 18 | 19 | function! s:log(...) 20 | return call('easycomplete#util#log', a:000) 21 | endfunction 22 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/kotlin.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#kotlin#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'kotlin_language_server', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name'])], 5 | \ 'root_uri':{ server_info -> easycomplete#util#GetDefaultRootUri() }, 6 | \ 'initialization_options': v:null, 7 | \ 'config': {}, 8 | \ 'allowlist': ['kotlin'] 9 | \ }) 10 | endfunction 11 | 12 | function! easycomplete#sources#kotlin#completor(opt, ctx) abort 13 | return easycomplete#DoLspComplete(a:opt, a:ctx) 14 | endfunction 15 | 16 | function! easycomplete#sources#kotlin#GotoDefinition(...) 17 | return easycomplete#DoLspDefinition(["kt"]) 18 | endfunction 19 | 20 | function! easycomplete#sources#kotlin#filter(matches) 21 | let ctx = easycomplete#context() 22 | let matches = a:matches 23 | let matches = map(copy(matches), function("easycomplete#util#FunctionSurffixMap")) 24 | return matches 25 | endfunction 26 | 27 | function! s:console(...) 28 | return call('easycomplete#log#log', a:000) 29 | endfunction 30 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/nim.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#nim#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'nimls', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name'])]}, 5 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 6 | \ 'initialization_options' : {'diagnostics': 'true'}, 7 | \ 'allowlist': a:opt["whitelist"], 8 | \ }) 9 | endfunction 10 | 11 | function! easycomplete#sources#nim#completor(opt, ctx) abort 12 | return easycomplete#DoLspComplete(a:opt, a:ctx) 13 | endfunction 14 | 15 | function! easycomplete#sources#nim#GotoDefinition(...) 16 | return easycomplete#DoLspDefinition(["nim","nimble"]) 17 | endfunction 18 | 19 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/php.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#php#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'intelephense', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name']), '--stdio']}, 5 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 6 | \ 'config': {'refresh_pattern': '\(\$[a-zA-Z0-9_:]*\|\k\+\)$'}, 7 | \ 'allowlist': a:opt["whitelist"], 8 | \ }) 9 | endfunction 10 | 11 | function! easycomplete#sources#php#completor(opt, ctx) abort 12 | return easycomplete#DoLspComplete(a:opt, a:ctx) 13 | endfunction 14 | 15 | function! easycomplete#sources#php#GotoDefinition(...) 16 | return easycomplete#DoLspDefinition(["php"]) 17 | endfunction 18 | 19 | function! easycomplete#sources#php#filter(matches) 20 | let ctx = easycomplete#context() 21 | let matches = a:matches 22 | let matches = map(copy(matches), function("easycomplete#util#FunctionSurffixMap")) 23 | return matches 24 | endfunction 25 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/py.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#py#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'pylsp', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name'])]}, 5 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 6 | \ 'allowlist': a:opt["whitelist"], 7 | \ }) 8 | endfunction 9 | 10 | function! easycomplete#sources#py#completor(opt, ctx) abort 11 | return easycomplete#DoLspComplete(a:opt, a:ctx) 12 | endfunction 13 | 14 | function! easycomplete#sources#py#GotoDefinition(...) 15 | return easycomplete#DoLspDefinition(["py", "pyi"]) 16 | endfunction 17 | 18 | function! easycomplete#sources#py#filter(matches) 19 | let ctx = easycomplete#context() 20 | let matches = a:matches 21 | let matches = map(copy(matches), function("easycomplete#util#FunctionSurffixMap")) 22 | return matches 23 | endfunction 24 | 25 | function! s:log(...) 26 | return call('easycomplete#util#log', a:000) 27 | endfunction 28 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/r.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#r#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'r-languageserver', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name'])], 5 | \ 'allowlist': a:opt['whitelist'], 6 | \ 'root_uri':{server_info->easycomplete#util#GetDefaultRootUri()}, 7 | \ }) 8 | endfunction 9 | 10 | function! easycomplete#sources#r#completor(opt, ctx) abort 11 | return easycomplete#DoLspComplete(a:opt, a:ctx) 12 | endfunction 13 | 14 | function! easycomplete#sources#r#GotoDefinition(...) 15 | return easycomplete#DoLspDefinition(["r", "rmd", "rmarkdown"]) 16 | endfunction 17 | 18 | function! s:log(...) 19 | return call('easycomplete#util#log', a:000) 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/ruby.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#ruby#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'solargraph', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name']), 'stdio']}, 5 | \ 'initialization_options': { 6 | \ 'diagnostics': 'true' 7 | \ }, 8 | \ 'allowlist': a:opt["whitelist"], 9 | \ }) 10 | endfunction 11 | 12 | function! easycomplete#sources#ruby#completor(opt, ctx) abort 13 | return easycomplete#DoLspComplete(a:opt, a:ctx) 14 | endfunction 15 | 16 | function! easycomplete#sources#ruby#GotoDefinition(...) 17 | return easycomplete#DoLspDefinition(["rb"]) 18 | endfunction 19 | 20 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/rust.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#rust#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'rust_analyzer', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name'])], 5 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 6 | \ 'allowlist': a:opt["whitelist"], 7 | \ 'initialization_options': { 8 | \ 'completion': { 9 | \ 'autoimport': { 'enable': v:true }, 10 | \ }, 11 | \ }, 12 | \ 'config': {}, 13 | \ 'workspace_config' : {}, 14 | \ 'semantic_highlight' : {} 15 | \ }) 16 | endfunction 17 | 18 | function! easycomplete#sources#rust#completor(opt, ctx) abort 19 | return easycomplete#DoLspComplete(a:opt, a:ctx) 20 | endfunction 21 | 22 | function! easycomplete#sources#rust#GotoDefinition(...) 23 | return easycomplete#DoLspDefinition(["rs", "rust"]) 24 | endfunction 25 | 26 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/snips.vim: -------------------------------------------------------------------------------- 1 | 2 | function! easycomplete#sources#snips#completor(opt, ctx) 3 | if !easycomplete#SnipSupports() 4 | call easycomplete#complete(a:opt['name'], a:ctx, a:ctx['startcol'], []) 5 | return v:true 6 | endif 7 | let l:typing = a:ctx['typing'] 8 | if index(['.','/',':'], a:ctx['char']) >= 0 9 | call easycomplete#complete(a:opt['name'], a:ctx, a:ctx['startcol'], []) 10 | return v:true 11 | endif 12 | if strlen(l:typing) == 0 13 | call easycomplete#complete(a:opt['name'], a:ctx, a:ctx['startcol'], []) 14 | return v:true 15 | endif 16 | call easycomplete#util#AsyncRun(function('s:CompleteHandler'), 17 | \ [l:typing, a:opt['name'], a:ctx, a:ctx['startcol']], 1) 18 | " #133 19 | " call easycomplete#complete(a:opt['name'], a:ctx, a:ctx['startcol'], []) 20 | return v:true 21 | endfunction 22 | 23 | function! s:CompleteHandler(typing, name, ctx, startcol) 24 | let suggestions = [] 25 | " 0.010s for these two function call 26 | let snippets = UltiSnips#SnippetsInCurrentScope() 27 | call UltiSnips#SnippetsInCurrentScope(1) 28 | 29 | for trigger in keys(snippets) 30 | try 31 | let description = get(snippets, trigger, "") 32 | let description = empty(description) ? "Snippet: " . trigger : description 33 | let snip_object = s:GetSnipObject(trigger, g:current_ulti_dict_info) 34 | catch /^Vim\%((\a\+)\)\=:E684/ 35 | " trigger 有可能是 i|n 这类包含特殊字符情况 36 | continue 37 | endtry 38 | try 39 | " Vim 性能比 Python 快五倍 40 | let code_info = easycomplete#util#GetSnippetsCodeInfo(snip_object) 41 | catch 42 | if has("python3") 43 | let code_info = easycomplete#python#GetSnippetsCodeInfo(snip_object) 44 | else 45 | continue 46 | endif 47 | endtry 48 | let sha256_str = strpart(easycomplete#util#Sha256(trigger . string(code_info)), 0, 15) 49 | let user_data_json = { 50 | \ 'plugin_name': a:name, 51 | \ 'sha256': sha256_str, 52 | \ } 53 | call add(suggestions, { 54 | \ 'word' : trigger, 55 | \ 'abbr' : trigger . '~', 56 | \ 'kind' : g:easycomplete_kindflag_snip, 57 | \ 'menu' : g:easycomplete_menuflag_snip, 58 | \ 'user_data': json_encode(user_data_json), 59 | \ 'info' : [description, "-----"] + s:CodeInfoFilter(code_info), 60 | \ 'user_data_json': user_data_json 61 | \ }) 62 | endfor 63 | call easycomplete#complete(a:name, a:ctx, a:startcol, suggestions) 64 | endfunction 65 | 66 | function! s:CodeInfoFilter(code_info) 67 | let code_info = type(a:code_info) == type("") ? [a:code_info] : a:code_info 68 | let count_index = 0 69 | let result_info = [] 70 | while count_index < len(code_info) 71 | let tmp_code_snip = code_info[count_index] 72 | let tmp_code_snip = substitute(tmp_code_snip, "$\\d\\+","","g") 73 | let tmp_code_snip = substitute(tmp_code_snip, "${\\d\\+:\\(\[^}\]\\+\\)}",'\=submatch(1)',"g") 74 | let tmp_code_snip = substitute(tmp_code_snip, "${\\d\\+}",'',"g") 75 | let tmp_code_snip = substitute(tmp_code_snip, "${\\(\[^}\]\\+\\)}"," ","g") 76 | call add(result_info, tmp_code_snip) 77 | let count_index += 1 78 | endwhile 79 | return result_info 80 | endfunction 81 | 82 | function! s:GetSnipObject(trigger, current_ulti_dict_info) 83 | let info_str = get(a:current_ulti_dict_info, a:trigger)['location'] 84 | let info_str_array = split(info_str, ":") 85 | let snip_object = {} 86 | let snip_object.filepath = info_str_array[0] 87 | let snip_object.line_number = info_str_array[1] 88 | return snip_object 89 | endfunction 90 | 91 | function! easycomplete#sources#snips#constructor(...) 92 | " Do Nothing 93 | endfunction 94 | 95 | function! s:log(...) 96 | return call('easycomplete#util#log', a:000) 97 | endfunction 98 | 99 | function! s:once(...) 100 | return call('easycomplete#util#once', a:000) 101 | endfunction 102 | 103 | function! s:console(...) 104 | return call('easycomplete#log#log', a:000) 105 | endfunction 106 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/vim.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#vim#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'vimls', 4 | \ 'cmd': {server_info->[easycomplete#installer#GetCommand(a:opt['name']), '--stdio']}, 5 | \ 'allowlist': a:opt["whitelist"], 6 | \ 'initialization_options': { 7 | \ 'vimruntime': expand($VIMRUNTIME), 8 | \ 'runtimepath': &rtp, 9 | \ 'iskeyword': '@,48-57,_,192-255,-#', 10 | \ 'indexes':{'runtime':v:true, 'gap':1, 'count':10, 'runtimepath': v:false}, 11 | \ "projectRootPatterns" : ["strange-root-pattern", ".git", "autoload", "plugin"], 12 | \ 'diagnostic': {"enable": v:true}, 13 | \ 'suggest': { 'fromVimruntime': v:false, 'fromRuntimepath': v:false} 14 | \ } 15 | \ }) 16 | endfunction 17 | 18 | function! easycomplete#sources#vim#completor(opt, ctx) abort 19 | return easycomplete#DoLspComplete(a:opt, a:ctx) 20 | endfunction 21 | 22 | function! easycomplete#sources#vim#GotoDefinition(...) 23 | return easycomplete#DoLspDefinition(["vim","vimrc","nvim"]) 24 | endfunction 25 | 26 | " hack for #98 #92 27 | function! easycomplete#sources#vim#filter(matches) 28 | let ctx = easycomplete#context() 29 | let matches = a:matches 30 | if ctx['typed'] =~ "s:\\w\\{-}$" 31 | " hack for vim-language-server: 32 | " s: 和 s:abc 匹配回来的 insertText 不应该带上 "s:" 33 | " g:b:l:a:v: 都是正确的,只有 s: 不正确 34 | " 需要修改 word 为 insertText.slice(2) 35 | let matches = map(copy(matches), function("s:VimHack_S_ColonMap")) 36 | endif 37 | if ctx['typed'] =~ '\(\w\+\.\)\{-1,}$' " VimDotTyping bugfix for #92 38 | call filter(matches, function("s:VimHack_S_DotFilter")) 39 | endif 40 | let matches = map(copy(matches), function("s:VimHack_A_DotMap")) 41 | let matches = map(copy(matches), function("easycomplete#util#FunctionSurffixMap")) 42 | return matches 43 | endfunction 44 | 45 | function! s:VimHack_S_DotFilter(key, val) 46 | if has_key(a:val, "abbr") && has_key(a:val, "word") 47 | \ && stridx(get(a:val, "word"), ".") > 0 48 | let vim_typing_word = s:VimHack_GetVimTypingWord() 49 | return stridx(get(a:val, "word"), vim_typing_word) == 0 50 | else 51 | return v:false 52 | endif 53 | endfunction 54 | 55 | function! s:VimHack_S_ColonMap(key, val) 56 | if has_key(a:val, "abbr") && has_key(a:val, "word") 57 | \ && get(a:val, "abbr") ==# get(a:val, "word") 58 | \ && matchstr(get(a:val, "word"), "^s:") == "s:" 59 | let a:val.word = get(a:val, "word")[2:] 60 | endif 61 | return a:val 62 | endfunction 63 | 64 | function! s:VimHack_A_DotMap(key, val) 65 | if has_key(a:val, "abbr") && has_key(a:val, "word") 66 | \ && stridx(get(a:val, "word"), ".") > 0 67 | let ctx = easycomplete#context() 68 | let vim_typing_word = s:VimHack_GetVimTypingWord() 69 | if ctx["char"] == "." 70 | let a:val.word = substitute(get(a:val, "word"), "^" . vim_typing_word, "", "g") 71 | else 72 | let word = easycomplete#util#GetTypingWord() 73 | let a:val.word = substitute(get(a:val, "word"), "^" . vim_typing_word[:-1 * ( 1 + strlen(word))], "", "g") 74 | endif 75 | let vim_typing_word = s:VimHack_GetVimTypingWord() 76 | endif 77 | return a:val 78 | endfunction 79 | 80 | function! s:VimHack_GetVimTypingWord() 81 | let start = col('.') - 1 82 | let line = getline('.') 83 | let width = 0 84 | let regx = '[a-zA-Z0-9_.:]' 85 | while start > 0 && line[start - 1] =~ regx 86 | let start = start - 1 87 | let width = width + 1 88 | endwhile 89 | let word = strpart(line, start, width) 90 | return word 91 | endfunction 92 | 93 | function! s:log(...) 94 | return call('easycomplete#util#log', a:000) 95 | endfunction 96 | -------------------------------------------------------------------------------- /autoload/easycomplete/sources/xml.vim: -------------------------------------------------------------------------------- 1 | function! easycomplete#sources#xml#constructor(opt, ctx) 2 | call easycomplete#RegisterLspServer(a:opt, { 3 | \ 'name': 'lemminx', 4 | \ 'cmd': [easycomplete#installer#GetCommand(a:opt['name'])], 5 | \ 'root_uri':{server_info -> easycomplete#util#GetDefaultRootUri()}, 6 | \ 'initialization_options': {}, 7 | \ 'allowlist': a:opt["whitelist"], 8 | \ }) 9 | endfunction 10 | 11 | function! easycomplete#sources#xml#completor(opt, ctx) abort 12 | return easycomplete#DoLspComplete(a:opt, a:ctx) 13 | endfunction 14 | 15 | function! easycomplete#sources#xml#GotoDefinition(...) 16 | return easycomplete#DoLspDefinition(["xml"]) 17 | endfunction 18 | 19 | function! easycomplete#sources#xml#filter(matches) 20 | let ctx = easycomplete#context() 21 | let matches = a:matches 22 | if ctx['typed'] =~ "\\w:\\w\\{-}$" " x:y~ 的处理 23 | let matches = map(copy(matches), function("s:XmlHack_S_ColonMap")) 24 | elseif ctx['typed'] =~ " 的处理 25 | let matches = map(copy(matches), function("s:XmlHack_S_ColonMap")) 26 | endif 27 | let matches = map(copy(matches), function('s:XmlSnip')) 28 | return matches 29 | endfunction 30 | 31 | function! s:XmlSnip(key, val) 32 | return easycomplete#util#SnipMap(a:key, a:val) 33 | endfunction 34 | 35 | function! s:XmlHack_S_ColonMap(key, val) 36 | if has_key(a:val, "abbr") && has_key(a:val, "word") 37 | \ && get(a:val, "abbr") =~ "\\w\\:\\w\\{-}\\~$" 38 | let abbr = a:val.abbr 39 | let a:val.word = substitute(substitute(abbr, "^\\w\\{-}\\:", "", 'g'), "\\~$", "", 'g') 40 | let a:val.user_data = "" 41 | elseif has_key(a:val, "abbr") && has_key(a:val, "word") 42 | \ && trim(get(a:val, "word")) =~ "/[:a-zA-Z0-9]\\{-}>$" 43 | let word = trim(a:val.word) 44 | let a:val.word = substitute(word, "^<\\{-}/", "", 'g') 45 | let a:val.user_data = "" 46 | endif 47 | return a:val 48 | endfunction 49 | 50 | function! s:log(...) 51 | return call('easycomplete#util#log', a:000) 52 | endfunction 53 | 54 | function! s:get(...) 55 | return call('easycomplete#util#get', a:000) 56 | endfunction 57 | 58 | function! s:console(...) 59 | return call('easycomplete#log#log', a:000) 60 | endfunction 61 | -------------------------------------------------------------------------------- /custom-config.md: -------------------------------------------------------------------------------- 1 | Full config in lua script with Packer.nvim: 2 | 3 | ```lua 4 | -- Packer.nvim 5 | use { 'jayli/vim-easycomplete', requires = {'SirVer/ultisnips'}} 6 | 7 | -- Enable the plugin. Default is on. Set `0` if you want to turn off the plugin. 8 | -- Install lsp via `:InstallLspServer` 9 | vim.g.easycomplete_enable = 1 10 | 11 | -- pum border. Default is on. 12 | vim.g.easycomplete_winborder = 1 13 | 14 | -- Highlight the symbol when holding the cursor if you need it. 15 | -- Default is off. 16 | vim.g.easycomplete_cursor_word_hl = 0 17 | 18 | -- GoTo code navigation 19 | vim.keymap.set('n', 'gr', ':EasyCompleteReference') 20 | vim.keymap.set('n', 'gd', ':EasyCompleteGotoDefinition') 21 | vim.keymap.set('n', 'rn', ':EasyCompleteRename') 22 | vim.keymap.set('n', 'gb', ':BackToOriginalBuffer') 23 | 24 | -- Using nerdfont is highly recommended 25 | vim.g.easycomplete_nerd_font = 1 26 | -- Custom kind icons. Of course you can use default settings without redefined kind icons 27 | vim.g.easycomplete_kind_icons = { 28 | buf = "", 29 | dict = "󰈍", 30 | snip = "", 31 | tabnine = "󱙺", 32 | operator = "󰞷", 33 | class = "", 34 | local = "✎", 35 | constant = "", 36 | enum = "", 37 | field = "", 38 | folder = "", 39 | interface = "", 40 | snippet = "", 41 | text = "", 42 | variable = "", 43 | event = "", 44 | const = "", 45 | let = "", 46 | color = "", 47 | constructor = "", 48 | enummember = "", 49 | file = "", 50 | function = "ƒ", 51 | keyword = "", 52 | struct = "󰙅", 53 | typeparameter = "§", 54 | module = "", 55 | var = "", 56 | alias = "", 57 | parameter = "󰏗", 58 | property = "󰙅" 59 | } 60 | 61 | -- Custom pum format. Only avilable with `g:easycomplete_nerd_font == 1` in nvim 62 | vim.g.easycomplete_pum_format = {"kind", "abbr", "menu"} 63 | 64 | -- Define highlight group for fuzzy matched charactors. 65 | -- All customizable highlight name: 66 | -- EasyPmenu 67 | -- EasyPmenuKind 68 | -- EasyPmenuExtra 69 | -- EasyFunction 70 | -- EasySnippet 71 | -- EasyTabNine 72 | -- EasySnippets 73 | vim.cmd[[ 74 | hi EasyFuzzyMatch guifg=lightblue 75 | ]] 76 | 77 | -- Enable Tabnine, default is on, install tabnine lsp via `:InstallLspServer tn` 78 | vim.g.easycomplete_tabnine_enable = 1 79 | -- Enable Tabnine suggestion, default is off 80 | vim.g.easycomplete_tabnine_suggestion = 0 81 | 82 | -- Enable directory complete. Default is on 83 | vim.g.easycomplete_directory_enable = 1 84 | 85 | -- Custom lsp support for a specific filetype 86 | vim.g.easycomplete_filetypes = { 87 | vim = { 88 | whitelist = vim.fn["easycomplete#FileTypes"]("vim", {"vim","vimrc","nvim"}) 89 | } 90 | } 91 | 92 | -- Enable ghost text support, default is on 93 | vim.g.easycomplete_ghost_text = 1 94 | 95 | -- Change the default complete trigger to another keymap 96 | -- Default is "" 97 | vim.g.easycomplete_tab_trigger = "" 98 | vim.g.easycomplete_shift_tab_trigger = "" 99 | 100 | -- Define the signature offset, default is 0 101 | vim.g.easycomplete_signature_offset = 0 102 | -- diagnostics keymap. Default is c-n 103 | vim.g.easycomplete_diagnostics_next = "" 104 | vim.g.easycomplete_diagnostics_prev = "" 105 | -- Enable diagnostics, default is 1 106 | vim.g.easycomplete_diagnostics_enable = 1 107 | -- Enable signature, default is 1 108 | vim.g.easycomplete_signature_enable = 1 109 | -- Enable diagnostics via cursor hold event, default is 1 110 | vim.g.easycomplete_diagnostics_hover = 1 111 | 112 | -- recommended 113 | vim.opt.updatetime = 150 114 | 115 | -- Do not select first matched item 116 | -- "set completeopt-=noselect" to automatically select first matched item 117 | vim.cmd('set completeopt+=noselect') 118 | ``` 119 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | easycomplete easycomplete.txt /*easycomplete* 2 | easycomplete.txt easycomplete.txt /*easycomplete.txt* 3 | -------------------------------------------------------------------------------- /lua/easycomplete/loading.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | local Util = require "easycomplete.util" 3 | local console = Util.console 4 | local loading_ns = vim.api.nvim_create_namespace('loading_ns') 5 | local loading_timer = vim.loop.new_timer() 6 | local loading_chars = {'⠇','⠋','⠙','⠸','⢰','⣠','⣄','⡆'} 7 | local cursor = 1 8 | 9 | function set_loading_interval(interval, callback) 10 | loading_timer:start(interval, interval, function () 11 | callback() 12 | end) 13 | end 14 | 15 | function clear_loading_interval() 16 | loading_timer:stop() 17 | end 18 | 19 | function M.start() 20 | local count = 1 21 | set_loading_interval(90, function() 22 | count = count + 1 23 | vim.schedule(function() 24 | if cursor == 1 and vim.fn["easycomplete#pum#visible"]() then 25 | M.stop() 26 | return 27 | end 28 | vim.api.nvim_buf_set_extmark(0, loading_ns, vim.fn.line('.') - 1, vim.fn.col('.') - 1, { 29 | id = 2, 30 | virt_text_pos = "eol", 31 | virt_text = {{tostring(M.get_loading_str()) .. "", "TabNineSuggestionFirstLine"}}, 32 | virt_lines = nil 33 | }) 34 | end) 35 | end) 36 | end 37 | 38 | function M.stop() 39 | if type(loading_timer) == "userdata" then 40 | clear_loading_interval(loading_timer) 41 | vim.api.nvim_buf_del_extmark(0, loading_ns, 2) 42 | end 43 | end 44 | 45 | function M.get_loading_str() 46 | if cursor < #loading_chars then 47 | cursor = cursor + 1 48 | elseif cursor == #loading_chars then 49 | cursor = 1 50 | end 51 | return loading_chars[cursor] 52 | end 53 | 54 | return M 55 | -------------------------------------------------------------------------------- /lua/easycomplete/tabnine.lua: -------------------------------------------------------------------------------- 1 | local Util = require "easycomplete.util" 2 | local loading = require "easycomplete.loading" 3 | local log = Util.log 4 | local console = Util.console 5 | local Export = {} 6 | local tabnine_ns = vim.api.nvim_create_namespace('tabnine_ns') 7 | 8 | function Export.nvim_init_tabnine_hl() 9 | local cursorline_bg = vim.fn["easycomplete#ui#GetBgColor"]("CursorLine") 10 | local normal_bg = vim.fn["easycomplete#ui#GetBgColor"]("Normal") 11 | 12 | 13 | local linenr_fg = vim.fn["easycomplete#ui#GetFgColor"]("LineNr") 14 | 15 | local snippet_fg = "" 16 | if vim.fn["easycomplete#ui#HighlightGroupExists"]("EasySnippets") then 17 | snippet_fg = vim.fn["easycomplete#ui#GetFgColor"]("EasySnippets") 18 | else 19 | snippet_fg = linenr_fg 20 | end 21 | 22 | if vim.fn.matchstr(cursorline_bg, "^\\d\\+") ~= "" then 23 | cursorline_bg = vim.fn.str2nr(cursorline_bg) 24 | end 25 | if vim.fn.matchstr(normal_bg, "^\\d\\+") ~= "" then 26 | normal_bg = vim.fn.str2nr(normal_bg) 27 | end 28 | if vim.fn.matchstr(snippet_fg, "^\\d\\+") ~= "" then 29 | snippet_fg = vim.fn.str2nr(snippet_fg) 30 | end 31 | 32 | vim.api.nvim_set_hl(0, "TabNineSuggestionFirstLine", { 33 | bg = cursorline_bg, 34 | fg = snippet_fg 35 | }) 36 | vim.api.nvim_set_hl(0, "TabNineSuggestionNoneFirstLine", { 37 | fg = snippet_fg, 38 | bg = normal_bg 39 | }) 40 | end 41 | 42 | function Export.init() 43 | Export.nvim_init_tabnine_hl() 44 | vim.api.nvim_create_autocmd({"ColorScheme"}, { 45 | pattern = {"*"}, 46 | callback = function() 47 | Export.nvim_init_tabnine_hl() 48 | end 49 | }) 50 | end 51 | 52 | -- code_block 是一个字符串,有可能包含回车符 53 | -- call v:lua.require("easycomplete.tabnine").show_hint() 54 | -- code_block 是数组类型 55 | function Export.show_hint(code_block) 56 | local lines = {} 57 | local count = 1 58 | local code_lines = code_block 59 | for key, line in pairs(code_lines) do 60 | local highlight_group = "" 61 | if count == 1 then 62 | highlight_group = "TabNineSuggestionFirstLine" 63 | else 64 | highlight_group = "TabNineSuggestionNoneFirstLine" 65 | end 66 | count = count + 1 67 | table.insert(lines, {{line, highlight_group}}) 68 | end 69 | 70 | local virt_text = lines[1] 71 | local virt_lines 72 | 73 | if #lines >= 2 then 74 | table.remove(lines, 1) 75 | virt_lines = lines 76 | else 77 | virt_lines = nil 78 | end 79 | 80 | vim.api.nvim_buf_set_extmark(0, tabnine_ns, vim.fn.line('.') - 1, vim.fn.col('.') - 1, { 81 | id = 1, 82 | virt_text_pos = "overlay", 83 | virt_text = virt_text, 84 | virt_lines = virt_lines 85 | }) 86 | end 87 | 88 | function Export.loading_start() 89 | loading.start() 90 | end 91 | 92 | function Export.loading_stop() 93 | loading.stop() 94 | end 95 | 96 | function Export.delete_hint() 97 | vim.api.nvim_buf_del_extmark(0, tabnine_ns, 1) 98 | end 99 | 100 | return Export 101 | -------------------------------------------------------------------------------- /my-custom-config.md: -------------------------------------------------------------------------------- 1 | ## my custom lua config with Packer.nvim 2 | 3 | ```lua 4 | use { 'jayli/vim-easycomplete', requires = {'SirVer/ultisnips'}} 5 | vim.g.easycomplete_diagnostics_enable = 1 6 | vim.g.easycomplete_signature_enable = 1 7 | vim.g.easycomplete_tabnine_enable = 1 8 | vim.g.easycomplete_tabnine_suggestion = 1 9 | vim.g.easycomplete_cursor_word_hl = 1 10 | vim.g.easycomplete_nerd_font = 1 11 | vim.g.easycomplete_enable = 1 12 | vim.keymap.set('n', 'gr', ':EasyCompleteReference') 13 | vim.keymap.set('n', 'gd', ':EasyCompleteGotoDefinition') 14 | vim.keymap.set('n', 'rn', ':EasyCompleteRename') 15 | vim.keymap.set('n', 'gb', ':BackToOriginalBuffer') 16 | vim.g.easycomplete_pum_format = {"kind", "abbr", "menu"} 17 | ``` 18 | 19 | With Lazy.nvim 20 | 21 | ```lua 22 | { 23 | "jayli/vim-easycomplete", 24 | dependencies={"SirVer/ultisnips"}, 25 | config = function() 26 | vim.g.easycomplete_diagnostics_enable = 1 27 | vim.g.easycomplete_signature_enable = 1 28 | vim.g.easycomplete_tabnine_enable = 1 29 | vim.g.easycomplete_tabnine_suggestion = 1 30 | vim.g.easycomplete_cursor_word_hl = 1 31 | vim.g.easycomplete_nerd_font = 1 32 | vim.g.easycomplete_enable = 1 33 | vim.keymap.set('n', 'gr', ':EasyCompleteReference') 34 | vim.keymap.set('n', 'gd', ':EasyCompleteGotoDefinition') 35 | vim.keymap.set('n', 'rn', ':EasyCompleteRename') 36 | vim.keymap.set('n', 'gb', ':BackToOriginalBuffer') 37 | vim.g.easycomplete_pum_format = {"kind", "abbr", "menu"} 38 | end 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /pythonx/EasyCompleteUtil/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | -------------------------------------------------------------------------------- /snippets/cmake.snippets: -------------------------------------------------------------------------------- 1 | snippet init 2 | cmake_minimum_required(VERSION ${1:2.8.2}) 3 | project(${2:ProjectName}) 4 | 5 | find_package(${3:library}) 6 | 7 | include_directories(${$3_INCLUDE_DIRS}) 8 | 9 | add_subdirectory(${0:src}) 10 | 11 | add_executable($2) 12 | 13 | target_link_libraries($2 ${$3_LIBRARIES}) 14 | 15 | snippet proj 16 | project(${0:Name}) 17 | 18 | snippet min 19 | cmake_minimum_required(VERSION ${0:2.8.2}) 20 | 21 | snippet include 22 | include_directories(${${0:include_dir}}) 23 | 24 | snippet find 25 | find_package(${1:library} ${0:REQUIRED}) 26 | 27 | snippet glob 28 | file(glob ${1:srcs} *.${0:cpp}) 29 | 30 | snippet subdir 31 | add_subdirectory(${0:src}) 32 | 33 | snippet lib 34 | add_library(${1:lib} ${${0:srcs}}) 35 | 36 | snippet link 37 | target_link_libraries(${1:bin} ${0:somelib}) 38 | 39 | snippet bin 40 | add_executable(${1:bin}) 41 | 42 | snippet set 43 | set(${1:var} ${0:val}) 44 | 45 | snippet dep 46 | add_dependencies(${1:target} 47 | ${0:dep} 48 | ) 49 | 50 | snippet Ext_url 51 | include(ExternalProject) 52 | ExternalProject_Add(${1:googletest} 53 | URL ${2:http://googletest.googlecode.com/files/gtest-1.7.0.zip} 54 | URL_HASH SHA1=${3:f85f6d2481e2c6c4a18539e391aa4ea8ab0394af} 55 | SOURCE_DIR "${4:${CMAKE_BINARY_DIR}/gtest-src}" 56 | BINARY_DIR "${0:${CMAKE_BINARY_DIR}/gtest-build}" 57 | CONFIGURE_COMMAND "" 58 | BUILD_COMMAND "" 59 | INSTALL_COMMAND "" 60 | TEST_COMMAND "" 61 | ) 62 | 63 | snippet Ext_git 64 | include(ExternalProject) 65 | ExternalProject_Add(${1:googletest} 66 | GIT_REPOSITORY ${2:https://github.com/google/googletest.git} 67 | GIT_TAG ${3:master} 68 | SOURCE_DIR "${4:${CMAKE_BINARY_DIR}/googletest-src}" 69 | BINARY_DIR "${0:${CMAKE_BINARY_DIR}/googletest-build}" 70 | CONFIGURE_COMMAND "" 71 | BUILD_COMMAND "" 72 | INSTALL_COMMAND "" 73 | TEST_COMMAND "" 74 | ) 75 | 76 | snippet props 77 | set_target_properties(${1:target} 78 | ${2:properties} ${3:compile_flags} 79 | ${0:"-O3 -Wall -pedantic"} 80 | ) 81 | 82 | snippet test 83 | add_test(${1:ATestName} ${0:testCommand --options}) 84 | -------------------------------------------------------------------------------- /snippets/dart-flutter.snippets: -------------------------------------------------------------------------------- 1 | # Snippets for dart in flutter project, to use add the following to your .vimrc 2 | # `autocmd BufRead,BufNewFile,BufEnter *.dart UltiSnipsAddFiletypes dart-flutter` 3 | # Flutter stateless widget 4 | snippet stless 5 | class $1 extends StatelessWidget { 6 | @override 7 | Widget build(BuildContext context) { 8 | return Container( 9 | $2 10 | ); 11 | } 12 | } 13 | 14 | # Flutter stateful widget 15 | snippet stful 16 | class $1 extends StatefulWidget { 17 | @override 18 | _$1State createState() => _$1State(); 19 | } 20 | 21 | class _$1State extends State<$1> { 22 | @override 23 | Widget build(BuildContext context) { 24 | return Container( 25 | $2 26 | ); 27 | } 28 | } 29 | 30 | # Flutter widget with AnimationController 31 | snippet stanim 32 | class $1 extends StatefulWidget { 33 | @override 34 | _$1State createState() => _$1State(); 35 | } 36 | 37 | class _$1State extends State<$1> 38 | with SingleTickerProviderStateMixin { 39 | AnimationController _controller; 40 | 41 | @override 42 | void initState() { 43 | super.initState(); 44 | _controller = AnimationController(vsync: this); 45 | } 46 | 47 | @override 48 | void dispose() { 49 | super.dispose(); 50 | _controller.dispose(); 51 | } 52 | 53 | @override 54 | Widget build(BuildContext context) { 55 | return Container( 56 | $2 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /snippets/dart.snippets: -------------------------------------------------------------------------------- 1 | snippet lib 2 | library ${1}; 3 | ${0} 4 | snippet im 5 | import 'package:${1}/${2}.dart'; 6 | ${0} 7 | snippet rgx 8 | new RegExp(r'${1}') 9 | snippet var 10 | var ${1} = ${2}; 11 | snippet main 12 | main() { 13 | ${0} 14 | } 15 | snippet st 16 | static ${0} 17 | snippet fi 18 | final ${0} 19 | snippet re 20 | return ${0} 21 | snippet br 22 | break; 23 | snippet th 24 | throw ${0} 25 | snippet cl 26 | class ${1:`vim_snippets#Filename("", "untitled")`} ${0} 27 | snippet in 28 | interface ${1:`vim_snippets#Filename("", "untitled")`} ${0} 29 | snippet imp 30 | implements ${0} 31 | snippet ext 32 | extends ${0} 33 | snippet if 34 | if (${1:true}) { 35 | ${0} 36 | } 37 | snippet ife 38 | if (${1:true}) { 39 | ${2} 40 | } else { 41 | ${0} 42 | } 43 | snippet el 44 | else 45 | snippet sw 46 | switch (${1}) { 47 | ${0} 48 | } 49 | snippet cs 50 | case ${1}: 51 | ${0} 52 | snippet de 53 | default: 54 | ${0} 55 | snippet for 56 | for (var ${2:i} = 0, len = ${1:things}.length; $2 < len; ${3:++}$2) { 57 | ${0:$1[$2]} 58 | } 59 | snippet fore 60 | for (final ${2:item} in ${1:itemList}) { 61 | ${0} 62 | } 63 | snippet wh 64 | while (${1:/* condition */}) { 65 | ${0} 66 | } 67 | snippet dowh 68 | do { 69 | ${0} 70 | } while (${0:/* condition */}); 71 | snippet as 72 | assert(${0:/* condition */}); 73 | snippet try 74 | try { 75 | ${0:${VISUAL}} 76 | } catch (${1:Exception e}) { 77 | } 78 | snippet tryf 79 | try { 80 | ${0:${VISUAL}} 81 | } catch (${1:Exception e}) { 82 | } finally { 83 | } 84 | -------------------------------------------------------------------------------- /snippets/eelixir.snippets: -------------------------------------------------------------------------------- 1 | extends html 2 | 3 | snippet % <% %> 4 | <% ${0} %> 5 | snippet = <%= %> 6 | <%= ${0} %> 7 | snippet # <%# %> 8 | <%# ${0} %> 9 | snippet end 10 | <% end %> 11 | snippet for 12 | <%= for ${1:item} <- ${2:items} ${3:@conn} do %> 13 | ${0} 14 | <% end %> 15 | snippet if 16 | <%= if ${1} do %> 17 | ${0:${VISUAL}} 18 | <% end %> 19 | snippet ife 20 | <%= if ${1} do %> 21 | ${2:${VISUAL}} 22 | <% else %> 23 | ${0} 24 | <% end %> 25 | snippet cond 26 | <%= cond do %> 27 | <% ${1} -> %> 28 | ${2:${VISUAL}} 29 | 30 | <% true -> %> 31 | ${0} 32 | <% end %> 33 | snippet unless 34 | <%= unless ${1} do %> 35 | ${0:${VISUAL}} 36 | <% end %> 37 | snippet ft form_tag 38 | <%= form_tag(${1:"/users"}, method: ${2::post}) %> 39 | ${0} 40 | 41 | 42 | snippet sl select 43 | <%= select ${1:f}, :${2:field}, ${3:[{"key", "value"}]}, prompt: ${4:"Prompt"} %> 44 | 45 | snippet sb submit 46 | <%= submit ${1:"Submit"} %> 47 | 48 | snippet rb radio_button 49 | <%= radio_button ${1:f}, :${2:field}, ${3:"value"} %> 50 | 51 | 52 | snippet et error_tag 53 | <%= error_tag ${1:f}, :${2:field} %> 54 | snippet ti text_input 55 | <%= text_input ${1:f}, :${2:field} %> 56 | snippet la label 57 | <%= label ${1:f}, :${2:field}, "${3:Label}" %> 58 | snippet pi password_input 59 | <%= password_input ${1:f}, :${2:password} %> 60 | snippet render 61 | <%= render "${1:index}.html", ${2:var: @var} %> 62 | snippet lin link 63 | <%= link "${1:Submit}", to: ${2:"/users"}, method: ${3::delete} %> 64 | snippet ff form_for 65 | <%= form_for @changeset, ${1:"/users"}, fn f -> %> 66 | ${0} 67 | 68 | <%= submit "Submit" %> 69 | <% end %> 70 | snippet pry 71 | <% require IEx; IEx.pry %> 72 | -------------------------------------------------------------------------------- /snippets/elm.snippets: -------------------------------------------------------------------------------- 1 | snippet mod 2 | module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (${1}) 3 | ${0} 4 | snippet imp 5 | import ${0:Http} 6 | snippet impe 7 | import ${1:Html} exposing (${0:..}) 8 | snippet impae 9 | import ${1:Json.Encode} as ${2:Encode} exposing (${0:Value}) 10 | snippet fn 11 | ${1:fn} : ${2:a} -> ${3:a} 12 | $1 ${4} = 13 | ${0} 14 | snippet fn1 15 | ${1:fn} : ${2:a} -> ${3:a} 16 | $1 ${4} = 17 | ${0} 18 | snippet fn2 19 | ${1:fn} : ${2:a} -> ${3:a} -> ${4:a} 20 | $1 ${5} = 21 | ${0} 22 | snippet fn3 23 | ${1:fn} : ${2:a} -> ${3:a} -> ${4:a} -> ${5:a} 24 | $1 ${6} = 25 | ${0} 26 | snippet fn0 27 | ${1:fn} : ${2:a} 28 | $1 = 29 | ${0} 30 | snippet case 31 | case ${1} of 32 | ${2} -> 33 | ${0} 34 | snippet - 35 | ${1} -> 36 | ${0} 37 | snippet let 38 | let 39 | ${1} = 40 | ${2} 41 | in 42 | ${0} 43 | snippet if 44 | if ${1} then 45 | ${2:${VISUAL}} 46 | else 47 | ${0} 48 | snippet ty 49 | type ${1:Msg} 50 | = ${0} 51 | snippet tya 52 | type alias ${1:Model} = 53 | ${0} 54 | snippet test 55 | test "${1}" <| \_ -> $0 56 | snippet desc 57 | describe "${1}" [ $0 ] 58 | snippet doc 59 | {-| ${0} 60 | -} 61 | snippet p 62 | |> ${0} 63 | snippet program Elm 0.18 program 64 | import Html exposing (Html) 65 | 66 | 67 | type alias Model = 68 | {} 69 | 70 | 71 | type Msg 72 | = Noop 73 | 74 | 75 | main : Program Never Model Msg 76 | main = 77 | Html.program 78 | { init = init 79 | , view = view 80 | , update = update 81 | , subscriptions = subscriptions 82 | } 83 | 84 | 85 | init : ( Model, Cmd Msg ) 86 | init = 87 | {} ! [] 88 | 89 | 90 | update : Msg -> Model -> ( Model, Cmd Msg ) 91 | update msg model = 92 | case msg of 93 | Noop -> 94 | model ! [] 95 | 96 | 97 | subscriptions : Model -> Sub Msg 98 | subscriptions model = 99 | Sub.none 100 | 101 | 102 | view : Model -> Html Msg 103 | view model = 104 | Html.text "Hello, sailor!" 105 | snippet element 106 | module Main exposing (Model, Msg(..), init, main, subscriptions, update, view) 107 | 108 | import Browser 109 | import Html exposing (..) 110 | import Json.Encode 111 | 112 | 113 | main : Program Flags Model Msg 114 | main = 115 | Browser.element 116 | { init = init 117 | , update = update 118 | , subscriptions = subscriptions 119 | , view = view 120 | } 121 | 122 | 123 | type alias Model = 124 | {} 125 | 126 | 127 | type alias Flags = 128 | Json.Encode.Value 129 | 130 | 131 | init : Flags -> ( Model, Cmd Msg ) 132 | init flags_ = 133 | ( {} 134 | , Cmd.none 135 | ) 136 | 137 | 138 | type Msg 139 | = Noop 140 | 141 | 142 | update : Msg -> Model -> ( Model, Cmd Msg ) 143 | update msg model = 144 | case msg of 145 | Noop -> 146 | ( model 147 | , Cmd.none 148 | ) 149 | 150 | 151 | subscriptions : Model -> Sub Msg 152 | subscriptions model = 153 | Sub.none 154 | 155 | 156 | view : Model -> Html Msg 157 | view model = 158 | h1 [] [ text "Hello, world!" ] 159 | -------------------------------------------------------------------------------- /snippets/eruby.snippets: -------------------------------------------------------------------------------- 1 | # .erb and .rhmtl files 2 | 3 | # Includes html.snippets 4 | extends html 5 | 6 | # Rails ***************************** 7 | snippet rc 8 | <% ${0} %> 9 | snippet rce 10 | <%= ${1} %> 11 | snippet % 12 | <% ${0} %> 13 | snippet = 14 | <%= ${1} %> 15 | snippet end 16 | <% end %> 17 | snippet ead 18 | <% ${1}.each do |${2}| %> 19 | ${0} 20 | <% end %> 21 | snippet for 22 | <% for ${2:item} in ${1} %> 23 | ${0} 24 | <% end %> 25 | snippet rp 26 | <%= render partial: '${0:item}' %> 27 | snippet rpl 28 | <%= render partial: '${1:item}', locals: { :${2:name} => '${3:value}'${0} } %> 29 | snippet rps 30 | <%= render partial: '${1:item}', status: ${0:500} %> 31 | snippet rpc 32 | <%= render partial: '${1:item}', collection: ${0:items} %> 33 | snippet lia 34 | <%= link_to '${1:link text...}', action: '${0:index}' %> 35 | snippet liai 36 | <%= link_to '${1:link text...}', action: '${2:edit}', id: ${0:@item} %> 37 | snippet lic 38 | <%= link_to '${1:link text...}', controller: '${0:items}' %> 39 | snippet lica 40 | <%= link_to '${1:link text...}', controller: '${2:items}', action: '${0:index}' %> 41 | snippet licai 42 | <%= link_to '${1:link text...}', controller: '${2:items}', action: '${3:edit}', id: ${0:@item} %> 43 | snippet yield 44 | <%= yield ${1::content_symbol} %> 45 | snippet conf 46 | <% content_for :${1:head} do %> 47 | ${0} 48 | <% end %> 49 | 50 | snippet cs 51 | <%= collection_select(:${1:object}, :${2:method}, ${3:collection}, :${4:value_method}, :${5:text_method}, options = {${0:prompt: true}}) %> 52 | snippet ct 53 | <%= content_tag '${1:DIV}', ${2:content}${0:,options} %> 54 | snippet ff 55 | <%= form_for @${1:model} do |f| %> 56 | ${0} 57 | <% end %> 58 | snippet ffi 59 | <%= ${1:f}.input :${0:attribute} %> 60 | snippet ffcb 61 | <%= ${1:f}.check_box :${0:attribute} %> 62 | snippet ffe 63 | <% error_messages_for :${1:model} %> 64 | 65 | <%= form_for @${2:model} do |f| %> 66 | ${0} 67 | <% end %> 68 | snippet ffff 69 | <%= ${1:f}.file_field :${0:attribute} %> 70 | snippet ffhf 71 | <%= ${1:f}.hidden_field :${0:attribute} %> 72 | snippet ffl 73 | <%= ${1:f}.label :${2:attribute}, '${0:$2}' %> 74 | snippet ffpf 75 | <%= ${1:f}.password_field :${0:attribute} %> 76 | snippet ffrb 77 | <%= ${1:f}.radio_button :${2:attribute}, :${0:tag_value} %> 78 | snippet ffs 79 | <%= ${1:f}.submit "${0:submit}" %> 80 | snippet ffta 81 | <%= ${1:f}.text_area :${0:attribute} %> 82 | snippet fftf 83 | <%= ${1:f}.text_field :${0:attribute} %> 84 | snippet fcs 85 | <%= ${1:f}.collection_select(:${2:method}, ${3:collection}, :${4:value_method}, :${5:text_method}, options = {${0:prompt: true}}) %> 86 | snippet fields 87 | <%= fields_for :${1:model}, @$1 do |${2:f}| %> 88 | ${0} 89 | <% end %> 90 | snippet i18 91 | I18n.t('${1:type.key}') 92 | snippet it 93 | <%= image_tag "${1}"${0} %> 94 | snippet jit 95 | <%= javascript_include_tag ${0::all} %> 96 | snippet jsit 97 | <%= javascript_include_tag "${0}" %> 98 | snippet lim 99 | <%= link_to ${1:model}.${2:name}, ${3:$1}_path(${0:$1}) %> 100 | snippet linp 101 | <%= link_to "${1:Link text...}", ${2:parent}_${3:child}_path(${4:@$2}, ${0:@$3}) %> 102 | snippet linpp 103 | <%= link_to "${1:Link text...}", ${2:parent}_${3:child}_path(${0:@$2}) %> 104 | snippet lip 105 | <%= link_to "${1:Link text...}", ${2:model}_path(${0:@$2}) %> 106 | snippet lipp 107 | <%= link_to "${1:Link text...}", ${0:model}s_path %> 108 | snippet lt 109 | <%= link_to "${1:name}", ${0:dest} %> 110 | snippet ntc 111 | <%= number_to_currency(${1}) %> 112 | snippet ofcfs 113 | <%= options_from_collection_for_select ${1:collection}, ${2:value_method}, ${3:text_method}, ${0:selected_value} %> 114 | snippet ofs 115 | <%= options_for_select ${1:collection}, ${2:value_method} %> 116 | snippet rf 117 | <%= render file: "${1:file}"${0} %> 118 | snippet rt 119 | <%= render template: "${1:file}"${0} %> 120 | snippet slt 121 | <%= stylesheet_link_tag ${1::all}, cache: ${0:true} %> 122 | snippet sslt 123 | <%= stylesheet_link_tag "${0}" %> 124 | snippet if 125 | <% if ${1} %> 126 | ${0:${VISUAL}} 127 | <% end %> 128 | snippet ife 129 | <% if ${1} %> 130 | ${2} 131 | <% else %> 132 | ${0} 133 | <% end %> 134 | snippet pry 135 | <% require 'pry'; binding.pry %> 136 | -------------------------------------------------------------------------------- /snippets/haskell.snippets: -------------------------------------------------------------------------------- 1 | snippet lang 2 | {-# LANGUAGE ${0:OverloadedStrings} #-} 3 | snippet haddock 4 | {-# OPTIONS_HADDOCK ${0:hide} #-} 5 | snippet ghc 6 | {-# OPTIONS_GHC ${0:-fno-warn-unused-imports} #-} 7 | snippet inline 8 | {-# INLINE ${0:name} #-} 9 | snippet info 10 | -- | 11 | -- Module : ${1:`substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')`} 12 | -- Copyright : ${2:Author} ${3:2011-2012} 13 | -- License : ${4:BSD3} 14 | -- 15 | -- Maintainer : ${5:email@something.com} 16 | -- Stability : ${6:experimental} 17 | -- Portability : ${7:unknown} 18 | -- 19 | -- ${0:Description} 20 | -- 21 | snippet imp 22 | import ${0:Data.Text} 23 | snippet import 24 | import ${0:Data.Text} 25 | snippet import2 26 | import ${1:Data.Text} (${0:head}) 27 | snippet impq 28 | import qualified ${1:Data.Text} as ${0:T} 29 | snippet importq 30 | import qualified ${1:Data.Text} as ${0:T} 31 | snippet inst 32 | instance ${1:Monoid} ${2:Type} where 33 | ${0} 34 | snippet ty 35 | type ${1:Type} = ${0:Type} 36 | snippet type 37 | type ${1:Type} = ${0:Type} 38 | snippet da 39 | data ${1:Type} = ${2:$1} ${0:Int} 40 | snippet data 41 | data ${1:Type} = ${2:$1} ${0:Int} 42 | snippet newtype 43 | newtype ${1:Type} = ${2:$1} ${0:Int} 44 | snippet class 45 | class ${1:Class} a where 46 | ${0} 47 | snippet module 48 | module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` ( 49 | ) where 50 | `expand('%') =~ 'Main' ? "\nmain :: IO ()\nmain = undefined" : ""` 51 | 52 | snippet mod 53 | module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` 54 | ( ${1} 55 | ) where 56 | 57 | `expand('%') =~ 'Main' ? "\nmain :: IO ()\nmain = undefined" : ""` 58 | snippet main 59 | main :: IO () 60 | main = ${0:undefined} 61 | snippet const 62 | ${1:name} :: ${2:a} 63 | $1 = ${0:undefined} 64 | snippet fn 65 | ${1:fn} :: ${2:a} -> ${3:a} 66 | $1 ${4} = ${0:undefined} 67 | snippet fn0 68 | ${1:fn} :: ${2:a} 69 | $1 = ${0:undefined} 70 | snippet fn1 71 | ${1:fn} :: ${2:a} -> ${3:a} 72 | $1 ${4} = ${0:undefined} 73 | snippet fn2 74 | ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} 75 | $1 ${5} = ${0:undefined} 76 | snippet fn3 77 | ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} -> ${5:a} 78 | $1 ${6} = ${0:undefined} 79 | snippet => "Type constraint" 80 | (${1:Class} ${2:a}) => $2 81 | snippet ap 82 | ${1:map} ${2:fn} ${0:list} 83 | snippet \ 84 | \\${1:x} -> ${0:expression} 85 | snippet (\ 86 | (\\${1:x} -> ${0:expression}) 87 | snippet <- 88 | ${1:a} <- ${0:m a} 89 | snippet -> 90 | ${1:m a} -> ${0:a} 91 | snippet tup 92 | (${1:a}, ${0:b}) 93 | snippet tup2 94 | (${1:a}, ${2:b}, ${0:c}) 95 | snippet tup3 96 | (${1:a}, ${2:b}, ${3:c}, ${0:d}) 97 | snippet rec 98 | ${1:Record} { ${2:recFieldA} = ${3:undefined} 99 | , ${4:recFieldB} = ${0:undefined} 100 | } 101 | snippet case 102 | case ${1:something} of 103 | ${2} -> ${0} 104 | snippet let 105 | let ${1} = ${2} 106 | in ${3} 107 | snippet where 108 | where 109 | ${1:fn} = ${0:undefined} 110 | snippet spec 111 | module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` (main, spec) where 112 | 113 | import Test.Hspec 114 | import Test.QuickCheck 115 | 116 | main :: IO () 117 | main = hspec spec 118 | 119 | spec :: Spec 120 | spec = 121 | describe "${1}" $ do 122 | it "${2}" $ 123 | $0 124 | snippet specf 125 | module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` (main, spec) where 126 | 127 | import Test.Hspec 128 | import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith) 129 | 130 | main :: IO () 131 | main = hspecWith defaultConfig {configFastFail = True} spec 132 | 133 | spec :: Spec 134 | spec = 135 | describe "${1}" $ do 136 | it "${2}" $ 137 | $0 138 | snippet desc 139 | describe "${1}" $ do 140 | $0 141 | snippet it 142 | it "${1}" $ 143 | $0 144 | snippet itp 145 | it "${1}" $ property $ 146 | $0 147 | snippet sb 148 | \`shouldBe\` $0 149 | snippet doc 150 | {-| ${0} 151 | -} 152 | -------------------------------------------------------------------------------- /snippets/htmldjango.snippets: -------------------------------------------------------------------------------- 1 | # Generic tags 2 | 3 | extends html 4 | 5 | snippet % 6 | {% ${1} %} 7 | snippet %% 8 | {% ${1:tag_name} %} 9 | ${0} 10 | {% end$1 %} 11 | snippet { 12 | {{ ${1} }} 13 | # Template Tags 14 | 15 | snippet autoescape 16 | {% autoescape ${1:off} %} 17 | ${0} 18 | {% endautoescape %} 19 | snippet block 20 | {% block ${1} %} 21 | ${0} 22 | {% endblock %} 23 | snippet # 24 | {# ${0:comment} #} 25 | snippet comment 26 | {% comment %} 27 | ${0} 28 | {% endcomment %} 29 | snippet cycle 30 | {% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} 31 | snippet debug 32 | {% debug %} 33 | snippet extends 34 | {% extends "${0:base.html}" %} 35 | snippet filter 36 | {% filter ${1} %} 37 | ${0} 38 | {% endfilter %} 39 | snippet firstof 40 | {% firstof ${1} %} 41 | snippet for 42 | {% for ${1} in ${2} %} 43 | ${0} 44 | {% endfor %} 45 | snippet empty 46 | {% empty %} 47 | ${0} 48 | snippet if 49 | {% if ${1} %} 50 | ${0} 51 | {% endif %} 52 | snippet el 53 | {% else %} 54 | ${1} 55 | snippet eif 56 | {% elif ${1} %} 57 | ${0} 58 | snippet ifchanged 59 | {% ifchanged %}${1}{% endifchanged %} 60 | snippet ifequal 61 | {% ifequal ${1} ${2} %} 62 | ${0} 63 | {% endifequal %} 64 | snippet ifnotequal 65 | {% ifnotequal ${1} ${2} %} 66 | ${0} 67 | {% endifnotequal %} 68 | snippet include 69 | {% include "${0}" %} 70 | snippet load 71 | {% load ${0} %} 72 | snippet now 73 | {% now "${0:jS F Y H:i}" %} 74 | snippet regroup 75 | {% regroup ${1} by ${2} as ${0} %} 76 | snippet spaceless 77 | {% spaceless %}${0}{% endspaceless %} 78 | snippet ssi 79 | {% ssi ${0} %} 80 | snippet trans 81 | {% trans "${0:string}" %} 82 | snippet url 83 | {% url ${1} as ${0} %} 84 | snippet widthratio 85 | {% widthratio ${1:this_value} ${2:max_value} ${0:100} %} 86 | snippet with 87 | {% with ${1} as ${2} %} 88 | ${0} 89 | {% endwith %} 90 | 91 | # Template Filters 92 | 93 | # Note: Since SnipMate can't determine which template filter you are 94 | # expanding without the "|" character, these do not add the "|" 95 | # character. These save a few keystrokes still. 96 | 97 | # Note: Template tags that take no arguments are not implemented. 98 | 99 | snippet add 100 | add:"${0}" 101 | snippet center 102 | center:"${0}" 103 | snippet cut 104 | cut:"${0}" 105 | snippet date 106 | date:"${0}" 107 | snippet default 108 | default:"${0}" 109 | snippet defaultifnone 110 | default_if_none:"${0}" 111 | snippet dictsort 112 | dictsort:"${0}" 113 | snippet dictsortrev 114 | dictsortreversed:"${0}" 115 | snippet divisibleby 116 | divisibleby:"${0}" 117 | snippet floatformat 118 | floatformat:"${0}" 119 | snippet getdigit 120 | get_digit:"${0}" 121 | snippet join 122 | join:"${0}" 123 | snippet lengthis 124 | length_is:"${0}" 125 | snippet pluralize 126 | pluralize:"${0}" 127 | snippet removetags 128 | removetags:"${0}" 129 | snippet slice 130 | slice:"${0}" 131 | snippet stringformat 132 | stringformat:"${0}" 133 | snippet time 134 | time:"${0}" 135 | snippet truncatewords 136 | truncatewords:${0} 137 | snippet truncatewordshtml 138 | truncatewords_html:${0} 139 | snippet urlizetrunc 140 | urlizetrunc:${0} 141 | snippet wordwrap 142 | wordwrap:${0} 143 | -------------------------------------------------------------------------------- /snippets/htmltornado.snippets: -------------------------------------------------------------------------------- 1 | # Generic tags 2 | 3 | snippet { 4 | {{ ${0} }} 5 | 6 | # Template tags 7 | 8 | snippet extends 9 | {% extends "${0:base.html}" %} 10 | snippet autoescape 11 | {% autoescape ${0:xhtml_escape | None} %} 12 | snippet apply 13 | {% apply ${1:function} %} 14 | ${0} 15 | {% end %} 16 | snippet block 17 | {% block ${1} %} 18 | ${0} 19 | {% end %} 20 | snippet for 21 | {% for ${1:item} in ${2} %} 22 | ${0} 23 | {% end %} 24 | snippet from 25 | {% from ${1:x} import ${0:y} %} 26 | snippet if 27 | {% if ${1:condition} %} 28 | ${0} 29 | {% end %} 30 | snippet eif 31 | {% elif ${0:condition} %} 32 | snippet el 33 | {% else %} 34 | snippet import 35 | {% import ${0:module} %} 36 | snippet include 37 | {% include "${0:filename}" %} 38 | snippet module 39 | {% module ${0:expression} %} 40 | snippet raw 41 | {% raw ${0:expression} %} 42 | snippet set 43 | {% set ${1:x} = ${0:y} %} 44 | snippet try 45 | {% try %} 46 | ${1:${VISUAL}} 47 | {% except %} 48 | ${2} 49 | {% finallly %} 50 | ${0} 51 | {% end %} 52 | snippet wh 53 | {% while ${1:condition} %} 54 | ${0} 55 | {% end %} 56 | -------------------------------------------------------------------------------- /snippets/javascript/javascript-react.snippets: -------------------------------------------------------------------------------- 1 | # Import 2 | snippet ir_react import React 3 | import React from 'react'; 4 | 5 | snippet irc_react import React and Component 6 | import React, { Component } from 'react'; 7 | 8 | snippet irh_react import React hooks 9 | import { use$1 } from 'react'; 10 | 11 | snippet ird_react import ReactDOM 12 | import ReactDOM from 'react-dom'; 13 | 14 | snippet irp_react import PropTypes 15 | import PropTypes from 'prop-types'; 16 | 17 | # Lifecycle Methods 18 | snippet cdm_react componentDidMount 19 | componentDidMount() { 20 | ${1} 21 | }; 22 | 23 | snippet cdup_react componentDidUpdate 24 | componentDidUpdate(prevProps, prevState) { 25 | ${1} 26 | }; 27 | 28 | snippet cwm_react componentWillMount 29 | componentWillMount() { 30 | ${1} 31 | }; 32 | 33 | snippet cwr_react componentWillReceiveProps 34 | componentWillReceiveProps(nextProps) { 35 | ${1} 36 | }; 37 | 38 | snippet cwun_react componentWillUnmount 39 | componentWillUnmount() { 40 | ${1} 41 | }; 42 | 43 | snippet cwu_react componentWillUpdate 44 | componentWillUpdate(nextProps, nextState) { 45 | ${1} 46 | }; 47 | 48 | snippet scu_react shouldComponentUpdate 49 | shouldComponentUpdate(nextProps, nextState) { 50 | ${1} 51 | } 52 | 53 | # Props 54 | snippet spt_react static propTypes 55 | static propTypes = { 56 | ${1}: PropTypes.${2} 57 | }; 58 | 59 | snippet pt_react propTypes 60 | ${1}.propTypes = { 61 | ${2}: PropTypes.${2} 62 | }; 63 | 64 | snippet sdp_react static defaultProps 65 | static defaultProps = { 66 | ${1}: ${2} 67 | }; 68 | 69 | snippet dp_react defaultProps 70 | ${1}.defaultProps = { 71 | ${2}: ${3} 72 | }; 73 | 74 | snippet pp_react props 75 | props.${1}; 76 | 77 | snippet tp_react this props 78 | this.props.${1}; 79 | 80 | # State 81 | snippet st_react 82 | state = { 83 | ${1}: ${2}, 84 | }; 85 | 86 | snippet sst_react 87 | this.setState({ 88 | ${1}: ${2} 89 | }); 90 | 91 | snippet tst_react 92 | this.state.${1}; 93 | 94 | # Component 95 | snippet raf_react 96 | const ${1:ComponentName} = (${2:props}) => { 97 | ${3:state} 98 | 99 | return ( 100 | <> 101 | ${4} 102 | 103 | ); 104 | }; 105 | 106 | snippet rcla_react 107 | class ${1:ClassName} extends Component { 108 | render() { 109 | return ( 110 | <> 111 | ${2} 112 | 113 | ); 114 | } 115 | } 116 | 117 | snippet ercla_react 118 | export default class ${1:ClassName} extends Component { 119 | render() { 120 | return ( 121 | <> 122 | ${2} 123 | 124 | ); 125 | }; 126 | }; 127 | 128 | snippet ctor_react 129 | constructor() { 130 | super(); 131 | 132 | ${1:state} 133 | } 134 | 135 | snippet ren_react 136 | render() { 137 | return ( 138 | <> 139 | ${2} 140 | 141 | ); 142 | } 143 | 144 | snippet fup_react 145 | forceUpdate(${1:callback}); 146 | 147 | 148 | # ReactDOM methods 149 | snippet rdr_react ReactDOM.render 150 | ReactDOM.render(${1}, ${2}); 151 | 152 | snippet rdh_react ReactDOM.hydrate 153 | ReactDOM.hydrate(${1:element}, ${2:container}[, ${3:callback}]); 154 | 155 | snippet rdcp_react ReactDOM.createPortal 156 | ReactDOM.createPortal(${1:child}, ${2:container}); 157 | -------------------------------------------------------------------------------- /snippets/javascript/javascript.node.snippets: -------------------------------------------------------------------------------- 1 | snippet #! 2 | #!/usr/bin/env node 3 | # module exports 4 | snippet ex 5 | module.exports = ${1}; 6 | # require 7 | snippet re 8 | const ${1} = require('${2:module_name}'); 9 | # EventEmitter 10 | snippet on 11 | on('${1:event_name}', function(${2:stream}) { 12 | ${3} 13 | }); 14 | snippet emit 15 | emit('${1:event_name}', ${2:args}); 16 | snippet once 17 | once('${1:event_name}', function(${2:stream}) { 18 | ${3} 19 | }); 20 | # http. User js function snippet as handler 21 | snippet http 22 | http.createServer(${1:handler}).listen(${2:port_number}); 23 | # net 24 | snippet net 25 | net.createServer(function(${1:socket}){ 26 | ${1}.on('data', function('data'){ 27 | ${2} 28 | ]}); 29 | ${1}.on('end', function(){ 30 | ${3} 31 | }); 32 | }).listen(${4:8124}); 33 | # Stream snippets 34 | snippet pipe 35 | pipe(${1:stream})${2} 36 | # Express snippets 37 | snippet eget 38 | ${1:app}.get('${2:route}', ${3:handler}); 39 | snippet epost 40 | ${1:app}.post('${2:route}', ${3:handler}); 41 | snippet eput 42 | ${1:app}.put('${2:route}', ${3:handler}); 43 | snippet edel 44 | ${1:app}.delete('${2:route}', ${3:handler}); 45 | # process snippets 46 | snippet stdin 47 | process.stdin 48 | snippet stdout 49 | process.stdout 50 | snippet stderr 51 | process.stderr 52 | -------------------------------------------------------------------------------- /snippets/jinja.snippets: -------------------------------------------------------------------------------- 1 | # Generic tags 2 | 3 | extends html 4 | 5 | snippet % 6 | {% ${1} %} 7 | snippet %% 8 | {% ${1:tag_name} %} 9 | ${0} 10 | {% end$1 %} 11 | snippet { 12 | {{ ${1} }} 13 | # Template Tags 14 | 15 | snippet autoescape 16 | {% autoescape ${1:off} %} 17 | ${0} 18 | {% endautoescape %} 19 | snippet block 20 | {% block ${1} %} 21 | ${0} 22 | {% endblock %} 23 | snippet # 24 | {# ${0:comment} #} 25 | snippet comment 26 | {% comment %} 27 | ${0} 28 | {% endcomment %} 29 | snippet cycle 30 | {% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} 31 | snippet debug 32 | {% debug %} 33 | snippet extends 34 | {% extends "${0:base.html}" %} 35 | snippet filter 36 | {% filter ${1} %} 37 | ${0} 38 | {% endfilter %} 39 | snippet firstof 40 | {% firstof ${1} %} 41 | snippet for 42 | {% for ${1} in ${2} %} 43 | ${0} 44 | {% endfor %} 45 | snippet empty 46 | {% empty %} 47 | ${0} 48 | snippet if 49 | {% if ${1} %} 50 | ${0} 51 | {% endif %} 52 | snippet el 53 | {% else %} 54 | ${1} 55 | snippet eif 56 | {% elif ${1} %} 57 | ${0} 58 | snippet ifchanged 59 | {% ifchanged %}${1}{% endifchanged %} 60 | snippet ifequal 61 | {% ifequal ${1} ${2} %} 62 | ${0} 63 | {% endifequal %} 64 | snippet ifnotequal 65 | {% ifnotequal ${1} ${2} %} 66 | ${0} 67 | {% endifnotequal %} 68 | snippet include 69 | {% include "${0}" %} 70 | snippet load 71 | {% load ${0} %} 72 | snippet now 73 | {% now "${0:jS F Y H:i}" %} 74 | snippet regroup 75 | {% regroup ${1} by ${2} as ${0} %} 76 | snippet spaceless 77 | {% spaceless %}${0}{% endspaceless %} 78 | snippet ssi 79 | {% ssi ${0} %} 80 | snippet trans 81 | {% trans %}${0}{% endtrans %} 82 | snippet url 83 | {% url ${1} as ${0} %} 84 | snippet widthratio 85 | {% widthratio ${1:this_value} ${2:max_value} ${0:100} %} 86 | snippet with 87 | {% with ${1} as ${2} %} 88 | ${0} 89 | {% endwith %} 90 | 91 | # Template Filters 92 | 93 | # Note: Since SnipMate can't determine which template filter you are 94 | # expanding without the "|" character, these do not add the "|" 95 | # character. These save a few keystrokes still. 96 | 97 | # Note: Template tags that take no arguments are not implemented. 98 | 99 | snippet add 100 | add:"${0}" 101 | snippet center 102 | center:"${0}" 103 | snippet cut 104 | cut:"${0}" 105 | snippet date 106 | date:"${0}" 107 | snippet default 108 | default:"${0}" 109 | snippet defaultifnone 110 | default_if_none:"${0}" 111 | snippet dictsort 112 | dictsort:"${0}" 113 | snippet dictsortrev 114 | dictsortreversed:"${0}" 115 | snippet divisibleby 116 | divisibleby:"${0}" 117 | snippet floatformat 118 | floatformat:"${0}" 119 | snippet getdigit 120 | get_digit:"${0}" 121 | snippet join 122 | join:"${0}" 123 | snippet lengthis 124 | length_is:"${0}" 125 | snippet pluralize 126 | pluralize:"${0}" 127 | snippet removetags 128 | removetags:"${0}" 129 | snippet slice 130 | slice:"${0}" 131 | snippet stringformat 132 | stringformat:"${0}" 133 | snippet time 134 | time:"${0}" 135 | snippet truncatewords 136 | truncatewords:${0} 137 | snippet truncatewordshtml 138 | truncatewords_html:${0} 139 | snippet urlizetrunc 140 | urlizetrunc:${0} 141 | snippet wordwrap 142 | wordwrap:${0} 143 | -------------------------------------------------------------------------------- /snippets/kotlin.snippets: -------------------------------------------------------------------------------- 1 | snippet fun 2 | fun ${1:name}(${2}): ${3:String} { 3 | ${4} 4 | } 5 | snippet pfun 6 | private fun ${1:name}(${2}): ${3:String} { 7 | ${4} 8 | } 9 | snippet ret 10 | return ${0} 11 | snippet whe 12 | when (${1:${VISUAL}}) { 13 | ${2} -> ${3} 14 | } 15 | snippet cla 16 | class ${1} { 17 | ${0:${VISUAL}} 18 | } 19 | snippet cobj 20 | companion object { 21 | ${0:${VISUAL}} 22 | } 23 | snippet obj 24 | object ${1} { 25 | ${0:${VISUAL}} 26 | } 27 | snippet if 28 | if (${1}) { 29 | ${0:${VISUAL}} 30 | } 31 | snippet ife 32 | if (${1}) { 33 | ${2:${VISUAL}} 34 | } else { 35 | ${0} 36 | } 37 | -------------------------------------------------------------------------------- /snippets/lua.snippets: -------------------------------------------------------------------------------- 1 | snippet #! 2 | #!/usr/bin/env lua 3 | $1 4 | snippet local 5 | local ${1:x} = ${0:1} 6 | snippet fun 7 | function ${1:fname}(${2:...}) 8 | ${0:-- body} 9 | end 10 | snippet for 11 | for ${1:i}=${2:1},${3:10} do 12 | ${0:print(i)} 13 | end 14 | snippet forp 15 | for ${1:i},${2:v} in pairs(${3:table_name}) do 16 | ${0:-- body} 17 | end 18 | snippet fori 19 | for ${1:i},${2:v} in ipairs(${3:table_name}) do 20 | ${0:-- body} 21 | end 22 | snippet if 23 | if ${1:condition} then 24 | ${2:-- body} 25 | end 26 | snippet ife 27 | if ${1:condition} then 28 | ${2:-- if condition} 29 | else 30 | ${0:-- else} 31 | end 32 | snippet elif 33 | elseif ${1:condition} then 34 | ${0:--body} 35 | snippet repeat 36 | repeat 37 | ${1:--body} 38 | until ${0:condition} 39 | snippet while 40 | while ${1:condition} do 41 | ${0:--body} 42 | end 43 | snippet print 44 | print("${1:string}") 45 | snippet im 46 | import "${1:import file}" 47 | -------------------------------------------------------------------------------- /snippets/make.snippets: -------------------------------------------------------------------------------- 1 | # base 2 | snippet base 3 | .PHONY: clean, mrproper 4 | CC = gcc 5 | CFLAGS = -g -Wall 6 | 7 | all: $1 8 | 9 | %.o: %.c 10 | $(CC) $(CFLAGS) -c -o $@ $< 11 | 12 | ${1:out}: $1.o 13 | $(CC) $(CFLAGS) -o $@ $+ 14 | 15 | clean: 16 | rm -f *.o core.* 17 | 18 | mrproper: clean 19 | rm -f $1 20 | # add 21 | snippet add 22 | ${1:out}: $1.o 23 | $(CC) $(CFLAGS) -o $@ $+ 24 | # print 25 | snippet print 26 | print-%: ; @echo $*=$($*) 27 | # ifeq 28 | snippet if 29 | ifeq (${1:cond0}, ${2:cond1}) 30 | ${0:${VISUAL}} 31 | endif 32 | # ifeq ... else ... endif 33 | snippet ife 34 | ifeq (${1:cond0}, ${2:cond1}) 35 | ${3:${VISUAL}} 36 | else 37 | ${0} 38 | endif 39 | # else ... 40 | snippet el 41 | else 42 | ${0:${VISUAL}} 43 | # .DEFAULT_GOAL := target 44 | snippet default 45 | .DEFAULT_GOAL := ${1} 46 | # help target for self-documented Makefile 47 | snippet help 48 | help: ## Prints help for targets with comments 49 | @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $\$1, $\$2}' 50 | ${0} 51 | -------------------------------------------------------------------------------- /snippets/mako.snippets: -------------------------------------------------------------------------------- 1 | snippet def 2 | <%def name="${1:name}"> 3 | ${0:} 4 | 5 | snippet call 6 | <%call expr="${1:name}"> 7 | ${0:} 8 | 9 | snippet doc 10 | <%doc> 11 | ${0:} 12 | 13 | snippet text 14 | <%text> 15 | ${0:} 16 | 17 | snippet for 18 | % for ${1:i} in ${2:iter}: 19 | ${0:} 20 | % endfor 21 | snippet if if 22 | % if ${1:condition}: 23 | ${0:} 24 | % endif 25 | snippet ife if/else 26 | % if ${1:condition}: 27 | ${2:} 28 | % else: 29 | ${0:} 30 | % endif 31 | snippet try 32 | % try: 33 | ${1:${VISUAL}} 34 | % except${2:}: 35 | ${0:pass} 36 | % endtry 37 | snippet wh 38 | % while ${1:}: 39 | ${0:} 40 | % endwhile 41 | snippet $ 42 | ${ ${0:} } 43 | snippet <% 44 | <% ${0:} %> 45 | snippet 47 | snippet inherit 48 | <%inherit file="${0:filename}" /> 49 | snippet include 50 | <%include file="${0:filename}" /> 51 | snippet namespace 52 | <%namespace file="${0:name}" /> 53 | snippet page 54 | <%page args="${0:}" /> 55 | -------------------------------------------------------------------------------- /snippets/markdown.snippets: -------------------------------------------------------------------------------- 1 | # Markdown 2 | 3 | # Includes octopress (http://octopress.org/) snippets 4 | 5 | # The suffix `c` stands for "Clipboard". 6 | 7 | snippet [ 8 | [${1:text}](https://${2:address}) 9 | snippet [* 10 | [${1:link}](${2:`@*`}) 11 | snippet [c 12 | [${1:link}](${2:`@+`}) 13 | snippet [" 14 | [${1:text}](https://${2:address} "${3:title}") 15 | snippet ["* 16 | [${1:link}](${2:`@*`} "${3:title}") 17 | snippet ["c 18 | [${1:link}](${2:`@+`} "${3:title}") 19 | snippet [: 20 | [${1:id}]: https://${2:url} 21 | 22 | snippet [:* 23 | [${1:id}]: ${2:`@*`} 24 | 25 | snippet [:c 26 | [${1:id}]: ${2:`@+`} 27 | 28 | snippet [:" 29 | [${1:id}]: https://${2:url} "${3:title}" 30 | 31 | snippet [:"* 32 | [${1:id}]: ${2:`@*`} "${3:title}" 33 | 34 | snippet [:"c 35 | [${1:id}]: ${2:`@+`} "${3:title}" 36 | 37 | snippet ![ 38 | ![${1:alttext}](${2:/images/image.jpg}) 39 | snippet ![* 40 | ![${1:alt}](${2:`@*`}) 41 | snippet ![c 42 | ![${1:alt}](${2:`@+`}) 43 | snippet ![" 44 | ![${1:alttext}](${2:/images/image.jpg} "${3:title}") 45 | snippet !["* 46 | ![${1:alt}](${2:`@*`} "${3:title}") 47 | snippet !["c 48 | ![${1:alt}](${2:`@+`} "${3:title}") 49 | snippet ![: 50 | ![${1:id}]: ${2:url} 51 | 52 | snippet ![:* 53 | ![${1:id}]: ${2:`@*`} 54 | 55 | snippet ![:" 56 | ![${1:id}]: ${2:url} "${3:title}" 57 | 58 | snippet ![:"* 59 | ![${1:id}]: ${2:`@*`} "${3:title}" 60 | 61 | snippet ![:"c 62 | ![${1:id}]: ${2:`@+`} "${3:title}" 63 | 64 | snippet < 65 | 66 | snippet <* 67 | <`@*`> 68 | snippet 70 | snippet ** 71 | **${1:bold}** 72 | snippet __ 73 | __${1:bold}__ 74 | snippet === 75 | `repeat('=', strlen(getline(line('.') - 3)))` 76 | 77 | ${0} 78 | snippet - 79 | - ${0} 80 | snippet --- 81 | `repeat('-', strlen(getline(line('.') - 3)))` 82 | 83 | ${0} 84 | snippet blockquote 85 | {% blockquote %} 86 | ${0:quote} 87 | {% endblockquote %} 88 | 89 | snippet blockquote-author 90 | {% blockquote ${1:author}, ${2:title} %} 91 | ${0:quote} 92 | {% endblockquote %} 93 | 94 | snippet blockquote-link 95 | {% blockquote ${1:author} ${2:URL} ${3:link_text} %} 96 | ${0:quote} 97 | {% endblockquote %} 98 | 99 | snippet ``` 100 | \`\`\`${1} 101 | ${0:${VISUAL}} 102 | \`\`\` 103 | 104 | # Language. 105 | snippet ```l 106 | \`\`\`${1:language} 107 | ${2:code} 108 | \`\`\` 109 | 110 | snippet codeblock-short 111 | {% codeblock %} 112 | ${0:code_snippet} 113 | {% endcodeblock %} 114 | 115 | snippet codeblock-full 116 | {% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %} 117 | ${0:code_snippet} 118 | {% endcodeblock %} 119 | 120 | snippet gist-full 121 | {% gist ${1:gist_id} ${0:filename} %} 122 | 123 | snippet gist-short 124 | {% gist ${0:gist_id} %} 125 | 126 | snippet img 127 | {% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${0:alt_text} %} 128 | 129 | snippet youtube 130 | {% youtube ${0:video_id} %} 131 | 132 | snippet tb 133 | | ${0:factors} | ${1:a} | ${2:b} | 134 | | ------------- |------------- | ------- | 135 | | ${3:f1} | Y | N | 136 | | ${4:f2} | Y | N | 137 | 138 | # The quote should appear only once in the text. It is inherently part of it. 139 | # See http://octopress.org/docs/plugins/pullquote/ for more info. 140 | 141 | snippet pullquote 142 | {% pullquote %} 143 | ${1:text} {" ${2:quote} "} ${0:text} 144 | {% endpullquote %} 145 | -------------------------------------------------------------------------------- /snippets/perl6.snippets: -------------------------------------------------------------------------------- 1 | # shebang 2 | snippet #! 3 | #!/usr/bin/env perl6 4 | 5 | # Hash Pointer 6 | snippet . 7 | => 8 | # Function 9 | snippet sub 10 | sub ${1:function_name}(${2:Str $var}) { 11 | ${3} 12 | } 13 | snippet mul 14 | multi ${1:function_name}(${2:Str $var}) { 15 | ${3} 16 | } 17 | # Conditional 18 | snippet if 19 | if ${1} { 20 | ${2} 21 | } 22 | # Conditional if..else 23 | snippet ife 24 | if ${1} { 25 | ${2} 26 | } 27 | else { 28 | ${3} 29 | } 30 | snippet eif 31 | elsif ${1} { 32 | ${2} 33 | } 34 | # Conditional One-line 35 | snippet xif 36 | ${1:expression} if ${2:condition}; 37 | # Unless conditional 38 | snippet unless 39 | unless ${1} { 40 | ${2} 41 | } 42 | # Unless conditional One-line 43 | snippet xunless 44 | ${1:expression} unless ${2:condition}; 45 | # Ternary conditional 46 | snippet tc 47 | ${1:condition} ?? ${2:value-if-true} !! ${3:value-if-false}; 48 | # given - when (perl6 switch) 49 | snippet switch 50 | given ${1:$var} { 51 | when ${2:condition} { 52 | ${3:# code block ...} 53 | } 54 | ${4} 55 | default { 56 | ${5} 57 | } 58 | } 59 | # 'loop' - C's for. 60 | snippet loop 61 | loop (my ${1:$i} = 0; $$1 < ${2:count}; $$1++) { 62 | ${3} 63 | } 64 | # for loop 65 | snippet for 66 | for ${1:@array} -> ${2:$variable} { 67 | ${3} 68 | } 69 | # While Loop 70 | snippet wh 71 | while ${1} { 72 | ${2} 73 | } 74 | # Repeat while and repean until 75 | snippet rp 76 | repeat { 77 | ${1} 78 | } ${2:while|until} ${3}; 79 | # classes .. 80 | snippet cl 81 | ${1:my} class ${2:ClassName} ${3:is|does Parent|Role}{ 82 | ${4} 83 | } 84 | snippet has 85 | has ${1:Type} ${2:$!identifier}; 86 | snippet mth 87 | method ${1:method_name}(${2:$attr}) { 88 | ${3} 89 | } 90 | snippet pmth 91 | method ${1:!}${2:method_name}(${3:$attr}) { 92 | ${4} 93 | } 94 | snippet smth 95 | submethod ${1:submethod_name}(${2:$attr}) { 96 | ${3} 97 | } 98 | # Tests 99 | snippet test 100 | use v6; 101 | use Test; 102 | ${1:use lib 'lib';} 103 | 104 | plan ${2:$num-tests}; 105 | 106 | # IO 107 | snippet slurp 108 | my ${1:$var} = "${2:filename}".IO.slurp; 109 | snippet rfile 110 | for "${1:filename}".IO.lines -> $line { 111 | ${2} 112 | } 113 | snippet open 114 | my $fh = open "${1:filename}", ${2::r|:w|:a}; 115 | ${3:# actions}; 116 | $fh.close; 117 | -------------------------------------------------------------------------------- /snippets/plsql.snippets: -------------------------------------------------------------------------------- 1 | # create package spec 2 | snippet ps 3 | create or replace package ${1:name} 4 | as 5 | ${0:-- spec} 6 | end; -- end of package spec $1 7 | # create package body 8 | snippet pb 9 | create or replace package body ${1:name} 10 | as 11 | ${0:-- body} 12 | end; -- end of package body $1; 13 | # package procedure spec 14 | snippet pps 15 | procedure ${1:name}(${0:args}); 16 | # package procedure body 17 | snippet ppb 18 | procedure ${1:name}(${2:args}) 19 | as 20 | begin 21 | ${0:-- body} 22 | end $2; 23 | # package function spec 24 | snippet pfs 25 | function ${1:name}(${2:args}) 26 | return ${0:type}; 27 | # package function body 28 | snippet pfb 29 | function ${1:name}(${2:args}) 30 | return ${3:type} 31 | as 32 | l_res $3; 33 | begin 34 | ${0:-- body}; 35 | return l_res; 36 | end $1; 37 | # snow errors 38 | snippet err 39 | show errors; 40 | # proc/func in parameter 41 | snippet p 42 | ${1:name} ${2:in} ${3:type} ${0: := null} 43 | # package type: record 44 | snippet tr 45 | type tr_${1:name} is record (${0:/* columns */}); 46 | # package type: nested table 47 | snippet tt 48 | type tt_${1:name} is table of tr_${0:name}; 49 | # package type: indexed table 50 | snippet tti 51 | type tt_${1:name} is table of tr_${0:name} index by binary_integer; 52 | # proc/func comment 53 | snippet doc 54 | /* 55 | * ${0: comment ...} 56 | */ 57 | # plsql block 58 | snippet beg 59 | begin 60 | ${0} 61 | end; 62 | # plsql block with declare part 63 | snippet dec 64 | declare 65 | ${1} 66 | begin 67 | ${0} 68 | end; 69 | # return pipe row 70 | snippet rpipe 71 | for ${1:i} in 1 .. ${0:l_res}.count loop 72 | pipe row( $2($1) ); 73 | end loop; 74 | return; 75 | # bulk collect 76 | snippet bc 77 | bulk collect into ${0} 78 | # local variable 79 | snippet l 80 | l_${1} ${0:number}; 81 | # output 82 | snippet log 83 | dbms_output.put_line('${0}'); 84 | # for loop 85 | snippet for 86 | for ${1:i} in ${2:1}..${3:42} loop 87 | ${0} 88 | end loop; 89 | # for loop with select 90 | snippet fors 91 | for ${1:rec} in (${2: select}) loop 92 | ${0} 93 | end loop; 94 | # for loop with collection 95 | snippet forc 96 | for ${1:i} in ${2:l_var}.first .. $2.last loop 97 | ${0: -- dbms_output.put_line($2($1)); } 98 | end loop; 99 | # if 100 | snippet if 101 | if ${1} then 102 | ${0} 103 | end if; 104 | snippet ife 105 | if ${1} then 106 | ${2} 107 | else 108 | ${0} 109 | end if; 110 | -------------------------------------------------------------------------------- /snippets/r.snippets: -------------------------------------------------------------------------------- 1 | snippet #! 2 | #!/usr/bin/env Rscript 3 | 4 | # includes 5 | snippet lib 6 | library(${0:package}) 7 | snippet req 8 | require(${0:package}) 9 | snippet source 10 | source('${0:file}') 11 | 12 | # conditionals 13 | snippet if 14 | if (${1:condition}) { 15 | ${0} 16 | } 17 | snippet el 18 | else { 19 | ${0} 20 | } 21 | snippet ei 22 | else if (${1:condition}) { 23 | ${0} 24 | } 25 | 26 | # loops 27 | snippet wh 28 | while(${1}) { 29 | ${2} 30 | } 31 | snippet for 32 | for (${1:item} in ${2:list}) { 33 | ${3} 34 | } 35 | snippet foreach 36 | foreach (${1:item} = ${2:list}) { 37 | ${3} 38 | } 39 | 40 | # functions 41 | snippet fun 42 | ${1:name} <- function (${2:variables}) { 43 | ${0} 44 | } 45 | snippet ret 46 | return(${0}) 47 | 48 | # dataframes, lists, etc 49 | snippet df 50 | ${1:name}[${2:rows}, ${0:cols}] 51 | snippet c 52 | c(${0:items}) 53 | snippet li 54 | list(${0:items}) 55 | snippet mat 56 | matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols}) 57 | 58 | # apply functions 59 | snippet apply 60 | apply(${1:array}, ${2:margin}, ${0:function}) 61 | snippet lapply 62 | lapply(${1:list}, ${0:function}) 63 | snippet sapply 64 | lapply(${1:list}, ${0:function}) 65 | snippet vapply 66 | vapply(${1:list}, ${2:function}, ${0:type}) 67 | snippet mapply 68 | mapply(${1:function}, ${0:...}) 69 | snippet tapply 70 | tapply(${1:vector}, ${2:index}, ${0:function}) 71 | snippet rapply 72 | rapply(${1:list}, ${0:function}) 73 | 74 | # plyr functions 75 | snippet dd 76 | ddply(${1:frame}, ${2:variables}, ${0:function}) 77 | snippet dl 78 | dlply(${1:frame}, ${2:variables}, ${0:function}) 79 | snippet da 80 | daply(${1:frame}, ${2:variables}, ${0:function}) 81 | snippet d_ 82 | d_ply(${1:frame}, ${2:variables}, ${0:function}) 83 | 84 | snippet ad 85 | adply(${1:array}, ${2:margin}, ${0:function}) 86 | snippet al 87 | alply(${1:array}, ${2:margin}, ${0:function}) 88 | snippet aa 89 | aaply(${1:array}, ${2:margin}, ${0:function}) 90 | snippet a_ 91 | a_ply(${1:array}, ${2:margin}, ${0:function}) 92 | 93 | snippet ld 94 | ldply(${1:list}, ${0:function}) 95 | snippet ll 96 | llply(${1:list}, ${0:function}) 97 | snippet la 98 | laply(${1:list}, ${0:function}) 99 | snippet l_ 100 | l_ply(${1:list}, ${0:function}) 101 | 102 | snippet md 103 | mdply(${1:matrix}, ${0:function}) 104 | snippet ml 105 | mlply(${1:matrix}, ${0:function}) 106 | snippet ma 107 | maply(${1:matrix}, ${0:function}) 108 | snippet m_ 109 | m_ply(${1:matrix}, ${0:function}) 110 | 111 | # plot functions 112 | snippet pl 113 | plot(${1:x}, ${0:y}) 114 | snippet ggp 115 | ggplot(${1:data}, aes(${0:aesthetics})) 116 | snippet img 117 | ${1:(jpeg,bmp,png,tiff)}(filename = '${2:filename}', width = ${3}, height = ${4}, unit = '${5}') 118 | ${0:plot} 119 | dev.off() 120 | 121 | # statistical test functions 122 | snippet fis 123 | fisher.test(${1:x}, ${0:y}) 124 | snippet chi 125 | chisq.test(${1:x}, ${0:y}) 126 | snippet tt 127 | t.test(${1:x}, ${0:y}) 128 | snippet wil 129 | wilcox.test(${1:x}, ${0:y}) 130 | snippet cor 131 | cor.test(${1:x}, ${0:y}) 132 | snippet fte 133 | var.test(${1:x}, ${0:y}) 134 | snippet kvt 135 | kv.test(${1:x}, ${0:y}) 136 | -------------------------------------------------------------------------------- /snippets/rst.snippets: -------------------------------------------------------------------------------- 1 | # rst 2 | 3 | snippet : 4 | :${1:field name}: ${0:field body} 5 | snippet * 6 | *${1:Emphasis}* ${0} 7 | snippet ** 8 | **${1:Strong emphasis}** ${0} 9 | snippet _ 10 | \`${1:hyperlink-name}\`_ 11 | .. _\`$1\`: ${0:link-block} 12 | snippet = 13 | ${1:Title} 14 | =====${2:=} 15 | ${0} 16 | snippet - 17 | ${1:Title} 18 | -----${2:-} 19 | ${0} 20 | #some directive 21 | snippet img: 22 | .. |${1:alias}| image:: ${0:img} 23 | snippet fig: 24 | .. figure:: ${1:img} 25 | :alt: ${2:alter text} 26 | 27 | $0 28 | snippet con: 29 | .. contents:: ${1:Table of Contents} 30 | 31 | ${0:content} 32 | snippet cod: 33 | .. code:: ${1:type} 34 | 35 | ${0:write some code} 36 | snippet tip: 37 | .. tip:: 38 | ${0:my tips} 39 | snippet not: 40 | .. note:: 41 | ${0:my notes} 42 | snippet war: 43 | .. warning:: 44 | ${0:attention!} 45 | snippet imp: 46 | .. important:: 47 | ${0:this is importatnt} 48 | snippet att: 49 | .. attention:: 50 | ${0:hey!} 51 | snippet dan: 52 | .. danger:: 53 | ${0:ah!} 54 | snippet err: 55 | .. error:: 56 | ${0:Error occur} 57 | snippet cau: 58 | .. caution:: 59 | ${0:Watch out!} 60 | #Sphinx only 61 | snippet sid: 62 | .. sidebar:: ${1:Title} 63 | 64 | ${0} 65 | snippet tod: 66 | .. todo:: 67 | ${0} 68 | snippet lis: 69 | .. list-table:: ${1:Title} 70 | :header-rows: 1 71 | :stub-columns: 0 72 | 73 | * - ${0:R1C1} 74 | - R1C2 75 | * - R2C1 76 | - R2C2 77 | snippet csv: 78 | .. csv-table:: ${1:Title} 79 | :header-rows: 1 80 | :stub-columns: 0 81 | 82 | ${0:R1C1}, R1C2 83 | R2C1, R2C2 84 | snippet toc: 85 | .. toctree:: 86 | :maxdepth: 2 87 | 88 | ${0} 89 | snippet dow: 90 | :download:\`${1:text} <${0:path}>\` 91 | snippet ref: 92 | :ref:\`${1:text} <${0:path}>\` 93 | snippet doc: 94 | :doc:\`${1:text} <${0:path}>\` 95 | # CJK optimize, CJK has no space between charaters 96 | snippet *c 97 | \ *${1:Emphasis}*\ ${0} 98 | snippet **c 99 | \ **${1:Strong emphasis}**\ ${0} 100 | 101 | # vim:set list noet sts=0 sw=4 ts=4: 102 | -------------------------------------------------------------------------------- /snippets/scss.snippets: -------------------------------------------------------------------------------- 1 | extends css 2 | 3 | snippet $ 4 | $${1:variable}: ${0:value}; 5 | snippet imp 6 | @import '${0}'; 7 | snippet mix 8 | @mixin ${1:name}(${2}) { 9 | ${0} 10 | } 11 | snippet inc 12 | @include ${1:mixin}(${2}); 13 | snippet ext 14 | @extend ${0}; 15 | snippet fun 16 | @function ${1:name}(${2:args}) { 17 | ${0} 18 | } 19 | snippet if 20 | @if ${1:condition} { 21 | ${0} 22 | } 23 | snippet ife 24 | @if ${1:condition} { 25 | ${2} 26 | } @else { 27 | ${0} 28 | } 29 | snippet eif 30 | @else if ${1:condition} { 31 | ${0} 32 | } 33 | snippet for 34 | @for ${1:$i} from ${2:1} through ${3:3} { 35 | ${0} 36 | } 37 | snippet each 38 | @each ${1:$item} in ${2:items} { 39 | ${0} 40 | } 41 | snippet while 42 | @while ${1:$i} ${2:>} ${3:0} { 43 | ${0} 44 | } 45 | -------------------------------------------------------------------------------- /snippets/sh.snippets: -------------------------------------------------------------------------------- 1 | # Shebang. Executing bash via /usr/bin/env makes scripts more portable. 2 | snippet #! 3 | #!/usr/bin/env sh 4 | 5 | snippet s#! 6 | #!/usr/bin/env sh 7 | set -eu 8 | 9 | snippet safe 10 | set -eu 11 | 12 | snippet bash 13 | #!/usr/bin/env bash 14 | 15 | snippet sbash 16 | #!/usr/bin/env bash 17 | set -euo pipefail 18 | IFS=$'\n\t' 19 | 20 | snippet if 21 | if [[ ${1:condition} ]]; then 22 | ${0:${VISUAL}} 23 | fi 24 | snippet elif 25 | elif [[ ${1:condition} ]]; then 26 | ${0:${VISUAL}} 27 | snippet for 28 | for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do 29 | ${0:${VISUAL}} 30 | done 31 | snippet fori 32 | for ${1:needle} in ${2:haystack} ; do 33 | ${0:${VISUAL}} 34 | done 35 | snippet wh 36 | while [[ ${1:condition} ]]; do 37 | ${0:${VISUAL}} 38 | done 39 | snippet until 40 | until [[ ${1:condition} ]]; do 41 | ${0:${VISUAL}} 42 | done 43 | snippet case 44 | case ${1:word} in 45 | ${2:pattern}) 46 | ${0};; 47 | esac 48 | snippet go 49 | while getopts '${1:o}' ${2:opts} 50 | do 51 | case $$2 in 52 | ${3:o0}) 53 | ${0:#staments};; 54 | esac 55 | done 56 | # Set SCRIPT_DIR variable to directory script is located. 57 | snippet sdir 58 | SCRIPT_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" && pwd )" 59 | # getopt 60 | snippet getopt 61 | __ScriptVersion="${1:version}" 62 | 63 | #=== FUNCTION ================================================================ 64 | # NAME: usage 65 | # DESCRIPTION: Display usage information. 66 | #=============================================================================== 67 | function usage () 68 | { 69 | echo "Usage : $${0:0} [options] [--] 70 | 71 | Options: 72 | -h|help Display this message 73 | -v|version Display script version" 74 | 75 | } # ---------- end of function usage ---------- 76 | 77 | #----------------------------------------------------------------------- 78 | # Handle command line arguments 79 | #----------------------------------------------------------------------- 80 | 81 | while getopts ":hv" opt 82 | do 83 | case $opt in 84 | 85 | h|help ) usage; exit 0 ;; 86 | 87 | v|version ) echo "$${0:0} -- Version $__ScriptVersion"; exit 0 ;; 88 | 89 | * ) echo -e "\n Option does not exist : $OPTARG\n" 90 | usage; exit 1 ;; 91 | 92 | esac # --- end of case --- 93 | done 94 | shift $(($OPTIND-1)) 95 | snippet root 96 | if [ \$(id -u) -ne 0 ]; then exec sudo \$0; fi 97 | 98 | snippet fun-sh 99 | ${1:function_name}() { 100 | ${0:#function_body} 101 | } 102 | 103 | snippet fun 104 | function ${1:function_name}() { 105 | ${0:#function_body} 106 | } 107 | -------------------------------------------------------------------------------- /snippets/snippets.snippets: -------------------------------------------------------------------------------- 1 | # snippets for making snippets :) 2 | snippet snip 3 | snippet ${1:trigger} "${2:description}" 4 | ${0:${VISUAL}} 5 | snippet v 6 | {VISUAL} 7 | snippet $ 8 | ${${1:1}:${0:text}} 9 | -------------------------------------------------------------------------------- /snippets/sql.snippets: -------------------------------------------------------------------------------- 1 | snippet tbl 2 | create table ${1:table} ( 3 | ${0:columns} 4 | ); 5 | snippet col 6 | ${1:name} ${2:type} ${3:default ''} ${0:not null} 7 | snippet ccol 8 | ${1:name} varchar2(${2:size}) ${3:default ''} ${0:not null} 9 | snippet ncol 10 | ${1:name} number ${3:default 0} ${0:not null} 11 | snippet dcol 12 | ${1:name} date ${3:default sysdate} ${0:not null} 13 | snippet ind 14 | create index ${0:$1_$2} on ${1:table}(${2:column}); 15 | snippet uind 16 | create unique index ${1:name} on ${2:table}(${0:column}); 17 | snippet tblcom 18 | comment on table ${1:table} is '${0:comment}'; 19 | snippet colcom 20 | comment on column ${1:table}.${2:column} is '${0:comment}'; 21 | snippet addcol 22 | alter table ${1:table} add (${2:column} ${0:type}); 23 | snippet seq 24 | create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${0:1}; 25 | snippet s* 26 | select * from ${0:table} 27 | -------------------------------------------------------------------------------- /snippets/tcl.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/env tclsh 2 | snippet #! 3 | #!/usr/bin/env tclsh 4 | 5 | # Process 6 | snippet pro 7 | proc ${1:function_name} {${2:args}} { 8 | ${0} 9 | } 10 | #xif 11 | snippet xif 12 | ${1:expr}? ${2:true} : ${0:false} 13 | # Conditional 14 | snippet if 15 | if {${1}} { 16 | ${0} 17 | } 18 | # Conditional if..else 19 | snippet ife 20 | if {${1}} { 21 | ${2} 22 | } else { 23 | ${0:# else...} 24 | } 25 | snippet eif 26 | elseif {${1}} { 27 | ${0} 28 | } 29 | # Conditional if..elsif..else 30 | snippet ifee 31 | if {${1}} { 32 | ${2} 33 | } elseif {${3}} { 34 | ${4:# elsif...} 35 | } else { 36 | ${0:# else...} 37 | } 38 | # If catch then 39 | snippet ifc 40 | if { [catch {${1:#do something...}} ${2:err}] } { 41 | ${0:# handle failure...} 42 | } 43 | # Catch 44 | snippet catch 45 | catch {${1}} ${2:err} ${0:options} 46 | # While Loop 47 | snippet wh 48 | while {${1}} { 49 | ${0} 50 | } 51 | # For Loop 52 | snippet for 53 | for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { 54 | ${0} 55 | } 56 | # Foreach Loop 57 | snippet fore 58 | foreach ${1:x} {${2:#list}} { 59 | ${0} 60 | } 61 | # after ms script... 62 | snippet af 63 | after ${1:ms} ${0:#do something} 64 | # after cancel id 65 | snippet afc 66 | after cancel ${0:id or script} 67 | # after idle 68 | snippet afi 69 | after idle ${0:script} 70 | # after info id 71 | snippet afin 72 | after info ${0:id} 73 | # Expr 74 | snippet exp 75 | expr {${0:#expression here}} 76 | # Switch 77 | snippet sw 78 | switch ${1:var} { 79 | ${3:pattern 1} { 80 | ${0:#do something} 81 | } 82 | default { 83 | ${2:#do something} 84 | } 85 | } 86 | # Case 87 | snippet ca 88 | ${1:pattern} { 89 | ${2:#do something} 90 | } 91 | # Namespace eval 92 | snippet ns 93 | namespace eval ${1:path} {${0:#script...}} 94 | # Namespace current 95 | snippet nsc 96 | namespace current 97 | -------------------------------------------------------------------------------- /snippets/typescript.snippets: -------------------------------------------------------------------------------- 1 | extends javascript 2 | 3 | snippet tconst "ts const" 4 | const ${1}: ${2:any} = ${3}; 5 | ${0} 6 | snippet tlet "ts let" 7 | let ${1}: ${2:any} = ${3}; 8 | ${0} 9 | snippet tvar "ts var" 10 | var ${1}: ${2:any} = ${3}; 11 | ${0} 12 | snippet + "ts create field" 13 | ${1}: ${0:any} 14 | snippet #+ "ts create private field using #" 15 | #${1}: ${0:any} 16 | snippet tpfi "ts create public field" 17 | public ${1}: ${0:any} 18 | snippet tprfi "ts create private field" 19 | private ${1}: ${0:any} 20 | snippet tprofi "ts create protected field" 21 | protected ${1}: ${0:any} 22 | snippet int "interface" 23 | interface ${1} { 24 | ${2}: ${3:any}; 25 | ${0} 26 | } 27 | snippet intx "interface extends" 28 | interface ${1} extends ${2} { 29 | ${3}: ${4:any}; 30 | ${0} 31 | } 32 | snippet tfun "ts function" 33 | function ${1}(${2}): ${3:any} { 34 | ${0} 35 | } 36 | snippet tpmet "ts public method" 37 | public ${1}(${2}): ${3:any} { 38 | ${0} 39 | } 40 | snippet tpsmet "ts public static method" 41 | public static ${1}(${2}): ${3:any} { 42 | ${0} 43 | } 44 | snippet tprmet "ts private method" 45 | private ${1}(${2}): ${3:any} { 46 | ${0} 47 | } 48 | snippet tpromet "ts protected method" 49 | protected ${1}(${2}): ${3:any} { 50 | ${0} 51 | } 52 | snippet tcla "ts class" 53 | class ${1} { 54 | ${2} 55 | constructor(public ${3}: ${4: any}) { 56 | ${5} 57 | } 58 | ${0} 59 | } 60 | snippet tclax "ts class extends" 61 | class ${1} extends ${2} { 62 | ${3} 63 | constructor(public ${4}: ${5: any}) { 64 | ${6} 65 | } 66 | ${0} 67 | } 68 | -------------------------------------------------------------------------------- /snippets/typescriptreact.snippets: -------------------------------------------------------------------------------- 1 | extends typescript 2 | -------------------------------------------------------------------------------- /snippets/ultisnips/README: -------------------------------------------------------------------------------- 1 | This directory contains the snippets for UltiSnips. 2 | https://github.com/sirver/ultisnips 3 | 4 | Standing On The Shoulders of Giants 5 | =================================== 6 | 7 | The snippets have been collected from various other project which I want to 8 | express my gratitude for. My main source for inspiration where the following 9 | two projects: 10 | 11 | TextMate: http://svn.textmate.org/trunk/Bundles/ 12 | SnipMate: http://code.google.com/p/snipmate/ 13 | 14 | UltiSnips has seen contributions by many individuals. Those contributions have 15 | been merged into this collection seamlessly and without further comments. 16 | 17 | -- vim:ft=rst:nospell: 18 | -------------------------------------------------------------------------------- /snippets/ultisnips/all.snippets: -------------------------------------------------------------------------------- 1 | # This file contains snippets that are always defined. I personally 2 | # have snippets for signatures and often needed texts 3 | 4 | # sligthly lower priority than everything else since specialized versions 5 | # should overwrite. The user needs to adjust her priority in her snippets to 6 | # ~-55 so that other filetypes will still overwrite. 7 | priority -60 8 | 9 | ############## 10 | # NICE BOXES # 11 | ############## 12 | global !p 13 | from EasyCompleteUtil.vimsnippets import foldmarker, make_box, get_comment_format 14 | LOREM = """ 15 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod \ 16 | tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At \ 17 | vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, \ 18 | no sea takimata sanctus est Lorem ipsum dolor sit amet. 19 | """ 20 | endglobal 21 | 22 | snippet box "A nice box with the current comment symbol" b 23 | `!p 24 | box = make_box(len(t[1])) 25 | snip.rv = box[0] 26 | snip += box[1] 27 | `${1:${VISUAL:content}}`!p 28 | box = make_box(len(t[1])) 29 | snip.rv = box[2] 30 | snip += box[3]` 31 | $0 32 | endsnippet 33 | 34 | snippet bbox "A nice box over the full width" b 35 | `!p 36 | if not snip.c: 37 | width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71 38 | box = make_box(len(t[1]), width) 39 | snip.rv = box[0] 40 | snip += box[1] 41 | `${1:${VISUAL:content}}`!p 42 | box = make_box(len(t[1]), width) 43 | snip.rv = box[2] 44 | snip += box[3]` 45 | $0 46 | endsnippet 47 | 48 | ########################## 49 | # LOREM IPSUM GENERATORS # 50 | ########################## 51 | snippet "lorem(([1-4])?[0-9])?" "Lorem Ipsum" r 52 | `!p snip.rv = " ".join(LOREM.split()[:int(match.group(1))]) if match.group(1) else LOREM` 53 | endsnippet 54 | 55 | ########################## 56 | # VIM MODELINE GENERATOR # 57 | ########################## 58 | # See advice on `:help 'tabstop'` for why these values are set. Uses second 59 | # modeline form ('set') to work in languages with comment terminators 60 | # (/* like C */). 61 | snippet modeline "Vim modeline" 62 | vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'` 63 | endsnippet 64 | 65 | ######### 66 | # DATES # 67 | ######### 68 | snippet date "YYYY-MM-DD" w 69 | `!v strftime("%Y-%m-%d")` 70 | endsnippet 71 | 72 | snippet ddate "Month DD, YYYY" w 73 | `!v strftime("%b %d, %Y")` 74 | endsnippet 75 | 76 | snippet diso "ISO format datetime" w 77 | `!v strftime("%Y-%m-%d %H:%M:%S%z")` 78 | endsnippet 79 | 80 | snippet time "hh:mm" w 81 | `!v strftime("%H:%M")` 82 | endsnippet 83 | 84 | snippet datetime "YYYY-MM-DD hh:mm" w 85 | `!v strftime("%Y-%m-%d %H:%M")` 86 | endsnippet 87 | 88 | snippet todo "TODO comment" bw 89 | `!p snip.rv=get_comment_format()[0]` ${2:TODO}: $0${3: <${4:`!v strftime('%d-%m-%y')`}${5:, `!v g:snips_author`}>} `!p snip.rv=get_comment_format()[2]` 90 | endsnippet 91 | 92 | ########## 93 | # Misc # 94 | ########## 95 | snippet uuid "Random UUID" w 96 | `!p if not snip.c: import uuid; snip.rv = str(uuid.uuid4())` 97 | endsnippet 98 | 99 | # vim:ft=snippets: 100 | -------------------------------------------------------------------------------- /snippets/ultisnips/bib.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet online "Online resource" b 4 | @online{${1:name}, 5 | author={${2:author}}, 6 | title={${3:title}}, 7 | date={${4:date}}, 8 | url={${5:url}} 9 | } 10 | $0 11 | endsnippet 12 | 13 | snippet article "Article reference" b 14 | @article{${1:name}, 15 | author={${2:author}}, 16 | title={${3:title}}, 17 | journaltitle={${4:journal}}, 18 | volume={${5:NN}}, 19 | number={${6:NN}}, 20 | year={${7:YYYY}}, 21 | pages={${8:NN}--${9:NN}} 22 | } 23 | $0 24 | endsnippet 25 | 26 | snippet book "Book reference" b 27 | @book{${1:name}, 28 | author={${2:author}}, 29 | title={${3:title}}, 30 | subtitle={${4:subtitle}}, 31 | year={${5:YYYY}}, 32 | location={${6:somewhere}}, 33 | publisher={${7:publisher}}, 34 | pages={${8:NN}--${9:NN}} 35 | } 36 | $0 37 | endsnippet 38 | 39 | snippet inb "In Book reference" b 40 | @inbook{${1:name}, 41 | author={${2:author}}, 42 | title={${3:title}}, 43 | subtitle={${4:subtitle}}, 44 | booktitle={${5:book}}, 45 | editor={${6:editor}}, 46 | year={${7:YYYY}}, 47 | location={${8:somewhere}}, 48 | publisher={${9:publisher}}, 49 | pages={${10:NN}--${11:NN}} 50 | } 51 | $0 52 | endsnippet 53 | -------------------------------------------------------------------------------- /snippets/ultisnips/bindzone.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | global !p 4 | def newsoa(): 5 | import datetime 6 | now = datetime.datetime.now() 7 | # return standard SOA formatted serial for today 8 | return now.strftime("%Y%m%d00") 9 | endglobal 10 | 11 | snippet zone "Bootstrap a new Bind zonefile" b 12 | $TTL 86400 13 | @ IN SOA ${1:example.net}. ${2:hostmaster.$1}.( 14 | `!p snip.rv = newsoa()`; serial 15 | 21600; refresh every 6 hours 16 | 3600; retry after one hour 17 | 604800; expire after a week 18 | 86400 ); minimum TTL of 1 day 19 | 20 | IN NS ns01.$1. 21 | IN MX 10 mail.$1. 22 | 23 | ns01.$1 IN A 24 | mail.$1 IN A 25 | endsnippet 26 | 27 | snippet A "Insert A Record" b 28 | ${1:hostname} IN A ${2:ip} 29 | endsnippet 30 | -------------------------------------------------------------------------------- /snippets/ultisnips/coffee-jasmine.snippets: -------------------------------------------------------------------------------- 1 | # 2 | # CoffeeScript versions -- adapted from the JS TextMate bundle + additions 3 | # for some jasmine-jquery matchers 4 | # 5 | priority -50 6 | 7 | extends coffee 8 | 9 | priority -49 10 | 11 | snippet des "Describe (coffee)" b 12 | describe '${1:description}', -> 13 | $0 14 | endsnippet 15 | 16 | snippet it "it (coffee)" b 17 | it '${1:description}', -> 18 | $0 19 | endsnippet 20 | 21 | snippet bef "before each (coffee)" b 22 | beforeEach -> 23 | $0 24 | endsnippet 25 | 26 | snippet aft "after each (coffee)" b 27 | afterEach -> 28 | $0 29 | endsnippet 30 | 31 | snippet any "any (coffee)" b 32 | jasmine.any($1) 33 | endsnippet 34 | 35 | snippet ru "runs (coffee)" b 36 | runs -> 37 | $0 38 | endsnippet 39 | 40 | snippet wa "waits (coffee)" b 41 | waits($1) 42 | endsnippet 43 | 44 | snippet ex "expect (coffee)" b 45 | expect(${1:target})$0 46 | endsnippet 47 | 48 | snippet ee "expect to equal (coffee)" b 49 | expect(${1:target}).toEqual(${2:value}) 50 | endsnippet 51 | 52 | snippet em "expect to match (coffee)" b 53 | expect(${1:target}).toMatch(${2:pattern}) 54 | endsnippet 55 | 56 | snippet eha "expect to have attribute (coffee)" b 57 | expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'}) 58 | endsnippet 59 | 60 | snippet et "expect to be truthy (coffee)" b 61 | expect(${1:target}).toBeTruthy() 62 | endsnippet 63 | 64 | snippet ef "expect to be falsy (coffee)" b 65 | expect(${1:target}).toBeFalsy() 66 | endsnippet 67 | 68 | snippet ed "expect to be defined (coffee)" b 69 | expect(${1:target}).toBeDefined() 70 | endsnippet 71 | 72 | snippet en "expect to be null (coffee)" b 73 | expect(${1:target}).toBeNull() 74 | endsnippet 75 | 76 | snippet ec "expect to contain (coffee)" b 77 | expect(${1:target}).toContain(${2:value}) 78 | endsnippet 79 | 80 | snippet ev "expect to be visible (coffee)" b 81 | expect(${1:target}).toBeVisible() 82 | endsnippet 83 | 84 | snippet eh "expect to be hidden (coffee)" b 85 | expect(${1:target}).toBeHidden() 86 | endsnippet 87 | 88 | snippet notx "expect not (coffee)" b 89 | expect(${1:target}).not$0 90 | endsnippet 91 | 92 | snippet note "expect not to equal (coffee)" b 93 | expect(${1:target}).not.toEqual(${2:value}) 94 | endsnippet 95 | 96 | snippet notm "expect not to match (coffee)" b 97 | expect(${1:target}).not.toMatch(${2:pattern}) 98 | endsnippet 99 | 100 | snippet notha "expect to not have attribute (coffee)" b 101 | expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'}) 102 | endsnippet 103 | 104 | snippet nott "expect not to be truthy (coffee)" b 105 | expect(${1:target}).not.toBeTruthy() 106 | endsnippet 107 | 108 | snippet notf "expect not to be falsy (coffee)" b 109 | expect(${1:target}).not.toBeFalsy() 110 | endsnippet 111 | 112 | snippet notd "expect not to be defined (coffee)" b 113 | expect(${1:target}).not.toBeDefined() 114 | endsnippet 115 | 116 | snippet notn "expect not to be null (coffee)" b 117 | expect(${1:target}).not.toBeNull() 118 | endsnippet 119 | 120 | snippet notc "expect not to contain (coffee)" b 121 | expect(${1:target}).not.toContain(${2:value}) 122 | endsnippet 123 | 124 | snippet notv "expect not to be visible (coffee)" b 125 | expect(${1:target}).not.toBeVisible() 126 | endsnippet 127 | 128 | snippet noth "expect not to be hidden (coffee)" b 129 | expect(${1:target}).not.toBeHidden() 130 | endsnippet 131 | 132 | snippet s "spy on (coffee)" b 133 | spyOn(${1:object}, "${2:method}")$0 134 | endsnippet 135 | 136 | snippet sr "spy on and return (coffee)" b 137 | spyOn(${1:object}, "${2:method}").andReturn(${3:arguments}) 138 | endsnippet 139 | 140 | snippet st "spy on and throw (coffee)" b 141 | spyOn(${1:object}, "${2:method}").andThrow(${3:exception}) 142 | endsnippet 143 | 144 | snippet sct "spy on and call through (coffee)" b 145 | spyOn(${1:object}, "${2:method}").andCallThrough() 146 | endsnippet 147 | 148 | snippet scf "spy on and call fake (coffee)" b 149 | spyOn(${1:object}, "${2:method}").andCallFake(${3:function}) 150 | endsnippet 151 | 152 | snippet esc "expect was called (coffee)" b 153 | expect(${1:target}).wasCalled() 154 | endsnippet 155 | 156 | snippet escw "expect was called with (coffee)" b 157 | expect(${1:target}).wasCalledWith(${2:arguments}) 158 | endsnippet 159 | 160 | snippet notsc "expect was not called (coffee)" b 161 | expect(${1:target}).wasNotCalled() 162 | endsnippet 163 | 164 | snippet noscw "expect was not called with (coffee)" b 165 | expect(${1:target}).wasNotCalledWith(${2:arguments}) 166 | endsnippet 167 | -------------------------------------------------------------------------------- /snippets/ultisnips/coffee-react.snippets: -------------------------------------------------------------------------------- 1 | # 2 | # CoffeeScript versions -- adapted from coffee-jasmine 3 | # for some ReactJS matchers. 4 | # 5 | priority -50 6 | 7 | extends coffee 8 | 9 | priority -49 10 | 11 | snippet createClass "React define Class" b 12 | ${1:classname}Class = React.createClass 13 | displayName: "$1" 14 | render: -> 15 | $2 16 | $1 = React.createFactory($1) 17 | endsnippet 18 | 19 | snippet PropTypes "React define propTypes" b 20 | propTypes: -> 21 | ${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} 22 | endsnippet 23 | 24 | snippet propType "React propType (key/value)" b 25 | ${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} 26 | $4 27 | endsnippet 28 | 29 | snippet setState "React setState" b 30 | @setState 31 | ${1:myvar}: ${2:myvalue} 32 | $3 33 | endsnippet 34 | 35 | snippet getInitialState "React define getInitialState" b 36 | getInitialState: -> 37 | ${1:myvar}: ${2:myvalue} 38 | $3 39 | endsnippet 40 | 41 | snippet getDefaultProps "React define getDefaultProps" b 42 | getDefaultProps: -> 43 | ${1:myvar}: ${2:myvalue} 44 | $3 45 | endsnippet 46 | 47 | snippet componentWillMount "React define componentWillMount" b 48 | componentWillMount: -> 49 | $1 50 | endsnippet 51 | 52 | snippet componentDidMount "React define componentDidMount" b 53 | componentDidMount: -> 54 | $1 55 | endsnippet 56 | 57 | snippet componentWillReceiveProps "React define componentWillReceiveProps" b 58 | componentWillReceiveProps: (nextProps) -> 59 | $1 60 | endsnippet 61 | 62 | snippet shouldComponentUpdate "React define shouldComponentUpdate" b 63 | shouldComponentUpdate: (nextProps, nextState) -> 64 | $1 65 | endsnippet 66 | 67 | snippet componentWillUpdate "React define componentWillUpdate" b 68 | componentWillUpdate: (nextProps, nextState) -> 69 | $1 70 | endsnippet 71 | 72 | snippet componentDidUpdate "React define componentDidUpdate" b 73 | componentDidUpdate: (prevProps, prevState) -> 74 | $1 75 | endsnippet 76 | 77 | snippet componentWillUnmount "React define componentWillUnmount" b 78 | componentWillUnmount: -> 79 | $1 80 | endsnippet 81 | -------------------------------------------------------------------------------- /snippets/ultisnips/coffee.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet fun "Function" b 4 | ${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`-> 5 | ${0:# body...} 6 | endsnippet 7 | 8 | snippet bfun "Function (bound)" i 9 | `!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr} 10 | endsnippet 11 | 12 | snippet if "If" b 13 | if ${1:condition} 14 | ${0:# body...} 15 | endsnippet 16 | 17 | snippet ife "If .. Else" b 18 | if ${1:condition} 19 | ${2:# body...} 20 | else 21 | ${3:# body...} 22 | endsnippet 23 | 24 | snippet elif "Else if" b 25 | else if ${1:condition} 26 | ${0:# body...} 27 | endsnippet 28 | 29 | snippet ifte "Ternary if" b 30 | if ${1:condition} then ${2:value} else ${3:other} 31 | endsnippet 32 | 33 | snippet unl "Unless" b 34 | ${1:action} unless ${2:condition} 35 | endsnippet 36 | 37 | snippet fora "Array Comprehension" b 38 | for ${1:name} in ${2:array} 39 | ${0:# body...} 40 | endsnippet 41 | 42 | snippet foro "Object Comprehension" b 43 | for ${1:key}, ${2:value} of ${3:Object} 44 | ${0:# body...} 45 | endsnippet 46 | 47 | snippet forr "Range Comprehension (inclusive)" b 48 | for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} 49 | ${0:# body...} 50 | endsnippet 51 | 52 | snippet forrex "Range Comprehension (exclusive)" b 53 | for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} 54 | ${0:# body...} 55 | endsnippet 56 | 57 | snippet swi "Switch" b 58 | switch ${1:object} 59 | when ${2:value} 60 | ${3:# body...} 61 | else 62 | $0 63 | endsnippet 64 | 65 | snippet swit "Switch when .. then" b 66 | switch ${1:object} 67 | when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value} 68 | else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value} 69 | endsnippet 70 | 71 | snippet cla "Class" b 72 | class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor} 73 | 74 | ${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` -> 75 | ${5:# body...}} 76 | $0 77 | endsnippet 78 | 79 | snippet try "Try .. Catch" b 80 | try 81 | $1 82 | catch ${2:error} 83 | $3 84 | endsnippet 85 | 86 | snippet req "Require" b 87 | ${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'}) 88 | endsnippet 89 | 90 | snippet # "Interpolated Code" i 91 | #{$1}$0 92 | endsnippet 93 | 94 | snippet log "Log" b 95 | console.log ${1:"${2:msg}"} 96 | endsnippet 97 | 98 | snippet kv "Key:value for object" b 99 | ${1:key}:${2:value} 100 | endsnippet 101 | -------------------------------------------------------------------------------- /snippets/ultisnips/crystal.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet "\b(de)?f" "def ..." r 4 | def ${1:method_name}${2:(${3:*args})} 5 | $0 6 | end 7 | endsnippet 8 | 9 | snippet "\b(pde)?f" "private def ..." r 10 | private def ${1:method_name}${2:(${3:*args})} 11 | $0 12 | end 13 | endsnippet 14 | -------------------------------------------------------------------------------- /snippets/ultisnips/cuda.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends cpp 4 | 5 | # vim:ft=snippets: 6 | -------------------------------------------------------------------------------- /snippets/ultisnips/eelixir.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends html 4 | 5 | snippet % "<% %>" w 6 | <% $0 %> 7 | endsnippet 8 | 9 | snippet = "<%= %>" w 10 | <%= $0 %> 11 | endsnippet 12 | 13 | snippet end "<% end %>" w 14 | <% end %> 15 | endsnippet 16 | 17 | snippet for 18 | <%= for ${1:item} <- ${2:$1s} ${3:@conn} do %> 19 | $0 20 | <% end %> 21 | endsnippet 22 | 23 | snippet ft "form_tag" w 24 | <%= form_tag(${1:"${2:/users}"}, method: ${3::post}) %> 25 | $0 26 | 27 | endsnippet 28 | 29 | snippet lin "link" w 30 | <%= link ${1:"${2:Submit}"}, to: ${3:"${4:/users}"}, method: ${5::delete} %> 31 | endsnippet 32 | 33 | snippet ff "form_for" w 34 | <%= form_for @changeset, ${1:"${2:/users}"}, fn f -> %> 35 | $0 36 | 37 | <%= submit "Submit" %> 38 | <% end %> 39 | endsnippet 40 | 41 | snippet gt "gettext" w 42 | <%= gettext("${0:${VISUAL}}") %> 43 | endsnippet 44 | -------------------------------------------------------------------------------- /snippets/ultisnips/ejs.snippets: -------------------------------------------------------------------------------- 1 | snippet for "ejs for loop" b 2 | <% for (let ${1:i = 0}; ${2:i 3 | ${0:body} 4 | <% } %> 5 | endsnippet 6 | snippet forE "ejs for Each loop" b 7 | <% ${1:array}.forEach((${2:single var}) => { %> 8 | ${0:body} 9 | <% }) %> 10 | endsnippet 11 | -------------------------------------------------------------------------------- /snippets/ultisnips/elm.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet impa "Qualified import" 4 | import ${1:Json.Encode} as ${0:`!p snip.rv = t[1].split(".")[-1]`} 5 | endsnippet 6 | 7 | snippet impae "Qualified import with exposing" 8 | import ${1:Json.Encode} as ${2:`!p snip.rv = t[1].split(".")[-1]`} exposing (${0:Value}) 9 | endsnippet 10 | -------------------------------------------------------------------------------- /snippets/ultisnips/erlang.snippets: -------------------------------------------------------------------------------- 1 | ########################################################################### 2 | # TEXTMATE SNIPPETS # 3 | ########################################################################### 4 | 5 | priority -50 6 | 7 | snippet pat "Case:Receive:Try Clause" 8 | ${1:pattern}${2: when ${3:guard}} -> 9 | ${4:body} 10 | endsnippet 11 | 12 | snippet mod "Module Directive" b 13 | -module(${1:`!p snip.rv = snip.basename or "module"`}). 14 | endsnippet 15 | 16 | snippet || "List Comprehension" 17 | [${1:X} || ${2:X} <- ${3:List}${4:, gen}] 18 | endsnippet 19 | 20 | snippet gen "Generator Expression" 21 | ${1:X} <- ${2:List}${3:, gen} 22 | endsnippet 23 | 24 | # vim:ft=snippets: 25 | -------------------------------------------------------------------------------- /snippets/ultisnips/go.snippets: -------------------------------------------------------------------------------- 1 | # Snippets for Go 2 | 3 | priority -50 4 | 5 | # when to abbriviate and when not? 6 | # b doesn't work here, because it ignores whitespace 7 | # optional local name? 8 | snippet /^import/ "Import declaration" r 9 | import ( 10 | "${1:package}" 11 | ) 12 | endsnippet 13 | 14 | snippet /^package/ "Package declaration" r 15 | // Package $1 provides ... 16 | package ${1:main} 17 | endsnippet 18 | 19 | # Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle 20 | snippet /^cons/ "Constants declaration" r 21 | const ( 22 | ${1:constant}${2/(.+)/ /}${2:type} = ${0:value} 23 | ) 24 | endsnippet 25 | 26 | snippet /^con/ "Constant declaration" r 27 | const ${1:name}${2/(.+)/ /}${2:type} = ${0:value} 28 | endsnippet 29 | 30 | snippet iota "Iota constant generator" b 31 | const ( 32 | ${1:constant}${2/(.+)/ /}${2:type} = iota 33 | ) 34 | endsnippet 35 | 36 | snippet struct "Struct declaration" b 37 | type ${1:Struct} struct { 38 | ${0:${VISUAL}} 39 | } 40 | endsnippet 41 | 42 | snippet interface "Interface declaration" b 43 | type ${1:Interface} interface { 44 | ${0:${VISUAL}} 45 | } 46 | endsnippet 47 | 48 | snippet if "If statement" b 49 | if ${1:condition}${1/(.+)/ /}{ 50 | ${0:${VISUAL}} 51 | } 52 | endsnippet 53 | 54 | snippet switch "Switch statement" b 55 | switch ${1:expression}${1/(.+)/ /}{ 56 | case$0 57 | } 58 | endsnippet 59 | 60 | # functions 61 | snippet /^main/ "Main function" r 62 | func main() { 63 | ${0:${VISUAL}} 64 | } 65 | endsnippet 66 | 67 | snippet /^meth/ "Method" r 68 | func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} { 69 | ${0:${VISUAL}} 70 | } 71 | endsnippet 72 | 73 | snippet func "Function" b 74 | func ${1:name}(${2:params})${3/(.+)/ /}${3:type} { 75 | ${0:${VISUAL}} 76 | } 77 | endsnippet 78 | 79 | snippet funch "HTTP handler" b 80 | func ${1:handler}(${2:w} http.ResponseWriter, ${3:r} *http.Request) { 81 | ${0:${VISUAL}} 82 | } 83 | endsnippet 84 | 85 | # types and variables 86 | snippet map "Map type" b 87 | map[${1:keytype}]${2:valtype} 88 | endsnippet 89 | 90 | snippet : "Variable declaration :=" b 91 | ${1:name} := ${0:value} 92 | endsnippet 93 | 94 | snippet var "Variable declaration" b 95 | var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}} 96 | endsnippet 97 | 98 | snippet vars "Variables declaration" b 99 | var ( 100 | ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} } 101 | ) 102 | endsnippet 103 | 104 | snippet json "JSON field" 105 | \`json:"${1:displayName}"\` 106 | endsnippet 107 | 108 | # vim:ft=snippets: 109 | 110 | # error handling 111 | snippet err "Basic error handling" b 112 | if err != nil { 113 | log.${1:Fatal}(err) 114 | } 115 | endsnippet 116 | -------------------------------------------------------------------------------- /snippets/ultisnips/haskell.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet imp "Simple import" 4 | import ${1:${2:Data}.${0:Text}} 5 | endsnippet 6 | 7 | snippet imp2 "Selective import" b 8 | import ${1:${2:Data}.${3:Text}} (${4})${0} 9 | endsnippet 10 | 11 | snippet impq "Qualified import" 12 | import qualified ${1:${2:Data}.${3:Text}} as ${0:`!p snip.rv = t[1].split(".")[-1]`} 13 | endsnippet 14 | -------------------------------------------------------------------------------- /snippets/ultisnips/help.snippets: -------------------------------------------------------------------------------- 1 | # Snippets for VIM Help Files 2 | 3 | priority -50 4 | 5 | global !p 6 | def sec_title(snip, t): 7 | file_start = snip.fn.split('.')[0] 8 | sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') 9 | return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1])) 10 | endglobal 11 | 12 | snippet sec "Section marker" b 13 | ============================================================================== 14 | ${1:SECTION}`!p snip.rv = sec_title(snip, t)` 15 | 16 | $0 17 | endsnippet 18 | 19 | snippet ssec "Sub section marker" b 20 | ${1:Subsection}`!p snip.rv = sec_title(snip, t) 21 | snip += "-"*len(t[1])` 22 | 23 | $0 24 | endsnippet 25 | 26 | snippet sssec "Subsub Section marker" b 27 | ${1:SubSubsection}:`!p snip.rv = sec_title(snip, t)` 28 | 29 | $0 30 | endsnippet 31 | 32 | # For vim help, follow the same settings as the official docs. 33 | snippet modeline "Vim help modeline" 34 | `!v 'vim'`:tw=78:ts=8:ft=help:norl: 35 | endsnippet 36 | 37 | # vim:ft=snippets: 38 | -------------------------------------------------------------------------------- /snippets/ultisnips/html_minimal.snippets: -------------------------------------------------------------------------------- 1 | # more can be found in snippets/html_minimal.snippets 2 | # these UltiSnips override snippets because nested placeholders are being used 3 | 4 | priority -49 5 | 6 | snippet id 7 | id="$1"$2 8 | endsnippet 9 | 10 | snippet idn 11 | id="$1" name="${2:$1}" 12 | endsnippet 13 | 14 | snippet label_and_input 15 | 16 | $8 17 | endsnippet 18 | 19 | snippet input 20 | $7 21 | endsnippet 22 | 23 | snippet submit 24 | $7 25 | endsnippet 26 | 27 | snippet textarea 28 | 29 | endsnippet 30 | 31 | snippet img 32 | $3 33 | endsnippet 34 | -------------------------------------------------------------------------------- /snippets/ultisnips/htmljinja.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends html, jinja2 4 | -------------------------------------------------------------------------------- /snippets/ultisnips/javascript-angular.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet iti "it (js, inject)" b 4 | it('${1:description}', inject(function($2) { 5 | $0 6 | })); 7 | endsnippet 8 | 9 | snippet befi "before each (js, inject)" b 10 | beforeEach(inject(function($1) { 11 | $0 12 | })); 13 | endsnippet 14 | 15 | snippet aconf "angular config" i 16 | config(function($1) { 17 | $0 18 | }); 19 | endsnippet 20 | 21 | snippet acont "angular controller" i 22 | controller('${1:name}', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 23 | $0 24 | }]); 25 | endsnippet 26 | 27 | snippet aconts "angular controller with scope" i 28 | controller('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 29 | $0 30 | }]); 31 | endsnippet 32 | 33 | snippet adir "angular directive" i 34 | directive('$1', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 35 | return { 36 | restrict: '${3:EA}', 37 | link: function(scope, element, attrs) { 38 | $0 39 | } 40 | }; 41 | }]); 42 | endsnippet 43 | 44 | snippet adirs "angular directive with scope" i 45 | directive('$1', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 46 | return { 47 | restrict: '${3:EA}', 48 | link: function(scope, element, attrs) { 49 | $0 50 | } 51 | }; 52 | }]); 53 | endsnippet 54 | 55 | snippet afact "angular factory" i 56 | factory('${1:name}', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 57 | $0 58 | }]); 59 | endsnippet 60 | 61 | snippet afacts "angular factory with scope" i 62 | factory('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 63 | $0 64 | }]); 65 | endsnippet 66 | 67 | snippet aserv "angular service" i 68 | service('${1:name}', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 69 | $0 70 | }]); 71 | endsnippet 72 | 73 | snippet aservs "angular service" i 74 | service('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { 75 | $0 76 | }]); 77 | endsnippet 78 | -------------------------------------------------------------------------------- /snippets/ultisnips/javascript-ember.snippets: -------------------------------------------------------------------------------- 1 | ################################################################### 2 | # Ember snippets # 3 | ################################################################### 4 | 5 | priority -50 6 | 7 | # Application 8 | snippet eapp "App.Name = Ember.Application.create({});" 9 | import Application from '@ember/application'; 10 | 11 | export default Application.extend({ 12 | ${0://Properties here...} 13 | }); 14 | endsnippet 15 | 16 | # Models 17 | snippet emod "import DS from 'ember-data';" 18 | import DS from 'ember-data'; 19 | 20 | export default DS.Model.extend({ 21 | ${0://Properties here...} 22 | }); 23 | endsnippet 24 | 25 | # Controller 26 | snippet econtroller "import Controller from '@ember/controller';" 27 | import Controller from '@ember/controller'; 28 | 29 | export default Controller.extend({ 30 | ${0://Properties here...} 31 | }); 32 | endsnippet 33 | 34 | # Route 35 | snippet eroute "import Route from '@ember/routing/route';" 36 | import Route from '@ember/routing/route'; 37 | 38 | export default Route.extend({ 39 | ${0://Properties here...} 40 | }); 41 | endsnippet 42 | 43 | # Component 44 | snippet ecomponent "import Component from '@ember/component';" 45 | import Component from '@ember/component'; 46 | 47 | export default Component.extend({ 48 | ${0://Properties here...} 49 | }); 50 | endsnippet 51 | 52 | # Object 53 | snippet eobj "import EmberObject from '@ember/object';" 54 | import EmberObject from '@ember/object'; 55 | 56 | export default EmberObject.extend({ 57 | ${0://Properties here...} 58 | }); 59 | endsnippet 60 | 61 | # Mixin 62 | snippet emix "App.MixinName = Ember.Model.extend({...});" 63 | import Mixin from '@ember/object/mixin'; 64 | 65 | export default Mixin.create({ 66 | ${0://Properties here...} 67 | }); 68 | endsnippet 69 | 70 | # Ember getter and setter 71 | snippet eget "this.get('property');" 72 | ${1:this}.get('${2:property}'); 73 | endsnippet 74 | 75 | snippet eset "this.set('property', value);" 76 | ${1:this}.set('${2:property}', ${3:value}); 77 | endsnippet 78 | 79 | # Computed properties 80 | snippet cproimport "import { computed } from '@ember/object';" 81 | import { computed } from '@ember/object'; 82 | endsnippet 83 | 84 | snippet cpro "property_name: computed('...', function() {...})," 85 | ${1:property_name}: computed('${3:argument}', function() { 86 | ${0://body...} 87 | }), 88 | endsnippet 89 | 90 | # Observers 91 | snippet prooimport "import { observer } from '@ember/object';" 92 | import { observer } from '@ember/object'; 93 | endsnippet 94 | 95 | snippet proo "property_name: observer('...', function() {...})," 96 | ${1:property_name}: observer('${3:argument}', function() { 97 | ${0://body...} 98 | }), 99 | endsnippet 100 | 101 | # vim:ft=snippets: 102 | -------------------------------------------------------------------------------- /snippets/ultisnips/javascript-jasmine-arrow.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | # JavaScript versions -- from the TextMate bundle + some additions 4 | # for jasmine-jquery matchers 5 | # 6 | 7 | snippet des "Describe (js)" b 8 | describe('${1:description}', () => { 9 | $0 10 | }); 11 | endsnippet 12 | 13 | snippet it "it (js)" b 14 | it('${1:description}', () => { 15 | $0 16 | }); 17 | endsnippet 18 | 19 | snippet bef "before each (js)" b 20 | beforeEach(() => { 21 | $0 22 | }); 23 | endsnippet 24 | 25 | snippet aft "after each (js)" b 26 | afterEach(() => { 27 | $0 28 | }); 29 | endsnippet 30 | 31 | snippet befa "before all (js)" b 32 | beforeAll(() => { 33 | $0 34 | }); 35 | endsnippet 36 | 37 | snippet afta "after all (js)" b 38 | afterAll(() => { 39 | $0 40 | }); 41 | endsnippet 42 | 43 | snippet ru "runs (js)" b 44 | runs(() => { 45 | $0 46 | }); 47 | endsnippet 48 | 49 | -------------------------------------------------------------------------------- /snippets/ultisnips/javascript-jsdoc.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | # JSDoc snippets 4 | 5 | snippet /* "A JSDoc comment" b 6 | /** 7 | * ${1:${VISUAL}}$0 8 | */ 9 | endsnippet 10 | 11 | snippet @au "@author email (First Last)" 12 | @author ${1:`!v g:snips_author`} [${2:`!v g:snips_author_email`}] 13 | endsnippet 14 | 15 | snippet @li "@license Description" 16 | @license ${1:MIT}$0 17 | endsnippet 18 | 19 | snippet @ver "@version Semantic version" 20 | @version ${1:0.1.0}$0 21 | endsnippet 22 | 23 | snippet @fileo "@fileoverview Description" b 24 | /** 25 | * @fileoverview ${1:${VISUAL:A description of the file}}$0 26 | */ 27 | endsnippet 28 | 29 | snippet @constr "@constructor" 30 | @constructor 31 | endsnippet 32 | 33 | snippet @p "@param {Type} varname Description" 34 | @param {${1:Type}} ${2:varname} ${3:Description} 35 | endsnippet 36 | 37 | snippet @ret "@return {Type} Description" 38 | @return {${1:Type}} ${2:Description} 39 | endsnippet 40 | 41 | snippet @pri "@private" 42 | @private 43 | endsnippet 44 | 45 | snippet @over "@override" 46 | @override 47 | endsnippet 48 | 49 | snippet @pro "@protected" 50 | @protected 51 | endsnippet 52 | -------------------------------------------------------------------------------- /snippets/ultisnips/javascript-node.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet #! "#!/usr/bin/env node" b 4 | #!/usr/bin/env node 5 | endsnippet 6 | 7 | snippet vreq "assign a CommonJS-style module to a var" 8 | var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('$1'); 9 | endsnippet 10 | 11 | snippet ex "module.exports" 12 | module.exports = $1; 13 | endsnippet 14 | 15 | snippet hcs "http.createServer" 16 | http.createServer($1).listen($2); 17 | endsnippet 18 | 19 | snippet ncs "net.createServer" 20 | net.createServer(function(${1:socket}){ 21 | $1.on('data', function(${3:data}){ 22 | $4 23 | }); 24 | $1.on('end', function(){ 25 | $5 26 | }); 27 | }).listen(${6:8124}); 28 | endsnippet 29 | 30 | snippet pipe "pipe" 31 | pipe(${1:stream})$2 32 | endsnippet 33 | 34 | # Express snippets 35 | 36 | snippet eget "express GET" 37 | ${1:app}.get('$2', $3); 38 | endsnippet 39 | 40 | snippet epost "express POST" 41 | ${1:app}.post('$2', $3); 42 | endsnippet 43 | 44 | snippet eput "express PUT" 45 | ${1:app}.put('$2', $3); 46 | endsnippet 47 | 48 | snippet edelete "express DELETE" 49 | ${1:app}.delete('$2', $3); 50 | endsnippet 51 | 52 | # process snippets 53 | 54 | snippet stdout "stdout" 55 | process.stdout 56 | endsnippet 57 | 58 | snippet stdin "stdin" 59 | process.stdin 60 | endsnippet 61 | 62 | snippet stderr "stderr" 63 | process.stderr 64 | endsnippet 65 | 66 | -------------------------------------------------------------------------------- /snippets/ultisnips/javascript_react.snippets: -------------------------------------------------------------------------------- 1 | global !p 2 | # Capitalize the first letter without affecting the rest of the letters 3 | def capitalize_first(word): 4 | if(word): 5 | word = word[0].upper() + word[1:] 6 | return word 7 | endglobal 8 | 9 | # Functional components 10 | snippet rfc_react "react functional component" b 11 | import React, {useState} from "react" 12 | 13 | function ${1:`!p snip.rv = snip.basename`}(${2}){ 14 | return( 15 |
16 | ${3:

Body

} 17 |
18 | ) 19 | } 20 | 21 | export default $4`!p snip.rv = snip.basename` 22 | endsnippet 23 | # React Hooks 24 | snippet useS "useState Hook" b 25 | const [${1}, set`!p snip.rv=capitalize_first(t[1])`] = useState(${3:"${4}"}) 26 | endsnippet 27 | snippet useE "useEffect Hook" b 28 | useEffect(() => { 29 | ${1:${0}} 30 | }${2}) 31 | endsnippet 32 | snippet useC "useContext Hook" b 33 | const ${1:context} = useContext(${2}) 34 | endsnippet 35 | snippet useRe "useReducer Hook" b 36 | const [${3:state}, ${4:dispatch}] = useReducer(${5:reducer}, ${2:initial_value}) 37 | endsnippet 38 | snippet useCB "useCallback(fn, inputs)" b 39 | const ${1:callback} = useCallback((${2})) => ${3:{ 40 | ${4} 41 | }}, [${5}]) 42 | endsnippet 43 | snippet useM "useMemo(fn, inputs)" b 44 | const ${1:memorized} = useMemo(() => ${2:{ 45 | ${3} 46 | }}, [${4}]) 47 | endsnippet 48 | snippet useR "useRef(defaultValue)" b 49 | const ${1:ref} = useRef(${2:null}) 50 | endsnippet 51 | snippet ir_react "import React" 52 | import React from "react" 53 | endsnippet 54 | snippet irc_react "import React and Component" 55 | import React, { Component } from "react" 56 | endsnippet 57 | -------------------------------------------------------------------------------- /snippets/ultisnips/jinja2.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | # http://jinja.pocoo.org/ 4 | 5 | # jinja2 is a full featured template engine for Python. It has full 6 | # unicode support, an optional integrated sandboxed execution 7 | # environment, widely used and BSD licensed. 8 | 9 | # possible extends: 10 | #extends html 11 | 12 | 13 | snippet block "block" b 14 | {% block ${1:name} %} 15 | $2 16 | {% endblock $1 %} 17 | endsnippet 18 | 19 | 20 | snippet {{ "variable" b 21 | {{ $1 }} 22 | endsnippet 23 | 24 | 25 | snippet {# "comment" b 26 | {# $1 #} 27 | endsnippet 28 | 29 | 30 | snippet # "comment" b 31 | {# $1 #} 32 | endsnippet 33 | 34 | 35 | snippet raw "escaped block" b 36 | {% raw %} 37 | $1 38 | {% endraw %} 39 | endsnippet 40 | 41 | 42 | snippet extends "extends" b 43 | {% extends "${1:template}" %} 44 | endsnippet 45 | 46 | 47 | snippet include "include" b 48 | {% include "${1:template}" %} 49 | endsnippet 50 | 51 | 52 | snippet import "import" b 53 | {% import "${1:template}" %} 54 | endsnippet 55 | 56 | 57 | snippet from "from/import/as" b 58 | {% from "${1:template}" import ${2:name}${3: as ${4:$2}} %} 59 | endsnippet 60 | 61 | 62 | snippet filter "filter" b 63 | {% filter ${1:filter} %} 64 | $2 65 | {% endfilter %} 66 | endsnippet 67 | 68 | 69 | # Being able to quickly remove the whole 'else' block seems faster to me than 70 | # choosing between 'for' and 'for/else' snippets from the menu. 71 | # snippet for "for" b 72 | # {% for ${1:item} in ${2:sequence} %} 73 | # $3${4: 74 | # {% else %} 75 | # $5} 76 | # {% endfor %} 77 | # endsnippet 78 | 79 | 80 | snippet for "for" b 81 | {% for ${1:item} in ${2:sequence} %} 82 | $3 83 | {% endfor %} 84 | endsnippet 85 | 86 | 87 | snippet for "for/else" b 88 | {% for ${1:item} in ${2:sequence} %} 89 | $3 90 | {% else %} 91 | $4 92 | {% endfor %} 93 | endsnippet 94 | 95 | 96 | snippet if "if" b 97 | {% if ${1:expr} %} 98 | $2 99 | {% endif %} 100 | endsnippet 101 | 102 | 103 | snippet if "if/else" b 104 | {% if ${1:expr} %} 105 | $2 106 | {% else %} 107 | $3 108 | {% endif %} 109 | endsnippet 110 | 111 | 112 | snippet if "if/elif/else" b 113 | {% if ${1:expr} %} 114 | $2 115 | {% elif %} 116 | $3 117 | {% else %} 118 | $4 119 | {% endif %} 120 | endsnippet 121 | 122 | 123 | snippet macro "macro" b 124 | {% macro ${1:name}(${2:args}) %} 125 | $3 126 | {% endmacro %} 127 | endsnippet 128 | 129 | 130 | snippet call "call" b 131 | {% call ${1:name}(${2:args}) %} 132 | $3 133 | {% endcall %} 134 | endsnippet 135 | 136 | 137 | snippet set "set" b 138 | {% set ${1:name} = ${2:'value'} %} 139 | endsnippet 140 | 141 | 142 | snippet trans "translation" b 143 | {% trans %} 144 | $1 145 | {% endtrans %} 146 | endsnippet 147 | 148 | 149 | snippet with "with" b 150 | {% with %} 151 | $1 152 | {% endwith %} 153 | endsnippet 154 | 155 | snippet autoescape "autoescape" b 156 | {% autoescape ${1:true} %} 157 | $2 158 | {% endautoescape %} 159 | endsnippet 160 | 161 | # Filters 162 | # @todo: expand only when snippet is preceeded by a | 163 | 164 | snippet batch "batch items" w 165 | batch(linecount=$1, fill_with=${2:None}) 166 | endsnippet 167 | 168 | 169 | snippet dictsort "sort and yield (key, value) pairs" w 170 | dictsort(case_sensitive=${1:False}, by=${2:'key'}) 171 | endsnippet 172 | 173 | 174 | snippet round "round number" w 175 | round(precision=${1:0}, method=${2:'common|ceil|floor'}) 176 | endsnippet 177 | 178 | 179 | snippet urlize "convert plain-text url to " w 180 | urlize(trim_url_limit=${1:None}, nofollow=${2:False}) 181 | endsnippet 182 | 183 | 184 | snippet wordwrap "wordwrap" w 185 | wordwrap(width=${1:79}, break_long_words=${2:True}) 186 | endsnippet 187 | 188 | 189 | snippet truncate "truncate" w 190 | truncate(lenght=${1:79}, killwords=${2:False}, end=${3:'...''}) 191 | endsnippet 192 | 193 | 194 | snippet sum "sum of sequence of numbers + start" w 195 | sum(attribute=${1:None}, start=${2:0}) 196 | endsnippet 197 | 198 | 199 | snippet sort "sort an iterable" w 200 | sort(reverse=${1:False}, case_sensitive=${2:False}, attribute=${3:None}) 201 | endsnippet 202 | 203 | 204 | snippet indent "indent" w 205 | indent(width=${1:4}, indentfirst=${2:False}) 206 | endsnippet 207 | 208 | 209 | # vim:ft=snippets: 210 | -------------------------------------------------------------------------------- /snippets/ultisnips/json.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet s "String" b 4 | "${1:key}": "${0:value}", 5 | endsnippet 6 | 7 | snippet n "Number" b 8 | "${1:key}": ${0:value}, 9 | endsnippet 10 | 11 | snippet a "Array" b 12 | [ 13 | ${VISUAL}$0 14 | ], 15 | endsnippet 16 | 17 | snippet na "Named array" b 18 | "${1:key}": [ 19 | ${VISUAL}$0 20 | ], 21 | endsnippet 22 | 23 | snippet o "Object" b 24 | { 25 | ${VISUAL}$0 26 | }, 27 | endsnippet 28 | 29 | snippet no "Named object" b 30 | "${1:key}": { 31 | ${VISUAL}$0 32 | }, 33 | endsnippet 34 | 35 | snippet null "Null" b 36 | "${0:key}": null, 37 | endsnippet 38 | 39 | 40 | global !p 41 | def compB(t, opts): 42 | if t: 43 | opts = [m[len(t):] for m in opts if m.startswith(t)] 44 | if len(opts) == 1: 45 | return opts[0] 46 | return "(" + '|'.join(opts) + ')' 47 | endglobal 48 | 49 | snippet b "Bool" b 50 | "${1:key}": $2`!p snip.rv=compB(t[2], ['true', 'false'])`, 51 | endsnippet 52 | -------------------------------------------------------------------------------- /snippets/ultisnips/julia.snippets: -------------------------------------------------------------------------------- 1 | # Documentation 2 | snippet docf "function documentation" b 3 | #' @description 4 | #' 5 | #' ${1:function description} 6 | #' 7 | #' ${2:@param ${3:name}::${4:Type} ${5:Description}} 8 | #' 9 | #' ${6:@returns ${7:name}::${8:Type} ${9:Description}} 10 | #' 11 | #' @examples 12 | #' 13 | #' ${10: function call examples} 14 | endsnippet 15 | 16 | snippet doct "type definition" b 17 | #' @description 18 | #' 19 | #' ${1:type description} 20 | #' 21 | #' ${2:@field ${3:name}::${4:Type} ${5:Description}} 22 | #' 23 | #' @examples 24 | #' 25 | #' ${10: constructor examples} 26 | endsnippet 27 | 28 | snippet par "function parameter documentation" b 29 | #' @param ${1:name}::${2:Type} ${0:Description} 30 | endsnippet 31 | 32 | snippet fld "type field documentation" b 33 | #' @field ${1:name}::${2:Type} ${0:Description} 34 | endsnippet 35 | 36 | # Debugging 37 | snippet deb "Debugger breakpoint" b 38 | Main.@bp 39 | endsnippet 40 | 41 | snippet inf "Infiltrator breakpoint" b 42 | Main.@infiltrate 43 | endsnippet 44 | -------------------------------------------------------------------------------- /snippets/ultisnips/ledger.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet t "Transaction" b 4 | ${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee} 5 | ${6:Expenses} \$${7:0.00} 6 | ${8:Assets:Checking}$0 7 | endsnippet 8 | -------------------------------------------------------------------------------- /snippets/ultisnips/lhaskell.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends haskell 4 | -------------------------------------------------------------------------------- /snippets/ultisnips/lua.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | ################################# 4 | # Snippets for the Lua language # 5 | ################################# 6 | snippet #! "#!/usr/bin/env lua" b 7 | #!/usr/bin/env lua 8 | $0 9 | endsnippet 10 | 11 | snippet assert "Assertion" b 12 | assert(${1:condition}`!p 13 | if t[2]: 14 | snip.rv = ", " 15 | else: 16 | snip.rv = "" 17 | `${2:msg}) 18 | endsnippet 19 | 20 | snippet !fun(ction)?! "New function" br 21 | function ${1:new_function}(${2:args}) 22 | $0 23 | end 24 | endsnippet 25 | 26 | snippet forp "pair for loop" b 27 | for ${1:name},${2:val} in pairs(${3:table_name}) do 28 | $0 29 | end 30 | endsnippet 31 | 32 | snippet fori "ipair for foop" b 33 | for ${1:idx},${2:val} in ipairs(${3:table_name}) do 34 | $0 35 | end 36 | endsnippet 37 | 38 | snippet for "numeric for loop" b 39 | for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do 40 | $0 41 | end 42 | endsnippet 43 | 44 | snippet do "do block" 45 | do 46 | $0 47 | end 48 | endsnippet 49 | 50 | snippet repeat "repeat loop" b 51 | repeat 52 | $1 53 | until $0 54 | endsnippet 55 | 56 | snippet while "while loop" b 57 | while $1 do 58 | $0 59 | end 60 | endsnippet 61 | 62 | snippet if "if statement" b 63 | if $1 then 64 | $0 65 | end 66 | endsnippet 67 | 68 | snippet ife "if/else statement" b 69 | if $1 then 70 | $2 71 | else 72 | $0 73 | end 74 | endsnippet 75 | 76 | snippet eif "if/elseif statement" b 77 | if $1 then 78 | $2 79 | elseif $3 then 80 | $0 81 | end 82 | endsnippet 83 | 84 | snippet eife "if/elseif/else statement" b 85 | if $1 then 86 | $2 87 | elseif $3 then 88 | $4 89 | else 90 | $0 91 | end 92 | endsnippet 93 | 94 | snippet pcall "pcall statement" b 95 | local ok, err = pcall(${1:your_function}) 96 | if not ok then 97 | handler(${2:ok, err}) 98 | ${3:else 99 | success(${4:ok, err}) 100 | }end 101 | endsnippet 102 | 103 | snippet local "local x = 1" 104 | local ${1:x} = ${0:1} 105 | endsnippet 106 | 107 | snippet use "Use" Ab 108 | use { '$1' } 109 | endsnippet 110 | 111 | snippet req "Require" 112 | require('$1') 113 | endsnippet 114 | 115 | 116 | # vim:ft=snippets: 117 | -------------------------------------------------------------------------------- /snippets/ultisnips/mako.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | ################# 4 | # From snipmate # 5 | ################# 6 | snippet def "definition" b 7 | <%def name="${1:name}"> 8 | ${2:} 9 | 10 | endsnippet 11 | 12 | snippet call "call" b 13 | <%call expr="${1:name}"> 14 | ${2:} 15 | 16 | endsnippet 17 | 18 | snippet doc "doc" b 19 | <%doc> 20 | ${1:} 21 | 22 | endsnippet 23 | 24 | snippet text "text" b 25 | <%text> 26 | ${1:} 27 | 28 | endsnippet 29 | 30 | snippet for "for" b 31 | % for ${1:i} in ${2:iter}: 32 | ${3:} 33 | % endfor 34 | endsnippet 35 | 36 | snippet if "if " b 37 | % if ${1:condition}: 38 | ${2:} 39 | % endif 40 | endsnippet 41 | 42 | snippet if "if/else" b 43 | % if ${1:condition}: 44 | ${2:} 45 | % else: 46 | ${3:} 47 | % endif 48 | endsnippet 49 | 50 | snippet try "try" b 51 | % try: 52 | ${1:} 53 | % except${2:}: 54 | ${3:pass} 55 | % endtry 56 | endsnippet 57 | 58 | snippet wh "wh" b 59 | % while ${1:}: 60 | ${2:} 61 | % endwhile 62 | endsnippet 63 | 64 | snippet $ "$" i 65 | ${${1:}} 66 | endsnippet 67 | 68 | snippet <% "<%" b 69 | <% ${1:} %> 70 | endsnippet 71 | 72 | snippet 74 | endsnippet 75 | 76 | snippet inherit "inherit" b 77 | <%inherit file="${1:filename}" /> 78 | endsnippet 79 | 80 | snippet include "include" b 81 | <%include file="${1:filename}" /> 82 | endsnippet 83 | 84 | snippet namespace "namespace" b 85 | <%namespace file="${1:name}" /> 86 | endsnippet 87 | 88 | snippet page "page" b 89 | <%page args="${1:}" /> 90 | endsnippet 91 | 92 | # vim:ft=snippets: 93 | -------------------------------------------------------------------------------- /snippets/ultisnips/markdown.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | global !p 4 | # A overkill(dirty) table with automatic alignment feature 5 | def create_table(snip): 6 | # retrieving single line from current string and treat it like tabstops count 7 | placeholders_string = snip.buffer[snip.line].strip() 8 | rows_amount = int(placeholders_string[0]) 9 | columns_amount = int(placeholders_string[1]) 10 | 11 | prefix_str = "from EasyCompleteUtil.vimsnippets import display_width;" 12 | 13 | # erase current line 14 | snip.buffer[snip.line] = "" 15 | 16 | # create anonymous snippet with expected content and number of tabstops 17 | anon_snippet_title = "| " 18 | anon_snippet_delimiter = "|" 19 | for col in range(1, columns_amount+1): 20 | sync_rows = [x*columns_amount+col for x in range(rows_amount+1)] 21 | sync_str = ",".join(["t[{0}]".format(x) for x in sync_rows]) 22 | max_width_str = "max(list(map(display_width, [" + sync_str + "])))" 23 | cur_width_str = "display_width(t[" + str(col) + "])" 24 | rv_val = "(" + max_width_str + "-" + cur_width_str + ")*' '" 25 | anon_snippet_title += "${" + str(col) + ":head" + str(col)\ 26 | + "}`!p " + prefix_str + "snip.rv=" + rv_val + "` | " 27 | anon_snippet_delimiter += ":`!p " + prefix_str + "snip.rv = "\ 28 | + max_width_str + "*'-'" + "`-|" 29 | 30 | anon_snippet_title += "\n" 31 | 32 | anon_snippet_delimiter += "\n" 33 | anon_snippet_body = "" 34 | for row in range(1, rows_amount+1): 35 | body_row = "| " 36 | for col in range(1, columns_amount+1): 37 | sync_rows = [x*columns_amount+col for x in range(rows_amount+1)] 38 | sync_str = ",".join(["t[{0}]".format(x) for x in sync_rows]) 39 | max_width_str = "max(list(map(display_width, [" + sync_str + "])))" 40 | cur_width_str = "display_width(t[" + str(row*columns_amount+col) + "])" 41 | rv_val = "(" + max_width_str + "-" + cur_width_str + ")*' '" 42 | placeholder = "R{0}C{1}".format(row, col) 43 | body_row += "${" + str(row*columns_amount+col) + ":" + placeholder\ 44 | + "}`!p " + prefix_str + "snip.rv=" + rv_val + "` | " 45 | 46 | body_row += "\n" 47 | anon_snippet_body += body_row 48 | 49 | anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body 50 | 51 | # expand anonymous snippet 52 | snip.expand_anon(anon_snippet_table) 53 | endglobal 54 | 55 | ########################### 56 | # Sections and Paragraphs # 57 | ########################### 58 | snippet sec "Section" b 59 | # ${1:Section Name} # 60 | $0 61 | endsnippet 62 | 63 | snippet ssec "Sub Section" b 64 | ## ${1:Section Name} ## 65 | $0 66 | endsnippet 67 | 68 | snippet sssec "SubSub Section" b 69 | ### ${1:Section Name} ### 70 | $0 71 | endsnippet 72 | 73 | snippet par "Paragraph" b 74 | #### ${1:Paragraph Name} #### 75 | $0 76 | endsnippet 77 | 78 | snippet spar "Paragraph" b 79 | ##### ${1:Paragraph Name} ##### 80 | $0 81 | endsnippet 82 | 83 | ################### 84 | # Text formatting # 85 | ################### 86 | 87 | snippet * "italics" 88 | *${1:${VISUAL}}*$0 89 | endsnippet 90 | 91 | snippet ** "bold" 92 | **${1:${VISUAL}}**$0 93 | endsnippet 94 | 95 | snippet *** "bold italics" 96 | ***${1:${VISUAL}}***$0 97 | endsnippet 98 | 99 | snippet /* "Comment" 100 | $0 101 | endsnippet 102 | 103 | ################ 104 | # Common stuff # 105 | ################ 106 | snippet link "Link to something" 107 | [${1:${VISUAL:Text}}](${3:https://${2:www.url.com}})$0 108 | endsnippet 109 | 110 | snippet img "Image" 111 | ![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0 112 | endsnippet 113 | 114 | snippet ilc "Inline Code" i 115 | \`${1:${VISUAL}}\`$0 116 | endsnippet 117 | 118 | snippet cbl "Codeblock" b 119 | \`\`\`$1 120 | ${2:${VISUAL}} 121 | \`\`\` 122 | $0 123 | endsnippet 124 | 125 | snippet refl "Reference Link" 126 | [${1:${VISUAL:Text}}][${2:id}]$0 127 | 128 | [$2]:${4:https://${3:www.url.com}} "${5:$4}" 129 | endsnippet 130 | 131 | snippet fnt "Footnote" 132 | [^${1:${VISUAL:Footnote}}]$0 133 | 134 | [^$1]:${2:Text} 135 | endsnippet 136 | 137 | snippet detail "Disclosure" 138 | 139 | ${1:${2}}$0 140 | 141 | endsnippet 142 | 143 | post_jump "create_table(snip)" 144 | snippet "tb([1-9][1-9])" "Fancy table" br 145 | `!p snip.rv = match.group(1)` 146 | endsnippet 147 | 148 | # vim:ft=snippets: 149 | -------------------------------------------------------------------------------- /snippets/ultisnips/matlab.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet switch "switch ... otherwise" 4 | switch ${1:n} 5 | case ${2:0} 6 | ${3}${4: 7 | otherwise 8 | ${5}} 9 | end 10 | endsnippet 11 | 12 | snippet clc "class with constructor" b 13 | classdef ${1:`!p 14 | snip.rv = snip.basename or "class_name"`} 15 | properties 16 | ${2} 17 | end 18 | methods 19 | function obj = $1(${3}) 20 | ${4} 21 | end${0} 22 | end 23 | end 24 | endsnippet 25 | -------------------------------------------------------------------------------- /snippets/ultisnips/ocaml.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet rs "raise" b 4 | raise (${1:Not_found}) 5 | endsnippet 6 | 7 | snippet open "open" 8 | let open ${1:module} in 9 | ${2:e} 10 | endsnippet 11 | 12 | snippet try "try" 13 | try ${1:e} 14 | with ${2:Not_found} -> ${3:()} 15 | endsnippet 16 | 17 | snippet ref "ref" 18 | let ${1:name} = ref ${2:val} in 19 | ${3:e} 20 | endsnippet 21 | 22 | snippet matchl "pattern match on a list" 23 | match ${1:list} with 24 | | [] -> ${2:()} 25 | | x::xs -> ${3:()} 26 | endsnippet 27 | 28 | snippet matcho "pattern match on an option type" 29 | match ${1:x} with 30 | | Some(${2:y}) -> ${3:()} 31 | | None -> ${4:()} 32 | endsnippet 33 | 34 | snippet fun "anonymous function" 35 | (fun ${1:x} -> ${2:x}) 36 | endsnippet 37 | 38 | snippet cc "commment" 39 | (* ${1:comment} *) 40 | endsnippet 41 | 42 | snippet let "let .. in binding" 43 | let ${1:x} = ${2:v} in 44 | ${3:e} 45 | endsnippet 46 | 47 | snippet lr "let rec" 48 | let rec ${1:f} = 49 | ${2:expr} 50 | endsnippet 51 | 52 | snippet if "if" 53 | if ${1:(* condition *)} then 54 | ${2:(* A *)} 55 | else 56 | ${3:(* B *)} 57 | endsnippet 58 | 59 | snippet If "If" 60 | if ${1:(* condition *)} then 61 | ${2:(* A *)} 62 | endsnippet 63 | 64 | snippet while "while" 65 | while ${1:(* condition *)} do 66 | ${2:(* A *)} 67 | done 68 | endsnippet 69 | 70 | snippet for "for" 71 | for ${1:i} = ${2:1} to ${3:10} do 72 | ${4:(* BODY *)} 73 | done 74 | endsnippet 75 | 76 | snippet match "match" 77 | match ${1:(* e1 *)} with 78 | | ${2:p} -> ${3:e2} 79 | endsnippet 80 | 81 | snippet Match "match" 82 | match ${1:(* e1 *)} with 83 | | ${2:p} -> ${3:e2} 84 | endsnippet 85 | 86 | snippet class "class" 87 | class ${1:name} = object 88 | ${2:methods} 89 | end 90 | endsnippet 91 | 92 | snippet obj "obj" 93 | object 94 | ${2:methods} 95 | end 96 | endsnippet 97 | 98 | snippet Obj "object" 99 | object (self) 100 | ${2:methods} 101 | end 102 | endsnippet 103 | 104 | snippet {{ "object functional update" 105 | {< ${1:x} = ${2:y} >} 106 | endsnippet 107 | 108 | snippet beg "beg" 109 | begin 110 | ${1:block} 111 | end 112 | endsnippet 113 | 114 | snippet ml "module instantiantion with functor" 115 | module ${1:Mod} = ${2:Functor}(${3:Arg}) 116 | endsnippet 117 | 118 | snippet mod "module - no signature" 119 | module ${1:(* Name *)} = struct 120 | ${2:(* BODY *)} 121 | end 122 | endsnippet 123 | 124 | snippet Mod "module with signature" 125 | module ${1:(* Name *)} : ${2:(* SIG *)} = struct 126 | ${3:(* BODY *)} 127 | end 128 | endsnippet 129 | 130 | snippet sig "anonymous signature" 131 | sig 132 | ${2:(* BODY *)} 133 | end 134 | endsnippet 135 | 136 | snippet sigf "functor signature or anonymous functor" 137 | functor (${1:Arg} : ${2:ARG}) -> ${3:(* BODY *)} 138 | endsnippet 139 | 140 | snippet func "define functor - no signature" 141 | module ${1:M} (${2:Arg} : ${3:ARG}) = struct 142 | ${4:(* BODY *)} 143 | end 144 | endsnippet 145 | 146 | snippet Func "define functor - with signature" 147 | module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct 148 | ${5:(* BODY *)} 149 | end 150 | endsnippet 151 | 152 | snippet mot "Declare module signature" 153 | module type ${1:(* Name *)} = sig 154 | ${2:(* BODY *)} 155 | end 156 | endsnippet 157 | 158 | snippet module "Module with anonymous signature" 159 | module ${1:(* Name *)} : sig 160 | ${2:(* SIGNATURE *)} 161 | end = struct 162 | ${3:(* BODY *)} 163 | end 164 | endsnippet 165 | 166 | snippet oo "odoc" 167 | (** ${1:odoc} *) 168 | endsnippet 169 | 170 | snippet qt "inline qtest" 171 | (*$T ${1:name} 172 | ${2:test} 173 | *) 174 | endsnippet 175 | -------------------------------------------------------------------------------- /snippets/ultisnips/octave.snippets: -------------------------------------------------------------------------------- 1 | extends matlab 2 | 3 | -------------------------------------------------------------------------------- /snippets/ultisnips/pandoc.snippets: -------------------------------------------------------------------------------- 1 | extends markdown 2 | 3 | # overwrite if necessary 4 | priority -49 5 | 6 | snippet title "Title Header" b 7 | % ${1:`!v easycomplete#Filename('$1', 'title')`} 8 | % ${2:`!v g:snips_author`} 9 | % ${3:`!v strftime("%d %B %Y")`} 10 | 11 | $0 12 | endsnippet 13 | -------------------------------------------------------------------------------- /snippets/ultisnips/perl.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | ########################################################################### 4 | # TextMate Snippets # 5 | ########################################################################### 6 | snippet ife "Conditional if..else (ife)" 7 | if ($1) { 8 | ${2:# body...} 9 | } 10 | else { 11 | ${3:# else...} 12 | } 13 | 14 | endsnippet 15 | 16 | snippet ifee "Conditional if..elsif..else (ifee)" 17 | if ($1) { 18 | ${2:# body...} 19 | } 20 | elsif ($3) { 21 | ${4:# elsif...} 22 | } 23 | else { 24 | ${5:# else...} 25 | } 26 | 27 | endsnippet 28 | 29 | snippet xunless "Conditional one-line (unless)" 30 | ${1:expression} unless ${2:condition}; 31 | 32 | endsnippet 33 | 34 | snippet xif "Conditional one-line (xif)" 35 | ${1:expression} if ${2:condition}; 36 | 37 | endsnippet 38 | 39 | snippet sub "Function (sub)" 40 | sub ${1:function_name} { 41 | ${2:# body...} 42 | } 43 | 44 | endsnippet 45 | 46 | snippet xfore "Loop one-line (xforeach)" 47 | ${1:expression} foreach @${2:array}; 48 | 49 | endsnippet 50 | 51 | snippet xwhile "Loop one-line (xwhile)" 52 | ${1:expression} while ${2:condition}; 53 | 54 | endsnippet 55 | 56 | snippet test "Test" 57 | #!/usr/bin/env perl -w 58 | 59 | use strict; 60 | use Test::More tests => ${1:1}; 61 | use ${2:ModuleName}; 62 | 63 | ok(${3:assertion}); 64 | 65 | endsnippet 66 | 67 | snippet class "class" 68 | package ${1:ClassName}; 69 | 70 | ${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new { 71 | my $class = shift; 72 | $class = ref $class if ref $class; 73 | my $self = bless {}, $class; 74 | $self; 75 | } 76 | 77 | 1; 78 | 79 | endsnippet 80 | 81 | snippet eval "eval" 82 | local $@; 83 | eval { 84 | ${1:# do something risky...} 85 | }; 86 | if (my $${2:exception} = $@) { 87 | ${3:# handle failure...} 88 | } 89 | 90 | endsnippet 91 | 92 | snippet for "for" 93 | for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) { 94 | ${3:# body...} 95 | } 96 | 97 | endsnippet 98 | 99 | snippet fore "foreach" 100 | foreach ${1:my $${2:x}} (@${3:array}) { 101 | ${4:# body...} 102 | } 103 | 104 | endsnippet 105 | 106 | snippet if "if" 107 | if ($1) { 108 | ${2:# body...} 109 | } 110 | 111 | endsnippet 112 | 113 | snippet slurp "slurp" 114 | my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> }; 115 | 116 | endsnippet 117 | 118 | snippet unless "unless" 119 | unless ($1) { 120 | ${2:# body...} 121 | } 122 | 123 | endsnippet 124 | 125 | snippet while "while" 126 | while ($1) { 127 | ${2:# body...} 128 | } 129 | 130 | endsnippet 131 | 132 | snippet until "until" 133 | until ($1) { 134 | ${2:# body...} 135 | } 136 | 137 | endsnippet 138 | 139 | # vim:ft=snippets: 140 | -------------------------------------------------------------------------------- /snippets/ultisnips/proto.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | global !p 4 | from EasyCompleteUtil.vimsnippets import complete 5 | 6 | FIELD_TYPES = [ 7 | 'double', 8 | 'float', 9 | 'int32', 10 | 'int64', 11 | 'uint32', 12 | 'uint64', 13 | 'sint32', 14 | 'sint64', 15 | 'fixed32', 16 | 'fixed64', 17 | 'sfixed32', 18 | 'sfixed64', 19 | 'bool', 20 | 'string', 21 | 'bytes'] 22 | endglobal 23 | 24 | snippet mess "Proto message" b 25 | // ${2:TODO(`whoami`): Describe this message.} 26 | message ${1:Name} { 27 | $0 28 | 29 | // Next available id: 1 30 | } 31 | endsnippet 32 | 33 | snippet reqf "Required field" b 34 | // ${4:TODO(`whoami`): Describe this field.} 35 | optional $1`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required 36 | endsnippet 37 | 38 | snippet optf "Optional field" b 39 | // ${4:TODO(`whoami`): Describe this field.} 40 | optional $1`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; 41 | endsnippet 42 | 43 | snippet repf "Repeated field" b 44 | // ${4:TODO(`whoami`): Describe this field.} 45 | repeated $1`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; 46 | endsnippet 47 | 48 | snippet enum "Enumeration" b 49 | // ${2:TODO(`whoami`): Describe this enum.} 50 | enum ${1:Name} { 51 | } 52 | endsnippet 53 | -------------------------------------------------------------------------------- /snippets/ultisnips/rnoweb.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends tex, r 4 | -------------------------------------------------------------------------------- /snippets/ultisnips/rust.snippets: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | # Rust Snippets # 3 | ####################################################################### 4 | 5 | priority -50 6 | 7 | snippet fn "fn name(?) -> ? {}" 8 | fn ${1:function_name}($2)${3/..*/ -> /}$3 { 9 | ${VISUAL}$0 10 | } 11 | endsnippet 12 | 13 | snippet pfn "pub fn name(?) -> ? {}" 14 | pub fn ${1:function_name}($2)${3/..*/ -> /}$3 { 15 | ${VISUAL}$0 16 | } 17 | endsnippet 18 | 19 | snippet afn "async fn name(?) -> ? {}" 20 | async fn ${1:function_name}($2)${3/..*/ -> /}$3 { 21 | ${VISUAL}$0 22 | } 23 | endsnippet 24 | 25 | snippet pafn "pub async fn name(?) -> ? {}" 26 | pub async fn ${1:function_name}($2)${3/..*/ -> /}$3 { 27 | ${VISUAL}$0 28 | } 29 | endsnippet 30 | 31 | snippet pri "print!(..)" b 32 | print!("$1"${2/..*/, /}$2); 33 | endsnippet 34 | 35 | snippet pln "println!(..)" b 36 | println!("$1"${2/..*/, /}$2); 37 | endsnippet 38 | 39 | snippet fmt "format!(..)" 40 | format!("$1"${2/..*/, /}$2); 41 | endsnippet 42 | 43 | snippet .it ".iter()" i 44 | .iter()$0 45 | endsnippet 46 | 47 | snippet impl "Struct/Trait implementation" b 48 | impl$4 ${1:Type/Trait}${2: for ${3:Type}}${4:<${5:T}>} { 49 | ${0} 50 | } 51 | endsnippet 52 | 53 | # vim:ft=snippets: 54 | -------------------------------------------------------------------------------- /snippets/ultisnips/sh.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | global !p 4 | import vim 5 | 6 | # Tests for the existence of a variable declared by Vim's filetype detection 7 | # suggesting the type of shell script of the current file 8 | def testShell(scope, shell): 9 | return vim.eval("exists('" + scope + ":is_" + shell + "')") 10 | 11 | # Loops over the possible variables, checking for global variables 12 | # first since they indicate an override by the user. 13 | def getShell(): 14 | for scope in ["g", "b"]: 15 | for shell in ["bash", "posix", "sh", "kornshell"]: 16 | if testShell(scope, shell) == "1": 17 | if shell == "kornshell": 18 | return "ksh" 19 | if shell == "posix": 20 | return "sh" 21 | return shell 22 | return "sh" 23 | endglobal 24 | 25 | ########################################################################### 26 | # TextMate Snippets # 27 | ########################################################################### 28 | snippet #! "#!/usr/bin/env (!env)" b 29 | `!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n" ` 30 | endsnippet 31 | 32 | snippet sbash "safe bash options" b 33 | #!/usr/bin/env bash 34 | set -euo pipefail 35 | IFS=$'\n\t' 36 | `!p snip.rv ='\n\n' ` 37 | endsnippet 38 | 39 | snippet temp "Tempfile" b 40 | ${1:TMPFILE}="$(mktemp -t ${3:--suffix=${4:.SUFFIX}} ${2:`!p 41 | snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" 42 | `}.XXXXXX)" 43 | ${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/}} 44 | 45 | endsnippet 46 | 47 | snippet /case|sw(itch)?/ "case .. esac (case)" rb 48 | case ${1:word} in 49 | ${2:pattern} ) 50 | ${0:${VISUAL}};; 51 | esac 52 | endsnippet 53 | 54 | snippet elif "elif .. (elif)" b 55 | elif ${2:[[ ${1:condition} ]]}; then 56 | ${0:${VISUAL}} 57 | endsnippet 58 | 59 | snippet for "for ... done (for)" b 60 | for (( i = 0; i < ${1:10}; i++ )); do 61 | ${0:${VISUAL}} 62 | done 63 | endsnippet 64 | 65 | snippet forin "for ... in ... done (forin)" b 66 | for ${1:i}${2/.+/ in /}${2:words}; do 67 | ${0:${VISUAL}} 68 | done 69 | endsnippet 70 | 71 | snippet here "here document (here)" 72 | <<-${2:'${1:TOKEN}'} 73 | $0`echo \\n`${1/['"`](.+)['"`]/$1/} 74 | endsnippet 75 | 76 | snippet /ift(est)?/ "if ... then (if)" rb 77 | if ${2:[ ${1:condition} ]}; then 78 | ${0:${VISUAL}} 79 | fi 80 | endsnippet 81 | 82 | snippet if "if ... then (if)" b 83 | if [[ ${1:condition} ]]; then 84 | ${0:${VISUAL}} 85 | fi 86 | endsnippet 87 | 88 | snippet until "until ... (done)" b 89 | until ${2:[[ ${1:condition} ]]}; do 90 | ${0:${VISUAL}} 91 | done 92 | endsnippet 93 | 94 | snippet /wh(ile)?/ "while ... (done)" rb 95 | while ${2:[[ ${1:condition} ]]}; do 96 | ${0:${VISUAL}} 97 | done 98 | endsnippet 99 | 100 | snippet func "function() {...}" b 101 | ${1:function} () { 102 | ${0:${VISUAL}} 103 | } 104 | endsnippet 105 | 106 | # vim:ft=snippets: 107 | -------------------------------------------------------------------------------- /snippets/ultisnips/snippets.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | # We use a little hack so that the snippet is expanded 4 | # and parsed correctly 5 | snippet usnip "Ultisnips snippet definition" b 6 | `!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b} 7 | ${0:${VISUAL}} 8 | `!p snip.rv = "endsnippet"` 9 | endsnippet 10 | 11 | snippet global "Global snippet" b 12 | `!p snip.rv = "global"` !p 13 | ${0:${VISUAL}} 14 | `!p snip.rv = "endglobal"` 15 | endsnippet 16 | 17 | snippet vis "${VISUAL}" i 18 | \$\{VISUAL${1:${2:default}${3:/transform/}}\} 19 | endsnippet 20 | 21 | # vim:ft=snippets: 22 | -------------------------------------------------------------------------------- /snippets/ultisnips/soy.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends html 4 | 5 | snippet ns "Namespace" b 6 | {namespace ${1:name}} 7 | endsnippet 8 | 9 | snippet tmpl "Template" b 10 | /** 11 | * ${2:TODO(`whoami`): Describe this template.} 12 | */ 13 | {template .${1:name}} 14 | $0 15 | {/template} 16 | endsnippet 17 | 18 | snippet msg "Message" b 19 | {msg desc="${1:description}"} 20 | $0 21 | {/msg} 22 | endsnippet 23 | 24 | snippet let "let command" b 25 | {let $${1:identifier}: ${2:expression} /} 26 | endsnippet 27 | 28 | snippet if "if .. (if)" b 29 | {if ${1:expression}} 30 | $0 31 | {/if} 32 | endsnippet 33 | 34 | snippet ife "if .. else (ife)" b 35 | {if ${1:expression}} 36 | $2 37 | {else} 38 | $0 39 | {/if} 40 | endsnippet 41 | 42 | snippet eli "else if .. (eli)" b 43 | {elif ${1:expression}} 44 | $0 45 | endsnippet 46 | 47 | snippet fore "foreach command" b 48 | {foreach $${1:var} in ${2:ref}} 49 | $0 50 | {/foreach} 51 | endsnippet 52 | 53 | snippet for "for command" b 54 | {for $${1:var} in range(${2:rangeexpr})} 55 | $0 56 | {/for} 57 | endsnippet 58 | 59 | snippet call "template call" b 60 | {call ${1:tmpl}} 61 | $0 62 | {/call} 63 | endsnippet 64 | -------------------------------------------------------------------------------- /snippets/ultisnips/supercollider.snippets: -------------------------------------------------------------------------------- 1 | snippet for 2 | for (${1:1}, ${2:10}) {${3: |i}|} 3 | $0 4 | } 5 | endsnippet 6 | snippet sdef 7 | SynthDef(\\${1:synthName}, {${2: |${3:x}|} 8 | $0 9 | }).add; 10 | endsnippet 11 | -------------------------------------------------------------------------------- /snippets/ultisnips/svelte.snippets: -------------------------------------------------------------------------------- 1 | extends html, javascript, css 2 | -------------------------------------------------------------------------------- /snippets/ultisnips/tcl.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | ########################################################################### 4 | # TEXTMATE SNIPPETS # 5 | ########################################################################### 6 | snippet for "for... (for)" b 7 | for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} { 8 | $4 9 | } 10 | 11 | endsnippet 12 | 13 | snippet foreach "foreach... (foreach)" 14 | foreach ${1:var} ${2:\$list} { 15 | $3 16 | } 17 | 18 | endsnippet 19 | 20 | snippet if "if... (if)" b 21 | if {${1:condition}} { 22 | $2 23 | } 24 | 25 | endsnippet 26 | 27 | snippet proc "proc... (proc)" b 28 | proc ${1:name} {${2:args}} \ 29 | { 30 | $3 31 | } 32 | 33 | endsnippet 34 | 35 | snippet switch "switch... (switch)" b 36 | switch ${1:-exact} -- ${2:\$var} { 37 | ${3:match} { 38 | $4 39 | } 40 | default {$5} 41 | } 42 | 43 | endsnippet 44 | 45 | snippet while "while... (while)" b 46 | while {${1:condition}} { 47 | $2 48 | } 49 | 50 | endsnippet 51 | 52 | # vim:ft=snippets: 53 | -------------------------------------------------------------------------------- /snippets/ultisnips/texmath.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | ############## 4 | # MATH STUFF # 5 | ############## 6 | 7 | snippet eqnn "Equation without a number" b 8 | \begin{equation*} 9 | ${0:${VISUAL}} 10 | \end{equation*} 11 | endsnippet 12 | 13 | snippet al "Align" b 14 | \begin{align} 15 | ${0:${VISUAL}} 16 | \end{align} 17 | endsnippet 18 | 19 | snippet alnn "Align without a number" b 20 | \begin{align*} 21 | ${0:${VISUAL}} 22 | \end{align*} 23 | endsnippet 24 | 25 | snippet eqa "Equation array" b 26 | \begin{eqnarray} 27 | ${1:${VISUAL}} & ${2:${VISUAL}} & ${0:${VISUAL}} 28 | \end{eqnarray} 29 | endsnippet 30 | 31 | snippet eqann "Equation array without a number" b 32 | \begin{eqnarray*} 33 | ${1:${VISUAL}} & ${2:${VISUAL}} & ${0:${VISUAL}} 34 | \end{eqnarray*} 35 | endsnippet 36 | 37 | ################# 38 | # PHYSICS STUFF # 39 | ################# 40 | 41 | snippet dv "Derivative" w 42 | \dv[${1:${VISUAL}}]{${2}}{${3}} 43 | endsnippet 44 | 45 | snippet pdv "Partial Derivative" w 46 | \pdv[${1:${VISUAL}}]{${2}}{${3}} 47 | endsnippet 48 | 49 | snippet SI "SI-Unit" w 50 | \SI{${1:${VISUAL}}}{${2}} 51 | endsnippet 52 | 53 | # vim:ft=snippets: 54 | -------------------------------------------------------------------------------- /snippets/ultisnips/typescript.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends javascript 4 | 5 | snippet int "interface" 6 | interface ${1} { 7 | } 8 | endsnippet 9 | snippet nspc "namespace" 10 | namespace ${1} { 11 | } 12 | endsnippet 13 | priority -49 14 | snippet fun "function (named)" b 15 | function ${1:function_name} (${2:argument}: ${3:argument_type}) { 16 | ${VISUAL}$0 17 | } 18 | endsnippet 19 | -------------------------------------------------------------------------------- /snippets/ultisnips/typescript_react.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | extends javascript_react 3 | extends typescript 4 | 5 | priority -49 6 | snippet rfc "react functional component" 7 | import React, { FC } from "react" 8 | 9 | interface ${1:function_name}Props {${4:props_types}} 10 | 11 | export const ${1:function_name}: FC<${1:function_name}Props> = (${2:props}) => ${3:function_body} 12 | endsnippet 13 | -------------------------------------------------------------------------------- /snippets/ultisnips/vim.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | ########################################################################### 4 | # SnipMate Snippets # 5 | ########################################################################### 6 | snippet gvar "Global / configuration variable" b 7 | if !exists("g:${1:MyUltraImportantVar}") 8 | let g:$1 = ${2:"${3:}"} 9 | endif 10 | endsnippet 11 | 12 | snippet guard "script reload guard" b 13 | if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700} 14 | finish 15 | endif 16 | let $1 = 1$3 17 | endsnippet 18 | 19 | snippet f "function" b 20 | fun ${1:function_name}($2) 21 | ${3:" code} 22 | endf 23 | endsnippet 24 | # vim:ft=snippets: 25 | -------------------------------------------------------------------------------- /snippets/ultisnips/vue.snippets: -------------------------------------------------------------------------------- 1 | extends html, javascript, css 2 | -------------------------------------------------------------------------------- /snippets/ultisnips/xhtml.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends html 4 | -------------------------------------------------------------------------------- /snippets/ultisnips/xml.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet xml "XML declaration" b 4 | 5 | 6 | endsnippet 7 | 8 | snippet t "Simple tag" b 9 | <${1:tag}> 10 | ${2:${VISUAL}} 11 | 12 | endsnippet 13 | 14 | snippet ti "Inline tag" b 15 | <${1:tag}>${2:${VISUAL}} 16 | endsnippet 17 | -------------------------------------------------------------------------------- /snippets/ultisnips/zsh.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends sh 4 | 5 | priority -49 6 | 7 | snippet #! "#!/usr/bin/env zsh" b 8 | #!/usr/bin/env zsh 9 | $0 10 | endsnippet 11 | 12 | # vim:ft=snippets: 13 | -------------------------------------------------------------------------------- /snippets/vim.snippets: -------------------------------------------------------------------------------- 1 | snippet header standard Vim script file header 2 | " File: ${1:`expand('%:t')`} 3 | " Author: ${2:`g:snips_author`} 4 | " Description: ${3} 5 | ${0:" Last Modified: `strftime("%B %d, %Y")`} 6 | snippet guard script reload guard 7 | if exists('${1:did_`easycomplete#Filename()`}') || &cp${2: || version < 700} 8 | finish 9 | endif 10 | let $1 = 1${0} 11 | snippet f function 12 | fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3}) 13 | ${0} 14 | endf 15 | snippet t try ... catch statement 16 | try 17 | ${1:${VISUAL}} 18 | catch ${2} 19 | ${0} 20 | endtry 21 | snippet for for ... in loop 22 | for ${1} in ${2} 23 | ${0:${VISUAL}} 24 | endfor 25 | snippet forkv for [key, value] in loop 26 | for [${1},${2}] in items(${3}) 27 | ${0} 28 | unlet $1 $2 29 | endfor 30 | snippet wh while loop 31 | while ${1} 32 | ${0:${VISUAL}} 33 | endw 34 | snippet if if statement 35 | if ${1} 36 | ${0:${VISUAL}} 37 | endif 38 | snippet ife if ... else statement 39 | if ${1} 40 | ${2:${VISUAL}} 41 | else 42 | ${0} 43 | endif 44 | snippet au augroup ... autocmd block 45 | augroup ${1:AU_NAME} 46 | autocmd! 47 | autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|} ${0} 48 | augroup END 49 | snippet auv augroupvisual ... autocmd block with visual placeholder 50 | augroup ${1:AU_NAME} 51 | autocmd! 52 | ${0:${VISUAL}} 53 | augroup END 54 | snippet bun Vundle.vim Plugin definition 55 | Plugin '${0}' 56 | snippet plug vim-plug Plugin definition 57 | Plug '${0}' 58 | snippet plugdo vim-plug Plugin definition with { 'do': '' } 59 | Plug '${1}', { 'do': '${0}' } 60 | snippet plugon vim-plug Plugin definition with { 'on': '' } 61 | Plug '${1}', { 'on': '${0}' } 62 | snippet plugfor vim-plug Plugin definition with { 'for': '' } 63 | Plug '${1}', { 'for': '${0}' } 64 | snippet plugbr vim-plug Plugin definition with { 'branch': '' } 65 | Plug '${1}', { 'branch': '${0}' } 66 | snippet plugtag vim-plug Plugin definition with { 'tag': '' } 67 | Plug '${1}', { 'tag': '${0}' } 68 | snippet let 69 | let ${1:variable} = ${0: value} 70 | snippet se 71 | set ${1:setting}; 72 | snippet set 73 | set ${1:setting} = ${0:value} 74 | snippet nn 75 | nnoremap ${1} ${2} 76 | snippet no 77 | noremap ${1} ${2} 78 | snippet vm 79 | vmap ${1} ${2} 80 | snippet im 81 | imap ${1} ${2} 82 | snippet exe 83 | execute ${1} 84 | snippet filename 85 | `Filename()` 86 | -------------------------------------------------------------------------------- /snippets/vue.snippets: -------------------------------------------------------------------------------- 1 | # This snippet file enables vue files to use tabs for html, js and css. It also 2 | # includes some vue-specific html-like snippets, as well as some general 3 | # boilerplate code for vue. 4 | 5 | extends html, javascript, css 6 | 7 | # These snippets form a port of Sarah Drasner's vue-sublime-snippets 8 | 9 | # some html-like snippets 10 | 11 | snippet slot 12 | 13 | 14 | snippet template 15 | 16 | 17 | snippet transition 18 | 19 | 20 | # The following snippets create more complex boilerplate code. 21 | 22 | snippet vbase 23 | 28 | 29 | 34 | 35 | 38 | 39 | snippet vimport:c 40 | import ${1:Name} from './components/$1.vue'; 41 | 42 | export default { 43 | components: { 44 | $1 45 | } 46 | } 47 | 48 | snippet vactions 49 | actions: { 50 | ${1:updateValue}({commit}, ${2:payload}) { 51 | commit($1, $2); 52 | } 53 | } 54 | 55 | # Add in js animation hooks 56 | snippet vanim:js:el 57 | 68 | 69 | 70 | 71 | snippet vanim:js:method 72 | methods: { 73 | beforeEnter(el) { 74 | console.log('beforeEnter'); 75 | }, 76 | enter(el, done) { 77 | console.log('enter'); 78 | done(); 79 | }, 80 | afterEnter(el) { 81 | console.log('afterEnter'); 82 | }, 83 | enterCancelled(el, done) { 84 | console.log('enterCancelled'); 85 | }, 86 | beforeLeave(el) { 87 | console.log('beforeLeave'); 88 | }, 89 | leave(el, done) { 90 | console.log('leave'); 91 | done(); 92 | }, 93 | afterLeave(el) { 94 | console.log('afterLeave'); 95 | }, 96 | leaveCancelled(el, done) { 97 | console.log('leaveCancelled'); 98 | } 99 | } 100 | 101 | snippet vcl 102 | @click="${1}" 103 | 104 | snippet vdata 105 | data() { 106 | return { 107 | ${1:key}: ${2:value} 108 | }; 109 | } 110 | 111 | snippet vfilter 112 | filters: { 113 | ${1:fnName}: function(${2:value}) { 114 | return; 115 | } 116 | } 117 | 118 | snippet vfor 119 |
120 | {{ $1 }} 121 |
122 | 123 | snippet vgetters 124 | getters: { 125 | ${1:value}: state => { 126 | return state.$1; 127 | } 128 | } 129 | 130 | snippet vimport 131 | import ${1:New} from './components/$1.vue'; 132 | 133 | snippet vkeep 134 | 135 | 136 |

default

137 |
138 |
139 | 140 | snippet vmixin 141 | const ${1:mixinName} = { 142 | mounted() { 143 | console.log('hello from mixin!') 144 | }, 145 | } 146 | const ${2:Component} = Vue.extend({ 147 | mixins: [$1] 148 | }) 149 | 150 | snippet vmutations 151 | mutations: { 152 | ${1:updateValue}(state, ${3:payload}) => { 153 | state.${2:value} = $3; 154 | } 155 | } 156 | 157 | snippet vprops:d 158 | ${1:propName}: { 159 | type: ${2:Number}, 160 | default: ${0} 161 | }, 162 | 163 | snippet vprops 164 | ${1:propName}: { 165 | type: ${2:Number} 166 | }, 167 | 168 | snippet vstore 169 | import Vue from 'vue'; 170 | import Vuex from 'vuex'; 171 | 172 | Vue.use(Vuex); 173 | 174 | export const store = new Vuex.Store({ 175 | state: { 176 | ${1:key}: ${2:value} 177 | } 178 | }); 179 | 180 | 181 | # vue-i18n snippets https://github.com/kazupon/vue-i18n 182 | 183 | snippet trans 184 | $t('$1') 185 | 186 | # Translation with parameter 187 | snippet transc 188 | $t('$1', { $2: $3 }) 189 | 190 | -------------------------------------------------------------------------------- /snippets/xml.snippets: -------------------------------------------------------------------------------- 1 | # xml declaration 2 | snippet xml 3 | 4 | # tag 5 | snippet t 6 | <${1:}> 7 | ${2} 8 | 9 | # inline tag 10 | snippet ti 11 | <${1:}>${2} 12 | 13 | -------------------------------------------------------------------------------- /snippets/zsh.snippets: -------------------------------------------------------------------------------- 1 | # #!/bin/zsh 2 | snippet #! 3 | #!/bin/zsh 4 | 5 | snippet if 6 | if ${1:condition}; then 7 | ${0:${VISUAL}} 8 | fi 9 | snippet ife 10 | if ${1:condition}; then 11 | ${2:${VISUAL}} 12 | else 13 | ${0:# statements} 14 | fi 15 | snippet eif 16 | elif ${1:condition}; then 17 | ${0:${VISUAL}} 18 | snippet for 19 | for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do 20 | ${0:${VISUAL}} 21 | done 22 | snippet fori 23 | for ${1:needle} in ${2:haystack}; do 24 | ${0:${VISUAL}} 25 | done 26 | snippet fore 27 | for ${1:item} in ${2:list}; do 28 | ${0:${VISUAL}} 29 | done 30 | snippet wh 31 | while ${1:condition}; do 32 | ${0:${VISUAL}} 33 | done 34 | snippet until 35 | until ${1:condition}; do 36 | ${0:${VISUAL}} 37 | done 38 | snippet repeat 39 | repeat ${1:integer}; do 40 | ${0:${VISUAL}} 41 | done 42 | snippet case 43 | case ${1:word} in 44 | ${2:pattern}) 45 | ${0};; 46 | esac 47 | snippet select 48 | select ${1:answer} in ${2:choices}; do 49 | ${0:${VISUAL}} 50 | done 51 | snippet ( 52 | ( ${0:#statements} ) 53 | snippet { 54 | { ${0:#statements} } 55 | snippet [ 56 | [[ ${0:test} ]] 57 | snippet always 58 | { ${1:try} } always { ${0:always} } 59 | snippet fun 60 | ${1:function_name}() { 61 | ${0:# function_body} 62 | } 63 | snippet ffun 64 | function ${1:function_name}() { 65 | ${0:# function_body} 66 | } 67 | --------------------------------------------------------------------------------