Update 2024-01-19 22:17 OpenBSD/amd64-x13
This commit is contained in:
parent
da8daa77e0
commit
39b6b970ad
4
.vim/pack/plugins/opt/vim-copilot/LICENSE.md
Normal file
4
.vim/pack/plugins/opt/vim-copilot/LICENSE.md
Normal file
@ -0,0 +1,4 @@
|
||||
GitHub Copilot is offered under the [GitHub Terms of
|
||||
Service](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot).
|
||||
|
||||
Copyright (C) 2023 GitHub, Inc. - All Rights Reserved.
|
64
.vim/pack/plugins/opt/vim-copilot/README.md
Normal file
64
.vim/pack/plugins/opt/vim-copilot/README.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Copilot.vim
|
||||
|
||||
GitHub Copilot uses OpenAI Codex to suggest code and entire functions in
|
||||
real-time right from your editor. Trained on billions of lines of public
|
||||
code, GitHub Copilot turns natural language prompts including comments and
|
||||
method names into coding suggestions across dozens of languages.
|
||||
|
||||
Copilot.vim is a Vim/Neovim plugin for GitHub Copilot.
|
||||
|
||||
To learn more, visit
|
||||
[https://github.com/features/copilot](https://github.com/features/copilot).
|
||||
|
||||
## Subscription
|
||||
|
||||
GitHub Copilot requires a subscription. It is free for verified students and
|
||||
maintainers of popular open source projects on GitHub.
|
||||
|
||||
GitHub Copilot is subject to the [GitHub Additional Product
|
||||
Terms](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features).
|
||||
|
||||
## Getting started
|
||||
|
||||
1. Install [Neovim][] or the latest patch of [Vim][] (9.0.0185 or newer).
|
||||
|
||||
2. Install [Node.js][].
|
||||
|
||||
3. Install `github/copilot.vim` using vim-plug, packer.nvim, or any other
|
||||
plugin manager. Or to install manually, run one of the following
|
||||
commands:
|
||||
|
||||
* Vim, Linux/macOS:
|
||||
|
||||
git clone https://github.com/github/copilot.vim.git \
|
||||
~/.vim/pack/github/start/copilot.vim
|
||||
|
||||
* Neovim, Linux/macOS:
|
||||
|
||||
git clone https://github.com/github/copilot.vim.git \
|
||||
~/.config/nvim/pack/github/start/copilot.vim
|
||||
|
||||
* Vim, Windows (PowerShell command):
|
||||
|
||||
git clone https://github.com/github/copilot.vim.git `
|
||||
$HOME/vimfiles/pack/github/start/copilot.vim
|
||||
|
||||
* Neovim, Windows (PowerShell command):
|
||||
|
||||
git clone https://github.com/github/copilot.vim.git `
|
||||
$HOME/AppData/Local/nvim/pack/github/start/copilot.vim
|
||||
|
||||
4. Start Neovim and invoke `:Copilot setup`.
|
||||
|
||||
[Node.js]: https://nodejs.org/en/download/
|
||||
[Neovim]: https://github.com/neovim/neovim/releases/latest
|
||||
[Vim]: https://github.com/vim/vim
|
||||
|
||||
Suggestions are displayed inline and can be accepted by pressing the tab key.
|
||||
See `:help copilot` for more information.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
We’d love to get your help in making GitHub Copilot better! If you have
|
||||
feedback or encounter any problems, please reach out on our [Feedback
|
||||
forum](https://github.com/orgs/community/discussions/categories/copilot).
|
4
.vim/pack/plugins/opt/vim-copilot/SECURITY.md
Normal file
4
.vim/pack/plugins/opt/vim-copilot/SECURITY.md
Normal file
@ -0,0 +1,4 @@
|
||||
If you discover a security issue in this repo, please submit it through the
|
||||
[GitHub Security Bug Bounty](https://hackerone.com/github).
|
||||
|
||||
Thanks for helping make GitHub Copilot safe for everyone.
|
815
.vim/pack/plugins/opt/vim-copilot/autoload/copilot.vim
Normal file
815
.vim/pack/plugins/opt/vim-copilot/autoload/copilot.vim
Normal file
@ -0,0 +1,815 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:has_nvim_ghost_text = has('nvim-0.6') && exists('*nvim_buf_get_mark')
|
||||
let s:vim_minimum_version = '9.0.0185'
|
||||
let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop')
|
||||
let s:has_ghost_text = s:has_nvim_ghost_text || s:has_vim_ghost_text
|
||||
|
||||
let s:hlgroup = 'CopilotSuggestion'
|
||||
let s:annot_hlgroup = 'CopilotAnnotation'
|
||||
|
||||
if s:has_vim_ghost_text && empty(prop_type_get(s:hlgroup))
|
||||
call prop_type_add(s:hlgroup, {'highlight': s:hlgroup})
|
||||
endif
|
||||
if s:has_vim_ghost_text && empty(prop_type_get(s:annot_hlgroup))
|
||||
call prop_type_add(s:annot_hlgroup, {'highlight': s:annot_hlgroup})
|
||||
endif
|
||||
|
||||
function! s:Echo(msg) abort
|
||||
if has('nvim') && &cmdheight == 0
|
||||
call v:lua.vim.notify(a:msg, v:null, {'title': 'GitHub Copilot'})
|
||||
else
|
||||
echo a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:EditorConfiguration() abort
|
||||
let filetypes = copy(s:filetype_defaults)
|
||||
if type(get(g:, 'copilot_filetypes')) == v:t_dict
|
||||
call extend(filetypes, g:copilot_filetypes)
|
||||
endif
|
||||
return {
|
||||
\ 'enableAutoCompletions': empty(get(g:, 'copilot_enabled', 1)) ? v:false : v:true,
|
||||
\ 'disabledLanguages': map(sort(keys(filter(filetypes, { k, v -> empty(v) }))), { _, v -> {'languageId': v}}),
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
function! s:StatusNotification(params, ...) abort
|
||||
let status = get(a:params, 'status', '')
|
||||
if status ==? 'error'
|
||||
let s:agent_error = a:params.message
|
||||
else
|
||||
unlet! s:agent_error
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#Init(...) abort
|
||||
call timer_start(0, { _ -> s:Start() })
|
||||
endfunction
|
||||
|
||||
function! s:Running() abort
|
||||
return exists('s:agent.job') || exists('s:agent.client_id')
|
||||
endfunction
|
||||
|
||||
function! s:Start() abort
|
||||
if s:Running()
|
||||
return
|
||||
endif
|
||||
let s:agent = copilot#agent#New({'methods': {
|
||||
\ 'statusNotification': function('s:StatusNotification'),
|
||||
\ 'PanelSolution': function('copilot#panel#Solution'),
|
||||
\ 'PanelSolutionsDone': function('copilot#panel#SolutionsDone'),
|
||||
\ 'copilot/openURL': function('s:OpenURL'),
|
||||
\ },
|
||||
\ 'editorConfiguration' : s:EditorConfiguration()})
|
||||
endfunction
|
||||
|
||||
function! s:Stop() abort
|
||||
if exists('s:agent')
|
||||
let agent = remove(s:, 'agent')
|
||||
call agent.Close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#Agent() abort
|
||||
call s:Start()
|
||||
return s:agent
|
||||
endfunction
|
||||
|
||||
function! copilot#RunningAgent() abort
|
||||
if s:Running()
|
||||
return s:agent
|
||||
else
|
||||
return v:null
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:NodeVersionWarning() abort
|
||||
if exists('s:agent.node_version') && s:agent.node_version =~# '^16\.'
|
||||
echohl WarningMsg
|
||||
echo "Warning: Node.js 16 is approaching end of life and support will be dropped in a future release of copilot.vim."
|
||||
echohl NONE
|
||||
elseif exists('s:agent.node_version_warning')
|
||||
echohl WarningMsg
|
||||
echo 'Warning:' s:agent.node_version_warning
|
||||
echohl NONE
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#Request(method, params, ...) abort
|
||||
let agent = copilot#Agent()
|
||||
return call(agent.Request, [a:method, a:params] + a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#Call(method, params, ...) abort
|
||||
let agent = copilot#Agent()
|
||||
return call(agent.Call, [a:method, a:params] + a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#Notify(method, params, ...) abort
|
||||
let agent = copilot#Agent()
|
||||
return call(agent.Notify, [a:method, a:params] + a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#NvimNs() abort
|
||||
return nvim_create_namespace('github-copilot')
|
||||
endfunction
|
||||
|
||||
function! copilot#Clear() abort
|
||||
if exists('g:_copilot_timer')
|
||||
call timer_stop(remove(g:, '_copilot_timer'))
|
||||
endif
|
||||
if exists('b:_copilot')
|
||||
call copilot#agent#Cancel(get(b:_copilot, 'first', {}))
|
||||
call copilot#agent#Cancel(get(b:_copilot, 'cycling', {}))
|
||||
endif
|
||||
call s:UpdatePreview()
|
||||
unlet! b:_copilot
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:Reject(bufnr) abort
|
||||
try
|
||||
let dict = getbufvar(a:bufnr, '_copilot')
|
||||
if type(dict) == v:t_dict && !empty(get(dict, 'shown_choices', {}))
|
||||
call copilot#Request('notifyRejected', {'uuids': keys(dict.shown_choices)})
|
||||
let dict.shown_choices = {}
|
||||
endif
|
||||
catch
|
||||
call copilot#logger#Exception()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! copilot#Dismiss() abort
|
||||
call s:Reject('%')
|
||||
call copilot#Clear()
|
||||
call s:UpdatePreview()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
let s:filetype_defaults = {
|
||||
\ 'yaml': 0,
|
||||
\ 'markdown': 0,
|
||||
\ 'help': 0,
|
||||
\ 'gitcommit': 0,
|
||||
\ 'gitrebase': 0,
|
||||
\ 'hgcommit': 0,
|
||||
\ 'svn': 0,
|
||||
\ 'cvs': 0,
|
||||
\ '.': 0}
|
||||
|
||||
function! s:BufferDisabled() abort
|
||||
if &buftype =~# '^\%(help\|prompt\|quickfix\|terminal\)$'
|
||||
return 5
|
||||
endif
|
||||
if exists('b:copilot_disabled')
|
||||
return empty(b:copilot_disabled) ? 0 : 3
|
||||
endif
|
||||
if exists('b:copilot_enabled')
|
||||
return empty(b:copilot_enabled) ? 4 : 0
|
||||
endif
|
||||
let short = empty(&l:filetype) ? '.' : split(&l:filetype, '\.', 1)[0]
|
||||
let config = {}
|
||||
if type(get(g:, 'copilot_filetypes')) == v:t_dict
|
||||
let config = g:copilot_filetypes
|
||||
endif
|
||||
if has_key(config, &l:filetype)
|
||||
return empty(config[&l:filetype])
|
||||
elseif has_key(config, short)
|
||||
return empty(config[short])
|
||||
elseif has_key(config, '*')
|
||||
return empty(config['*'])
|
||||
else
|
||||
return get(s:filetype_defaults, short, 1) == 0 ? 2 : 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#Enabled() abort
|
||||
return get(g:, 'copilot_enabled', 1)
|
||||
\ && empty(s:BufferDisabled())
|
||||
\ && empty(copilot#Agent().StartupError())
|
||||
endfunction
|
||||
|
||||
function! copilot#Complete(...) abort
|
||||
if exists('g:_copilot_timer')
|
||||
call timer_stop(remove(g:, '_copilot_timer'))
|
||||
endif
|
||||
let params = copilot#doc#Params()
|
||||
if !exists('b:_copilot.params') || b:_copilot.params !=# params
|
||||
let b:_copilot = {'params': params, 'first':
|
||||
\ copilot#Request('getCompletions', params)}
|
||||
let g:_copilot_last = b:_copilot
|
||||
endif
|
||||
let completion = b:_copilot.first
|
||||
if !a:0
|
||||
return completion.Await()
|
||||
else
|
||||
call copilot#agent#Result(completion, a:1)
|
||||
if a:0 > 1
|
||||
call copilot#agent#Error(completion, a:2)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:HideDuringCompletion() abort
|
||||
return get(g:, 'copilot_hide_during_completion', 1)
|
||||
endfunction
|
||||
|
||||
function! s:SuggestionTextWithAdjustments() abort
|
||||
try
|
||||
if mode() !~# '^[iR]' || (s:HideDuringCompletion() && pumvisible()) || !exists('b:_copilot.suggestions')
|
||||
return ['', 0, 0, '']
|
||||
endif
|
||||
let choice = get(b:_copilot.suggestions, b:_copilot.choice, {})
|
||||
if !has_key(choice, 'range') || choice.range.start.line != line('.') - 1 || type(choice.text) !=# v:t_string
|
||||
return ['', 0, 0, '']
|
||||
endif
|
||||
let line = getline('.')
|
||||
let offset = col('.') - 1
|
||||
let choice_text = strpart(line, 0, copilot#doc#UTF16ToByteIdx(line, choice.range.start.character)) . choice.text
|
||||
let typed = strpart(line, 0, offset)
|
||||
let end_offset = copilot#doc#UTF16ToByteIdx(line, choice.range.end.character)
|
||||
if end_offset < 0
|
||||
let end_offset = len(line)
|
||||
endif
|
||||
let delete = strpart(line, offset, end_offset - offset)
|
||||
let uuid = get(choice, 'uuid', '')
|
||||
if typed =~# '^\s*$'
|
||||
let leading = matchstr(choice_text, '^\s\+')
|
||||
let unindented = strpart(choice_text, len(leading))
|
||||
if strpart(typed, 0, len(leading)) == leading && unindented !=# delete
|
||||
return [unindented, len(typed) - len(leading), strchars(delete), uuid]
|
||||
endif
|
||||
elseif typed ==# strpart(choice_text, 0, offset)
|
||||
return [strpart(choice_text, offset), 0, strchars(delete), uuid]
|
||||
endif
|
||||
catch
|
||||
call copilot#logger#Exception()
|
||||
endtry
|
||||
return ['', 0, 0, '']
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:Advance(count, context, ...) abort
|
||||
if a:context isnot# get(b:, '_copilot', {})
|
||||
return
|
||||
endif
|
||||
let a:context.choice += a:count
|
||||
if a:context.choice < 0
|
||||
let a:context.choice += len(a:context.suggestions)
|
||||
endif
|
||||
let a:context.choice %= len(a:context.suggestions)
|
||||
call s:UpdatePreview()
|
||||
endfunction
|
||||
|
||||
function! s:GetSuggestionsCyclingCallback(context, result) abort
|
||||
let callbacks = remove(a:context, 'cycling_callbacks')
|
||||
let seen = {}
|
||||
for suggestion in a:context.suggestions
|
||||
let seen[suggestion.text] = 1
|
||||
endfor
|
||||
for suggestion in get(a:result, 'completions', [])
|
||||
if !has_key(seen, suggestion.text)
|
||||
call add(a:context.suggestions, suggestion)
|
||||
let seen[suggestion.text] = 1
|
||||
endif
|
||||
endfor
|
||||
for Callback in callbacks
|
||||
call Callback(a:context)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:GetSuggestionsCycling(callback) abort
|
||||
if exists('b:_copilot.cycling_callbacks')
|
||||
call add(b:_copilot.cycling_callbacks, a:callback)
|
||||
elseif exists('b:_copilot.cycling')
|
||||
call a:callback(b:_copilot)
|
||||
elseif exists('b:_copilot.suggestions')
|
||||
let b:_copilot.cycling_callbacks = [a:callback]
|
||||
let b:_copilot.cycling = copilot#Request('getCompletionsCycling',
|
||||
\ b:_copilot.first.params,
|
||||
\ function('s:GetSuggestionsCyclingCallback', [b:_copilot]),
|
||||
\ function('s:GetSuggestionsCyclingCallback', [b:_copilot]),
|
||||
\ )
|
||||
call s:UpdatePreview()
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! copilot#Next() abort
|
||||
return s:GetSuggestionsCycling(function('s:Advance', [1]))
|
||||
endfunction
|
||||
|
||||
function! copilot#Previous() abort
|
||||
return s:GetSuggestionsCycling(function('s:Advance', [-1]))
|
||||
endfunction
|
||||
|
||||
function! copilot#GetDisplayedSuggestion() abort
|
||||
let [text, outdent, delete, uuid] = s:SuggestionTextWithAdjustments()
|
||||
|
||||
return {
|
||||
\ 'uuid': uuid,
|
||||
\ 'text': text,
|
||||
\ 'outdentSize': outdent,
|
||||
\ 'deleteSize': delete}
|
||||
endfunction
|
||||
|
||||
function! s:ClearPreview() abort
|
||||
if s:has_nvim_ghost_text
|
||||
call nvim_buf_del_extmark(0, copilot#NvimNs(), 1)
|
||||
elseif s:has_vim_ghost_text
|
||||
call prop_remove({'type': s:hlgroup, 'all': v:true})
|
||||
call prop_remove({'type': s:annot_hlgroup, 'all': v:true})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:UpdatePreview() abort
|
||||
try
|
||||
let [text, outdent, delete, uuid] = s:SuggestionTextWithAdjustments()
|
||||
let text = split(text, "\n", 1)
|
||||
if empty(text[-1])
|
||||
call remove(text, -1)
|
||||
endif
|
||||
if empty(text) || !s:has_ghost_text
|
||||
return s:ClearPreview()
|
||||
endif
|
||||
if exists('b:_copilot.cycling_callbacks')
|
||||
let annot = '(1/…)'
|
||||
elseif exists('b:_copilot.cycling')
|
||||
let annot = '(' . (b:_copilot.choice + 1) . '/' . len(b:_copilot.suggestions) . ')'
|
||||
else
|
||||
let annot = ''
|
||||
endif
|
||||
call s:ClearPreview()
|
||||
if s:has_nvim_ghost_text
|
||||
let data = {'id': 1}
|
||||
let data.virt_text_win_col = virtcol('.') - 1
|
||||
let append = strpart(getline('.'), col('.') - 1 + delete)
|
||||
let data.virt_text = [[text[0] . append . repeat(' ', delete - len(text[0])), s:hlgroup]]
|
||||
if len(text) > 1
|
||||
let data.virt_lines = map(text[1:-1], { _, l -> [[l, s:hlgroup]] })
|
||||
if !empty(annot)
|
||||
let data.virt_lines[-1] += [[' '], [annot, s:annot_hlgroup]]
|
||||
endif
|
||||
elseif len(annot)
|
||||
let data.virt_text += [[' '], [annot, s:annot_hlgroup]]
|
||||
endif
|
||||
let data.hl_mode = 'combine'
|
||||
call nvim_buf_set_extmark(0, copilot#NvimNs(), line('.')-1, col('.')-1, data)
|
||||
else
|
||||
call prop_add(line('.'), col('.'), {'type': s:hlgroup, 'text': text[0]})
|
||||
for line in text[1:]
|
||||
call prop_add(line('.'), 0, {'type': s:hlgroup, 'text_align': 'below', 'text': line})
|
||||
endfor
|
||||
if !empty(annot)
|
||||
call prop_add(line('.'), col('$'), {'type': s:annot_hlgroup, 'text': ' ' . annot})
|
||||
endif
|
||||
endif
|
||||
if !has_key(b:_copilot.shown_choices, uuid)
|
||||
let b:_copilot.shown_choices[uuid] = v:true
|
||||
call copilot#Request('notifyShown', {'uuid': uuid})
|
||||
endif
|
||||
catch
|
||||
return copilot#logger#Exception()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:HandleTriggerResult(result) abort
|
||||
if !exists('b:_copilot')
|
||||
return
|
||||
endif
|
||||
let b:_copilot.suggestions = get(a:result, 'completions', [])
|
||||
let b:_copilot.choice = 0
|
||||
let b:_copilot.shown_choices = {}
|
||||
call s:UpdatePreview()
|
||||
endfunction
|
||||
|
||||
function! copilot#Suggest() abort
|
||||
try
|
||||
call copilot#Complete(function('s:HandleTriggerResult'), function('s:HandleTriggerResult'))
|
||||
catch
|
||||
call copilot#logger#Exception()
|
||||
endtry
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:Trigger(bufnr, timer) abort
|
||||
let timer = get(g:, '_copilot_timer', -1)
|
||||
if a:bufnr !=# bufnr('') || a:timer isnot# timer || mode() !=# 'i'
|
||||
return
|
||||
endif
|
||||
unlet! g:_copilot_timer
|
||||
return copilot#Suggest()
|
||||
endfunction
|
||||
|
||||
function! copilot#IsMapped() abort
|
||||
return get(g:, 'copilot_assume_mapped') ||
|
||||
\ hasmapto('copilot#Accept(', 'i')
|
||||
endfunction
|
||||
|
||||
function! copilot#Schedule(...) abort
|
||||
if !s:has_ghost_text || !copilot#Enabled() || !copilot#IsMapped()
|
||||
call copilot#Clear()
|
||||
return
|
||||
endif
|
||||
call s:UpdatePreview()
|
||||
let delay = a:0 ? a:1 : get(g:, 'copilot_idle_delay', 15)
|
||||
call timer_stop(get(g:, '_copilot_timer', -1))
|
||||
let g:_copilot_timer = timer_start(delay, function('s:Trigger', [bufnr('')]))
|
||||
endfunction
|
||||
|
||||
function! copilot#OnInsertLeave() abort
|
||||
return copilot#Clear()
|
||||
endfunction
|
||||
|
||||
function! copilot#OnInsertEnter() abort
|
||||
return copilot#Schedule()
|
||||
endfunction
|
||||
|
||||
function! copilot#OnCompleteChanged() abort
|
||||
if s:HideDuringCompletion()
|
||||
return copilot#Clear()
|
||||
else
|
||||
return copilot#Schedule()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#OnCursorMovedI() abort
|
||||
return copilot#Schedule()
|
||||
endfunction
|
||||
|
||||
function! copilot#OnBufUnload() abort
|
||||
call s:Reject(+expand('<abuf>'))
|
||||
endfunction
|
||||
|
||||
function! copilot#OnVimLeavePre() abort
|
||||
endfunction
|
||||
|
||||
function! copilot#TextQueuedForInsertion() abort
|
||||
try
|
||||
return remove(s:, 'suggestion_text')
|
||||
catch
|
||||
return ''
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! copilot#Accept(...) abort
|
||||
let s = copilot#GetDisplayedSuggestion()
|
||||
if !empty(s.text)
|
||||
unlet! b:_copilot
|
||||
let text = ''
|
||||
if a:0 > 1
|
||||
let text = substitute(matchstr(s.text, "\n*" . '\%(' . a:2 .'\)'), "\n*$", '', '')
|
||||
endif
|
||||
if empty(text)
|
||||
let text = s.text
|
||||
endif
|
||||
call copilot#Request('notifyAccepted', {'uuid': s.uuid, 'acceptedLength': copilot#doc#UTF16Width(text)})
|
||||
call s:ClearPreview()
|
||||
let s:suggestion_text = text
|
||||
return repeat("\<Left>\<Del>", s.outdentSize) . repeat("\<Del>", s.deleteSize) .
|
||||
\ "\<C-R>\<C-O>=copilot#TextQueuedForInsertion()\<CR>" . (a:0 > 1 ? '' : "\<End>")
|
||||
endif
|
||||
let default = get(g:, 'copilot_tab_fallback', pumvisible() ? "\<C-N>" : "\t")
|
||||
if !a:0
|
||||
return default
|
||||
elseif type(a:1) == v:t_string
|
||||
return a:1
|
||||
elseif type(a:1) == v:t_func
|
||||
try
|
||||
return call(a:1, [])
|
||||
catch
|
||||
return default
|
||||
endtry
|
||||
else
|
||||
return default
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#AcceptWord(...) abort
|
||||
return copilot#Accept(a:0 ? a:1 : '', '\%(\k\@!.\)*\k*')
|
||||
endfunction
|
||||
|
||||
function! copilot#AcceptLine(...) abort
|
||||
return copilot#Accept(a:0 ? a:1 : "\r", "[^\n]\\+")
|
||||
endfunction
|
||||
|
||||
function! s:BrowserCallback(into, code) abort
|
||||
let a:into.code = a:code
|
||||
endfunction
|
||||
|
||||
function! copilot#Browser() abort
|
||||
if type(get(g:, 'copilot_browser')) == v:t_list
|
||||
let cmd = copy(g:copilot_browser)
|
||||
elseif type(get(g:, 'open_command')) == v:t_list
|
||||
let cmd = copy(g:open_command)
|
||||
elseif has('win32')
|
||||
let cmd = ['rundll32', 'url.dll,FileProtocolHandler']
|
||||
elseif has('mac')
|
||||
let cmd = ['open']
|
||||
elseif executable('wslview')
|
||||
return ['wslview']
|
||||
elseif executable('xdg-open')
|
||||
return ['xdg-open']
|
||||
else
|
||||
return []
|
||||
endif
|
||||
if executable(get(cmd, 0, ''))
|
||||
return cmd
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:OpenURL(params) abort
|
||||
echo a:params.target
|
||||
let browser = copilot#Browser()
|
||||
if empty(browser)
|
||||
return v:false
|
||||
endif
|
||||
let status = {}
|
||||
call copilot#job#Stream(browser + [a:params.target], v:null, v:null, function('s:BrowserCallback', [status]))
|
||||
let time = reltime()
|
||||
while empty(status) && reltimefloat(reltime(time)) < 1
|
||||
sleep 10m
|
||||
endwhile
|
||||
return get(status, 'code') ? v:false : v:true
|
||||
endfunction
|
||||
|
||||
let s:commands = {}
|
||||
|
||||
function! s:EnabledStatusMessage() abort
|
||||
let buf_disabled = s:BufferDisabled()
|
||||
if !s:has_ghost_text
|
||||
if has('nvim')
|
||||
return "Neovim 0.6 required to support ghost text"
|
||||
else
|
||||
return "Vim " . s:vim_minimum_version . " required to support ghost text"
|
||||
endif
|
||||
elseif !copilot#IsMapped()
|
||||
return '<Tab> map has been disabled or is claimed by another plugin'
|
||||
elseif !get(g:, 'copilot_enabled', 1)
|
||||
return 'Disabled globally by :Copilot disable'
|
||||
elseif buf_disabled is# 5
|
||||
return 'Disabled for current buffer by buftype=' . &buftype
|
||||
elseif buf_disabled is# 4
|
||||
return 'Disabled for current buffer by b:copilot_enabled'
|
||||
elseif buf_disabled is# 3
|
||||
return 'Disabled for current buffer by b:copilot_disabled'
|
||||
elseif buf_disabled is# 2
|
||||
return 'Disabled for filetype=' . &filetype . ' by internal default'
|
||||
elseif buf_disabled
|
||||
return 'Disabled for filetype=' . &filetype . ' by g:copilot_filetypes'
|
||||
elseif !copilot#Enabled()
|
||||
return 'BUG: Something is wrong with enabling/disabling'
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:VerifySetup() abort
|
||||
let error = copilot#Agent().StartupError()
|
||||
if !empty(error)
|
||||
echo 'Copilot: ' . error
|
||||
return
|
||||
endif
|
||||
|
||||
let status = copilot#Call('checkStatus', {})
|
||||
|
||||
if !has_key(status, 'user')
|
||||
echo 'Copilot: Not authenticated. Invoke :Copilot setup'
|
||||
return
|
||||
endif
|
||||
|
||||
if status.status ==# 'NoTelemetryConsent'
|
||||
echo 'Copilot: Telemetry terms not accepted. Invoke :Copilot setup'
|
||||
return
|
||||
endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:commands.status(opts) abort
|
||||
if !s:VerifySetup()
|
||||
return
|
||||
endif
|
||||
|
||||
let status = s:EnabledStatusMessage()
|
||||
if !empty(status)
|
||||
echo 'Copilot: ' . status
|
||||
return
|
||||
endif
|
||||
|
||||
let startup_error = copilot#Agent().StartupError()
|
||||
if !empty(startup_error)
|
||||
echo 'Copilot: ' . startup_error
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('s:agent_error')
|
||||
echo 'Copilot: ' . s:agent_error
|
||||
return
|
||||
endif
|
||||
|
||||
let status = copilot#Call('checkStatus', {})
|
||||
if status.status ==# 'NotAuthorized'
|
||||
echo 'Copilot: Not authorized'
|
||||
return
|
||||
endif
|
||||
|
||||
echo 'Copilot: Enabled and online'
|
||||
call s:NodeVersionWarning()
|
||||
endfunction
|
||||
|
||||
function! s:commands.signout(opts) abort
|
||||
let status = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}})
|
||||
if has_key(status, 'user')
|
||||
echo 'Copilot: Signed out as GitHub user ' . status.user
|
||||
else
|
||||
echo 'Copilot: Not signed in'
|
||||
endif
|
||||
call copilot#Call('signOut', {})
|
||||
endfunction
|
||||
|
||||
function! s:commands.setup(opts) abort
|
||||
let startup_error = copilot#Agent().StartupError()
|
||||
if !empty(startup_error)
|
||||
echo 'Copilot: ' . startup_error
|
||||
return
|
||||
endif
|
||||
|
||||
let browser = copilot#Browser()
|
||||
|
||||
let status = copilot#Call('checkStatus', {})
|
||||
if has_key(status, 'user')
|
||||
let data = {}
|
||||
else
|
||||
let data = copilot#Call('signInInitiate', {})
|
||||
endif
|
||||
|
||||
if has_key(data, 'verificationUri')
|
||||
let uri = data.verificationUri
|
||||
if has('clipboard')
|
||||
let @+ = data.userCode
|
||||
let @* = data.userCode
|
||||
endif
|
||||
call s:Echo("First copy your one-time code: " . data.userCode)
|
||||
try
|
||||
if len(&mouse)
|
||||
let mouse = &mouse
|
||||
set mouse=
|
||||
endif
|
||||
if get(a:opts, 'bang')
|
||||
call s:Echo("In your browser, visit " . uri)
|
||||
elseif len(browser)
|
||||
call s:Echo("Press ENTER to open GitHub in your browser")
|
||||
let c = getchar()
|
||||
while c isnot# 13 && c isnot# 10 && c isnot# 0
|
||||
let c = getchar()
|
||||
endwhile
|
||||
let status = {}
|
||||
call copilot#job#Stream(browser + [uri], v:null, v:null, function('s:BrowserCallback', [status]))
|
||||
let time = reltime()
|
||||
while empty(status) && reltimefloat(reltime(time)) < 5
|
||||
sleep 10m
|
||||
endwhile
|
||||
if get(status, 'code', browser[0] !=# 'xdg-open') != 0
|
||||
call s:Echo("Failed to open browser. Visit " . uri)
|
||||
else
|
||||
call s:Echo("Opened " . uri)
|
||||
endif
|
||||
else
|
||||
call s:Echo("Could not find browser. Visit " . uri)
|
||||
endif
|
||||
call s:Echo("Waiting (could take up to 5 seconds)")
|
||||
let request = copilot#Request('signInConfirm', {'userCode': data.userCode}).Wait()
|
||||
finally
|
||||
if exists('mouse')
|
||||
let &mouse = mouse
|
||||
endif
|
||||
endtry
|
||||
if request.status ==# 'error'
|
||||
return 'echoerr ' . string('Copilot: Authentication failure: ' . request.error.message)
|
||||
else
|
||||
let status = request.result
|
||||
endif
|
||||
endif
|
||||
|
||||
let user = get(status, 'user', '<unknown>')
|
||||
|
||||
echo 'Copilot: Authenticated as GitHub user ' . user
|
||||
endfunction
|
||||
|
||||
let s:commands.auth = s:commands.setup
|
||||
|
||||
function! s:commands.help(opts) abort
|
||||
return a:opts.mods . ' help ' . (len(a:opts.arg) ? ':Copilot_' . a:opts.arg : 'copilot')
|
||||
endfunction
|
||||
|
||||
function! s:commands.version(opts) abort
|
||||
let info = copilot#agent#EditorInfo()
|
||||
echo 'copilot.vim ' .info.editorPluginInfo.version
|
||||
echo info.editorInfo.name . ' ' . info.editorInfo.version
|
||||
if s:Running()
|
||||
let versions = s:agent.Call('getVersion', {})
|
||||
echo 'dist/agent.js ' . versions.version
|
||||
echo 'Node.js ' . get(s:agent, 'node_version', substitute(get(versions, 'runtimeVersion', '?'), '^node/', '', 'g'))
|
||||
call s:NodeVersionWarning()
|
||||
else
|
||||
echo 'dist/agent.js not running'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:UpdateEditorConfiguration() abort
|
||||
try
|
||||
if s:Running()
|
||||
call copilot#Notify('notifyChangeConfiguration', {'settings': s:EditorConfiguration()})
|
||||
endif
|
||||
catch
|
||||
call copilot#logger#Exception()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
let s:feedback_url = 'https://github.com/orgs/community/discussions/categories/copilot'
|
||||
function! s:commands.feedback(opts) abort
|
||||
echo s:feedback_url
|
||||
let browser = copilot#Browser()
|
||||
if len(browser)
|
||||
call copilot#job#Stream(browser + [s:feedback_url], v:null, v:null, v:null)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:commands.restart(opts) abort
|
||||
call s:Stop()
|
||||
let err = copilot#Agent().StartupError()
|
||||
if !empty(err)
|
||||
return 'echoerr ' . string('Copilot: ' . err)
|
||||
endif
|
||||
echo 'Copilot: Restarting agent.'
|
||||
endfunction
|
||||
|
||||
function! s:commands.disable(opts) abort
|
||||
let g:copilot_enabled = 0
|
||||
call s:UpdateEditorConfiguration()
|
||||
endfunction
|
||||
|
||||
function! s:commands.enable(opts) abort
|
||||
let g:copilot_enabled = 1
|
||||
call s:UpdateEditorConfiguration()
|
||||
endfunction
|
||||
|
||||
function! s:commands.panel(opts) abort
|
||||
if s:VerifySetup()
|
||||
return copilot#panel#Open(a:opts)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#CommandComplete(arg, lead, pos) abort
|
||||
let args = matchstr(strpart(a:lead, 0, a:pos), 'C\%[opilot][! ] *\zs.*')
|
||||
if args !~# ' '
|
||||
return sort(filter(map(keys(s:commands), { k, v -> tr(v, '_', '-') }),
|
||||
\ { k, v -> strpart(v, 0, len(a:arg)) ==# a:arg }))
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#Command(line1, line2, range, bang, mods, arg) abort
|
||||
let cmd = matchstr(a:arg, '^\%(\\.\|\S\)\+')
|
||||
let arg = matchstr(a:arg, '\s\zs\S.*')
|
||||
if cmd ==# 'log'
|
||||
return a:mods . ' split +$ ' . fnameescape(copilot#logger#File())
|
||||
endif
|
||||
if !empty(cmd) && !has_key(s:commands, tr(cmd, '-', '_'))
|
||||
return 'echoerr ' . string('Copilot: unknown command ' . string(cmd))
|
||||
endif
|
||||
try
|
||||
let err = copilot#Agent().StartupError()
|
||||
if !empty(err)
|
||||
return 'echo ' . string('Copilot: ' . err)
|
||||
endif
|
||||
try
|
||||
let opts = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}})
|
||||
catch
|
||||
call copilot#logger#Exception()
|
||||
let opts = {'status': 'VimException'}
|
||||
endtry
|
||||
if empty(cmd)
|
||||
if opts.status ==# 'VimException'
|
||||
return a:mods . ' split +$ ' . fnameescape(copilot#logger#File())
|
||||
elseif opts.status !=# 'OK' && opts.status !=# 'MaybeOK'
|
||||
let cmd = 'setup'
|
||||
else
|
||||
let cmd = 'panel'
|
||||
endif
|
||||
endif
|
||||
call extend(opts, {'line1': a:line1, 'line2': a:line2, 'range': a:range, 'bang': a:bang, 'mods': a:mods, 'arg': arg})
|
||||
let retval = s:commands[tr(cmd, '-', '_')](opts)
|
||||
if type(retval) == v:t_string
|
||||
return retval
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
catch /^Copilot:/
|
||||
return 'echoerr ' . string(v:exception)
|
||||
endtry
|
||||
endfunction
|
603
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/agent.vim
Normal file
603
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/agent.vim
Normal file
@ -0,0 +1,603 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:plugin_version = copilot#version#String()
|
||||
|
||||
let s:error_exit = -1
|
||||
|
||||
let s:root = expand('<sfile>:h:h:h')
|
||||
|
||||
if !exists('s:instances')
|
||||
let s:instances = {}
|
||||
endif
|
||||
|
||||
" allow sourcing this file to reload the Lua file too
|
||||
if has('nvim')
|
||||
lua package.loaded._copilot = nil
|
||||
endif
|
||||
|
||||
let s:jobstop = function(exists('*jobstop') ? 'jobstop' : 'job_stop')
|
||||
function! s:Kill(agent, ...) abort
|
||||
if has_key(a:agent, 'job')
|
||||
call s:jobstop(a:agent.job)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:AgentClose() dict abort
|
||||
if !has_key(self, 'job')
|
||||
return
|
||||
endif
|
||||
if exists('*chanclose')
|
||||
call chanclose(self.job, 'stdin')
|
||||
else
|
||||
call ch_close_in(self.job)
|
||||
endif
|
||||
call copilot#logger#Info('agent stopped')
|
||||
call timer_start(2000, function('s:Kill', [self]))
|
||||
endfunction
|
||||
|
||||
function! s:LogSend(request, line) abort
|
||||
return '--> ' . a:line
|
||||
endfunction
|
||||
|
||||
function! s:RejectRequest(request, error) abort
|
||||
if a:request.status ==# 'canceled'
|
||||
return
|
||||
endif
|
||||
let a:request.waiting = {}
|
||||
call remove(a:request, 'resolve')
|
||||
let reject = remove(a:request, 'reject')
|
||||
let a:request.status = 'error'
|
||||
let a:request.error = a:error
|
||||
for Cb in reject
|
||||
let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'error', Cb]))] = 1
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:Send(agent, request) abort
|
||||
try
|
||||
call ch_sendexpr(a:agent.job, a:request)
|
||||
return v:true
|
||||
catch /^Vim\%((\a\+)\)\=:E631:/
|
||||
return v:false
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:AgentNotify(method, params) dict abort
|
||||
return s:Send(self, {'method': a:method, 'params': a:params})
|
||||
endfunction
|
||||
|
||||
function! s:RequestWait() dict abort
|
||||
while self.status ==# 'running'
|
||||
sleep 1m
|
||||
endwhile
|
||||
while !empty(get(self, 'waiting', {}))
|
||||
sleep 1m
|
||||
endwhile
|
||||
return self
|
||||
endfunction
|
||||
|
||||
function! s:RequestAwait() dict abort
|
||||
call self.Wait()
|
||||
if has_key(self, 'result')
|
||||
return self.result
|
||||
endif
|
||||
throw 'copilot#agent:E' . self.error.code . ': ' . self.error.message
|
||||
endfunction
|
||||
|
||||
function! s:RequestAgent() dict abort
|
||||
return get(s:instances, self.agent_id, v:null)
|
||||
endfunction
|
||||
|
||||
if !exists('s:id')
|
||||
let s:id = 0
|
||||
endif
|
||||
|
||||
function! s:SetUpRequest(agent, id, method, params, ...) abort
|
||||
let request = {
|
||||
\ 'agent_id': a:agent.id,
|
||||
\ 'id': a:id,
|
||||
\ 'method': a:method,
|
||||
\ 'params': a:params,
|
||||
\ 'Agent': function('s:RequestAgent'),
|
||||
\ 'Wait': function('s:RequestWait'),
|
||||
\ 'Await': function('s:RequestAwait'),
|
||||
\ 'Cancel': function('s:RequestCancel'),
|
||||
\ 'resolve': [],
|
||||
\ 'reject': [],
|
||||
\ 'status': 'running'}
|
||||
let a:agent.requests[a:id] = request
|
||||
let args = a:000[2:-1]
|
||||
if len(args)
|
||||
if !empty(a:1)
|
||||
call add(request.resolve, { v -> call(a:1, [v] + args)})
|
||||
endif
|
||||
if !empty(a:2)
|
||||
call add(request.reject, { v -> call(a:2, [v] + args)})
|
||||
endif
|
||||
return request
|
||||
endif
|
||||
if a:0 && !empty(a:1)
|
||||
call add(request.resolve, a:1)
|
||||
endif
|
||||
if a:0 > 1 && !empty(a:2)
|
||||
call add(request.reject, a:2)
|
||||
endif
|
||||
return request
|
||||
endfunction
|
||||
|
||||
function! s:UrlEncode(str) abort
|
||||
return substitute(iconv(a:str, 'latin1', 'utf-8'),'[^A-Za-z0-9._~!$&''()*+,;=:@/-]','\="%".printf("%02X",char2nr(submatch(0)))','g')
|
||||
endfunction
|
||||
|
||||
let s:slash = exists('+shellslash') ? '\' : '/'
|
||||
function! s:UriFromBufnr(bufnr) abort
|
||||
let absolute = tr(bufname(a:bufnr), s:slash, '/')
|
||||
if absolute !~# '^\a\+:\|^/\|^$' && getbufvar(a:bufnr, 'buftype') =~# '^\%(nowrite\)\=$'
|
||||
let absolute = substitute(tr(getcwd(), s:slash, '/'), '/\=$', '/', '') . absolute
|
||||
endif
|
||||
if has('win32') && absolute =~# '^\a://\@!'
|
||||
return 'file:///' . strpart(absolute, 0, 2) . s:UrlEncode(strpart(absolute, 2))
|
||||
elseif absolute =~# '^/'
|
||||
return 'file://' . s:UrlEncode(absolute)
|
||||
elseif absolute =~# '^\a[[:alnum:].+-]*:\|^$'
|
||||
return absolute
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:BufferText(bufnr) abort
|
||||
return join(getbufline(a:bufnr, 1, '$'), "\n") . "\n"
|
||||
endfunction
|
||||
|
||||
function! s:LogMessage(params) abort
|
||||
call copilot#logger#Raw(get(a:params, 'level', 3), get(a:params, 'message', ''))
|
||||
endfunction
|
||||
|
||||
function! s:ShowMessageRequest(params) abort
|
||||
let choice = inputlist([a:params.message . "\n\nRequest Actions:"] +
|
||||
\ map(copy(get(a:params, 'actions', [])), { i, v -> (i + 1) . '. ' . v.title}))
|
||||
return choice > 0 ? get(a:params.actions, choice - 1, v:null) : v:null
|
||||
endfunction
|
||||
|
||||
function! s:SendRequest(agent, request) abort
|
||||
if empty(s:Send(a:agent, a:request)) && has_key(a:agent.requests, a:request.id)
|
||||
call s:RejectRequest(remove(a:agent.requests, a:request.id), {'code': 257, 'message': 'Write failed'})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:AgentRequest(method, params, ...) dict abort
|
||||
let s:id += 1
|
||||
let request = {'method': a:method, 'params': deepcopy(a:params), 'id': s:id}
|
||||
for doc in filter([get(request.params, 'doc', {}), get(request.params, 'textDocument',{})], 'type(get(v:val, "uri", "")) == v:t_number')
|
||||
let bufnr = doc.uri
|
||||
let doc.uri = s:UriFromBufnr(doc.uri)
|
||||
let uri = doc.uri
|
||||
let languageId = copilot#doc#LanguageForFileType(getbufvar(bufnr, '&filetype'))
|
||||
let doc_version = getbufvar(bufnr, 'changedtick')
|
||||
if has_key(self.open_buffers, bufnr) && (
|
||||
\ self.open_buffers[bufnr].uri !=# doc.uri ||
|
||||
\ self.open_buffers[bufnr].languageId !=# languageId)
|
||||
call remove(self.open_buffers, bufnr)
|
||||
sleep 1m
|
||||
endif
|
||||
if !has_key(self.open_buffers, bufnr)
|
||||
let td_item = {
|
||||
\ 'uri': doc.uri,
|
||||
\ 'version': doc_version,
|
||||
\ 'languageId': languageId,
|
||||
\ 'text': s:BufferText(bufnr)}
|
||||
call self.Notify('textDocument/didOpen', {'textDocument': td_item})
|
||||
let self.open_buffers[bufnr] = {
|
||||
\ 'uri': doc.uri,
|
||||
\ 'version': doc_version,
|
||||
\ 'languageId': languageId}
|
||||
else
|
||||
let vtd_id = {
|
||||
\ 'uri': doc.uri,
|
||||
\ 'version': doc_version}
|
||||
call self.Notify('textDocument/didChange', {
|
||||
\ 'textDocument': vtd_id,
|
||||
\ 'contentChanges': [{'text': s:BufferText(bufnr)}]})
|
||||
let self.open_buffers[bufnr].version = doc_version
|
||||
endif
|
||||
let doc.version = doc_version
|
||||
endfor
|
||||
call timer_start(0, { _ -> s:SendRequest(self, request) })
|
||||
return call('s:SetUpRequest', [self, s:id, a:method, a:params] + a:000)
|
||||
endfunction
|
||||
|
||||
function! s:AgentCall(method, params, ...) dict abort
|
||||
let request = call(self.Request, [a:method, a:params] + a:000)
|
||||
if a:0
|
||||
return request
|
||||
endif
|
||||
return request.Await()
|
||||
endfunction
|
||||
|
||||
function! s:AgentCancel(request) dict abort
|
||||
if has_key(self.requests, get(a:request, 'id', ''))
|
||||
call remove(self.requests, a:request.id)
|
||||
call self.Notify('$/cancelRequest', {'id': a:request.id})
|
||||
endif
|
||||
if get(a:request, 'status', '') ==# 'running'
|
||||
let a:request.status = 'canceled'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:RequestCancel() dict abort
|
||||
let agent = self.Agent()
|
||||
if !empty(agent)
|
||||
call agent.Cancel(self)
|
||||
elseif get(self, 'status', '') ==# 'running'
|
||||
let self.status = 'canceled'
|
||||
endif
|
||||
return self
|
||||
endfunction
|
||||
|
||||
function! s:DispatchMessage(agent, method, handler, id, params, ...) abort
|
||||
try
|
||||
let response = {'result': call(a:handler, [a:params])}
|
||||
if response.result is# 0
|
||||
let response.result = v:null
|
||||
endif
|
||||
catch
|
||||
call copilot#logger#Exception('lsp.request.' . a:method)
|
||||
let response = {'error': {'code': -32000, 'message': v:exception}}
|
||||
endtry
|
||||
if !empty(a:id)
|
||||
call s:Send(a:agent, extend({'id': a:id}, response))
|
||||
endif
|
||||
return response
|
||||
endfunction
|
||||
|
||||
function! s:OnMessage(agent, body, ...) abort
|
||||
if !has_key(a:body, 'method')
|
||||
return s:OnResponse(a:agent, a:body)
|
||||
endif
|
||||
let request = a:body
|
||||
let id = get(request, 'id', v:null)
|
||||
let params = get(request, 'params', v:null)
|
||||
if has_key(a:agent.methods, request.method)
|
||||
return s:DispatchMessage(a:agent, request.method, a:agent.methods[request.method], id, params)
|
||||
elseif !empty(id)
|
||||
call s:Send(a:agent, {"id": id, "error": {"code": -32700, "message": "Method not found: " . request.method}})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:OnResponse(agent, response, ...) abort
|
||||
let response = a:response
|
||||
let id = get(a:response, 'id', v:null)
|
||||
if !has_key(a:agent.requests, id)
|
||||
return
|
||||
endif
|
||||
let request = remove(a:agent.requests, id)
|
||||
if request.status ==# 'canceled'
|
||||
return
|
||||
endif
|
||||
let request.waiting = {}
|
||||
let resolve = remove(request, 'resolve')
|
||||
let reject = remove(request, 'reject')
|
||||
if has_key(response, 'result')
|
||||
let request.status = 'success'
|
||||
let request.result = response.result
|
||||
for Cb in resolve
|
||||
let request.waiting[timer_start(0, function('s:Callback', [request, 'result', Cb]))] = 1
|
||||
endfor
|
||||
else
|
||||
let request.status = 'error'
|
||||
let request.error = response.error
|
||||
for Cb in reject
|
||||
let request.waiting[timer_start(0, function('s:Callback', [request, 'error', Cb]))] = 1
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:OnErr(agent, line, ...) abort
|
||||
call copilot#logger#Debug('<-! ' . a:line)
|
||||
endfunction
|
||||
|
||||
function! s:OnExit(agent, code, ...) abort
|
||||
let a:agent.exit_status = a:code
|
||||
if has_key(a:agent, 'job')
|
||||
call remove(a:agent, 'job')
|
||||
endif
|
||||
if has_key(a:agent, 'client_id')
|
||||
call remove(a:agent, 'client_id')
|
||||
endif
|
||||
let code = a:code < 0 || a:code > 255 ? 256 : a:code
|
||||
for id in sort(keys(a:agent.requests), { a, b -> +a > +b })
|
||||
call s:RejectRequest(remove(a:agent.requests, id), {'code': code, 'message': 'Agent exited', 'data': {'status': a:code}})
|
||||
endfor
|
||||
call timer_start(0, { _ -> get(s:instances, a:agent.id) is# a:agent ? remove(s:instances, a:agent.id) : {} })
|
||||
call copilot#logger#Info('agent exited with status ' . a:code)
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#LspInit(agent_id, initialize_result) abort
|
||||
if !has_key(s:instances, a:agent_id)
|
||||
return
|
||||
endif
|
||||
let instance = s:instances[a:agent_id]
|
||||
call timer_start(0, { _ -> s:GetCapabilitiesResult(a:initialize_result, instance)})
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#LspExit(agent_id, code, signal) abort
|
||||
if !has_key(s:instances, a:agent_id)
|
||||
return
|
||||
endif
|
||||
let instance = remove(s:instances, a:agent_id)
|
||||
call s:OnExit(instance, a:code)
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#LspResponse(agent_id, opts, ...) abort
|
||||
if !has_key(s:instances, a:agent_id)
|
||||
return
|
||||
endif
|
||||
call s:OnResponse(s:instances[a:agent_id], a:opts)
|
||||
endfunction
|
||||
|
||||
function! s:LspRequest(method, params, ...) dict abort
|
||||
let id = v:lua.require'_copilot'.lsp_request(self.id, a:method, a:params)
|
||||
if id isnot# v:null
|
||||
return call('s:SetUpRequest', [self, id, a:method, a:params] + a:000)
|
||||
endif
|
||||
if has_key(self, 'client_id')
|
||||
call copilot#agent#LspExit(self.client_id, -1, -1)
|
||||
endif
|
||||
throw 'copilot#agent: LSP client not available'
|
||||
endfunction
|
||||
|
||||
function! s:LspClose() dict abort
|
||||
if !has_key(self, 'client_id')
|
||||
return
|
||||
endif
|
||||
return luaeval('vim.lsp.get_client_by_id(_A).stop()', self.client_id)
|
||||
endfunction
|
||||
|
||||
function! s:LspNotify(method, params) dict abort
|
||||
return v:lua.require'_copilot'.rpc_notify(self.id, a:method, a:params)
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#LspHandle(agent_id, request) abort
|
||||
if !has_key(s:instances, a:agent_id)
|
||||
return
|
||||
endif
|
||||
return s:OnMessage(s:instances[a:agent_id], a:request)
|
||||
endfunction
|
||||
|
||||
function! s:GetNodeVersion(command) abort
|
||||
let out = []
|
||||
let err = []
|
||||
let status = copilot#job#Stream(a:command + ['--version'], function('add', [out]), function('add', [err]))
|
||||
let string = matchstr(join(out, ''), '^v\zs\d\+\.[^[:space:]]*')
|
||||
if status != 0
|
||||
let string = ''
|
||||
endif
|
||||
let major = str2nr(string)
|
||||
let minor = str2nr(matchstr(string, '\.\zs\d\+'))
|
||||
return {'status': status, 'string': string, 'major': major, 'minor': minor}
|
||||
endfunction
|
||||
|
||||
function! s:Command() abort
|
||||
if !has('nvim-0.6') && v:version < 900
|
||||
return [v:null, '', 'Vim version too old']
|
||||
endif
|
||||
let agent = get(g:, 'copilot_agent_command', '')
|
||||
if empty(agent) || !filereadable(agent)
|
||||
let agent = s:root . '/dist/agent.js'
|
||||
if !filereadable(agent)
|
||||
return [v:null, '', 'Could not find dist/agent.js (bad install?)']
|
||||
endif
|
||||
endif
|
||||
let node = get(g:, 'copilot_node_command', '')
|
||||
if empty(node)
|
||||
let node = ['node']
|
||||
elseif type(node) == type('')
|
||||
let node = [expand(node)]
|
||||
endif
|
||||
if !executable(get(node, 0, ''))
|
||||
if get(node, 0, '') ==# 'node'
|
||||
return [v:null, '', 'Node.js not found in PATH']
|
||||
else
|
||||
return [v:null, '', 'Node.js executable `' . get(node, 0, '') . "' not found"]
|
||||
endif
|
||||
endif
|
||||
if get(g:, 'copilot_ignore_node_version')
|
||||
return [node + [agent, '--stdio'], '', '']
|
||||
endif
|
||||
let node_version = s:GetNodeVersion(node)
|
||||
let warning = ''
|
||||
if node_version.major < 18 && get(node, 0, '') !=# 'node' && executable('node')
|
||||
let node_version_from_path = s:GetNodeVersion(['node'])
|
||||
if node_version_from_path.major >= 18
|
||||
let warning = 'Ignoring g:copilot_node_command: Node.js ' . node_version.string . ' is end-of-life'
|
||||
let node = ['node']
|
||||
let node_version = node_version_from_path
|
||||
endif
|
||||
endif
|
||||
if node_version.status != 0
|
||||
return [v:null, '', 'Node.js exited with status ' . node_version.status]
|
||||
endif
|
||||
if !get(g:, 'copilot_ignore_node_version')
|
||||
if node_version.major == 0
|
||||
return [v:null, node_version.string, 'Could not determine Node.js version']
|
||||
elseif node_version.major < 16 || node_version.major == 16 && node_version.minor < 14 || node_version.major == 17 && node_version.minor < 3
|
||||
" 16.14+ and 17.3+ still work for now, but are end-of-life
|
||||
return [v:null, node_version.string, 'Node.js version 18.x or newer required but found ' . node_version.string]
|
||||
endif
|
||||
endif
|
||||
return [node + [agent, '--stdio'], node_version.string, warning]
|
||||
endfunction
|
||||
|
||||
function! s:UrlDecode(str) abort
|
||||
return substitute(a:str, '%\(\x\x\)', '\=iconv(nr2char("0x".submatch(1)), "utf-8", "latin1")', 'g')
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#EditorInfo() abort
|
||||
if !exists('s:editor_version')
|
||||
if has('nvim')
|
||||
let s:editor_version = matchstr(execute('version'), 'NVIM v\zs[^[:space:]]\+')
|
||||
else
|
||||
let s:editor_version = (v:version / 100) . '.' . (v:version % 100) . (exists('v:versionlong') ? printf('.%04d', v:versionlong % 1000) : '')
|
||||
endif
|
||||
endif
|
||||
let info = {
|
||||
\ 'editorInfo': {'name': has('nvim') ? 'Neovim': 'Vim', 'version': s:editor_version},
|
||||
\ 'editorPluginInfo': {'name': 'copilot.vim', 'version': s:plugin_version}}
|
||||
if type(get(g:, 'copilot_proxy')) == v:t_string
|
||||
let proxy = g:copilot_proxy
|
||||
else
|
||||
let proxy = ''
|
||||
endif
|
||||
let match = matchlist(proxy, '\c^\%([^:]\+://\)\=\%(\([^/#]\+@\)\)\=\%(\([^/:#]\+\)\|\[\([[:xdigit:]:]\+\)\]\)\%(:\(\d\+\)\)\=\%(/\|$\|?strict_\=ssl=\(.*\)\)')
|
||||
if !empty(match)
|
||||
let info.networkProxy = {'host': match[2] . match[3], 'port': empty(match[4]) ? 80 : +match[4]}
|
||||
if match[5] =~? '^[0f]'
|
||||
let info.networkProxy.rejectUnauthorized = v:false
|
||||
elseif match[5] =~? '^[1t]'
|
||||
let info.networkProxy.rejectUnauthorized = v:true
|
||||
elseif exists('g:copilot_proxy_strict_ssl')
|
||||
let info.networkProxy.rejectUnauthorized = empty(g:copilot_proxy_strict_ssl) ? v:false : v:true
|
||||
endif
|
||||
if !empty(match[1])
|
||||
let info.networkProxy.username = s:UrlDecode(matchstr(match[1], '^[^:@]*'))
|
||||
let info.networkProxy.password = s:UrlDecode(matchstr(match[1], ':\zs[^@]*'))
|
||||
endif
|
||||
endif
|
||||
return info
|
||||
endfunction
|
||||
|
||||
function! s:GetCapabilitiesResult(result, agent) abort
|
||||
let a:agent.capabilities = get(a:result, 'capabilities', {})
|
||||
let info = copilot#agent#EditorInfo()
|
||||
call a:agent.Request('setEditorInfo', extend({'editorConfiguration': a:agent.editorConfiguration}, info))
|
||||
endfunction
|
||||
|
||||
function! s:GetCapabilitiesError(error, agent) abort
|
||||
if a:error.code == s:error_exit
|
||||
let a:agent.startup_error = 'Agent exited with status ' . a:error.data.status
|
||||
else
|
||||
let a:agent.startup_error = 'Unexpected error ' . a:error.code . ' calling agent: ' . a:error.message
|
||||
call a:agent.Close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:AgentStartupError() dict abort
|
||||
while (has_key(self, 'job') || has_key(self, 'client_id')) && !has_key(self, 'startup_error') && !has_key(self, 'capabilities')
|
||||
sleep 10m
|
||||
endwhile
|
||||
if has_key(self, 'capabilities')
|
||||
return ''
|
||||
else
|
||||
return get(self, 'startup_error', 'Something unexpected went wrong spawning the agent')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#New(...) abort
|
||||
let opts = a:0 ? a:1 : {}
|
||||
let instance = {'requests': {},
|
||||
\ 'editorConfiguration': get(opts, 'editorConfiguration', {}),
|
||||
\ 'Close': function('s:AgentClose'),
|
||||
\ 'Notify': function('s:AgentNotify'),
|
||||
\ 'Request': function('s:AgentRequest'),
|
||||
\ 'Call': function('s:AgentCall'),
|
||||
\ 'Cancel': function('s:AgentCancel'),
|
||||
\ 'StartupError': function('s:AgentStartupError'),
|
||||
\ }
|
||||
let instance.methods = extend({
|
||||
\ 'LogMessage': function('s:LogMessage'),
|
||||
\ 'window/logMessage': function('s:LogMessage'),
|
||||
\ }, get(opts, 'methods', {}))
|
||||
let [command, node_version, command_error] = s:Command()
|
||||
if len(command_error)
|
||||
if empty(command)
|
||||
let instance.id = -1
|
||||
let instance.startup_error = command_error
|
||||
return instance
|
||||
else
|
||||
let instance.node_version_warning = command_error
|
||||
endif
|
||||
endif
|
||||
if !empty(node_version)
|
||||
let instance.node_version = node_version
|
||||
endif
|
||||
if has('nvim')
|
||||
call extend(instance, {
|
||||
\ 'Close': function('s:LspClose'),
|
||||
\ 'Notify': function('s:LspNotify'),
|
||||
\ 'Request': function('s:LspRequest')})
|
||||
let instance.client_id = v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods))
|
||||
let instance.id = instance.client_id
|
||||
else
|
||||
let state = {'headers': {}, 'mode': 'headers', 'buffer': ''}
|
||||
let instance.open_buffers = {}
|
||||
let instance.methods = extend({'window/showMessageRequest': function('s:ShowMessageRequest')}, instance.methods)
|
||||
let instance.job = job_start(command, {
|
||||
\ 'cwd': copilot#job#Cwd(),
|
||||
\ 'in_mode': 'lsp',
|
||||
\ 'out_mode': 'lsp',
|
||||
\ 'out_cb': { j, d -> timer_start(0, function('s:OnMessage', [instance, d])) },
|
||||
\ 'err_cb': { j, d -> timer_start(0, function('s:OnErr', [instance, d])) },
|
||||
\ 'exit_cb': { j, d -> timer_start(0, function('s:OnExit', [instance, d])) },
|
||||
\ })
|
||||
let instance.id = exists('*jobpid') ? jobpid(instance.job) : job_info(instance.job).process
|
||||
let capabilities = {'workspace': {'workspaceFolders': v:true}, 'copilot': {}}
|
||||
for name in keys(instance.methods)
|
||||
if name =~# '^copilot/'
|
||||
let capabilities.copilot[matchstr(name, '/\zs.*')] = v:true
|
||||
endif
|
||||
endfor
|
||||
let request = instance.Request('initialize', {'capabilities': capabilities}, function('s:GetCapabilitiesResult'), function('s:GetCapabilitiesError'), instance)
|
||||
endif
|
||||
let s:instances[instance.id] = instance
|
||||
return instance
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#Cancel(request) abort
|
||||
if type(a:request) == type({}) && has_key(a:request, 'Cancel')
|
||||
call a:request.Cancel()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:Callback(request, type, callback, timer) abort
|
||||
call remove(a:request.waiting, a:timer)
|
||||
if has_key(a:request, a:type)
|
||||
call a:callback(a:request[a:type])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#Result(request, callback) abort
|
||||
if has_key(a:request, 'resolve')
|
||||
call add(a:request.resolve, a:callback)
|
||||
elseif has_key(a:request, 'result')
|
||||
let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'result', a:callback]))] = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#agent#Error(request, callback) abort
|
||||
if has_key(a:request, 'reject')
|
||||
call add(a:request.reject, a:callback)
|
||||
elseif has_key(a:request, 'error')
|
||||
let a:request.waiting[timer_start(0, function('s:Callback', [a:request, 'error', a:callback]))] = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:CloseBuffer(bufnr) abort
|
||||
for instance in values(s:instances)
|
||||
try
|
||||
if has_key(instance, 'job') && has_key(instance.open_buffers, a:bufnr)
|
||||
let buffer = remove(instance.open_buffers, a:bufnr)
|
||||
call instance.Notify('textDocument/didClose', {'textDocument': {'uri': buffer.uri}})
|
||||
endif
|
||||
catch
|
||||
call copilot#logger#Exception()
|
||||
endtry
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
augroup copilot_agent
|
||||
autocmd!
|
||||
if !has('nvim')
|
||||
autocmd BufUnload * call s:CloseBuffer(+expand('<abuf>'))
|
||||
endif
|
||||
augroup END
|
111
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/doc.vim
Normal file
111
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/doc.vim
Normal file
@ -0,0 +1,111 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:slash = exists('+shellslash') ? '\' : '/'
|
||||
|
||||
function! copilot#doc#UTF16Width(str) abort
|
||||
return strchars(substitute(a:str, "\\%#=2[^\u0001-\uffff]", " ", 'g'))
|
||||
endfunction
|
||||
|
||||
if exists('*utf16idx')
|
||||
|
||||
function! copilot#doc#UTF16ToByteIdx(str, utf16_idx) abort
|
||||
return byteidx(a:str, a:utf16_idx, 1)
|
||||
endfunction
|
||||
|
||||
elseif has('nvim')
|
||||
|
||||
function! copilot#doc#UTF16ToByteIdx(str, utf16_idx) abort
|
||||
try
|
||||
return v:lua.vim.str_byteindex(a:str, a:utf16_idx, 1)
|
||||
catch /^Vim(return):E5108:/
|
||||
return -1
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
else
|
||||
|
||||
function! copilot#doc#UTF16ToByteIdx(str, utf16_idx) abort
|
||||
if copilot#doc#UTF16Width(a:str) < a:utf16_idx
|
||||
return -1
|
||||
endif
|
||||
let end_offset = len(a:str)
|
||||
while copilot#doc#UTF16Width(strpart(a:str, 0, end_offset)) > a:utf16_idx && end_offset > 0
|
||||
let end_offset -= 1
|
||||
endwhile
|
||||
return end_offset
|
||||
endfunction
|
||||
|
||||
endif
|
||||
|
||||
|
||||
let s:language_normalization_map = {
|
||||
\ "bash": "shellscript",
|
||||
\ "bst": "bibtex",
|
||||
\ "cs": "csharp",
|
||||
\ "cuda": "cuda-cpp",
|
||||
\ "dosbatch": "bat",
|
||||
\ "dosini": "ini",
|
||||
\ "gitcommit": "git-commit",
|
||||
\ "gitrebase": "git-rebase",
|
||||
\ "make": "makefile",
|
||||
\ "objc": "objective-c",
|
||||
\ "objcpp": "objective-cpp",
|
||||
\ "ps1": "powershell",
|
||||
\ "raku": "perl6",
|
||||
\ "sh": "shellscript",
|
||||
\ "text": "plaintext",
|
||||
\ }
|
||||
function! copilot#doc#LanguageForFileType(filetype) abort
|
||||
let filetype = substitute(a:filetype, '\..*', '', '')
|
||||
return get(s:language_normalization_map, empty(filetype) ? "text" : filetype, filetype)
|
||||
endfunction
|
||||
|
||||
function! s:RelativePath(absolute) abort
|
||||
if exists('b:copilot_relative_path')
|
||||
return b:copilot_relative_path
|
||||
elseif exists('b:copilot_root')
|
||||
let root = b:copilot_root
|
||||
elseif len(get(b:, 'projectionist', {}))
|
||||
let root = sort(keys(b:projectionist), { a, b -> a < b })[0]
|
||||
else
|
||||
let root = getcwd()
|
||||
endif
|
||||
let root = tr(root, s:slash, '/') . '/'
|
||||
if strpart(tr(a:absolute, 'A-Z', 'a-z'), 0, len(root)) ==# tr(root, 'A-Z', 'a-z')
|
||||
return strpart(a:absolute, len(root))
|
||||
else
|
||||
return fnamemodify(a:absolute, ':t')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! copilot#doc#Get() abort
|
||||
let absolute = tr(@%, s:slash, '/')
|
||||
if absolute !~# '^\a\+:\|^/\|^$' && &buftype =~# '^\%(nowrite\)\=$'
|
||||
let absolute = substitute(tr(getcwd(), s:slash, '/'), '/\=$', '/', '') . absolute
|
||||
endif
|
||||
let doc = {
|
||||
\ 'uri': bufnr(''),
|
||||
\ 'version': getbufvar('', 'changedtick'),
|
||||
\ 'relativePath': s:RelativePath(absolute),
|
||||
\ 'insertSpaces': &expandtab ? v:true : v:false,
|
||||
\ 'tabSize': shiftwidth(),
|
||||
\ 'indentSize': shiftwidth(),
|
||||
\ }
|
||||
let line = getline('.')
|
||||
let col_byte = col('.') - (mode() =~# '^[iR]' || empty(line))
|
||||
let col_utf16 = copilot#doc#UTF16Width(strpart(line, 0, col_byte))
|
||||
let doc.position = {'line': line('.') - 1, 'character': col_utf16}
|
||||
return doc
|
||||
endfunction
|
||||
|
||||
function! copilot#doc#Params(...) abort
|
||||
let extra = a:0 ? a:1 : {}
|
||||
let params = extend({'doc': extend(copilot#doc#Get(), get(extra, 'doc', {}))}, extra, 'keep')
|
||||
let params.textDocument = {
|
||||
\ 'uri': params.doc.uri,
|
||||
\ 'version': params.doc.version,
|
||||
\ 'relativePath': params.doc.relativePath,
|
||||
\ }
|
||||
let params.position = params.doc.position
|
||||
return params
|
||||
endfunction
|
106
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/job.vim
Normal file
106
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/job.vim
Normal file
@ -0,0 +1,106 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
function! copilot#job#Nop(...) abort
|
||||
endfunction
|
||||
|
||||
function! s:Jobs(job_or_jobs) abort
|
||||
let jobs = type(a:job_or_jobs) == v:t_list ? copy(a:job_or_jobs) : [a:job_or_jobs]
|
||||
call map(jobs, { k, v -> type(v) == v:t_dict ? get(v, 'job', '') : v })
|
||||
call filter(jobs, { k, v -> type(v) !=# type('') })
|
||||
return jobs
|
||||
endfunction
|
||||
|
||||
let s:job_stop = exists('*job_stop') ? 'job_stop' : 'jobstop'
|
||||
function! copilot#job#Stop(job) abort
|
||||
for job in s:Jobs(a:job)
|
||||
call call(s:job_stop, [job])
|
||||
endfor
|
||||
return copilot#job#Wait(a:job)
|
||||
endfunction
|
||||
|
||||
let s:sleep = has('patch-8.2.2366') ? 'sleep! 1m' : 'sleep 1m'
|
||||
function! copilot#job#Wait(jobs) abort
|
||||
let jobs = s:Jobs(a:jobs)
|
||||
if exists('*jobwait')
|
||||
call jobwait(jobs)
|
||||
else
|
||||
for job in jobs
|
||||
while ch_status(job) !=# 'closed' || job_status(job) ==# 'run'
|
||||
exe s:sleep
|
||||
endwhile
|
||||
endfor
|
||||
endif
|
||||
return a:jobs
|
||||
endfunction
|
||||
|
||||
function! s:VimExitCallback(result, exit_cb, job, data) abort
|
||||
let a:result.exit_status = a:data
|
||||
if !has_key(a:result, 'closed')
|
||||
return
|
||||
endif
|
||||
call remove(a:result, 'closed')
|
||||
call a:exit_cb(a:result.exit_status)
|
||||
endfunction
|
||||
|
||||
function! s:VimCloseCallback(result, exit_cb, job) abort
|
||||
if !has_key(a:result, 'exit_status')
|
||||
let a:result.closed = v:true
|
||||
return
|
||||
endif
|
||||
call a:exit_cb(a:result.exit_status)
|
||||
endfunction
|
||||
|
||||
function! s:NvimCallback(cb, job, data, type) dict abort
|
||||
let self[a:type][0] .= remove(a:data, 0)
|
||||
call extend(self[a:type], a:data)
|
||||
while len(self[a:type]) > 1
|
||||
call a:cb(substitute(remove(self[a:type], 0), "\r$", '', ''))
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! s:NvimExitCallback(out_cb, err_cb, exit_cb, job, data, type) dict abort
|
||||
if len(self.stderr[0])
|
||||
call a:err_cb(substitute(self.stderr[0], "\r$", '', ''))
|
||||
endif
|
||||
call a:exit_cb(a:data)
|
||||
endfunction
|
||||
|
||||
function! copilot#job#Cwd() abort
|
||||
let home = expand("~")
|
||||
if !isdirectory(home) && isdirectory($VIM)
|
||||
return $VIM
|
||||
endif
|
||||
return home
|
||||
endfunction
|
||||
|
||||
function! copilot#job#Stream(argv, out_cb, err_cb, ...) abort
|
||||
let exit_status = []
|
||||
let ExitCb = function(a:0 && !empty(a:1) ? a:1 : { e -> add(exit_status, e) }, a:000[2:-1])
|
||||
let OutCb = function(empty(a:out_cb) ? 'copilot#job#Nop' : a:out_cb, a:000[2:-1])
|
||||
let ErrCb = function(empty(a:err_cb) ? 'copilot#job#Nop' : a:err_cb, a:000[2:-1])
|
||||
let state = {'headers': {}, 'mode': 'headers', 'buffer': ''}
|
||||
if exists('*job_start')
|
||||
let result = {}
|
||||
let job = job_start(a:argv, {
|
||||
\ 'cwd': copilot#job#Cwd(),
|
||||
\ 'out_mode': 'raw',
|
||||
\ 'out_cb': { j, d -> OutCb(d) },
|
||||
\ 'err_cb': { j, d -> ErrCb(d) },
|
||||
\ 'exit_cb': function('s:VimExitCallback', [result, ExitCb]),
|
||||
\ 'close_cb': function('s:VimCloseCallback', [result, ExitCb]),
|
||||
\ })
|
||||
else
|
||||
let jopts = {
|
||||
\ 'cwd': copilot#job#Cwd(),
|
||||
\ 'stderr': [''],
|
||||
\ 'on_stdout': { j, d, t -> OutCb(join(d, "\n")) },
|
||||
\ 'on_stderr': function('s:NvimCallback', [ErrCb]),
|
||||
\ 'on_exit': function('s:NvimExitCallback', [OutCb, ErrCb, ExitCb])}
|
||||
let job = jobstart(a:argv, jopts)
|
||||
endif
|
||||
if a:0
|
||||
return job
|
||||
endif
|
||||
call copilot#job#Wait(job)
|
||||
return exit_status[0]
|
||||
endfunction
|
@ -0,0 +1,77 @@
|
||||
if !exists('s:log_file')
|
||||
let s:log_file = tempname() . '-copilot.log'
|
||||
try
|
||||
call writefile([], s:log_file)
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
|
||||
function! copilot#logger#File() abort
|
||||
return s:log_file
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Raw(level, message) abort
|
||||
if $COPILOT_AGENT_VERBOSE !~# '^\%(1\|true\)$' && a:level < 1
|
||||
return
|
||||
endif
|
||||
let lines = type(a:message) == v:t_list ? copy(a:message) : split(a:message, "\n", 1)
|
||||
try
|
||||
if !filewritable(s:log_file)
|
||||
return
|
||||
endif
|
||||
call map(lines, { k, L -> type(L) == v:t_func ? call(L, []) : L })
|
||||
call writefile(lines, s:log_file, 'a')
|
||||
catch
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Trace(...) abort
|
||||
call copilot#logger#Raw(-1, a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Debug(...) abort
|
||||
call copilot#logger#Raw(0, a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Info(...) abort
|
||||
call copilot#logger#Raw(1, a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Warn(...) abort
|
||||
call copilot#logger#Raw(2, a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Error(...) abort
|
||||
call copilot#logger#Raw(3, a:000)
|
||||
endfunction
|
||||
|
||||
function! copilot#logger#Exception(...) abort
|
||||
if !empty(v:exception) && v:exception !=# 'Vim:Interrupt'
|
||||
call copilot#logger#Error('Exception: ' . v:exception . ' @ ' . v:throwpoint)
|
||||
let agent = copilot#RunningAgent()
|
||||
if !empty(agent)
|
||||
let [_, type, code, message; __] = matchlist(v:exception, '^\%(\(^[[:alnum:]_#]\+\)\%((\a\+)\)\=\%(\(:E-\=\d\+\)\)\=:\s*\)\=\(.*\)$')
|
||||
let stacklines = []
|
||||
for frame in split(substitute(v:throwpoint, ', \S\+ \(\d\+\)$', '[\1]', ''), '\.\@<!\.\.\.\@!')
|
||||
let fn_line = matchlist(frame, '^\%(function \)\=\(\S\+\)\[\(\d+\)\]$')
|
||||
if !empty(fn_line)
|
||||
call add(stacklines, {'function': substitute(fn_line[1], '^<SNR>\d\+_', '<SID>', ''), 'lineno': +fn_line[2]})
|
||||
elseif frame =~# ' Autocmds for "\*"$'
|
||||
call add(stacklines, {'function': frame})
|
||||
elseif frame =~# ' Autocmds for ".*"$'
|
||||
call add(stacklines, {'function': substitute(frame, ' for ".*"$', ' for "[redacted]"', '')})
|
||||
else
|
||||
call add(stacklines, {'function': '[redacted]'})
|
||||
endif
|
||||
endfor
|
||||
return agent.Request('telemetry/exception', {
|
||||
\ 'transaction': a:0 ? a:1 : '',
|
||||
\ 'platform': 'other',
|
||||
\ 'exception_detail': [{
|
||||
\ 'type': type . code,
|
||||
\ 'value': message,
|
||||
\ 'stacktrace': stacklines}]
|
||||
\ })
|
||||
endif
|
||||
endif
|
||||
endfunction
|
155
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/panel.vim
Normal file
155
.vim/pack/plugins/opt/vim-copilot/autoload/copilot/panel.vim
Normal file
@ -0,0 +1,155 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
if !exists('s:panel_id')
|
||||
let s:panel_id = 0
|
||||
endif
|
||||
|
||||
let s:separator = repeat('─', 72)
|
||||
|
||||
function! s:Solutions(state) abort
|
||||
return sort(values(get(a:state, 'solutions', {})), { a, b -> a.score < b.score })
|
||||
endfunction
|
||||
|
||||
function! s:Render(panel_id) abort
|
||||
let bufnr = bufnr('^' . a:panel_id . '$')
|
||||
let state = getbufvar(bufnr, 'copilot_panel')
|
||||
if !bufloaded(bufnr) || type(state) != v:t_dict
|
||||
return
|
||||
endif
|
||||
let sorted = s:Solutions(state)
|
||||
if !empty(get(state, 'status', ''))
|
||||
let lines = ['Error: ' . state.status]
|
||||
else
|
||||
let target = get(state, 'count_target', '?')
|
||||
let received = has_key(state, 'status') ? target : len(sorted)
|
||||
let lines = ['Synthesiz' . (has_key(state, 'status') ? 'ed ' : 'ing ') . received . '/' . target . ' solutions (Duplicates hidden)']
|
||||
endif
|
||||
if len(sorted)
|
||||
call add(lines, 'Press <CR> on a solution to accept')
|
||||
endif
|
||||
for solution in sorted
|
||||
let lines += [s:separator] + split(solution.displayText, "\n", 1)
|
||||
endfor
|
||||
try
|
||||
call setbufvar(bufnr, '&modifiable', 1)
|
||||
call setbufvar(bufnr, '&readonly', 0)
|
||||
call setbufline(bufnr, 1, lines)
|
||||
finally
|
||||
call setbufvar(bufnr, '&modifiable', 0)
|
||||
call setbufvar(bufnr, '&readonly', 1)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! copilot#panel#Solution(params, ...) abort
|
||||
let state = getbufvar('^' . a:params.panelId . '$', 'copilot_panel')
|
||||
if !bufloaded(a:params.panelId) || type(state) != v:t_dict
|
||||
return
|
||||
endif
|
||||
let state.solutions[a:params.solutionId] = a:params
|
||||
call s:Render(a:params.panelId)
|
||||
endfunction
|
||||
|
||||
function! copilot#panel#SolutionsDone(params, ...) abort
|
||||
let state = getbufvar('^' . a:params.panelId . '$', 'copilot_panel')
|
||||
if !bufloaded(a:params.panelId) || type(state) != v:t_dict
|
||||
call copilot#logger#Debug('SolutionsDone: ' . a:params.panelId)
|
||||
return
|
||||
endif
|
||||
let state.status = get(a:params, 'message', '')
|
||||
call s:Render(a:params.panelId)
|
||||
endfunction
|
||||
|
||||
function! copilot#panel#Accept(...) abort
|
||||
let state = get(b:, 'copilot_panel', {})
|
||||
let solutions = s:Solutions(state)
|
||||
if empty(solutions)
|
||||
return ''
|
||||
endif
|
||||
if !has_key(state, 'bufnr') || !bufloaded(get(state, 'bufnr', -1))
|
||||
return "echoerr 'Buffer was closed'"
|
||||
endif
|
||||
let at = a:0 ? a:1 : line('.')
|
||||
let solution_index = 0
|
||||
for lnum in range(1, at)
|
||||
if getline(lnum) ==# s:separator
|
||||
let solution_index += 1
|
||||
endif
|
||||
endfor
|
||||
if solution_index > 0 && solution_index <= len(solutions)
|
||||
let solution = solutions[solution_index - 1]
|
||||
let lnum = solution.range.start.line + 1
|
||||
if getbufline(state.bufnr, lnum) !=# [state.line]
|
||||
return 'echoerr "Buffer has changed since synthesizing solution"'
|
||||
endif
|
||||
let lines = split(solution.displayText, "\n", 1)
|
||||
let old_first = getline(solution.range.start.line + 1)
|
||||
let lines[0] = strpart(old_first, 0, copilot#doc#UTF16ToByteIdx(old_first, solution.range.start.character)) . lines[0]
|
||||
let old_last = getline(solution.range.end.line + 1)
|
||||
let lines[-1] .= strpart(old_last, copilot#doc#UTF16ToByteIdx(old_last, solution.range.start.character))
|
||||
call setbufline(state.bufnr, solution.range.start.line + 1, lines[0])
|
||||
call appendbufline(state.bufnr, solution.range.start.line + 1, lines[1:-1])
|
||||
call copilot#Request('notifyAccepted', {'uuid': solution.solutionId})
|
||||
bwipeout
|
||||
let win = bufwinnr(state.bufnr)
|
||||
if win > 0
|
||||
exe win . 'wincmd w'
|
||||
exe solution.range.start.line + len(lines)
|
||||
if state.was_insert
|
||||
startinsert!
|
||||
else
|
||||
normal! $
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:Initialize(state) abort
|
||||
let &l:filetype = 'copilot' . (empty(a:state.filetype) ? '' : '.' . a:state.filetype)
|
||||
let &l:tabstop = a:state.tabstop
|
||||
call clearmatches()
|
||||
call matchadd('CopilotSuggestion', '\C^' . s:separator . '\n\zs' . escape(a:state.line, '][^$.*\~'), 10, 4)
|
||||
nmap <buffer><script> <CR> <Cmd>exe copilot#panel#Accept()<CR>
|
||||
nmap <buffer><script> [[ <Cmd>call search('^─\{9,}\n.', 'bWe')<CR>
|
||||
nmap <buffer><script> ]] <Cmd>call search('^─\{9,}\n.', 'We')<CR>
|
||||
endfunction
|
||||
|
||||
function! s:BufReadCmd() abort
|
||||
setlocal bufhidden=wipe buftype=nofile nobuflisted readonly nomodifiable
|
||||
let state = get(b:, 'copilot_panel')
|
||||
if type(state) != v:t_dict
|
||||
return
|
||||
endif
|
||||
call s:Initialize(state)
|
||||
call s:Render(expand('<amatch>'))
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! copilot#panel#Open(opts) abort
|
||||
let s:panel_id += 1
|
||||
let state = {'solutions': {}, 'filetype': &filetype, 'line': getline('.'), 'bufnr': bufnr(''), 'tabstop': &tabstop}
|
||||
let bufname = 'copilot:///' . s:panel_id
|
||||
let params = copilot#doc#Params({'panelId': bufname})
|
||||
let state.was_insert = mode() =~# '^[iR]'
|
||||
if state.was_insert
|
||||
stopinsert
|
||||
else
|
||||
let params.doc.position.character = copilot#doc#UTF16Width(state.line)
|
||||
let params.position.character = params.doc.position.character
|
||||
endif
|
||||
let response = copilot#Request('getPanelCompletions', params).Wait()
|
||||
if response.status ==# 'error'
|
||||
return 'echoerr ' . string(response.error.message)
|
||||
endif
|
||||
let state.count_target = response.result.solutionCountTarget
|
||||
exe substitute(a:opts.mods, '\C\<tab\>', '-tab', 'g') 'keepalt split' bufname
|
||||
let b:copilot_panel = state
|
||||
call s:Initialize(state)
|
||||
call s:Render(@%)
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
augroup github_copilot_panel
|
||||
autocmd!
|
||||
autocmd BufReadCmd copilot:///* exe s:BufReadCmd()
|
||||
augroup END
|
@ -0,0 +1,3 @@
|
||||
function! copilot#version#String() abort
|
||||
return '1.15.0'
|
||||
endfunction
|
777
.vim/pack/plugins/opt/vim-copilot/dist/agent.js
vendored
Normal file
777
.vim/pack/plugins/opt/vim-copilot/dist/agent.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
.vim/pack/plugins/opt/vim-copilot/dist/agent.js.map
vendored
Normal file
6
.vim/pack/plugins/opt/vim-copilot/dist/agent.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/darwin/arm64/kerberos.node
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/darwin/arm64/kerberos.node
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/darwin/x64/kerberos.node
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/darwin/x64/kerberos.node
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/linux/arm64/kerberos.node
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/linux/arm64/kerberos.node
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/linux/x64/kerberos.node
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/linux/x64/kerberos.node
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/win32/x64/kerberos.node
vendored
Normal file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/compiled/win32/x64/kerberos.node
vendored
Normal file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/crypt32.node
vendored
Normal file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/crypt32.node
vendored
Normal file
Binary file not shown.
100260
.vim/pack/plugins/opt/vim-copilot/dist/resources/cl100k/tokenizer_cushman002.json
vendored
Normal file
100260
.vim/pack/plugins/opt/vim-copilot/dist/resources/cl100k/tokenizer_cushman002.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
100001
.vim/pack/plugins/opt/vim-copilot/dist/resources/cl100k/vocab_cushman002.bpe
vendored
Normal file
100001
.vim/pack/plugins/opt/vim-copilot/dist/resources/cl100k/vocab_cushman002.bpe
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-go.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-go.wasm
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-javascript.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-javascript.wasm
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-python.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-python.wasm
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-ruby.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-ruby.wasm
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-tsx.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-tsx.wasm
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-typescript.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter-typescript.wasm
vendored
Executable file
Binary file not shown.
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter.wasm
vendored
Executable file
BIN
.vim/pack/plugins/opt/vim-copilot/dist/tree-sitter.wasm
vendored
Executable file
Binary file not shown.
167
.vim/pack/plugins/opt/vim-copilot/doc/copilot.txt
Normal file
167
.vim/pack/plugins/opt/vim-copilot/doc/copilot.txt
Normal file
@ -0,0 +1,167 @@
|
||||
*copilot.txt* GitHub Copilot - Your AI pair programmer
|
||||
|
||||
GETTING STARTED *copilot*
|
||||
|
||||
Invoke `:Copilot setup` to authenticate and enable GitHub Copilot.
|
||||
|
||||
Suggestions are displayed inline and can be accepted by pressing <Tab>. If
|
||||
inline suggestions do not appear to be working, invoke `:Copilot status` to
|
||||
verify Copilot is enabled and not experiencing any issues.
|
||||
|
||||
COMMANDS *:Copilot*
|
||||
|
||||
*:Copilot_disable*
|
||||
:Copilot disable Globally disable GitHub Copilot inline suggestions.
|
||||
|
||||
*:Copilot_enable*
|
||||
:Copilot enable Re-enable GitHub Copilot after :Copilot disable.
|
||||
|
||||
*:Copilot_setup*
|
||||
:Copilot setup Authenticate and enable GitHub Copilot.
|
||||
|
||||
*:Copilot_signout*
|
||||
:Copilot signout Sign out of GitHub Copilot.
|
||||
|
||||
*:Copilot_status*
|
||||
:Copilot status Check if GitHub Copilot is operational for the current
|
||||
buffer and report on any issues.
|
||||
|
||||
*:Copilot_panel*
|
||||
:Copilot panel Open a window with up to 10 completions for the
|
||||
current buffer. Use <CR> to accept a solution. Maps
|
||||
are also provided for [[ and ]] to jump from solution
|
||||
to solution. This is the default command if :Copilot
|
||||
is called without an argument.
|
||||
|
||||
*:Copilot_version*
|
||||
:Copilot version Show version information.
|
||||
|
||||
*:Copilot_feedback*
|
||||
:Copilot feedback Open the website for providing GitHub Copilot
|
||||
feedback. Be sure to include |:Copilot_version|
|
||||
output when reporting a bug.
|
||||
|
||||
OPTIONS *copilot-options*
|
||||
|
||||
*g:copilot_filetypes*
|
||||
g:copilot_filetypes A dictionary mapping file types to their enabled
|
||||
status. Most file types are enabled by default, so
|
||||
generally this is used for opting out.
|
||||
>
|
||||
let g:copilot_filetypes = {
|
||||
\ 'xml': v:false,
|
||||
\ }
|
||||
<
|
||||
Disabling all file types can be done by setting the
|
||||
special key "*". File types can then be turned back
|
||||
on individually.
|
||||
>
|
||||
let g:copilot_filetypes = {
|
||||
\ '*': v:false,
|
||||
\ 'python': v:true,
|
||||
\ }
|
||||
<
|
||||
*b:copilot_enabled*
|
||||
b:copilot_enabled Set to v:false to disable GitHub Copilot for the
|
||||
current buffer. Or set to v:true to force enabling
|
||||
it, overriding g:copilot_filetypes.
|
||||
|
||||
*g:copilot_node_command*
|
||||
g:copilot_node_command Tell Copilot what `node` binary to use with
|
||||
g:copilot_node_command. This is useful if the `node`
|
||||
in your PATH is an unsupported version.
|
||||
>
|
||||
let g:copilot_node_command =
|
||||
\ "~/.nodenv/versions/18.18.0/bin/node"
|
||||
<
|
||||
*g:copilot_proxy*
|
||||
g:copilot_proxy Tell Copilot what proxy server to use. This is a
|
||||
string in the format of `hostname:port` or
|
||||
`username:password@host:port`.
|
||||
>
|
||||
let g:copilot_proxy = 'localhost:3128'
|
||||
<
|
||||
*g:copilot_proxy_strict_ssl*
|
||||
g:copilot_proxy_strict_ssl
|
||||
Corporate proxies sometimes use a man-in-the-middle
|
||||
SSL certificate which is incompatible with GitHub
|
||||
Copilot. To work around this, SSL certificate
|
||||
verification can be disabled:
|
||||
>
|
||||
let g:copilot_proxy_strict_ssl = v:false
|
||||
<
|
||||
MAPS *copilot-maps*
|
||||
|
||||
*copilot-i_<Tab>*
|
||||
Copilot.vim uses <Tab> to accept the current suggestion. If you have an
|
||||
existing <Tab> map, that will be used as the fallback when no suggestion is
|
||||
displayed.
|
||||
|
||||
*copilot#Accept()*
|
||||
If you'd rather use a key that isn't <Tab>, define an <expr> map that calls
|
||||
copilot#Accept(). Here's an example with CTRL-J:
|
||||
>
|
||||
imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
|
||||
let g:copilot_no_tab_map = v:true
|
||||
<
|
||||
Lua version:
|
||||
>
|
||||
vim.keymap.set('i', '<C-J>', 'copilot#Accept("\\<CR>")', {
|
||||
expr = true,
|
||||
replace_keycodes = false
|
||||
})
|
||||
vim.g.copilot_no_tab_map = true
|
||||
<
|
||||
The argument to copilot#Accept() is the fallback for when no suggestion is
|
||||
displayed. In this example, a regular carriage return is used. If no
|
||||
fallback is desired, use an argument of "" (an empty string).
|
||||
|
||||
Other Maps ~
|
||||
|
||||
Note that M- (a.k.a. meta or alt) maps are highly dependent on your terminal
|
||||
to function correctly and may be unsupported with your setup. As an
|
||||
alternative, you can create your own versions that invoke the <Plug> maps
|
||||
instead. Here's an example that maps CTRL-L to accept one word of the
|
||||
current suggestion:
|
||||
>
|
||||
imap <C-L> <Plug>(copilot-accept-word)
|
||||
<
|
||||
Lua version:
|
||||
>
|
||||
vim.keymap.set('i', '<C-L>', '<Plug>(copilot-accept-word)')
|
||||
<
|
||||
*copilot-i_CTRL-]*
|
||||
<C-]> Dismiss the current suggestion.
|
||||
<Plug>(copilot-dismiss)
|
||||
|
||||
*copilot-i_ALT-]*
|
||||
<M-]> Cycle to the next suggestion, if one is available.
|
||||
<Plug>(copilot-next)
|
||||
|
||||
*copilot-i_ALT-[*
|
||||
<M-[> Cycle to the previous suggestion.
|
||||
<Plug>(copilot-previous)
|
||||
|
||||
*copilot-i_ALT-\*
|
||||
<M-\> Explicitly request a suggestion, even if Copilot
|
||||
<Plug>(copilot-suggest) is disabled.
|
||||
|
||||
*copilot-i_ALT-Right*
|
||||
<M-Right> Accept the next word of the current suggestion.
|
||||
<Plug>(copilot-accept-word)
|
||||
|
||||
*copilot-i_ALT-CTRL-Right*
|
||||
|
||||
<M-C-Right> Accept the next line of the current suggestion.
|
||||
<Plug>(copilot-accept-line)
|
||||
|
||||
SYNTAX HIGHLIGHTING *copilot-highlighting*
|
||||
|
||||
Inline suggestions are highlighted using the CopilotSuggestion group,
|
||||
defaulting to a medium gray. The best place to override this is a file named
|
||||
after/colors/<colorschemename>.vim in your 'runtimepath' (e.g.,
|
||||
~/.config/nvim/after/colors/solarized.vim). Example declaration:
|
||||
>
|
||||
highlight CopilotSuggestion guifg=#555555 ctermfg=8
|
||||
<
|
||||
vim:tw=78:et:ft=help:norl:
|
83
.vim/pack/plugins/opt/vim-copilot/lua/_copilot.lua
Normal file
83
.vim/pack/plugins/opt/vim-copilot/lua/_copilot.lua
Normal file
@ -0,0 +1,83 @@
|
||||
local copilot = {}
|
||||
|
||||
copilot.lsp_start_client = function(cmd, handler_names)
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
local handlers = {}
|
||||
local id
|
||||
for _, name in ipairs(handler_names) do
|
||||
handlers[name] = function(err, result)
|
||||
if result then
|
||||
local retval = vim.call('copilot#agent#LspHandle', id, { method = name, params = result })
|
||||
if type(retval) == 'table' then
|
||||
return retval.result, retval.error
|
||||
end
|
||||
end
|
||||
end
|
||||
if name:match('^copilot/') then
|
||||
capabilities.copilot = capabilities.copilot or {}
|
||||
capabilities.copilot[name:match('^copilot/(.*)$')] = true
|
||||
end
|
||||
end
|
||||
id = vim.lsp.start_client({
|
||||
cmd = cmd,
|
||||
cmd_cwd = vim.call('copilot#job#Cwd'),
|
||||
name = 'copilot',
|
||||
capabilities = capabilities,
|
||||
handlers = handlers,
|
||||
get_language_id = function(bufnr, filetype)
|
||||
return vim.call('copilot#doc#LanguageForFileType', filetype)
|
||||
end,
|
||||
on_init = function(client, initialize_result)
|
||||
vim.call('copilot#agent#LspInit', client.id, initialize_result)
|
||||
end,
|
||||
on_exit = function(code, signal, client_id)
|
||||
vim.schedule(function()
|
||||
vim.call('copilot#agent#LspExit', client_id, code, signal)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
return id
|
||||
end
|
||||
|
||||
copilot.lsp_request = function(client_id, method, params)
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
pcall(vim.lsp.buf_attach_client, 0, client_id)
|
||||
for _, doc in ipairs({ params.doc, params.textDocument }) do
|
||||
if doc and type(doc.uri) == 'number' then
|
||||
local bufnr = doc.uri
|
||||
pcall(vim.lsp.buf_attach_client, bufnr, client_id)
|
||||
doc.uri = vim.uri_from_bufnr(bufnr)
|
||||
doc.version = vim.lsp.util.buf_versions[bufnr]
|
||||
end
|
||||
end
|
||||
local _, id
|
||||
_, id = client.request(method, params, function(err, result)
|
||||
vim.call('copilot#agent#LspResponse', client_id, { id = id, error = err, result = result })
|
||||
end)
|
||||
return id
|
||||
end
|
||||
|
||||
copilot.rpc_request = function(client_id, method, params)
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
local _, id
|
||||
_, id = client.rpc.request(method, params, function(err, result)
|
||||
vim.call('copilot#agent#LspResponse', client_id, { id = id, error = err, result = result })
|
||||
end)
|
||||
return id
|
||||
end
|
||||
|
||||
copilot.rpc_notify = function(client_id, method, params)
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
return client.rpc.notify(method, params)
|
||||
end
|
||||
|
||||
return copilot
|
113
.vim/pack/plugins/opt/vim-copilot/plugin/copilot.vim
Normal file
113
.vim/pack/plugins/opt/vim-copilot/plugin/copilot.vim
Normal file
@ -0,0 +1,113 @@
|
||||
if exists('g:loaded_copilot')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_copilot = 1
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
command! -bang -nargs=? -range=-1 -complete=customlist,copilot#CommandComplete Copilot exe copilot#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)
|
||||
|
||||
if v:version < 800 || !exists('##CompleteChanged')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:ColorScheme() abort
|
||||
if &t_Co == 256
|
||||
hi def CopilotSuggestion guifg=#808080 ctermfg=244
|
||||
else
|
||||
hi def CopilotSuggestion guifg=#808080 ctermfg=8
|
||||
endif
|
||||
hi def link CopilotAnnotation Normal
|
||||
endfunction
|
||||
|
||||
function! s:MapTab() abort
|
||||
if get(g:, 'copilot_no_tab_map') || get(g:, 'copilot_no_maps')
|
||||
return
|
||||
endif
|
||||
let tab_map = maparg('<Tab>', 'i', 0, 1)
|
||||
if !has_key(tab_map, 'rhs')
|
||||
imap <script><silent><nowait><expr> <Tab> copilot#Accept()
|
||||
elseif tab_map.rhs !~# 'copilot'
|
||||
if tab_map.expr
|
||||
let tab_fallback = '{ -> ' . tab_map.rhs . ' }'
|
||||
else
|
||||
let tab_fallback = substitute(json_encode(tab_map.rhs), '<', '\\<', 'g')
|
||||
endif
|
||||
let tab_fallback = substitute(tab_fallback, '<SID>', '<SNR>' . get(tab_map, 'sid') . '_', 'g')
|
||||
if get(tab_map, 'noremap') || get(tab_map, 'script') || mapcheck('<Left>', 'i') || mapcheck('<Del>', 'i')
|
||||
exe 'imap <script><silent><nowait><expr> <Tab> copilot#Accept(' . tab_fallback . ')'
|
||||
else
|
||||
exe 'imap <silent><nowait><expr> <Tab> copilot#Accept(' . tab_fallback . ')'
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:Event(type) abort
|
||||
try
|
||||
call call('copilot#On' . a:type, [])
|
||||
catch
|
||||
call copilot#logger#Exception('autocmd.' . a:type)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
augroup github_copilot
|
||||
autocmd!
|
||||
autocmd InsertLeave * call s:Event('InsertLeave')
|
||||
autocmd BufLeave * if mode() =~# '^[iR]'|call s:Event('InsertLeave')|endif
|
||||
autocmd InsertEnter * call s:Event('InsertEnter')
|
||||
autocmd BufEnter * if mode() =~# '^[iR]'|call s:Event('InsertEnter')|endif
|
||||
autocmd CursorMovedI * call s:Event('CursorMovedI')
|
||||
autocmd CompleteChanged * call s:Event('CompleteChanged')
|
||||
autocmd ColorScheme,VimEnter * call s:ColorScheme()
|
||||
autocmd VimEnter * call s:MapTab()
|
||||
autocmd BufUnload * call s:Event('BufUnload')
|
||||
autocmd VimLeavePre * call s:Event('VimLeavePre')
|
||||
autocmd BufReadCmd copilot://* setlocal buftype=nofile bufhidden=wipe nobuflisted readonly nomodifiable
|
||||
augroup END
|
||||
|
||||
call s:ColorScheme()
|
||||
call s:MapTab()
|
||||
if !get(g:, 'copilot_no_maps')
|
||||
imap <Plug>(copilot-dismiss) <Cmd>call copilot#Dismiss()<CR>
|
||||
if empty(mapcheck('<C-]>', 'i'))
|
||||
imap <silent><script><nowait><expr> <C-]> copilot#Dismiss() . "\<C-]>"
|
||||
endif
|
||||
imap <Plug>(copilot-next) <Cmd>call copilot#Next()<CR>
|
||||
imap <Plug>(copilot-previous) <Cmd>call copilot#Previous()<CR>
|
||||
imap <Plug>(copilot-suggest) <Cmd>call copilot#Suggest()<CR>
|
||||
imap <script><silent><nowait><expr> <Plug>(copilot-accept-word) copilot#AcceptWord()
|
||||
imap <script><silent><nowait><expr> <Plug>(copilot-accept-line) copilot#AcceptLine()
|
||||
try
|
||||
if !has('nvim') && &encoding ==# 'utf-8'
|
||||
" avoid 8-bit meta collision with UTF-8 characters
|
||||
let s:restore_encoding = 1
|
||||
set encoding=cp949
|
||||
endif
|
||||
if empty(mapcheck('<M-]>', 'i'))
|
||||
imap <M-]> <Plug>(copilot-next)
|
||||
endif
|
||||
if empty(mapcheck('<M-[>', 'i'))
|
||||
imap <M-[> <Plug>(copilot-previous)
|
||||
endif
|
||||
if empty(mapcheck('<M-Bslash>', 'i'))
|
||||
imap <M-Bslash> <Plug>(copilot-suggest)
|
||||
endif
|
||||
if empty(mapcheck('<M-Right>', 'i'))
|
||||
imap <M-Right> <Plug>(copilot-accept-word)
|
||||
endif
|
||||
if empty(mapcheck('<M-C-Right>', 'i'))
|
||||
imap <M-Down> <Plug>(copilot-accept-line)
|
||||
endif
|
||||
finally
|
||||
if exists('s:restore_encoding')
|
||||
set encoding=utf-8
|
||||
endif
|
||||
endtry
|
||||
endif
|
||||
|
||||
call copilot#Init()
|
||||
|
||||
let s:dir = expand('<sfile>:h:h')
|
||||
if getftime(s:dir . '/doc/copilot.txt') > getftime(s:dir . '/doc/tags')
|
||||
silent! execute 'helptags' fnameescape(s:dir . '/doc')
|
||||
endif
|
19
.vim/pack/plugins/opt/vim-copilot/syntax/copilot.vim
Normal file
19
.vim/pack/plugins/opt/vim-copilot/syntax/copilot.vim
Normal file
@ -0,0 +1,19 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:subtype = matchstr(&l:filetype, '\<copilot\.\zs[[:alnum:]_-]\+')
|
||||
if !empty(s:subtype) && s:subtype !=# 'copilot'
|
||||
exe 'syn include @copilotLanguageTop syntax/' . s:subtype . '.vim'
|
||||
unlet! b:current_syntax
|
||||
endif
|
||||
|
||||
syn region copilotHeader start="\%^" end="^─\@="
|
||||
syn region copilotSolution matchgroup=copilotSeparator start="^─\{9,}$" end="\%(^─\{9,\}$\)\@=\|\%$" keepend contains=@copilotLanguageTop
|
||||
|
||||
hi def link copilotHeader PreProc
|
||||
hi def link copilotSeparator Comment
|
||||
|
||||
let b:current_syntax = "copilot"
|
96
.vim/pack/plugins/start/vim-autotag/README.markdown
Normal file
96
.vim/pack/plugins/start/vim-autotag/README.markdown
Normal file
@ -0,0 +1,96 @@
|
||||
autotag.vim
|
||||
============
|
||||
|
||||
If you use ctags to make tags files of your source, it's nice to be able to re-run ctags on a source file when you save it.
|
||||
|
||||
However, using `ctags -a` will only change existing entries in a tags file or add new ones. It doesn't delete entries that no longer exist. Should you delete an entity from your source file that's represented by an entry in a tags file, that entry will remain after calling `ctags -a`.
|
||||
|
||||
This python function will do two things:
|
||||
|
||||
1) It will search for a tags file starting in the directory where your source file resides and moving up a directory at a time until it either finds one or runs out of directories to try.
|
||||
|
||||
2) Should it find a tags file, it will then delete all entries in said tags file referencing the source file you've just saved and then execute `ctags -a` on that source file using the relative path to the source file from the tags file.
|
||||
|
||||
This way, every time you save a file, your tags file will be seamlessly updated.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Currently I suggest you use Vundle and install as a normal Bundle
|
||||
|
||||
From the Vim command-line
|
||||
|
||||
:BundleInstall 'craigemery/vim-autotag'
|
||||
|
||||
And add to your ~/.vimrc
|
||||
|
||||
Bundle 'craigemery/vim-autotag'
|
||||
|
||||
Or you can manually install
|
||||
cd
|
||||
git clone git://github.com/craigemery/vim-autotag.git
|
||||
cd ~/.vim/
|
||||
mkdir -p plugin
|
||||
cp ~/vim-autotag.git/plugin/* plugin/
|
||||
|
||||
### Install as a Pathogen bundle
|
||||
```
|
||||
git clone git://github.com/craigemery/vim-autotag.git ~/.vim/bundle/vim-autotag
|
||||
```
|
||||
|
||||
Getting round other ctags limitations
|
||||
-------------------------------------
|
||||
ctags is very file name suffix driven. When the file has no suffix, ctags can fail to detect the file type.
|
||||
The easiest way to replicate this is when using a #! shebang. I've seen "#!/usr/bin/env python3" in a
|
||||
shebang not get detected by ctags.
|
||||
But Vim is better at this. So Vim's filetype buffer setting can help.
|
||||
So when the buffer being written has no suffix to the file name then the Vim filetype value will be used instead.
|
||||
So far I've only implemented "python" as one that is given to ctags --language-force=<here> as is.
|
||||
Other filetypes could be mapped. There's a dict in the AutTag class.
|
||||
To not map a filetype to a forced language kind, add the vim file type to the comma "," separated
|
||||
list in autotagExcludeFiletypes.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
Autotag can be configured using the following global variables:
|
||||
|
||||
| Name | Purpose |
|
||||
| ---- | ------- |
|
||||
| `g:autotagExcludeSuffixes` | suffixes to not ctags on |
|
||||
| `g:autotagExcludeFiletypes` | filetypes to not try & force a language choice on ctags |
|
||||
| `g:autotagVerbosityLevel` | logging verbosity (as in Python logging module) |
|
||||
| `g:autotagCtagsCmd` | name of ctags command |
|
||||
| `g:autotagTagsFile` | name of tags file to look for |
|
||||
| `g:autotagDisabled` | Disable autotag (enable by setting to any non-blank value) |
|
||||
| `g:autotagStopAt` | stop looking for a tags file (and make one) at this directory (defaults to $HOME) |
|
||||
| `g:autotagStartMethod` | Now AutoTag uses Python multiprocessing, the start method is an internal aspect that Python uses.
|
||||
|
||||
These can be overridden with buffer specific ones. b: instead of g:
|
||||
Example:
|
||||
```
|
||||
let g:autotagTagsFile=".tags"
|
||||
```
|
||||
|
||||
macOS, Python 3.8 and 'spawn'
|
||||
-----------------------------
|
||||
With the release of Python 3.8, the default start method for multiprocessing on macOS has become 'spawn'
|
||||
At the time of writing there are issues with 'spawn' and I advise making AutoTag ask Python to use 'fork'
|
||||
i.e. before loading the plugin:
|
||||
```
|
||||
let g:autotagStartMethod='fork'
|
||||
```
|
||||
|
||||
Self-Promotion
|
||||
--------------
|
||||
|
||||
Like autotag.vim? Follow the repository on
|
||||
[GitHub](https://github.com/craigemery/vim-autotag) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=1343). And if
|
||||
you're feeling especially charitable, follow [craigemery] on
|
||||
[GitHub](https://github.com/craigemery).
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) Craig Emery. Distributed under the same terms as Vim itself.
|
||||
See `:help license`.
|
319
.vim/pack/plugins/start/vim-autotag/autoload/autotag.py
Normal file
319
.vim/pack/plugins/start/vim-autotag/autoload/autotag.py
Normal file
@ -0,0 +1,319 @@
|
||||
"""
|
||||
(c) Craig Emery 2017-2022
|
||||
AutoTag.py
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import os
|
||||
import fileinput
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
import subprocess
|
||||
from traceback import format_exc
|
||||
import multiprocessing as mp
|
||||
from glob import glob
|
||||
import vim # pylint: disable=import-error
|
||||
|
||||
__all__ = ["autotag"]
|
||||
|
||||
# global vim config variables used (all are g:autotag<name>):
|
||||
# name purpose
|
||||
# ExcludeSuffixes suffixes to not ctags on
|
||||
# VerbosityLevel logging verbosity (as in Python logging module)
|
||||
# CtagsCmd name of ctags command
|
||||
# TagsFile name of tags file to look for
|
||||
# Disabled Disable autotag (enable by setting to any non-blank value)
|
||||
# StopAt stop looking for a tags file (and make one) at this directory (defaults to $HOME)
|
||||
GLOBALS_DEFAULTS = dict(ExcludeSuffixes="tml.xml.text.txt",
|
||||
VerbosityLevel=logging.WARNING,
|
||||
CtagsCmd="ctags",
|
||||
TagsFile="tags",
|
||||
TagsDir="",
|
||||
Disabled=0,
|
||||
StopAt=0,
|
||||
StartMethod="")
|
||||
|
||||
|
||||
def do_cmd(cmd, cwd):
|
||||
""" Abstract subprocess """
|
||||
with subprocess.Popen(cmd, cwd=cwd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, universal_newlines=True) as proc:
|
||||
stdout = proc.communicate()[0]
|
||||
return stdout.split("\n")
|
||||
|
||||
|
||||
def vim_global(name, kind=str):
|
||||
""" Get global variable from vim, cast it appropriately """
|
||||
ret = GLOBALS_DEFAULTS.get(name, None)
|
||||
try:
|
||||
vname = "autotag" + name
|
||||
v_buffer = "b:" + vname
|
||||
exists_buffer = (vim.eval(f"exists('{v_buffer}')") == "1")
|
||||
v_global = "g:" + vname
|
||||
exists_global = (vim.eval(f"exists('{v_global}')") == "1")
|
||||
if exists_buffer:
|
||||
ret = vim.eval(v_buffer)
|
||||
elif exists_global:
|
||||
ret = vim.eval(v_global)
|
||||
else:
|
||||
if isinstance(ret, int):
|
||||
vim.command(f"let {v_global}={ret}")
|
||||
else:
|
||||
vim.command(f"let {v_global}=\"{ret}\"")
|
||||
finally:
|
||||
if kind == bool:
|
||||
ret = (ret in [1, "1", "true", "yes"])
|
||||
elif kind == int:
|
||||
try:
|
||||
val = int(ret)
|
||||
except TypeError:
|
||||
val = ret
|
||||
except ValueError:
|
||||
val = ret
|
||||
ret = val
|
||||
elif kind == str:
|
||||
ret = str(ret)
|
||||
return ret
|
||||
|
||||
|
||||
def init_multiprocessing():
|
||||
""" Init multiprocessing, set_executable() & get the context we'll use """
|
||||
wanted_start_method = vim_global("StartMethod") or None
|
||||
used_start_method = mp.get_start_method()
|
||||
if wanted_start_method in mp.get_all_start_methods():
|
||||
used_start_method = wanted_start_method
|
||||
else:
|
||||
wanted_start_method = None
|
||||
# here wanted_start_method is either a valid method or None
|
||||
# used_start_method is what the module has as the default or our overriden value
|
||||
ret = mp.get_context(wanted_start_method) # wanted_start_method might be None
|
||||
try:
|
||||
mp.set_executable
|
||||
except AttributeError:
|
||||
return ret
|
||||
if used_start_method == 'spawn':
|
||||
suff = os.path.splitext(sys.executable)[1]
|
||||
pat1 = f"python*{suff}"
|
||||
pat2 = os.path.join("bin", pat1)
|
||||
exes = glob(os.path.join(sys.exec_prefix, pat1)) + glob(os.path.join(sys.exec_prefix, pat2))
|
||||
if exes:
|
||||
win = [exe for exe in exes if exe.endswith(f"w{suff}")]
|
||||
if win:
|
||||
# In Windows pythonw.exe is best
|
||||
ret.set_executable(win[0])
|
||||
else:
|
||||
# This isn't great, for now pick the first one
|
||||
ret.set_executable(exes[0])
|
||||
return ret
|
||||
|
||||
|
||||
CTX = init_multiprocessing()
|
||||
|
||||
|
||||
class VimAppendHandler(logging.Handler):
|
||||
""" Logger handler that finds a buffer and appends the log message as a new line """
|
||||
def __init__(self, name):
|
||||
logging.Handler.__init__(self)
|
||||
self.__name = name
|
||||
self.__formatter = logging.Formatter()
|
||||
|
||||
def __find_buffer(self):
|
||||
""" Look for the named buffer """
|
||||
for buff in vim.buffers:
|
||||
if buff and buff.name and buff.name.endswith(self.__name):
|
||||
yield buff
|
||||
|
||||
def emit(self, record):
|
||||
""" Emit the logging message """
|
||||
for buff in self.__find_buffer():
|
||||
buff.append(self.__formatter.format(record))
|
||||
|
||||
|
||||
def set_logger_verbosity():
|
||||
""" Set the verbosity of the logger """
|
||||
level = vim_global("VerbosityLevel", kind=int)
|
||||
LOGGER.setLevel(level)
|
||||
|
||||
|
||||
def make_and_add_handler(logger, name):
|
||||
""" Make the handler and add it to the standard logger """
|
||||
ret = VimAppendHandler(name)
|
||||
logger.addHandler(ret)
|
||||
return ret
|
||||
|
||||
|
||||
try:
|
||||
LOGGER
|
||||
except NameError:
|
||||
DEBUG_NAME = "autotag_debug"
|
||||
LOGGER = logging.getLogger(DEBUG_NAME)
|
||||
HANDLER = make_and_add_handler(LOGGER, DEBUG_NAME)
|
||||
set_logger_verbosity()
|
||||
|
||||
|
||||
class AutoTag(): # pylint: disable=too-many-instance-attributes
|
||||
""" Class that does auto ctags updating """
|
||||
LOG = LOGGER
|
||||
AUTOFILETYPES = ["python"]
|
||||
FILETYPES = {}
|
||||
|
||||
def __init__(self):
|
||||
self.locks = {}
|
||||
self.tags = defaultdict(list)
|
||||
self.excludesuffix = ["." + s for s in vim_global("ExcludeSuffixes").split(".")]
|
||||
self.excludefiletype = vim_global("ExcludeFiletypes").split(",")
|
||||
set_logger_verbosity()
|
||||
self.sep_used_by_ctags = '/'
|
||||
self.ctags_cmd = vim_global("CtagsCmd")
|
||||
self.tags_file = str(vim_global("TagsFile"))
|
||||
self.tags_dir = str(vim_global("TagsDir"))
|
||||
self.parents = os.pardir * (len(os.path.split(self.tags_dir)) - 1)
|
||||
self.count = 0
|
||||
self.stop_at = vim_global("StopAt")
|
||||
|
||||
def find_tag_file(self, source):
|
||||
""" Find the tag file that belongs to the source file """
|
||||
AutoTag.LOG.info('source = "%s"', source)
|
||||
(drive, fname) = os.path.splitdrive(source)
|
||||
ret = None
|
||||
while ret is None:
|
||||
fname = os.path.dirname(fname)
|
||||
AutoTag.LOG.info('drive = "%s", file = "%s"', drive, fname)
|
||||
tags_dir = os.path.join(drive, fname)
|
||||
tags_file = os.path.join(tags_dir, self.tags_dir, self.tags_file)
|
||||
AutoTag.LOG.info('testing tags_file "%s"', tags_file)
|
||||
if os.path.isfile(tags_file):
|
||||
stinf = os.stat(tags_file)
|
||||
if stinf:
|
||||
size = getattr(stinf, 'st_size', None)
|
||||
if size is None:
|
||||
AutoTag.LOG.warning("Could not stat tags file %s", tags_file)
|
||||
ret = ""
|
||||
ret = (fname, tags_file)
|
||||
elif tags_dir and tags_dir == self.stop_at:
|
||||
AutoTag.LOG.info("Reached %s. Making one %s", self.stop_at, tags_file)
|
||||
open(tags_file, 'wb').close()
|
||||
ret = (fname, tags_file)
|
||||
ret = ""
|
||||
elif not fname or fname == os.sep or fname == "//" or fname == "\\\\":
|
||||
AutoTag.LOG.info('bail (file = "%s")', fname)
|
||||
ret = ""
|
||||
return ret or None
|
||||
|
||||
def add_source(self, source, filetype):
|
||||
""" Make a note of the source file, ignoring some etc """
|
||||
if not source:
|
||||
AutoTag.LOG.warning('No source')
|
||||
return
|
||||
if os.path.basename(source) == self.tags_file:
|
||||
AutoTag.LOG.info("Ignoring tags file %s", self.tags_file)
|
||||
return
|
||||
suff = os.path.splitext(source)[1]
|
||||
if suff:
|
||||
AutoTag.LOG.info("Source %s has suffix %s, so filetype doesn't count!", source, suff)
|
||||
filetype = None
|
||||
else:
|
||||
AutoTag.LOG.info("Source %s has no suffix, so filetype counts!", source)
|
||||
|
||||
if suff in self.excludesuffix:
|
||||
AutoTag.LOG.info("Ignoring excluded suffix %s for file %s", suff, source)
|
||||
return
|
||||
if filetype in self.excludefiletype:
|
||||
AutoTag.LOG.info("Ignoring excluded filetype %s for file %s", filetype, source)
|
||||
return
|
||||
found = self.find_tag_file(source)
|
||||
if found:
|
||||
(tags_dir, tags_file) = found
|
||||
relative_source = os.path.splitdrive(source)[1][len(tags_dir):]
|
||||
if relative_source[0] == os.sep:
|
||||
relative_source = relative_source[1:]
|
||||
if os.sep != self.sep_used_by_ctags:
|
||||
relative_source = relative_source.replace(os.sep, self.sep_used_by_ctags)
|
||||
key = (tags_dir, tags_file, filetype)
|
||||
self.tags[key].append(relative_source)
|
||||
if key not in self.locks:
|
||||
self.locks[key] = CTX.Lock()
|
||||
|
||||
@staticmethod
|
||||
def good_tag(line, excluded):
|
||||
""" Filter method for stripping tags """
|
||||
if line[0] == '!':
|
||||
return True
|
||||
fields = line.split('\t')
|
||||
AutoTag.LOG.log(1, "read tags line:%s", str(fields))
|
||||
if len(fields) > 3 and fields[1] not in excluded:
|
||||
return True
|
||||
return False
|
||||
|
||||
def strip_tags(self, tags_file, sources):
|
||||
""" Strip all tags for a given source file """
|
||||
AutoTag.LOG.info("Stripping tags for %s from tags file %s", ",".join(sources), tags_file)
|
||||
backup = ".SAFE"
|
||||
try:
|
||||
with fileinput.FileInput(files=tags_file, inplace=True, backup=backup) as source:
|
||||
for line in source:
|
||||
line = line.strip()
|
||||
if self.good_tag(line, sources):
|
||||
print(line)
|
||||
finally:
|
||||
try:
|
||||
os.unlink(tags_file + backup)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
def _vim_ft_to_ctags_ft(self, name):
|
||||
""" convert vim filetype strings to ctags strings """
|
||||
if name in AutoTag.AUTOFILETYPES:
|
||||
return name
|
||||
return self.FILETYPES.get(name, None)
|
||||
|
||||
def update_tags_file(self, key, sources):
|
||||
""" Strip all tags for the source file, then re-run ctags in append mode """
|
||||
(tags_dir, tags_file, filetype) = key
|
||||
lock = self.locks[key]
|
||||
if self.tags_dir:
|
||||
sources = [os.path.join(self.parents + s) for s in sources]
|
||||
cmd = [self.ctags_cmd]
|
||||
if self.tags_file:
|
||||
cmd += ["-f", self.tags_file]
|
||||
if filetype:
|
||||
ctags_filetype = self._vim_ft_to_ctags_ft(filetype)
|
||||
if ctags_filetype:
|
||||
cmd += [f"--language-force={ctags_filetype}"]
|
||||
cmd += ["-a"]
|
||||
|
||||
def is_file(src):
|
||||
""" inner """
|
||||
return os.path.isfile(os.path.join(tags_dir, self.tags_dir, src))
|
||||
|
||||
srcs = list(filter(is_file, sources))
|
||||
if not srcs:
|
||||
return
|
||||
|
||||
cmd += [f'"{s}"' for s in srcs]
|
||||
cmd = " ".join(cmd)
|
||||
with lock:
|
||||
self.strip_tags(tags_file, sources)
|
||||
AutoTag.LOG.log(1, "%s: %s", tags_dir, cmd)
|
||||
for line in do_cmd(cmd, self.tags_dir or tags_dir):
|
||||
AutoTag.LOG.log(10, line)
|
||||
|
||||
def rebuild_tag_files(self):
|
||||
""" rebuild the tags file thread worker """
|
||||
for (key, sources) in self.tags.items():
|
||||
AutoTag.LOG.info('Process(%s, %s)', key, ",".join(sources))
|
||||
proc = CTX.Process(target=self.update_tags_file, args=(key, sources))
|
||||
proc.daemon = True
|
||||
proc.start()
|
||||
|
||||
|
||||
def autotag():
|
||||
""" Do the work """
|
||||
try:
|
||||
if not vim_global("Disabled", bool):
|
||||
runner = AutoTag()
|
||||
runner.add_source(vim.eval("expand(\"%:p\")"), vim.eval("&ft"))
|
||||
runner.rebuild_tag_files()
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logging.warning(format_exc())
|
16
.vim/pack/plugins/start/vim-autotag/autoload/autotag.vim
Normal file
16
.vim/pack/plugins/start/vim-autotag/autoload/autotag.vim
Normal file
@ -0,0 +1,16 @@
|
||||
if ! has("python3")
|
||||
finish
|
||||
endif
|
||||
python3 import sys, os, vim
|
||||
python3 sys.path.insert(0, os.path.dirname(vim.eval('expand("<sfile>")')))
|
||||
python3 import autotag
|
||||
|
||||
function! autotag#Run()
|
||||
if exists("b:netrw_method")
|
||||
return
|
||||
endif
|
||||
python3 autotag.autotag()
|
||||
if exists(":TlistUpdate")
|
||||
TlistUpdate
|
||||
endif
|
||||
endfunction
|
39
.vim/pack/plugins/start/vim-autotag/plugin/autotag.vim
Executable file
39
.vim/pack/plugins/start/vim-autotag/plugin/autotag.vim
Executable file
@ -0,0 +1,39 @@
|
||||
"
|
||||
" (c) Craig Emery 2017-2022
|
||||
"
|
||||
" Increment the number below for a dynamic #include guard
|
||||
let s:autotag_vim_version=1
|
||||
|
||||
if exists("g:autotag_vim_version_sourced")
|
||||
if s:autotag_vim_version == g:autotag_vim_version_sourced
|
||||
finish
|
||||
endif
|
||||
endif
|
||||
|
||||
let g:autotag_vim_version_sourced=s:autotag_vim_version
|
||||
|
||||
" This file supplies automatic tag regeneration when saving files
|
||||
" There's a problem with ctags when run with -a (append)
|
||||
" ctags doesn't remove entries for the supplied source file that no longer exist
|
||||
" so this script (implemented in Python) finds a tags file for the file vim has
|
||||
" just saved, removes all entries for that source file and *then* runs ctags -a
|
||||
|
||||
if !has("python3")
|
||||
finish
|
||||
endif " !has("python3")
|
||||
|
||||
function! AutoTagDebug()
|
||||
new
|
||||
file autotag_debug
|
||||
setlocal buftype=nowrite
|
||||
setlocal bufhidden=delete
|
||||
setlocal noswapfile
|
||||
normal
|
||||
endfunction
|
||||
|
||||
augroup autotag
|
||||
au!
|
||||
autocmd BufWritePost,FileWritePost * call autotag#Run ()
|
||||
augroup END
|
||||
|
||||
" vim:shiftwidth=3:ts=3
|
22
.vim/pack/plugins/start/vim-cool/LICENSE
Normal file
22
.vim/pack/plugins/start/vim-cool/LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Romain Lafourcade
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
64
.vim/pack/plugins/start/vim-cool/README.md
Normal file
64
.vim/pack/plugins/start/vim-cool/README.md
Normal file
@ -0,0 +1,64 @@
|
||||
# vim-cool
|
||||
|
||||
Vim-cool disables search highlighting when you are done searching and re-enables it when you search again. That's it. No more `:noh<CR>`, no more `/sytdstdrsid<CR>`, and no more dodgy `<C-l>` mappings.
|
||||
|
||||
Vim-cool is cool.
|
||||
|
||||
Vim-cool is *experimental*.
|
||||
|
||||
![cool](https://user-images.githubusercontent.com/344335/226825463-4ff5e352-ac2e-4f4d-94c7-a8109da7b6db.gif)
|
||||
|
||||
## Requirements
|
||||
|
||||
Vim-cool is intended to be used with Vim, **and only Vim**, 7.4.2008 or later. It may or may not work in other editors but they are not and will not be officially supported.
|
||||
|
||||
## Installation
|
||||
|
||||
Follow your favorite plugin/runtimepath manager's instructions.
|
||||
|
||||
If you choose manual installation, just put `plugin/cool.vim` where it belongs:
|
||||
|
||||
$HOME/.vim/plugin/cool.vim on Unix-like systems
|
||||
$HOME\vimfiles\plugin\cool.vim on Windows
|
||||
|
||||
In Vim 8.0 and above, see `:help package`.
|
||||
|
||||
## Setup
|
||||
|
||||
The whole assumption behind Vim-cool is that the user enabled search highlighting but they don't want the highlighting to linger on when they are done searching. This implies that the user has the following line in their `vimrc`:
|
||||
|
||||
set hlsearch
|
||||
|
||||
That's it. Nothing else to do.
|
||||
|
||||
## Experimental features
|
||||
|
||||
* Show number of matches in the command-line:
|
||||
|
||||
let g:cool_total_matches = 1
|
||||
|
||||
![demo](https://user-images.githubusercontent.com/344335/226825418-12931cf3-5f89-4375-89be-c98a57e177df.png)
|
||||
|
||||
* Do something when we are doing `nnnNNnn`, do something else or do nothing when we are not:
|
||||
|
||||
set statusline+=%{get(g:,'cool_is_searching',0)?'Yep':''}
|
||||
|
||||
## Background
|
||||
|
||||
I wrote the first iteration of vim-cool in about twenty minutes, mostly to test a few ideas I had after a short discussion about `'hlsearch'` and `:nohlsearch` on #vim.
|
||||
|
||||
Because it relied almost exclusively on mappings, that first iteration was way too brittle to be of any use and actually messed with a bunch of my own mappings.
|
||||
|
||||
Then came [@purpleP](https://github.com/purpleP) and [the game-changing approach](https://github.com/romainl/vim-cool/issues/9) he put together with the help of [@chrisbra](https://github.com/chrisbra), [@justinmk](https://github.com/justinmk), [@jamessan](https://github.com/jamessan), and [@ZyX-I](https://github.com/ZyX-I).
|
||||
|
||||
The current version, essentially a weaponized version of @purpleP's code, doesn't rely on mappings anymore and thus should be devoid of nasty side-effects.
|
||||
|
||||
Many thanks to [@bounceme](https://github.com/bounceme) for his help.
|
||||
|
||||
## What they say about vim-cool
|
||||
|
||||
- **puremourning**, in #vim:
|
||||
|
||||
> vim-cool is by far my favourite plugin
|
||||
>
|
||||
> it's just so... cool.
|
136
.vim/pack/plugins/start/vim-cool/plugin/cool.vim
Normal file
136
.vim/pack/plugins/start/vim-cool/plugin/cool.vim
Normal file
@ -0,0 +1,136 @@
|
||||
" vim-cool - Disable hlsearch when you are done searching.
|
||||
" Maintainer: romainl <romainlafourcade@gmail.com>
|
||||
" Version: 0.0.2
|
||||
" License: MIT License
|
||||
" Location: plugin/cool.vim
|
||||
" Website: https://github.com/romainl/vim-cool
|
||||
|
||||
if exists("g:loaded_cool") || v:version < 704 || &compatible
|
||||
finish
|
||||
endif
|
||||
let g:loaded_cool = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
augroup Cool
|
||||
autocmd!
|
||||
augroup END
|
||||
|
||||
if exists('##OptionSet')
|
||||
if !exists('*execute')
|
||||
autocmd Cool OptionSet highlight let <SID>saveh = &highlight
|
||||
endif
|
||||
" toggle coolness when hlsearch is toggled
|
||||
autocmd Cool OptionSet hlsearch call <SID>PlayItCool(v:option_old, v:option_new)
|
||||
endif
|
||||
|
||||
function! s:StartHL()
|
||||
if !v:hlsearch || mode() isnot 'n'
|
||||
return
|
||||
endif
|
||||
let g:cool_is_searching = 1
|
||||
let [pos, rpos] = [winsaveview(), getpos('.')]
|
||||
silent! exe "keepjumps go".(line2byte('.')+col('.')-(v:searchforward ? 2 : 0))
|
||||
try
|
||||
silent keepjumps norm! n
|
||||
if getpos('.') != rpos
|
||||
throw 0
|
||||
endif
|
||||
catch /^\%(0$\|Vim\%(\w\|:Interrupt$\)\@!\)/
|
||||
call <SID>StopHL()
|
||||
return
|
||||
finally
|
||||
call winrestview(pos)
|
||||
endtry
|
||||
if !get(g:,'cool_total_matches') || !exists('*reltimestr')
|
||||
return
|
||||
endif
|
||||
exe "silent! norm! :let g:cool_char=nr2char(screenchar(screenrow(),1))\<cr>"
|
||||
let cool_char = remove(g:,'cool_char')
|
||||
if cool_char !~ '[/?]'
|
||||
return
|
||||
endif
|
||||
let [f, ws, now, noOf] = [0, &wrapscan, reltime(), [0,0]]
|
||||
set nowrapscan
|
||||
try
|
||||
while f < 2
|
||||
if reltimestr(reltime(now))[:-6] =~ '[1-9]'
|
||||
" time >= 100ms
|
||||
return
|
||||
endif
|
||||
let noOf[v:searchforward ? f : !f] += 1
|
||||
try
|
||||
silent exe "keepjumps norm! ".(f ? 'n' : 'N')
|
||||
catch /^Vim[^)]\+):E38[45]\D/
|
||||
call setpos('.',rpos)
|
||||
let f += 1
|
||||
endtry
|
||||
endwhile
|
||||
finally
|
||||
call winrestview(pos)
|
||||
let &wrapscan = ws
|
||||
endtry
|
||||
redraw|echo cool_char.@/ 'match' noOf[0] 'of' noOf[0] + noOf[1] - 1
|
||||
endfunction
|
||||
|
||||
function! s:StopHL()
|
||||
if !v:hlsearch || mode() isnot 'n'
|
||||
return
|
||||
else
|
||||
let g:cool_is_searching = 0
|
||||
silent call feedkeys("\<Plug>(StopHL)", 'm')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if !exists('*execute')
|
||||
let s:saveh = &highlight
|
||||
" toggle highlighting, a workaround for :nohlsearch in autocmds
|
||||
function! s:AuNohlsearch()
|
||||
noautocmd set highlight+=l:-
|
||||
autocmd Cool Insertleave *
|
||||
\ noautocmd let &highlight = s:saveh | autocmd! Cool InsertLeave *
|
||||
return ''
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:PlayItCool(old, new)
|
||||
if a:old == 0 && a:new == 1
|
||||
" nohls --> hls
|
||||
" set up coolness
|
||||
noremap <silent> <Plug>(StopHL) :<C-U>nohlsearch<cr>
|
||||
if !exists('*execute')
|
||||
noremap! <expr> <Plug>(StopHL) <SID>AuNohlsearch()
|
||||
|
||||
" If no "execute()", ":tnoremap" isn't probably implemented too.
|
||||
else
|
||||
noremap! <expr> <Plug>(StopHL) execute('nohlsearch')[-1]
|
||||
if exists(':tnoremap')
|
||||
tnoremap <expr> <Plug>(StopHL) execute('nohlsearch')[-1]
|
||||
endif
|
||||
endif
|
||||
|
||||
autocmd Cool CursorMoved * call <SID>StartHL()
|
||||
autocmd Cool InsertEnter * call <SID>StopHL()
|
||||
elseif a:old == 1 && a:new == 0
|
||||
" hls --> nohls
|
||||
" tear down coolness
|
||||
nunmap <Plug>(StopHL)
|
||||
unmap! <expr> <Plug>(StopHL)
|
||||
if exists(':tunmap')
|
||||
tunmap <Plug>(StopHL)
|
||||
endif
|
||||
|
||||
autocmd! Cool CursorMoved
|
||||
autocmd! Cool InsertEnter
|
||||
else
|
||||
" nohls --> nohls
|
||||
" do nothing
|
||||
return
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" play it cool
|
||||
call <SID>PlayItCool(0, &hlsearch)
|
||||
|
||||
let &cpo = s:save_cpo
|
1148
.vim/pack/plugins/start/vim-easy-align/autoload/easy_align.vim
Normal file
1148
.vim/pack/plugins/start/vim-easy-align/autoload/easy_align.vim
Normal file
File diff suppressed because it is too large
Load Diff
891
.vim/pack/plugins/start/vim-easy-align/doc/easy_align.txt
Normal file
891
.vim/pack/plugins/start/vim-easy-align/doc/easy_align.txt
Normal file
@ -0,0 +1,891 @@
|
||||
easy-align.txt easy-align Last change: December 14 2014
|
||||
EASY-ALIGN - TABLE OF CONTENTS *easyalign* *easy-align* *easy-align-toc*
|
||||
==============================================================================
|
||||
|
||||
vim-easy-align
|
||||
Demo |easy-align-1|
|
||||
Features |easy-align-2|
|
||||
Installation |easy-align-3|
|
||||
TLDR - One-minute guide |easy-align-4|
|
||||
Usage |easy-align-5|
|
||||
Concept of alignment rule |easy-align-5-1|
|
||||
Execution models |easy-align-5-2|
|
||||
1. Using <Plug> mappings |easy-align-5-2-1|
|
||||
2. Using :EasyAlign command |easy-align-5-2-2|
|
||||
Interactive mode |easy-align-5-3|
|
||||
Predefined alignment rules |easy-align-5-3-1|
|
||||
Examples |easy-align-5-3-2|
|
||||
Using regular expressions |easy-align-5-3-3|
|
||||
Alignment options in interactive mode |easy-align-5-3-4|
|
||||
Live interactive mode |easy-align-5-4|
|
||||
Non-interactive mode |easy-align-5-5|
|
||||
Partial alignment in blockwise-visual mode |easy-align-5-6|
|
||||
Alignment options |easy-align-6|
|
||||
List of options |easy-align-6-1|
|
||||
Filtering lines |easy-align-6-2|
|
||||
Examples |easy-align-6-2-1|
|
||||
Ignoring delimiters in comments or strings |easy-align-6-3|
|
||||
Ignoring unmatched lines |easy-align-6-4|
|
||||
Aligning delimiters of different lengths |easy-align-6-5|
|
||||
Adjusting indentation |easy-align-6-6|
|
||||
Alignments over multiple occurrences of delimiters |easy-align-6-7|
|
||||
Extending alignment rules |easy-align-6-8|
|
||||
Examples |easy-align-6-8-1|
|
||||
Other options |easy-align-7|
|
||||
Disabling &foldmethod during alignment |easy-align-7-1|
|
||||
Left/right/center mode switch in interactive mode |easy-align-7-2|
|
||||
Advanced examples and use cases |easy-align-8|
|
||||
Related work |easy-align-9|
|
||||
Author |easy-align-10|
|
||||
License |easy-align-11|
|
||||
|
||||
|
||||
VIM-EASY-ALIGN *vim-easy-align*
|
||||
==============================================================================
|
||||
|
||||
A simple, easy-to-use Vim alignment plugin.
|
||||
|
||||
|
||||
*easy-align-1*
|
||||
DEMO *easy-align-demo*
|
||||
==============================================================================
|
||||
|
||||
Screencast:
|
||||
https://raw.githubusercontent.com/junegunn/i/master/vim-easy-align.gif
|
||||
|
||||
(Too fast? Slower GIF is {here}{1})
|
||||
|
||||
{1} https://raw.githubusercontent.com/junegunn/i/master/vim-easy-align-slow.gif
|
||||
|
||||
|
||||
*easy-align-2*
|
||||
FEATURES *easy-align-features*
|
||||
==============================================================================
|
||||
|
||||
- Easy to use
|
||||
- Comes with a predefined set of alignment rules
|
||||
- Provides a fast and intuitive interface
|
||||
- Extensible
|
||||
- You can define your own rules
|
||||
- Supports arbitrary regular expressions
|
||||
- Optimized for code editing
|
||||
- Takes advantage of syntax highlighting feature to avoid unwanted
|
||||
alignments
|
||||
|
||||
|
||||
*easy-align-3*
|
||||
INSTALLATION *easy-align-installation*
|
||||
==============================================================================
|
||||
|
||||
Use your favorite plugin manager.
|
||||
|
||||
Using {vim-plug}{2}:
|
||||
>
|
||||
Plug 'junegunn/vim-easy-align'
|
||||
<
|
||||
{2} https://github.com/junegunn/vim-plug
|
||||
|
||||
|
||||
*easy-align-4*
|
||||
TLDR - ONE-MINUTE GUIDE *easy-align-tldr-one-minute-guide*
|
||||
==============================================================================
|
||||
|
||||
Add the following mappings to your .vimrc.
|
||||
|
||||
*<Plug>(EasyAlign)*
|
||||
>
|
||||
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
|
||||
vmap <Enter> <Plug>(EasyAlign)
|
||||
|
||||
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
<
|
||||
And with the following lines of text,
|
||||
>
|
||||
apple =red
|
||||
grass+=green
|
||||
sky-= blue
|
||||
<
|
||||
try these commands:
|
||||
|
||||
- vip<Enter>=
|
||||
- `v`isual-select `i`nner `p`aragraph
|
||||
- Start EasyAlign command (<Enter>)
|
||||
- Align around `=`
|
||||
- `gaip=`
|
||||
- Start EasyAlign command (`ga`) for `i`nner `p`aragraph
|
||||
- Align around `=`
|
||||
|
||||
Notice that the commands are repeatable with `.` key if you have installed
|
||||
{repeat.vim}{3}. Install {visualrepeat}{4} as well if you want to repeat in
|
||||
visual mode.
|
||||
|
||||
{3} https://github.com/tpope/vim-repeat
|
||||
{4} https://github.com/vim-scripts/visualrepeat
|
||||
|
||||
|
||||
*easy-align-5*
|
||||
USAGE *easy-align-usage*
|
||||
==============================================================================
|
||||
|
||||
|
||||
< Concept of alignment rule >_________________________________________________~
|
||||
*easy-align-concept-of-alignment-rule*
|
||||
*easy-align-5-1*
|
||||
|
||||
Though easy-align can align lines of text around any delimiter, it provides
|
||||
shortcuts for the most common use cases with the concept of "alignment rule".
|
||||
|
||||
An alignment rule is a predefined set of options for common alignment tasks,
|
||||
which is identified by a single character, DELIMITER KEY, such as <Space>,
|
||||
`=`, `:`, `.`, `|`, `&`, `#`, and `,`.
|
||||
|
||||
Think of it as a shortcut. Instead of writing regular expression and setting
|
||||
several options, you can just type in a single character.
|
||||
|
||||
|
||||
< Execution models >__________________________________________________________~
|
||||
*easy-align-execution-models*
|
||||
*easy-align-5-2*
|
||||
|
||||
There are two ways to use easy-align.
|
||||
|
||||
|
||||
1. Using <Plug> mappings~
|
||||
*easy-align-1-using-plug-mappings*
|
||||
*easy-align-5-2-1*
|
||||
|
||||
The recommended method is to use <Plug> mappings as described earlier.
|
||||
|
||||
*<Plug>(LiveEasyAlign)*
|
||||
|
||||
----------------------+--------+-----------------------------------------------------
|
||||
Mapping | Mode | Description ~
|
||||
----------------------+--------+-----------------------------------------------------
|
||||
<Plug>(EasyAlign) | normal | Start interactive mode for a motion/text object
|
||||
<Plug>(EasyAlign) | visual | Start interactive mode for the selection
|
||||
<Plug>(LiveEasyAlign) | normal | Start live-interactive mode for a motion/text object
|
||||
<Plug>(LiveEasyAlign) | visual | Start live-interactive mode for the selection
|
||||
----------------------+--------+-----------------------------------------------------
|
||||
|
||||
|
||||
2. Using :EasyAlign command~
|
||||
*easy-align-2-using-easyalign-command*
|
||||
*easy-align-5-2-2*
|
||||
|
||||
*:EasyAlign*
|
||||
|
||||
If you prefer command-line or do not want to start interactive mode, you can
|
||||
use `:EasyAlign` command instead.
|
||||
|
||||
*:LiveEasyAlign*
|
||||
|
||||
-------------------------------------------+-----------------------------------------------
|
||||
Mode | Command ~
|
||||
-------------------------------------------+-----------------------------------------------
|
||||
Interactive mode | `:EasyAlign[!] [OPTIONS]`
|
||||
Live interactive mode | `:LiveEasyAlign[!] [...]`
|
||||
Non-interactive mode (predefined rules) | `:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]`
|
||||
Non-interactive mode (regular expressions) | `:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]`
|
||||
-------------------------------------------+-----------------------------------------------
|
||||
|
||||
|
||||
< Interactive mode >__________________________________________________________~
|
||||
*easy-align-interactive-mode*
|
||||
*easy-align-5-3*
|
||||
|
||||
The following sections will assume that you have <Plug>(EasyAlign) mappings in
|
||||
your .vimrc as below:
|
||||
>
|
||||
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
|
||||
vmap <Enter> <Plug>(EasyAlign)
|
||||
|
||||
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
<
|
||||
With these mappings, you can align text with only a few keystrokes.
|
||||
|
||||
1. <Enter> key in visual mode, or `ga` followed by a motion or a text object to
|
||||
start interactive mode
|
||||
2. Optional: Enter keys to select alignment mode (left, right, or center)
|
||||
3. Optional: N-th delimiter (default: 1)
|
||||
- `1` Around the 1st occurrences of delimiters
|
||||
- `2` Around the 2nd occurrences of delimiters
|
||||
- ...
|
||||
- `*` Around all occurrences of delimiters
|
||||
- `**` Left-right alternating alignment around all delimiters
|
||||
- `-` Around the last occurrences of delimiters (`-1`)
|
||||
- `-2` Around the second to last occurrences of delimiters
|
||||
- ...
|
||||
4. Delimiter key (a single keystroke; <Space>, `=`, `:`, `.`, `|`, `&`, `#`, `,`)
|
||||
|
||||
|
||||
Predefined alignment rules~
|
||||
*easy-align-predefined-alignment-rules*
|
||||
*easy-align-5-3-1*
|
||||
|
||||
--------------+--------------------------------------------------------------------
|
||||
Delimiter key | Description/Use cases ~
|
||||
--------------+--------------------------------------------------------------------
|
||||
<Space> | General alignment around whitespaces
|
||||
`=` | Operators containing equals sign ( `=` , `==,` `!=` , `+=` , `&&=` , ...)
|
||||
`:` | Suitable for formatting JSON or YAML
|
||||
`.` | Multi-line method chaining
|
||||
`,` | Multi-line method arguments
|
||||
`&` | LaTeX tables (matches `&` and `\\` )
|
||||
`#` | Ruby/Python comments
|
||||
`"` | Vim comments
|
||||
<Bar> | Table markdown
|
||||
--------------+--------------------------------------------------------------------
|
||||
|
||||
*g:easy_align_delimiters*
|
||||
|
||||
You can override these default rules or define your own rules with
|
||||
`g:easy_align_delimiters`, which will be described in {the later section}{5}.
|
||||
|
||||
{5} https://github.com/junegunn/vim-easy-align#extending-alignment-rules
|
||||
|
||||
|
||||
Examples~
|
||||
*easy-align-examples*
|
||||
*easy-align-5-3-2*
|
||||
|
||||
------------------+------------------------------------+--------------------
|
||||
With visual map | Description | Equivalent command ~
|
||||
------------------+------------------------------------+--------------------
|
||||
<Enter><Space> | Around 1st whitespaces | :'<,'>EasyAlign\
|
||||
<Enter>2<Space> | Around 2nd whitespaces | :'<,'>EasyAlign2\
|
||||
<Enter>-<Space> | Around the last whitespaces | :'<,'>EasyAlign-\
|
||||
<Enter>-2<Space> | Around the 2nd to last whitespaces | :'<,'>EasyAlign-2\
|
||||
<Enter>: | Around 1st colon ( `key: value` ) | :'<,'>EasyAlign:
|
||||
<Enter><Right>: | Around 1st colon ( `key : value` ) | :'<,'>EasyAlign:<l1
|
||||
<Enter>= | Around 1st operators with = | :'<,'>EasyAlign=
|
||||
<Enter>3= | Around 3rd operators with = | :'<,'>EasyAlign3=
|
||||
<Enter>*= | Around all operators with = | :'<,'>EasyAlign*=
|
||||
<Enter>**= | Left-right alternating around = | :'<,'>EasyAlign**=
|
||||
<Enter><Enter>= | Right alignment around 1st = | :'<,'>EasyAlign!=
|
||||
<Enter><Enter>**= | Right-left alternating around = | :'<,'>EasyAlign!**=
|
||||
------------------+------------------------------------+--------------------
|
||||
|
||||
|
||||
Using regular expressions~
|
||||
*easy-align-using-regular-expressions*
|
||||
*easy-align-5-3-3*
|
||||
|
||||
Instead of finishing the command with a predefined delimiter key, you can type
|
||||
in a regular expression after CTRL-/ or CTRL-X key. For example, if you want
|
||||
to align text around all occurrences of numbers:
|
||||
|
||||
- <Enter>
|
||||
- `*`
|
||||
- CTRL-X
|
||||
- `[0-9]\+`
|
||||
|
||||
|
||||
Alignment options in interactive mode~
|
||||
*easy-align-alignment-options-in-interactive-mode*
|
||||
*easy-align-5-3-4*
|
||||
|
||||
While in interactive mode, you can set alignment options using special
|
||||
shortcut keys listed below. The meaning of each option will be described in
|
||||
{the following sections}{6}.
|
||||
|
||||
--------+--------------------+---------------------------------------------------
|
||||
Key | Option | Values ~
|
||||
--------+--------------------+---------------------------------------------------
|
||||
CTRL-F | `filter` | Input string ( `[gv]/.*/?` )
|
||||
CTRL-I | `indentation` | shallow, deep, none, keep
|
||||
CTRL-L | `left_margin` | Input number or string
|
||||
CTRL-R | `right_margin` | Input number or string
|
||||
CTRL-D | `delimiter_align` | left, center, right
|
||||
CTRL-U | `ignore_unmatched` | 0, 1
|
||||
CTRL-G | `ignore_groups` | [], ["String'], ["Comment'], ["String', "Comment']
|
||||
CTRL-A | `align` | Input string ( `/[lrc]+\*{0,2}/` )
|
||||
<Left> | `stick_to_left` | `{ 'stick_to_left': 1, 'left_margin': 0 }`
|
||||
<Right> | `stick_to_left` | `{ 'stick_to_left': 0, 'left_margin': 1 }`
|
||||
<Down> | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
|
||||
--------+--------------------+---------------------------------------------------
|
||||
|
||||
{6} https://github.com/junegunn/vim-easy-align#alignment-options
|
||||
|
||||
|
||||
< Live interactive mode >_____________________________________________________~
|
||||
*easy-align-live-interactive-mode*
|
||||
*easy-align-5-4*
|
||||
|
||||
If you're performing a complex alignment where multiple options should be
|
||||
carefully adjusted, try "live interactive mode" where you can preview the
|
||||
result of the alignment on-the-fly as you type in.
|
||||
|
||||
Live interactive mode can be started with either <Plug>(LiveEasyAlign) map or
|
||||
`:LiveEasyAlign` command. Or you can switch to live interactive mode while in
|
||||
ordinary interactive mode by pressing CTRL-P. (P for Preview)
|
||||
|
||||
In live interactive mode, you have to type in the same delimiter (or CTRL-X on
|
||||
regular expression) again to finalize the alignment. This allows you to
|
||||
preview the result of the alignment and freely change the delimiter using
|
||||
backspace key without leaving the interactive mode.
|
||||
|
||||
|
||||
< Non-interactive mode >______________________________________________________~
|
||||
*easy-align-non-interactive-mode*
|
||||
*easy-align-5-5*
|
||||
|
||||
Instead of starting interactive mode, you can use declarative, non-interactive
|
||||
`:EasyAlign` command.
|
||||
>
|
||||
" Using predefined alignment rules
|
||||
" :EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
|
||||
:EasyAlign :
|
||||
:EasyAlign =
|
||||
:EasyAlign *=
|
||||
:EasyAlign 3\
|
||||
|
||||
" Using arbitrary regular expressions
|
||||
" :EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
|
||||
:EasyAlign /[:;]\+/
|
||||
:EasyAlign 2/[:;]\+/
|
||||
:EasyAlign */[:;]\+/
|
||||
:EasyAlign **/[:;]\+/
|
||||
<
|
||||
A command can end with alignment options, {each of which will be discussed in
|
||||
detail later}{6}, in Vim dictionary format.
|
||||
|
||||
- `:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': 0 }`
|
||||
|
||||
`stick_to_left` of 1 means that the matched delimiter should be positioned
|
||||
right next to the preceding token, and `left_margin` of 0 removes the margin
|
||||
on the left. So we get:
|
||||
>
|
||||
apple;: banana:: cake
|
||||
data;; exchange:; format
|
||||
<
|
||||
Option names are fuzzy-matched, so you can write as follows:
|
||||
|
||||
- `:EasyAlign * /[:;]\+/ { 'stl': 1, 'l': 0 }`
|
||||
|
||||
You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
|
||||
- `:EasyAlign*/[:;]\+/{'s':1,'l':0}`
|
||||
|
||||
Nice. But let's make it even shorter. Option values can be written in
|
||||
shorthand notation.
|
||||
|
||||
- `:EasyAlign*/[:;]\+/<l0`
|
||||
|
||||
The following table summarizes the shorthand notation.
|
||||
|
||||
-------------------+-----------
|
||||
Option | Expression~
|
||||
-------------------+-----------
|
||||
`filter` | `[gv]/.*/`
|
||||
`left_margin` | `l[0-9]+`
|
||||
`right_margin` | `r[0-9]+`
|
||||
`stick_to_left` | `<` or `>`
|
||||
`ignore_unmatched` | `iu[01]`
|
||||
`ignore_groups` | `ig\[.*\]`
|
||||
`align` | `a[lrc*]*`
|
||||
`delimiter_align` | `d[lrc]`
|
||||
`indentation` | `i[ksdn]`
|
||||
-------------------+-----------
|
||||
|
||||
For your information, the same operation can be done in interactive mode as
|
||||
follows:
|
||||
|
||||
- <Enter>
|
||||
- `*`
|
||||
- <Left>
|
||||
- CTRL-X
|
||||
- `[:;]\+`
|
||||
|
||||
{6} https://github.com/junegunn/vim-easy-align#alignment-options
|
||||
|
||||
|
||||
< Partial alignment in blockwise-visual mode >________________________________~
|
||||
*easy-align-partial-alignment-in-blockwise-visual-mode*
|
||||
*easy-align-5-6*
|
||||
|
||||
In blockwise-visual mode (CTRL-V), EasyAlign command aligns only the selected
|
||||
text in the block, instead of the whole lines in the range.
|
||||
|
||||
Consider the following case where you want to align text around `=>`
|
||||
operators.
|
||||
>
|
||||
my_hash = { :a => 1,
|
||||
:aa => 2,
|
||||
:aaa => 3 }
|
||||
<
|
||||
In non-blockwise visual mode (`v` / `V`), <Enter>= won't work since the
|
||||
assignment operator in the first line gets in the way. So we instead enter
|
||||
blockwise-visual mode (CTRL-V), and select the text around`=>` operators, then
|
||||
press <Enter>=.
|
||||
>
|
||||
my_hash = { :a => 1,
|
||||
:aa => 2,
|
||||
:aaa => 3 }
|
||||
<
|
||||
However, in this case, we don't really need blockwise visual mode since the
|
||||
same can be easily done using the negative N-th parameter: <Enter>-=
|
||||
|
||||
|
||||
*easy-align-6*
|
||||
ALIGNMENT OPTIONS *easy-align-alignment-options*
|
||||
==============================================================================
|
||||
|
||||
|
||||
< List of options >___________________________________________________________~
|
||||
*easy-align-list-of-options*
|
||||
*easy-align-6-1*
|
||||
|
||||
-------------------+---------+-----------------------+--------------------------------------------------------
|
||||
Option | Type | Default | Description ~
|
||||
-------------------+---------+-----------------------+--------------------------------------------------------
|
||||
`filter` | string | | Line filtering expression: `g/../` or `v/../`
|
||||
`left_margin` | number | 1 | Number of spaces to attach before delimiter
|
||||
`left_margin` | string | `' '` | String to attach before delimiter
|
||||
`right_margin` | number | 1 | Number of spaces to attach after delimiter
|
||||
`right_margin` | string | `' '` | String to attach after delimiter
|
||||
`stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side
|
||||
`ignore_groups` | list | ["String', "Comment'] | Delimiters in these syntax highlight groups are ignored
|
||||
`ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter
|
||||
`indentation` | string | `k` | Indentation method (keep, deep, shallow, none)
|
||||
`delimiter_align` | string | `r` | Determines how to align delimiters of different lengths
|
||||
`align` | string | `l` | Alignment modes for multiple occurrences of delimiters
|
||||
-------------------+---------+-----------------------+--------------------------------------------------------
|
||||
|
||||
There are 4 ways to set alignment options (from lowest precedence to highest):
|
||||
|
||||
1. Some option values can be set with corresponding global variables
|
||||
2. Option values can be specified in the definition of each alignment rule
|
||||
3. Option values can be given as arguments to `:EasyAlign` command
|
||||
4. Option values can be set in interactive mode using special shortcut keys
|
||||
|
||||
*g:easy_align_ignore_groups* *g:easy_align_ignore_unmatched*
|
||||
*g:easy_align_indentation* *g:easy_align_delimiter_align*
|
||||
|
||||
-------------------+-----------------+-------------+--------------------------------
|
||||
Option name | Shortcut key | Abbreviated | Global variable ~
|
||||
-------------------+-----------------+-------------+--------------------------------
|
||||
`filter` | CTRL-F | `[gv]/.*/` |
|
||||
`left_margin` | CTRL-L | `l[0-9]+` |
|
||||
`right_margin` | CTRL-R | `r[0-9]+` |
|
||||
`stick_to_left` | <Left>, <Right> | `<` or `>` |
|
||||
`ignore_groups` | CTRL-G | `ig\[.*\]` | `g:easy_align_ignore_groups`
|
||||
`ignore_unmatched` | CTRL-U | `iu[01]` | `g:easy_align_ignore_unmatched`
|
||||
`indentation` | CTRL-I | `i[ksdn]` | `g:easy_align_indentation`
|
||||
`delimiter_align` | CTRL-D | `d[lrc]` | `g:easy_align_delimiter_align`
|
||||
`align` | CTRL-A | `a[lrc*]*` |
|
||||
-------------------+-----------------+-------------+--------------------------------
|
||||
|
||||
|
||||
< Filtering lines >___________________________________________________________~
|
||||
*easy-align-filtering-lines*
|
||||
*easy-align-6-2*
|
||||
|
||||
With `filter` option, you can align lines that only match or do not match a
|
||||
given pattern. There are several ways to set the pattern.
|
||||
|
||||
1. Press CTRL-F in interactive mode and type in `g/pat/` or `v/pat/`
|
||||
2. In command-line, it can be written in dictionary format: `{'filter':
|
||||
'g/pat/'}`
|
||||
3. Or in shorthand notation: `g/pat/` or `v/pat/`
|
||||
|
||||
(You don't need to escape "/'s in the regular expression)
|
||||
|
||||
|
||||
Examples~
|
||||
|
||||
*easy-align-6-2-1*
|
||||
>
|
||||
" Start interactive mode with filter option set to g/hello/
|
||||
EasyAlign g/hello/
|
||||
|
||||
" Start live interactive mode with filter option set to v/goodbye/
|
||||
LiveEasyAlign v/goodbye/
|
||||
|
||||
" Align the lines with 'hi' around the first colons
|
||||
EasyAlign:g/hi/
|
||||
<
|
||||
|
||||
< Ignoring delimiters in comments or strings >________________________________~
|
||||
*easy-align-ignoring-delimiters-in-comments-or-strings*
|
||||
*easy-align-6-3*
|
||||
|
||||
EasyAlign can be configured to ignore delimiters in certain syntax highlight
|
||||
groups, such as code comments or strings. By default, delimiters that are
|
||||
highlighted as code comments or strings are ignored.
|
||||
>
|
||||
" Default:
|
||||
" If a delimiter is in a highlight group whose name matches
|
||||
" any of the followings, it will be ignored.
|
||||
let g:easy_align_ignore_groups = ['Comment', 'String']
|
||||
<
|
||||
For example, the following paragraph
|
||||
>
|
||||
{
|
||||
# Quantity of apples: 1
|
||||
apple: 1,
|
||||
# Quantity of bananas: 2
|
||||
bananas: 2,
|
||||
# Quantity of grape:fruits: 3
|
||||
'grape:fruits': 3
|
||||
}
|
||||
<
|
||||
becomes as follows on <Enter>: (or `:EasyAlign:`)
|
||||
>
|
||||
{
|
||||
# Quantity of apples: 1
|
||||
apple: 1,
|
||||
# Quantity of bananas: 2
|
||||
bananas: 2,
|
||||
# Quantity of grape:fruits: 3
|
||||
'grape:fruits': 3
|
||||
}
|
||||
<
|
||||
Naturally, this feature only works when syntax highlighting is enabled.
|
||||
|
||||
You can change the default rule by using one of these 4 methods.
|
||||
|
||||
1. Press CTRL-G in interactive mode to switch groups
|
||||
2. Define global `g:easy_align_ignore_groups` list
|
||||
3. Define a custom rule in `g:easy_align_delimiters` with `ignore_groups` option
|
||||
4. Provide `ignore_groups` option to `:EasyAlign` command. e.g. `:EasyAlign:ig[]`
|
||||
|
||||
For example if you set `ignore_groups` option to be an empty list, you get
|
||||
>
|
||||
{
|
||||
# Quantity of apples: 1
|
||||
apple: 1,
|
||||
# Quantity of bananas: 2
|
||||
bananas: 2,
|
||||
# Quantity of grape: fruits: 3
|
||||
'grape: fruits': 3
|
||||
}
|
||||
<
|
||||
If a pattern in `ignore_groups` is prepended by a `!`, it will have the
|
||||
opposite meaning. For instance, if `ignore_groups` is given as `['!Comment']`,
|
||||
delimiters that are not highlighted as Comment will be ignored during the
|
||||
alignment.
|
||||
|
||||
|
||||
< Ignoring unmatched lines >__________________________________________________~
|
||||
*easy-align-ignoring-unmatched-lines*
|
||||
*easy-align-6-4*
|
||||
|
||||
`ignore_unmatched` option determines how EasyAlign command processes lines
|
||||
that do not have N-th delimiter.
|
||||
|
||||
1. In left-alignment mode, they are ignored
|
||||
2. In right or center-alignment mode, they are not ignored, and the last tokens
|
||||
from those lines are aligned as well as if there is an invisible trailing
|
||||
delimiter at the end of each line
|
||||
3. If `ignore_unmatched` is 1, they are ignored regardless of the alignment mode
|
||||
4. If `ignore_unmatched` is 0, they are not ignored regardless of the mode
|
||||
|
||||
Let's take an example. When we align the following code block around the (1st)
|
||||
colons,
|
||||
>
|
||||
{
|
||||
apple: proc {
|
||||
this_line_does_not_have_a_colon
|
||||
},
|
||||
bananas: 2,
|
||||
grapefruits: 3
|
||||
}
|
||||
<
|
||||
this is usually what we want.
|
||||
>
|
||||
{
|
||||
apple: proc {
|
||||
this_line_does_not_have_a_colon
|
||||
},
|
||||
bananas: 2,
|
||||
grapefruits: 3
|
||||
}
|
||||
<
|
||||
However, we can override this default behavior by setting `ignore_unmatched`
|
||||
option to zero using one of the following methods.
|
||||
|
||||
1. Press CTRL-U in interactive mode to toggle `ignore_unmatched` option
|
||||
2. Set the global `g:easy_align_ignore_unmatched` variable to 0
|
||||
3. Define a custom alignment rule with `ignore_unmatched` option set to 0
|
||||
4. Provide `ignore_unmatched` option to `:EasyAlign` command. e.g.
|
||||
`:EasyAlign:iu0`
|
||||
|
||||
Then we get,
|
||||
>
|
||||
{
|
||||
apple: proc {
|
||||
this_line_does_not_have_a_colon
|
||||
},
|
||||
bananas: 2,
|
||||
grapefruits: 3
|
||||
}
|
||||
<
|
||||
|
||||
< Aligning delimiters of different lengths >__________________________________~
|
||||
*easy-align-aligning-delimiters-of-different-lengths*
|
||||
*easy-align-6-5*
|
||||
|
||||
Global `g:easy_align_delimiter_align` option and rule-wise/command-wise
|
||||
`delimiter_align` option determines how matched delimiters of different
|
||||
lengths are aligned.
|
||||
>
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
<
|
||||
By default, delimiters are right-aligned as follows.
|
||||
>
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
<
|
||||
However, with `:EasyAlign=dl`, delimiters are left-aligned.
|
||||
>
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
<
|
||||
And on `:EasyAlign=dc`, center-aligned.
|
||||
>
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
<
|
||||
In interactive mode, you can change the option value with CTRL-D key.
|
||||
|
||||
|
||||
< Adjusting indentation >_____________________________________________________~
|
||||
*easy-align-adjusting-indentation*
|
||||
*easy-align-6-6*
|
||||
|
||||
By default :EasyAlign command keeps the original indentation of the lines. But
|
||||
then again we have `indentation` option. See the following example.
|
||||
>
|
||||
# Lines with different indentation
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign=is
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign=id
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign=in
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
<
|
||||
In interactive mode, you can change the option value with CTRL-I key.
|
||||
|
||||
|
||||
< Alignments over multiple occurrences of delimiters >________________________~
|
||||
*easy-align-alignments-over-multiple-occurrences-of-delimiters*
|
||||
*easy-align-6-7*
|
||||
|
||||
As stated above, "N-th" parameter is used to target specific occurrences of
|
||||
the delimiter when it appears multiple times in each line.
|
||||
|
||||
To recap:
|
||||
>
|
||||
" Left-alignment around the FIRST occurrences of delimiters
|
||||
:EasyAlign =
|
||||
|
||||
" Left-alignment around the SECOND occurrences of delimiters
|
||||
:EasyAlign 2=
|
||||
|
||||
" Left-alignment around the LAST occurrences of delimiters
|
||||
:EasyAlign -=
|
||||
|
||||
" Left-alignment around ALL occurrences of delimiters
|
||||
:EasyAlign *=
|
||||
|
||||
" Left-right ALTERNATING alignment around all occurrences of delimiters
|
||||
:EasyAlign **=
|
||||
|
||||
" Right-left ALTERNATING alignment around all occurrences of delimiters
|
||||
:EasyAlign! **=
|
||||
<
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences
|
||||
of the delimiters with "align' option. (The option can also be set in
|
||||
interactive mode with the special key CTRL-A)
|
||||
>
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
:EasyAlign = { 'align': 'll' }
|
||||
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'a': 'rlc' }
|
||||
|
||||
" Using shorthand notation
|
||||
:EasyAlign = arlc
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2=arlc
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *=arlc
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **=arlc
|
||||
|
||||
" Right, left, center, center, center, ... repeating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=arlc*
|
||||
|
||||
" Right, left, center, right, left, center, ... alternating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=arlc**
|
||||
<
|
||||
|
||||
< Extending alignment rules >_________________________________________________~
|
||||
*easy-align-extending-alignment-rules*
|
||||
*easy-align-6-8*
|
||||
|
||||
Although the default rules should cover the most of the use cases, you can
|
||||
extend the rules by setting a dictionary named `g:easy_align_delimiters`.
|
||||
|
||||
You may refer to the definitions of the default alignment rules {here}{7}.
|
||||
|
||||
{7} https://github.com/junegunn/vim-easy-align/blob/2.9.6/autoload/easy_align.vim#L32-L46
|
||||
|
||||
|
||||
Examples~
|
||||
|
||||
*easy-align-6-8-1*
|
||||
>
|
||||
let g:easy_align_delimiters = {
|
||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||
\ '/': {
|
||||
\ 'pattern': '//\+\|/\*\|\*/',
|
||||
\ 'delimiter_align': 'l',
|
||||
\ 'ignore_groups': ['!Comment'] },
|
||||
\ ']': {
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0,
|
||||
\ 'stick_to_left': 0
|
||||
\ },
|
||||
\ ')': {
|
||||
\ 'pattern': '[()]',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0,
|
||||
\ 'stick_to_left': 0
|
||||
\ },
|
||||
\ 'd': {
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0
|
||||
\ }
|
||||
\ }
|
||||
<
|
||||
|
||||
*easy-align-7*
|
||||
OTHER OPTIONS *easy-align-other-options*
|
||||
==============================================================================
|
||||
|
||||
|
||||
< Disabling &foldmethod during alignment >____________________________________~
|
||||
*easy-align-disabling-foldmethod-during-alignment*
|
||||
*easy-align-7-1*
|
||||
|
||||
*g:easy_align_bypass_fold*
|
||||
|
||||
{It is reported}{8} that 'foldmethod' value of `expr` or `syntax` can
|
||||
significantly slow down the alignment when editing a large, complex file with
|
||||
many folds. To alleviate this issue, EasyAlign provides an option to
|
||||
temporarily set 'foldmethod' to `manual` during the alignment task. In order
|
||||
to enable this feature, set `g:easy_align_bypass_fold` switch to 1.
|
||||
>
|
||||
let g:easy_align_bypass_fold = 1
|
||||
<
|
||||
{8} https://github.com/junegunn/vim-easy-align/issues/14
|
||||
|
||||
|
||||
< Left/right/center mode switch in interactive mode >_________________________~
|
||||
*easy-align-left-right-center-mode-switch-in-interactive-mode*
|
||||
*easy-align-7-2*
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
*g:easy_align_interactive_modes* *g:easy_align_bang_interactive_modes*
|
||||
>
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
<
|
||||
|
||||
*easy-align-8*
|
||||
ADVANCED EXAMPLES AND USE CASES *easy-align-advanced-examples-and-use-cases*
|
||||
==============================================================================
|
||||
|
||||
See {EXAMPLES.md}{9} for more examples.
|
||||
|
||||
{9} https://github.com/junegunn/vim-easy-align/blob/master/EXAMPLES.md
|
||||
|
||||
|
||||
*easy-align-9*
|
||||
RELATED WORK *easy-align-related-work*
|
||||
==============================================================================
|
||||
|
||||
- {DrChip's Alignment Tool for Vim}{10}
|
||||
- {Tabular}{11}
|
||||
|
||||
{10} http://www.drchip.org/astronaut/vim/align.html
|
||||
{11} https://github.com/godlygeek/tabular
|
||||
|
||||
|
||||
*easy-align-10*
|
||||
AUTHOR *easy-align-author*
|
||||
==============================================================================
|
||||
|
||||
{Junegunn Choi}{12}
|
||||
|
||||
{12} https://github.com/junegunn
|
||||
|
||||
|
||||
*easy-align-11*
|
||||
LICENSE *easy-align-license*
|
||||
==============================================================================
|
||||
|
||||
MIT
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:
|
84
.vim/pack/plugins/start/vim-easy-align/doc/tags
Normal file
84
.vim/pack/plugins/start/vim-easy-align/doc/tags
Normal file
@ -0,0 +1,84 @@
|
||||
:EasyAlign easy_align.txt /*:EasyAlign*
|
||||
:LiveEasyAlign easy_align.txt /*:LiveEasyAlign*
|
||||
<Plug>(EasyAlign) easy_align.txt /*<Plug>(EasyAlign)*
|
||||
<Plug>(LiveEasyAlign) easy_align.txt /*<Plug>(LiveEasyAlign)*
|
||||
easy-align easy_align.txt /*easy-align*
|
||||
easy-align-1 easy_align.txt /*easy-align-1*
|
||||
easy-align-1-using-plug-mappings easy_align.txt /*easy-align-1-using-plug-mappings*
|
||||
easy-align-10 easy_align.txt /*easy-align-10*
|
||||
easy-align-11 easy_align.txt /*easy-align-11*
|
||||
easy-align-2 easy_align.txt /*easy-align-2*
|
||||
easy-align-2-using-easyalign-command easy_align.txt /*easy-align-2-using-easyalign-command*
|
||||
easy-align-3 easy_align.txt /*easy-align-3*
|
||||
easy-align-4 easy_align.txt /*easy-align-4*
|
||||
easy-align-5 easy_align.txt /*easy-align-5*
|
||||
easy-align-5-1 easy_align.txt /*easy-align-5-1*
|
||||
easy-align-5-2 easy_align.txt /*easy-align-5-2*
|
||||
easy-align-5-2-1 easy_align.txt /*easy-align-5-2-1*
|
||||
easy-align-5-2-2 easy_align.txt /*easy-align-5-2-2*
|
||||
easy-align-5-3 easy_align.txt /*easy-align-5-3*
|
||||
easy-align-5-3-1 easy_align.txt /*easy-align-5-3-1*
|
||||
easy-align-5-3-2 easy_align.txt /*easy-align-5-3-2*
|
||||
easy-align-5-3-3 easy_align.txt /*easy-align-5-3-3*
|
||||
easy-align-5-3-4 easy_align.txt /*easy-align-5-3-4*
|
||||
easy-align-5-4 easy_align.txt /*easy-align-5-4*
|
||||
easy-align-5-5 easy_align.txt /*easy-align-5-5*
|
||||
easy-align-5-6 easy_align.txt /*easy-align-5-6*
|
||||
easy-align-6 easy_align.txt /*easy-align-6*
|
||||
easy-align-6-1 easy_align.txt /*easy-align-6-1*
|
||||
easy-align-6-2 easy_align.txt /*easy-align-6-2*
|
||||
easy-align-6-2-1 easy_align.txt /*easy-align-6-2-1*
|
||||
easy-align-6-3 easy_align.txt /*easy-align-6-3*
|
||||
easy-align-6-4 easy_align.txt /*easy-align-6-4*
|
||||
easy-align-6-5 easy_align.txt /*easy-align-6-5*
|
||||
easy-align-6-6 easy_align.txt /*easy-align-6-6*
|
||||
easy-align-6-7 easy_align.txt /*easy-align-6-7*
|
||||
easy-align-6-8 easy_align.txt /*easy-align-6-8*
|
||||
easy-align-6-8-1 easy_align.txt /*easy-align-6-8-1*
|
||||
easy-align-7 easy_align.txt /*easy-align-7*
|
||||
easy-align-7-1 easy_align.txt /*easy-align-7-1*
|
||||
easy-align-7-2 easy_align.txt /*easy-align-7-2*
|
||||
easy-align-8 easy_align.txt /*easy-align-8*
|
||||
easy-align-9 easy_align.txt /*easy-align-9*
|
||||
easy-align-adjusting-indentation easy_align.txt /*easy-align-adjusting-indentation*
|
||||
easy-align-advanced-examples-and-use-cases easy_align.txt /*easy-align-advanced-examples-and-use-cases*
|
||||
easy-align-aligning-delimiters-of-different-lengths easy_align.txt /*easy-align-aligning-delimiters-of-different-lengths*
|
||||
easy-align-alignment-options easy_align.txt /*easy-align-alignment-options*
|
||||
easy-align-alignment-options-in-interactive-mode easy_align.txt /*easy-align-alignment-options-in-interactive-mode*
|
||||
easy-align-alignments-over-multiple-occurrences-of-delimiters easy_align.txt /*easy-align-alignments-over-multiple-occurrences-of-delimiters*
|
||||
easy-align-author easy_align.txt /*easy-align-author*
|
||||
easy-align-concept-of-alignment-rule easy_align.txt /*easy-align-concept-of-alignment-rule*
|
||||
easy-align-demo easy_align.txt /*easy-align-demo*
|
||||
easy-align-disabling-foldmethod-during-alignment easy_align.txt /*easy-align-disabling-foldmethod-during-alignment*
|
||||
easy-align-examples easy_align.txt /*easy-align-examples*
|
||||
easy-align-execution-models easy_align.txt /*easy-align-execution-models*
|
||||
easy-align-extending-alignment-rules easy_align.txt /*easy-align-extending-alignment-rules*
|
||||
easy-align-features easy_align.txt /*easy-align-features*
|
||||
easy-align-filtering-lines easy_align.txt /*easy-align-filtering-lines*
|
||||
easy-align-ignoring-delimiters-in-comments-or-strings easy_align.txt /*easy-align-ignoring-delimiters-in-comments-or-strings*
|
||||
easy-align-ignoring-unmatched-lines easy_align.txt /*easy-align-ignoring-unmatched-lines*
|
||||
easy-align-installation easy_align.txt /*easy-align-installation*
|
||||
easy-align-interactive-mode easy_align.txt /*easy-align-interactive-mode*
|
||||
easy-align-left-right-center-mode-switch-in-interactive-mode easy_align.txt /*easy-align-left-right-center-mode-switch-in-interactive-mode*
|
||||
easy-align-license easy_align.txt /*easy-align-license*
|
||||
easy-align-list-of-options easy_align.txt /*easy-align-list-of-options*
|
||||
easy-align-live-interactive-mode easy_align.txt /*easy-align-live-interactive-mode*
|
||||
easy-align-non-interactive-mode easy_align.txt /*easy-align-non-interactive-mode*
|
||||
easy-align-other-options easy_align.txt /*easy-align-other-options*
|
||||
easy-align-partial-alignment-in-blockwise-visual-mode easy_align.txt /*easy-align-partial-alignment-in-blockwise-visual-mode*
|
||||
easy-align-predefined-alignment-rules easy_align.txt /*easy-align-predefined-alignment-rules*
|
||||
easy-align-related-work easy_align.txt /*easy-align-related-work*
|
||||
easy-align-tldr-one-minute-guide easy_align.txt /*easy-align-tldr-one-minute-guide*
|
||||
easy-align-toc easy_align.txt /*easy-align-toc*
|
||||
easy-align-usage easy_align.txt /*easy-align-usage*
|
||||
easy-align-using-regular-expressions easy_align.txt /*easy-align-using-regular-expressions*
|
||||
easyalign easy_align.txt /*easyalign*
|
||||
g:easy_align_bang_interactive_modes easy_align.txt /*g:easy_align_bang_interactive_modes*
|
||||
g:easy_align_bypass_fold easy_align.txt /*g:easy_align_bypass_fold*
|
||||
g:easy_align_delimiter_align easy_align.txt /*g:easy_align_delimiter_align*
|
||||
g:easy_align_delimiters easy_align.txt /*g:easy_align_delimiters*
|
||||
g:easy_align_ignore_groups easy_align.txt /*g:easy_align_ignore_groups*
|
||||
g:easy_align_ignore_unmatched easy_align.txt /*g:easy_align_ignore_unmatched*
|
||||
g:easy_align_indentation easy_align.txt /*g:easy_align_indentation*
|
||||
g:easy_align_interactive_modes easy_align.txt /*g:easy_align_interactive_modes*
|
||||
vim-easy-align easy_align.txt /*vim-easy-align*
|
142
.vim/pack/plugins/start/vim-easy-align/plugin/easy_align.vim
Normal file
142
.vim/pack/plugins/start/vim-easy-align/plugin/easy_align.vim
Normal file
@ -0,0 +1,142 @@
|
||||
" Copyright (c) 2014 Junegunn Choi
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be
|
||||
" included in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
if exists("g:loaded_easy_align_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_easy_align_plugin = 1
|
||||
|
||||
command! -nargs=* -range -bang EasyAlign <line1>,<line2>call easy_align#align(<bang>0, 0, 'command', <q-args>)
|
||||
command! -nargs=* -range -bang LiveEasyAlign <line1>,<line2>call easy_align#align(<bang>0, 1, 'command', <q-args>)
|
||||
|
||||
let s:last_command = 'EasyAlign'
|
||||
|
||||
function! s:abs(v)
|
||||
return a:v >= 0 ? a:v : - a:v
|
||||
endfunction
|
||||
|
||||
function! s:remember_visual(mode)
|
||||
let s:last_visual = [a:mode, s:abs(line("'>") - line("'<")), s:abs(col("'>") - col("'<"))]
|
||||
endfunction
|
||||
|
||||
function! s:repeat_visual()
|
||||
let [mode, ldiff, cdiff] = s:last_visual
|
||||
let cmd = 'normal! '.mode
|
||||
if ldiff > 0
|
||||
let cmd .= ldiff . 'j'
|
||||
endif
|
||||
|
||||
let ve_save = &virtualedit
|
||||
try
|
||||
if mode == "\<C-V>"
|
||||
if cdiff > 0
|
||||
let cmd .= cdiff . 'l'
|
||||
endif
|
||||
set virtualedit+=block
|
||||
endif
|
||||
execute cmd.":\<C-r>=g:easy_align_last_command\<Enter>\<Enter>"
|
||||
call s:set_repeat()
|
||||
finally
|
||||
if ve_save != &virtualedit
|
||||
let &virtualedit = ve_save
|
||||
endif
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:repeat_in_visual()
|
||||
if exists('g:easy_align_last_command')
|
||||
call s:remember_visual(visualmode())
|
||||
call s:repeat_visual()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:set_repeat()
|
||||
silent! call repeat#set("\<Plug>(EasyAlignRepeat)")
|
||||
endfunction
|
||||
|
||||
function! s:generic_easy_align_op(type, vmode, live)
|
||||
if !&modifiable
|
||||
if a:vmode
|
||||
normal! gv
|
||||
endif
|
||||
return
|
||||
endif
|
||||
let sel_save = &selection
|
||||
let &selection = "inclusive"
|
||||
|
||||
if a:vmode
|
||||
let vmode = a:type
|
||||
let [l1, l2] = ["'<", "'>"]
|
||||
call s:remember_visual(vmode)
|
||||
else
|
||||
let vmode = ''
|
||||
let [l1, l2] = [line("'["), line("']")]
|
||||
unlet! s:last_visual
|
||||
endif
|
||||
|
||||
try
|
||||
let range = l1.','.l2
|
||||
if get(g:, 'easy_align_need_repeat', 0)
|
||||
execute range . g:easy_align_last_command
|
||||
else
|
||||
execute range . "call easy_align#align(0, a:live, vmode, '')"
|
||||
end
|
||||
call s:set_repeat()
|
||||
finally
|
||||
let &selection = sel_save
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:easy_align_op(type, ...)
|
||||
call s:generic_easy_align_op(a:type, a:0, 0)
|
||||
endfunction
|
||||
|
||||
function! s:live_easy_align_op(type, ...)
|
||||
call s:generic_easy_align_op(a:type, a:0, 1)
|
||||
endfunction
|
||||
|
||||
function! s:easy_align_repeat()
|
||||
if exists('s:last_visual')
|
||||
call s:repeat_visual()
|
||||
else
|
||||
try
|
||||
let g:easy_align_need_repeat = 1
|
||||
normal! .
|
||||
finally
|
||||
unlet! g:easy_align_need_repeat
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <silent> <Plug>(EasyAlign) :set opfunc=<SID>easy_align_op<Enter>g@
|
||||
vnoremap <silent> <Plug>(EasyAlign) :<C-U>call <SID>easy_align_op(visualmode(), 1)<Enter>
|
||||
nnoremap <silent> <Plug>(LiveEasyAlign) :set opfunc=<SID>live_easy_align_op<Enter>g@
|
||||
vnoremap <silent> <Plug>(LiveEasyAlign) :<C-U>call <SID>live_easy_align_op(visualmode(), 1)<Enter>
|
||||
|
||||
" vim-repeat support
|
||||
nnoremap <silent> <Plug>(EasyAlignRepeat) :call <SID>easy_align_repeat()<Enter>
|
||||
vnoremap <silent> <Plug>(EasyAlignRepeat) :<C-U>call <SID>repeat_in_visual()<Enter>
|
||||
|
||||
" Backward-compatibility (deprecated)
|
||||
nnoremap <silent> <Plug>(EasyAlignOperator) :set opfunc=<SID>easy_align_op<Enter>g@
|
||||
|
66
.vim/pack/plugins/start/vim-fzf-tags/README.md
Normal file
66
.vim/pack/plugins/start/vim-fzf-tags/README.md
Normal file
@ -0,0 +1,66 @@
|
||||
fzf-tags
|
||||
========
|
||||
|
||||
`fzf-tags` bridges the gap between tags and fzf.vim.
|
||||
|
||||
It combines `:tag` and `:tselect` into a single improved command.
|
||||
|
||||
`:FZFTags` looks up the identifier under the cursor.
|
||||
- If there are 0 or 1 definitions, the behavior is same as `:tag`.
|
||||
- When there are multiple definitions, the results are piped to fzf for
|
||||
interactive filtering (https://github.com/junegunn/fzf#search-syntax).
|
||||
|
||||
`:FZFTselect` behaves just like `:tselect`.
|
||||
- Loads the tags matching the argument into an FZF window.
|
||||
- If no argument is provided, the last tag on the tag-stack is used.
|
||||
|
||||
This plugin uses the built-in `:tag` command under the hood, which
|
||||
yields a couple benefits.
|
||||
|
||||
- Tag stack management works as expected (CTRL-T or `:pop` return you
|
||||
to your previous location).
|
||||
- Tag priority works as expected (`:help tag-priority`).
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
```vim
|
||||
Plug 'zackhsi/fzf-tags'
|
||||
```
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
### Mappings
|
||||
|
||||
`fzf-tags` exposes the `<Plug>(fzf_tags)` mapping.
|
||||
|
||||
To override the default jump-to-tag binding:
|
||||
|
||||
```vim
|
||||
nmap <C-]> <Plug>(fzf_tags)
|
||||
```
|
||||
|
||||
Additionally, `fzf-tags` exposes a fuzzy `:tselect`. To replace the default `:ts`:
|
||||
|
||||
```vim
|
||||
noreabbrev <expr> ts getcmdtype() == ":" && getcmdline() == 'ts' ? 'FZFTselect' : 'ts'
|
||||
```
|
||||
|
||||
### Prompt
|
||||
|
||||
To replace the default prompt `🔎`:
|
||||
|
||||
```vim
|
||||
let g:fzf_tags_prompt = "Gd "
|
||||
```
|
||||
|
||||
### Layout
|
||||
|
||||
`fzf-tags` respects the global
|
||||
[`g:fzf_layout`](https://github.com/junegunn/fzf/blob/master/README-VIM.md#configuration)
|
||||
setting. For example:
|
||||
|
||||
```vim
|
||||
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Comment' } }
|
||||
```
|
128
.vim/pack/plugins/start/vim-fzf-tags/autoload/fzf_tags.vim
Normal file
128
.vim/pack/plugins/start/vim-fzf-tags/autoload/fzf_tags.vim
Normal file
@ -0,0 +1,128 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:default_fzf_tags_prompt = ' 🔎 '
|
||||
let s:fzf_tags_prompt = get(g:, 'fzf_tags_prompt', s:default_fzf_tags_prompt)
|
||||
|
||||
let s:default_fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
|
||||
let s:fzf_layout = get(g:, 'fzf_layout', s:default_fzf_layout)
|
||||
|
||||
let s:actions = {
|
||||
\ 'ctrl-t': 'tab split',
|
||||
\ 'ctrl-x': 'split',
|
||||
\ 'ctrl-v': 'vsplit' }
|
||||
|
||||
function! fzf_tags#SelectCommand(identifier)
|
||||
let identifier = empty(a:identifier) ? s:tagstack_head() : a:identifier
|
||||
if empty(identifier)
|
||||
echohl Error
|
||||
echo "Tag stack empty"
|
||||
echohl None
|
||||
else
|
||||
call fzf_tags#Find(identifier)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! fzf_tags#FindCommand(identifier)
|
||||
return fzf_tags#Find(empty(a:identifier) ? expand('<cword>') : a:identifier)
|
||||
endfunction
|
||||
|
||||
function! fzf_tags#Find(identifier)
|
||||
let identifier = s:strip_leading_bangs(a:identifier)
|
||||
let source_lines = s:source_lines(identifier)
|
||||
|
||||
if len(source_lines) == 0
|
||||
echohl WarningMsg
|
||||
echo 'Tag not found: ' . identifier
|
||||
echohl None
|
||||
elseif len(source_lines) == 1
|
||||
execute 'tag' identifier
|
||||
else
|
||||
let expect_keys = join(keys(s:actions), ',')
|
||||
let run_spec = {
|
||||
\ 'source': source_lines,
|
||||
\ 'sink*': function('s:sink', [identifier]),
|
||||
\ 'options': '--expect=' . expect_keys . ' --ansi --no-sort --tiebreak index --prompt "' . s:fzf_tags_prompt . '\"' . identifier . '\" > "',
|
||||
\ }
|
||||
let final_run_spec = extend(run_spec, s:fzf_layout)
|
||||
call fzf#run(final_run_spec)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:tagstack_head()
|
||||
let stack = gettagstack()
|
||||
return stack.length != 0 ? stack.items[-1].tagname : ""
|
||||
endfunction
|
||||
|
||||
function! s:tagsearch_string(identifier)
|
||||
return '^' . a:identifier . '$'
|
||||
endfunction
|
||||
|
||||
function! s:strip_leading_bangs(identifier)
|
||||
if (a:identifier[0] !=# '!')
|
||||
return a:identifier
|
||||
else
|
||||
return s:strip_leading_bangs(a:identifier[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:source_lines(identifier)
|
||||
let tagstring = s:tagsearch_string(a:identifier)
|
||||
let relevant_fields = map(
|
||||
\ taglist(tagstring, expand('%:p')),
|
||||
\ function('s:tag_to_string')
|
||||
\ )
|
||||
return map(s:align_lists(relevant_fields), 'join(v:val, " ")')
|
||||
endfunction
|
||||
|
||||
function! s:tag_to_string(index, tag_dict)
|
||||
let components = [a:index + 1]
|
||||
if has_key(a:tag_dict, 'filename')
|
||||
call add(components, s:magenta(a:tag_dict['filename']))
|
||||
endif
|
||||
if has_key(a:tag_dict, 'class')
|
||||
call add(components, s:green(a:tag_dict['class']))
|
||||
endif
|
||||
if has_key(a:tag_dict, 'cmd')
|
||||
call add(components, s:red(a:tag_dict['cmd']))
|
||||
endif
|
||||
return components
|
||||
endfunction
|
||||
|
||||
function! s:align_lists(lists)
|
||||
let maxes = {}
|
||||
for list in a:lists
|
||||
let i = 0
|
||||
while i < len(list)
|
||||
let maxes[i] = max([get(maxes, i, 0), len(list[i])])
|
||||
let i += 1
|
||||
endwhile
|
||||
endfor
|
||||
for list in a:lists
|
||||
call map(list, "printf('%-'.maxes[v:key].'s', v:val)")
|
||||
endfor
|
||||
return a:lists
|
||||
endfunction
|
||||
|
||||
function! s:sink(identifier, selection)
|
||||
let selected_with_key = a:selection[0]
|
||||
let selected_text = a:selection[1]
|
||||
|
||||
" Open new split or tab.
|
||||
if has_key(s:actions, selected_with_key)
|
||||
execute 'silent' s:actions[selected_with_key]
|
||||
endif
|
||||
|
||||
" Go to tag!
|
||||
let l:count = split(selected_text)[0]
|
||||
execute l:count . 'tag /' . s:tagsearch_string(a:identifier)
|
||||
endfunction
|
||||
|
||||
function! s:green(s)
|
||||
return "\033[32m" . a:s . "\033[m"
|
||||
endfunction
|
||||
function! s:magenta(s)
|
||||
return "\033[35m" . a:s . "\033[m"
|
||||
endfunction
|
||||
function! s:red(s)
|
||||
return "\033[31m" . a:s . "\033[m"
|
||||
endfunction
|
3
.vim/pack/plugins/start/vim-fzf-tags/plugin/fzf-tags.vim
Normal file
3
.vim/pack/plugins/start/vim-fzf-tags/plugin/fzf-tags.vim
Normal file
@ -0,0 +1,3 @@
|
||||
command! -nargs=? -bar FZFTags :call fzf_tags#FindCommand(<q-args>)
|
||||
command! -nargs=? -bar FZFTselect :call fzf_tags#SelectCommand(<q-args>)
|
||||
nnoremap <silent> <Plug>(fzf_tags) :FZFTags<Return>
|
21
.vim/pack/plugins/start/vim-fzf/LICENSE
Normal file
21
.vim/pack/plugins/start/vim-fzf/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Junegunn Choi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
443
.vim/pack/plugins/start/vim-fzf/README.md
Normal file
443
.vim/pack/plugins/start/vim-fzf/README.md
Normal file
@ -0,0 +1,443 @@
|
||||
fzf :heart: vim
|
||||
===============
|
||||
|
||||
Things you can do with [fzf][fzf] and Vim.
|
||||
|
||||
Rationale
|
||||
---------
|
||||
|
||||
[fzf][fzf] itself is not a Vim plugin, and the official repository only
|
||||
provides the [basic wrapper function][run] for Vim. It's up to the users to
|
||||
write their own Vim commands with it. However, I've learned that many users of
|
||||
fzf are not familiar with Vimscript and are looking for the "default"
|
||||
implementation of the features they can find in the alternative Vim plugins.
|
||||
|
||||
Why you should use fzf on Vim
|
||||
-----------------------------
|
||||
|
||||
Because you can and you love fzf.
|
||||
|
||||
fzf runs asynchronously and can be orders of magnitude faster than similar Vim
|
||||
plugins. However, the benefit may not be noticeable if the size of the input
|
||||
is small, which is the case for many of the commands provided here.
|
||||
Nevertheless I wrote them anyway since it's really easy to implement custom
|
||||
selector with fzf.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
fzf.vim depends on the basic Vim plugin of [the main fzf
|
||||
repository][fzf-main], which means you need to **set up both "fzf" and
|
||||
"fzf.vim" on Vim**. To learn more about fzf/Vim integration, see
|
||||
[README-VIM][README-VIM].
|
||||
|
||||
[fzf-main]: https://github.com/junegunn/fzf
|
||||
[README-VIM]: https://github.com/junegunn/fzf/blob/master/README-VIM.md
|
||||
|
||||
### Using [vim-plug](https://github.com/junegunn/vim-plug)
|
||||
|
||||
```vim
|
||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
```
|
||||
|
||||
`fzf#install()` makes sure that you have the latest binary, but it's optional,
|
||||
so you can omit it if you use a plugin manager that doesn't support hooks.
|
||||
|
||||
### Dependencies
|
||||
|
||||
- [fzf][fzf-main] 0.41.1 or above
|
||||
- For syntax-highlighted preview, install [bat](https://github.com/sharkdp/bat)
|
||||
- If [delta](https://github.com/dandavison/delta) is available, `GF?`,
|
||||
`Commits` and `BCommits` will use it to format `git diff` output.
|
||||
- `Ag` requires [The Silver Searcher (ag)][ag]
|
||||
- `Rg` requires [ripgrep (rg)][rg]
|
||||
- `Tags` and `Helptags` require Perl
|
||||
|
||||
Commands
|
||||
--------
|
||||
|
||||
| Command | List |
|
||||
| --- | --- |
|
||||
| `:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined) |
|
||||
| `:GFiles [OPTS]` | Git files (`git ls-files`) |
|
||||
| `:GFiles?` | Git files (`git status`) |
|
||||
| `:Buffers` | Open buffers |
|
||||
| `:Colors` | Color schemes |
|
||||
| `:Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
|
||||
| `:Rg [PATTERN]` | [rg][rg] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
|
||||
| `:RG [PATTERN]` | [rg][rg] search result; relaunch ripgrep on every keystroke |
|
||||
| `:Lines [QUERY]` | Lines in loaded buffers |
|
||||
| `:BLines [QUERY]` | Lines in the current buffer |
|
||||
| `:Tags [QUERY]` | Tags in the project (`ctags -R`) |
|
||||
| `:BTags [QUERY]` | Tags in the current buffer |
|
||||
| `:Changes` | Changelist across all open buffers |
|
||||
| `:Marks` | Marks |
|
||||
| `:Jumps` | Jumps |
|
||||
| `:Windows` | Windows |
|
||||
| `:Locate PATTERN` | `locate` command output |
|
||||
| `:History` | `v:oldfiles` and open buffers |
|
||||
| `:History:` | Command history |
|
||||
| `:History/` | Search history |
|
||||
| `:Snippets` | Snippets ([UltiSnips][us]) |
|
||||
| `:Commits [LOG_OPTS]` | Git commits (requires [fugitive.vim][f]) |
|
||||
| `:BCommits [LOG_OPTS]` | Git commits for the current buffer; visual-select lines to track changes in the range |
|
||||
| `:Commands` | Commands |
|
||||
| `:Maps` | Normal mode mappings |
|
||||
| `:Helptags` | Help tags <sup id="a1">[1](#helptags)</sup> |
|
||||
| `:Filetypes` | File types
|
||||
|
||||
- Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key
|
||||
bindings to open in a new tab, a new split, or in a new vertical split
|
||||
- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen
|
||||
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
|
||||
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
|
||||
|
||||
(<a name="helptags">1</a>: `Helptags` will shadow the command of the same name
|
||||
from [pathogen][pat]. But its functionality is still available via `call
|
||||
pathogen#helptags()`. [↩](#a1))
|
||||
|
||||
[pat]: https://github.com/tpope/vim-pathogen
|
||||
[f]: https://github.com/tpope/vim-fugitive
|
||||
|
||||
Customization
|
||||
-------------
|
||||
|
||||
### Configuration options of the base plugin
|
||||
|
||||
Every command in fzf.vim internally calls `fzf#wrap` function of the main
|
||||
repository which supports a set of global option variables. So please read
|
||||
through [README-VIM][README-VIM] to learn more about them.
|
||||
|
||||
### Configuration options for fzf.vim
|
||||
|
||||
All configuration values for this plugin are stored in `g:fzf_vim` dictionary,
|
||||
so **make sure to initialize it before assigning any configuration values to
|
||||
it**.
|
||||
|
||||
```vim
|
||||
" Initialize configuration dictionary
|
||||
let g:fzf_vim = {}
|
||||
```
|
||||
|
||||
#### Preview window
|
||||
|
||||
Some commands will show the preview window on the right. You can customize the
|
||||
behavior with `g:fzf_vim.preview_window`. Here are some examples:
|
||||
|
||||
```vim
|
||||
" This is the default option:
|
||||
" - Preview window on the right with 50% width
|
||||
" - CTRL-/ will toggle preview window.
|
||||
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
|
||||
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
|
||||
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
|
||||
|
||||
" Preview window is hidden by default. You can toggle it with ctrl-/.
|
||||
" It will show on the right with 50% width, but if the width is smaller
|
||||
" than 70 columns, it will show above the candidate list
|
||||
let g:fzf_vim.preview_window = ['hidden,right,50%,<70(up,40%)', 'ctrl-/']
|
||||
|
||||
" Empty value to disable preview window altogether
|
||||
let g:fzf_vim.preview_window = []
|
||||
|
||||
" fzf.vim needs bash to display the preview window.
|
||||
" On Windows, fzf.vim will first see if bash is in $PATH, then if
|
||||
" Git bash (C:\Program Files\Git\bin\bash.exe) is available.
|
||||
" If you want it to use a different bash, set this variable.
|
||||
" let g:fzf_vim = {}
|
||||
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
|
||||
```
|
||||
|
||||
#### Command-level options
|
||||
|
||||
```vim
|
||||
" [Buffers] Jump to the existing window if possible
|
||||
let g:fzf_vim.buffers_jump = 1
|
||||
|
||||
" [[B]Commits] Customize the options used by 'git log':
|
||||
let g:fzf_vim.commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
|
||||
|
||||
" [Tags] Command to generate tags file
|
||||
let g:fzf_vim.tags_command = 'ctags -R'
|
||||
|
||||
" [Commands] --expect expression for directly executing the command
|
||||
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'
|
||||
```
|
||||
|
||||
#### List type to handle multiple selections
|
||||
|
||||
The following commands will fill the quickfix list when multiple entries are
|
||||
selected.
|
||||
|
||||
* `Ag`
|
||||
* `Rg` / `RG`
|
||||
* `Lines` / `BLines`
|
||||
* `Tags` / `BTags`
|
||||
|
||||
By setting `g:fzf_vim.listproc`, you can make them use location list instead.
|
||||
|
||||
```vim
|
||||
" Default: Use quickfix list
|
||||
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#quickfix(list) }
|
||||
|
||||
" Use location list instead of quickfix list
|
||||
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#location(list) }
|
||||
```
|
||||
|
||||
You can customize the list type per command by defining variables named
|
||||
`g:fzf_vim.listproc_{command_name_in_lowercase}`.
|
||||
|
||||
```vim
|
||||
" Command-wise customization
|
||||
let g:fzf_vim.listproc_ag = { list -> fzf#vim#listproc#quickfix(list) }
|
||||
let g:fzf_vim.listproc_rg = { list -> fzf#vim#listproc#location(list) }
|
||||
```
|
||||
|
||||
You can further customize the behavior by providing a custom function to
|
||||
process the list instead of using the predefined `fzf#vim#listproc#quickfix`
|
||||
or `fzf#vim#listproc#location`.
|
||||
|
||||
```vim
|
||||
" A customized version of fzf#vim#listproc#quickfix.
|
||||
" The last two lines are commented out not to move to the first entry.
|
||||
function! g:fzf_vim.listproc(list)
|
||||
call setqflist(a:list)
|
||||
copen
|
||||
wincmd p
|
||||
" cfirst
|
||||
" normal! zvzz
|
||||
endfunction
|
||||
```
|
||||
|
||||
### Advanced customization
|
||||
|
||||
#### Vim functions
|
||||
|
||||
Each command in fzf.vim is backed by a Vim function. You can override
|
||||
a command or define a variation of it by calling its corresponding function.
|
||||
|
||||
| Command | Vim function |
|
||||
| --- | --- |
|
||||
| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` |
|
||||
| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` |
|
||||
| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` |
|
||||
| `Buffers` | `fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])` |
|
||||
| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` |
|
||||
| `Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])` |
|
||||
| `RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])` |
|
||||
| ... | ... |
|
||||
|
||||
(We can see that the last two optional arguments of each function are
|
||||
identical. They are directly passed to `fzf#wrap` function. If you haven't
|
||||
read [README-VIM][README-VIM] already, please read it before proceeding.)
|
||||
|
||||
#### Example: Customizing `Files` command
|
||||
|
||||
This is the default definition of `Files` command:
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)
|
||||
```
|
||||
|
||||
Let's say you want to a variation of it called `ProjectFiles` that only
|
||||
searches inside `~/projects` directory. Then you can do it like this:
|
||||
|
||||
```vim
|
||||
command! -bang ProjectFiles call fzf#vim#files('~/projects', <bang>0)
|
||||
```
|
||||
|
||||
Or, if you want to override the command with different fzf options, just pass
|
||||
a custom spec to the function.
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline']}, <bang>0)
|
||||
```
|
||||
|
||||
Want a preview window?
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)
|
||||
```
|
||||
|
||||
It kind of works, but you probably want a nicer previewer program than `cat`.
|
||||
fzf.vim ships [a versatile preview script](bin/preview.sh) you can readily
|
||||
use. It internally executes [bat](https://github.com/sharkdp/bat) for syntax
|
||||
highlighting, so make sure to install it.
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)
|
||||
```
|
||||
|
||||
However, it's not ideal to hard-code the path to the script which can be
|
||||
different in different circumstances. So in order to make it easier to set up
|
||||
the previewer, fzf.vim provides `fzf#vim#with_preview` helper function.
|
||||
Similarly to `fzf#wrap`, it takes a spec dictionary and returns a copy of it
|
||||
with additional preview options.
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
|
||||
```
|
||||
|
||||
You can just omit the spec argument if you only want the previewer.
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
|
||||
```
|
||||
|
||||
#### Example: `git grep` wrapper
|
||||
|
||||
The following example implements `GGrep` command that works similarly to
|
||||
predefined `Ag` or `Rg` using `fzf#vim#grep`.
|
||||
|
||||
- We set the base directory to git root by setting `dir` attribute in spec
|
||||
dictionary.
|
||||
- [The preview script](bin/preview.sh) supports `grep` format
|
||||
(`FILE_PATH:LINE_NO:...`), so we can just wrap the spec with
|
||||
`fzf#vim#with_preview` as before to enable previewer.
|
||||
|
||||
```vim
|
||||
command! -bang -nargs=* GGrep
|
||||
\ call fzf#vim#grep(
|
||||
\ 'git grep --line-number -- '.fzf#shellescape(<q-args>),
|
||||
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
||||
```
|
||||
|
||||
Mappings
|
||||
--------
|
||||
|
||||
| Mapping | Description |
|
||||
| --- | --- |
|
||||
| `<plug>(fzf-maps-n)` | Normal mode mappings |
|
||||
| `<plug>(fzf-maps-i)` | Insert mode mappings |
|
||||
| `<plug>(fzf-maps-x)` | Visual mode mappings |
|
||||
| `<plug>(fzf-maps-o)` | Operator-pending mappings |
|
||||
| `<plug>(fzf-complete-word)` | `cat /usr/share/dict/words` |
|
||||
| `<plug>(fzf-complete-path)` | Path completion using `find` (file + dir) |
|
||||
| `<plug>(fzf-complete-file)` | File completion using `find` |
|
||||
| `<plug>(fzf-complete-line)` | Line completion (all open buffers) |
|
||||
| `<plug>(fzf-complete-buffer-line)` | Line completion (current buffer only) |
|
||||
|
||||
```vim
|
||||
" Mapping selecting mappings
|
||||
nmap <leader><tab> <plug>(fzf-maps-n)
|
||||
xmap <leader><tab> <plug>(fzf-maps-x)
|
||||
omap <leader><tab> <plug>(fzf-maps-o)
|
||||
|
||||
" Insert mode completion
|
||||
imap <c-x><c-k> <plug>(fzf-complete-word)
|
||||
imap <c-x><c-f> <plug>(fzf-complete-path)
|
||||
imap <c-x><c-l> <plug>(fzf-complete-line)
|
||||
```
|
||||
|
||||
Completion functions
|
||||
--------------------
|
||||
|
||||
| Function | Description |
|
||||
| --- | --- |
|
||||
| `fzf#vim#complete#path(command, [spec])` | Path completion |
|
||||
| `fzf#vim#complete#word([spec])` | Word completion |
|
||||
| `fzf#vim#complete#line([spec])` | Line completion (all open buffers) |
|
||||
| `fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only) |
|
||||
|
||||
```vim
|
||||
" Path completion with custom source command
|
||||
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('fd')
|
||||
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files')
|
||||
|
||||
" Word completion with custom spec with popup layout option
|
||||
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
|
||||
```
|
||||
|
||||
Custom completion
|
||||
-----------------
|
||||
|
||||
`fzf#vim#complete` is a helper function for creating custom fuzzy completion
|
||||
using fzf. If the first parameter is a command string or a Vim list, it will
|
||||
be used as the source.
|
||||
|
||||
```vim
|
||||
" Replace the default dictionary completion with fzf-based fuzzy completion
|
||||
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')
|
||||
```
|
||||
|
||||
For advanced uses, you can pass an options dictionary to the function. The set
|
||||
of options is pretty much identical to that for `fzf#run` only with the
|
||||
following exceptions:
|
||||
|
||||
- `reducer` (funcref)
|
||||
- Reducer transforms the output lines of fzf into a single string value
|
||||
- `prefix` (string or funcref; default: `\k*$`)
|
||||
- Regular expression pattern to extract the completion prefix
|
||||
- Or a function to extract completion prefix
|
||||
- Both `source` and `options` can be given as funcrefs that take the
|
||||
completion prefix as the argument and return the final value
|
||||
- `sink` or `sink*` are ignored
|
||||
|
||||
```vim
|
||||
" Global line completion (not just open buffers. ripgrep required.)
|
||||
inoremap <expr> <c-x><c-l> fzf#vim#complete(fzf#wrap({
|
||||
\ 'prefix': '^.*$',
|
||||
\ 'source': 'rg -n ^ --color always',
|
||||
\ 'options': '--ansi --delimiter : --nth 3..',
|
||||
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
|
||||
```
|
||||
|
||||
### Reducer example
|
||||
|
||||
```vim
|
||||
function! s:make_sentence(lines)
|
||||
return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.'
|
||||
endfunction
|
||||
|
||||
inoremap <expr> <c-x><c-s> fzf#vim#complete({
|
||||
\ 'source': 'cat /usr/share/dict/words',
|
||||
\ 'reducer': function('<sid>make_sentence'),
|
||||
\ 'options': '--multi --reverse --margin 15%,0',
|
||||
\ 'left': 20})
|
||||
```
|
||||
|
||||
Status line of terminal buffer
|
||||
------------------------------
|
||||
|
||||
When fzf starts in a terminal buffer (see [fzf/README-VIM.md][termbuf]), you
|
||||
may want to customize the statusline of the containing buffer.
|
||||
|
||||
[termbuf]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzf-inside-terminal-buffer
|
||||
|
||||
### Hide statusline
|
||||
|
||||
```vim
|
||||
autocmd! FileType fzf set laststatus=0 noshowmode noruler
|
||||
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
|
||||
```
|
||||
|
||||
### Custom statusline
|
||||
|
||||
```vim
|
||||
function! s:fzf_statusline()
|
||||
" Override statusline as you like
|
||||
highlight fzf1 ctermfg=161 ctermbg=251
|
||||
highlight fzf2 ctermfg=23 ctermbg=251
|
||||
highlight fzf3 ctermfg=237 ctermbg=251
|
||||
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
||||
endfunction
|
||||
|
||||
autocmd! User FzfStatusLine call <SID>fzf_statusline()
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
[fzf]: https://github.com/junegunn/fzf
|
||||
[run]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun
|
||||
[ag]: https://github.com/ggreer/the_silver_searcher
|
||||
[rg]: https://github.com/BurntSushi/ripgrep
|
||||
[us]: https://github.com/SirVer/ultisnips
|
1718
.vim/pack/plugins/start/vim-fzf/autoload/fzf/vim.vim
Executable file
1718
.vim/pack/plugins/start/vim-fzf/autoload/fzf/vim.vim
Executable file
File diff suppressed because it is too large
Load Diff
164
.vim/pack/plugins/start/vim-fzf/autoload/fzf/vim/complete.vim
Normal file
164
.vim/pack/plugins/start/vim-fzf/autoload/fzf/vim/complete.vim
Normal file
@ -0,0 +1,164 @@
|
||||
" Copyright (c) 2015 Junegunn Choi
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be
|
||||
" included in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
|
||||
function! s:extend(base, extra)
|
||||
let base = copy(a:base)
|
||||
if has_key(a:extra, 'options')
|
||||
let extra = copy(a:extra)
|
||||
let extra.extra_options = remove(extra, 'options')
|
||||
return extend(base, extra)
|
||||
endif
|
||||
return extend(base, a:extra)
|
||||
endfunction
|
||||
|
||||
if v:version >= 704
|
||||
function! s:function(name)
|
||||
return function(a:name)
|
||||
endfunction
|
||||
else
|
||||
function! s:function(name)
|
||||
" By Ingo Karkat
|
||||
return function(substitute(a:name, '^s:', matchstr(expand('<sfile>'), '<SNR>\d\+_\zefunction$'), ''))
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! fzf#vim#complete#word(...)
|
||||
let sources = empty(&dictionary) ? ['/usr/share/dict/words'] : split(&dictionary, ',')
|
||||
return fzf#vim#complete(s:extend({
|
||||
\ 'source': 'cat ' . join(map(sources, 'fzf#shellescape(v:val)'))},
|
||||
\ get(a:000, 0, fzf#wrap())))
|
||||
endfunction
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" <plug>(fzf-complete-path)
|
||||
" <plug>(fzf-complete-file)
|
||||
" <plug>(fzf-complete-file-ag)
|
||||
" ----------------------------------------------------------------------------
|
||||
function! s:file_split_prefix(prefix)
|
||||
let expanded = expand(a:prefix)
|
||||
let slash = (s:is_win && !&shellslash) ? '\\' : '/'
|
||||
return isdirectory(expanded) ?
|
||||
\ [expanded,
|
||||
\ substitute(a:prefix, '[/\\]*$', slash, ''),
|
||||
\ ''] :
|
||||
\ [fnamemodify(expanded, ':h'),
|
||||
\ substitute(fnamemodify(a:prefix, ':h'), '[/\\]*$', slash, ''),
|
||||
\ fnamemodify(expanded, ':t')]
|
||||
endfunction
|
||||
|
||||
function! s:file_source(prefix)
|
||||
let [dir, head, tail] = s:file_split_prefix(a:prefix)
|
||||
return printf(
|
||||
\ "cd %s && ".s:file_cmd." | sed %s",
|
||||
\ fzf#shellescape(dir), fzf#shellescape('s:^:'.(empty(a:prefix) || a:prefix == tail ? '' : head).':'))
|
||||
endfunction
|
||||
|
||||
function! s:file_options(prefix)
|
||||
let [_, head, tail] = s:file_split_prefix(a:prefix)
|
||||
return ['--prompt', head, '--query', tail]
|
||||
endfunction
|
||||
|
||||
function! s:fname_prefix(str)
|
||||
let isf = &isfname
|
||||
let white = []
|
||||
let black = []
|
||||
if isf =~ ',,,'
|
||||
call add(white, ',')
|
||||
let isf = substitute(isf, ',,,', ',', 'g')
|
||||
endif
|
||||
if isf =~ ',^,,'
|
||||
call add(black, ',')
|
||||
let isf = substitute(isf, ',^,,', ',', 'g')
|
||||
endif
|
||||
|
||||
for token in split(isf, ',')
|
||||
let target = white
|
||||
if token[0] == '^'
|
||||
let target = black
|
||||
let token = token[1:]
|
||||
endif
|
||||
|
||||
let ends = matchlist(token, '\(.\+\)-\(.\+\)')
|
||||
if empty(ends)
|
||||
call add(target, token)
|
||||
else
|
||||
let ends = map(ends[1:2], "len(v:val) == 1 ? char2nr(v:val) : str2nr(v:val)")
|
||||
for i in range(ends[0], ends[1])
|
||||
call add(target, nr2char(i))
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
let prefix = a:str
|
||||
for offset in range(1, len(a:str))
|
||||
let char = a:str[len(a:str) - offset]
|
||||
if (char =~ '\w' || index(white, char) >= 0) && index(black, char) < 0
|
||||
continue
|
||||
endif
|
||||
let prefix = strpart(a:str, len(a:str) - offset + 1)
|
||||
break
|
||||
endfor
|
||||
|
||||
return prefix
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#complete#path(command, ...)
|
||||
let s:file_cmd = a:command
|
||||
return fzf#vim#complete(s:extend({
|
||||
\ 'prefix': s:function('s:fname_prefix'),
|
||||
\ 'source': s:function('s:file_source'),
|
||||
\ 'options': s:function('s:file_options')}, get(a:000, 0, fzf#wrap())))
|
||||
endfunction
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" <plug>(fzf-complete-line)
|
||||
" <plug>(fzf-complete-buffer-line)
|
||||
" ----------------------------------------------------------------------------
|
||||
function! s:reduce_line(lines)
|
||||
return join(split(a:lines[0], '\t\zs')[3:], '')
|
||||
endfunction
|
||||
|
||||
|
||||
function! fzf#vim#complete#line(...)
|
||||
let [display_bufnames, lines] = fzf#vim#_lines(0)
|
||||
let nth = display_bufnames ? 4 : 3
|
||||
return fzf#vim#complete(s:extend({
|
||||
\ 'prefix': '^.*$',
|
||||
\ 'source': lines,
|
||||
\ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1',
|
||||
\ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, fzf#wrap())))
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#complete#buffer_line(...)
|
||||
return fzf#vim#complete(s:extend({
|
||||
\ 'prefix': '^.*$',
|
||||
\ 'source': fzf#vim#_uniq(getline(1, '$'))}, get(a:000, 0, fzf#wrap())))
|
||||
endfunction
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
@ -0,0 +1,38 @@
|
||||
" Copyright (c) 2023 Junegunn Choi
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be
|
||||
" included in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
function! fzf#vim#listproc#quickfix(list)
|
||||
call setqflist(a:list)
|
||||
copen
|
||||
wincmd p
|
||||
cfirst
|
||||
normal! zvzz
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#listproc#location(list)
|
||||
call setloclist(0, a:list)
|
||||
lopen
|
||||
wincmd p
|
||||
lfirst
|
||||
normal! zvzz
|
||||
endfunction
|
3
.vim/pack/plugins/start/vim-fzf/bin/preview.rb
Executable file
3
.vim/pack/plugins/start/vim-fzf/bin/preview.rb
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
puts 'preview.rb is deprecated. Use preview.sh instead.'
|
86
.vim/pack/plugins/start/vim-fzf/bin/preview.sh
Executable file
86
.vim/pack/plugins/start/vim-fzf/bin/preview.sh
Executable file
@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
REVERSE="\x1b[7m"
|
||||
RESET="\x1b[m"
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "usage: $0 [--tag] FILENAME[:LINENO][:IGNORED]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $1 = --tag ]]; then
|
||||
shift
|
||||
"$(dirname "${BASH_SOURCE[0]}")/tagpreview.sh" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Ignore if an empty path is given
|
||||
[[ -z $1 ]] && exit
|
||||
|
||||
IFS=':' read -r -a INPUT <<< "$1"
|
||||
FILE=${INPUT[0]}
|
||||
CENTER=${INPUT[1]}
|
||||
|
||||
if [[ "$1" =~ ^[A-Za-z]:\\ ]]; then
|
||||
FILE=$FILE:${INPUT[1]}
|
||||
CENTER=${INPUT[2]}
|
||||
fi
|
||||
|
||||
if [[ -n "$CENTER" && ! "$CENTER" =~ ^[0-9] ]]; then
|
||||
exit 1
|
||||
fi
|
||||
CENTER=${CENTER/[^0-9]*/}
|
||||
|
||||
# MS Win support
|
||||
if [[ "$FILE" =~ '\' ]]; then
|
||||
if [ -z "$MSWINHOME" ]; then
|
||||
MSWINHOME="$HOMEDRIVE$HOMEPATH"
|
||||
fi
|
||||
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null ; then
|
||||
MSWINHOME="${MSWINHOME//\\/\\\\}"
|
||||
FILE="${FILE/#\~\\/$MSWINHOME\\}"
|
||||
FILE=$(wslpath -u "$FILE")
|
||||
elif [ -n "$MSWINHOME" ]; then
|
||||
FILE="${FILE/#\~\\/$MSWINHOME\\}"
|
||||
fi
|
||||
fi
|
||||
|
||||
FILE="${FILE/#\~\//$HOME/}"
|
||||
if [ ! -r "$FILE" ]; then
|
||||
echo "File not found ${FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$CENTER" ]; then
|
||||
CENTER=0
|
||||
fi
|
||||
|
||||
# Sometimes bat is installed as batcat.
|
||||
if command -v batcat > /dev/null; then
|
||||
BATNAME="batcat"
|
||||
elif command -v bat > /dev/null; then
|
||||
BATNAME="bat"
|
||||
fi
|
||||
|
||||
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
|
||||
${BATNAME} --style="${BAT_STYLE:-numbers}" --color=always --pager=never \
|
||||
--highlight-line=$CENTER -- "$FILE"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
FILE_LENGTH=${#FILE}
|
||||
MIME=$(file --dereference --mime -- "$FILE")
|
||||
if [[ "${MIME:FILE_LENGTH}" =~ binary ]]; then
|
||||
echo "$MIME"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}"
|
||||
CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND}
|
||||
CMD=${CMD//{\}/$(printf %q "$FILE")}
|
||||
|
||||
eval "$CMD" 2> /dev/null | awk "{ \
|
||||
if (NR == $CENTER) \
|
||||
{ gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \
|
||||
else printf(\"$RESET%s\n\", \$0); \
|
||||
}"
|
73
.vim/pack/plugins/start/vim-fzf/bin/tagpreview.sh
Executable file
73
.vim/pack/plugins/start/vim-fzf/bin/tagpreview.sh
Executable file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
REVERSE="\x1b[7m"
|
||||
RESET="\x1b[m"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: $0 FILENAME:TAGFILE:EXCMD"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IFS=':' read -r FILE TAGFILE EXCMD <<< "$*"
|
||||
|
||||
# Complete file paths which are relative to the given tag file
|
||||
if [ "${FILE:0:1}" != "/" ]; then
|
||||
FILE="$(dirname "${TAGFILE}")/${FILE}"
|
||||
fi
|
||||
|
||||
if [ ! -r "$FILE" ]; then
|
||||
echo "File not found ${FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If users aren't using vim, they are probably using neovim
|
||||
if command -v vim > /dev/null; then
|
||||
VIMNAME="vim"
|
||||
elif command -v nvim > /dev/null; then
|
||||
VIMNAME="nvim"
|
||||
else
|
||||
echo "Cannot preview tag: vim or nvim unavailable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CENTER="$("${VIMNAME}" -R -i NONE -u NONE -e -m -s "${FILE}" \
|
||||
-c "set nomagic" \
|
||||
-c "${EXCMD}" \
|
||||
-c 'let l=line(".") | new | put =l | print | qa!')" || exit
|
||||
|
||||
START_LINE="$(( CENTER - FZF_PREVIEW_LINES / 2 ))"
|
||||
if (( START_LINE <= 0 )); then
|
||||
START_LINE=1
|
||||
fi
|
||||
END_LINE="$(( START_LINE + FZF_PREVIEW_LINES - 1 ))"
|
||||
|
||||
# Sometimes bat is installed as batcat.
|
||||
if command -v batcat > /dev/null; then
|
||||
BATNAME="batcat"
|
||||
elif command -v bat > /dev/null; then
|
||||
BATNAME="bat"
|
||||
fi
|
||||
|
||||
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
|
||||
${BATNAME} --style="${BAT_STYLE:-numbers}" \
|
||||
--color=always \
|
||||
--pager=never \
|
||||
--wrap=never \
|
||||
--terminal-width="${FZF_PREVIEW_COLUMNS}" \
|
||||
--line-range="${START_LINE}:${END_LINE}" \
|
||||
--highlight-line="${CENTER}" \
|
||||
"$FILE"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}"
|
||||
CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND}
|
||||
CMD=${CMD//{\}/$(printf %q "$FILE")}
|
||||
|
||||
eval "$CMD" 2> /dev/null | awk "{ \
|
||||
if (NR >= $START_LINE && NR <= $END_LINE) { \
|
||||
if (NR == $CENTER) \
|
||||
{ gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \
|
||||
else printf(\"$RESET%s\n\", \$0); \
|
||||
} \
|
||||
}"
|
15
.vim/pack/plugins/start/vim-fzf/bin/tags.pl
Executable file
15
.vim/pack/plugins/start/vim-fzf/bin/tags.pl
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
|
||||
foreach my $file (@ARGV) {
|
||||
open my $lines, $file;
|
||||
while (<$lines>) {
|
||||
unless (/^\!/) {
|
||||
s/^[^\t]*/sprintf("%-24s", $&)/e;
|
||||
s/$/\t$file/;
|
||||
print;
|
||||
}
|
||||
}
|
||||
close $lines;
|
||||
}
|
515
.vim/pack/plugins/start/vim-fzf/doc/fzf-vim.txt
Normal file
515
.vim/pack/plugins/start/vim-fzf/doc/fzf-vim.txt
Normal file
@ -0,0 +1,515 @@
|
||||
fzf-vim.txt fzf-vim Last change: October 14 2023
|
||||
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
|
||||
==============================================================================
|
||||
|
||||
fzf :heart: vim |fzf-vim-fzfheart-vim|
|
||||
Rationale |fzf-vim-rationale|
|
||||
Why you should use fzf on Vim |fzf-vim-why-you-should-use-fzf-on-vim|
|
||||
Installation |fzf-vim-installation|
|
||||
Using vim-plug |fzf-vim-using-vim-plug|
|
||||
Dependencies |fzf-vim-dependencies|
|
||||
Commands |fzf-vim-commands|
|
||||
Customization |fzf-vim-customization|
|
||||
Configuration options of the base plugin |fzf-vim-configuration-options-of-the-base-plugin|
|
||||
Configuration options for fzf.vim |fzf-vim-configuration-options-for-fzf-vim|
|
||||
Preview window |fzf-vim-preview-window|
|
||||
Command-level options |fzf-vim-command-level-options|
|
||||
List type to handle multiple selections |fzf-vim-list-type-to-handle-multiple-selections|
|
||||
Advanced customization |fzf-vim-advanced-customization|
|
||||
Vim functions |fzf-vim-vim-functions|
|
||||
Example: Customizing Files command |fzf-vim-example-customizing-files-command|
|
||||
Example: git grep wrapper |fzf-vim-example-git-grep-wrapper|
|
||||
Mappings |fzf-vim-mappings|
|
||||
Completion functions |fzf-vim-completion-functions|
|
||||
Custom completion |fzf-vim-custom-completion|
|
||||
Reducer example |fzf-vim-reducer-example|
|
||||
Status line of terminal buffer |fzf-vim-status-line-of-terminal-buffer|
|
||||
Hide statusline |fzf-vim-hide-statusline|
|
||||
Custom statusline |fzf-vim-custom-statusline|
|
||||
License |fzf-vim-license|
|
||||
|
||||
FZF :HEART: VIM *fzf-vim-fzfheart-vim*
|
||||
==============================================================================
|
||||
|
||||
Things you can do with {fzf}{1} and Vim.
|
||||
|
||||
{1} https://github.com/junegunn/fzf
|
||||
|
||||
|
||||
RATIONALE *fzf-vim-rationale*
|
||||
==============================================================================
|
||||
|
||||
{fzf}{1} itself is not a Vim plugin, and the official repository only provides
|
||||
the {basic wrapper function}{2} for Vim. It's up to the users to write their
|
||||
own Vim commands with it. However, I've learned that many users of fzf are not
|
||||
familiar with Vimscript and are looking for the "default" implementation of
|
||||
the features they can find in the alternative Vim plugins.
|
||||
|
||||
{1} https://github.com/junegunn/fzf
|
||||
{2} https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun
|
||||
|
||||
|
||||
WHY YOU SHOULD USE FZF ON VIM *fzf-vim-why-you-should-use-fzf-on-vim*
|
||||
==============================================================================
|
||||
|
||||
Because you can and you love fzf.
|
||||
|
||||
fzf runs asynchronously and can be orders of magnitude faster than similar Vim
|
||||
plugins. However, the benefit may not be noticeable if the size of the input
|
||||
is small, which is the case for many of the commands provided here.
|
||||
Nevertheless I wrote them anyway since it's really easy to implement custom
|
||||
selector with fzf.
|
||||
|
||||
|
||||
INSTALLATION *fzf-vim-installation*
|
||||
==============================================================================
|
||||
|
||||
fzf.vim depends on the basic Vim plugin of {the main fzf repository}{1}, which
|
||||
means you need to set up both "fzf" and "fzf.vim" on Vim. To learn more about
|
||||
fzf/Vim integration, see {README-VIM}{3}.
|
||||
|
||||
{1} https://github.com/junegunn/fzf
|
||||
{3} https://github.com/junegunn/fzf/blob/master/README-VIM.md
|
||||
|
||||
|
||||
< Using vim-plug >____________________________________________________________~
|
||||
*fzf-vim-using-vim-plug*
|
||||
>
|
||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
<
|
||||
`fzf#install()` makes sure that you have the latest binary, but it's optional,
|
||||
so you can omit it if you use a plugin manager that doesn't support hooks.
|
||||
|
||||
|
||||
< Dependencies >______________________________________________________________~
|
||||
*fzf-vim-dependencies*
|
||||
|
||||
- {fzf}{1} 0.41.1 or above
|
||||
- For syntax-highlighted preview, install {bat}{4}
|
||||
- If {delta}{5} is available, `GF?`, `Commits` and `BCommits` will use it to
|
||||
format `git diff` output.
|
||||
- `Ag` requires {The Silver Searcher (ag)}{6}
|
||||
- `Rg` requires {ripgrep (rg)}{7}
|
||||
- `Tags` and `Helptags` require Perl
|
||||
|
||||
{1} https://github.com/junegunn/fzf
|
||||
{4} https://github.com/sharkdp/bat
|
||||
{5} https://github.com/dandavison/delta
|
||||
{6} https://github.com/ggreer/the_silver_searcher
|
||||
{7} https://github.com/BurntSushi/ripgrep
|
||||
|
||||
|
||||
COMMANDS *fzf-vim-commands*
|
||||
==============================================================================
|
||||
|
||||
*:Files* *:GFiles* *:Buffers* *:Colors* *:Ag* *:Rg* *:RG* *:Lines* *:BLines* *:Tags* *:BTags*
|
||||
*:Changes* *:Marks* *:Jumps* *:Windows* *:Locate* *:History* *:Snippets* *:Commits* *:BCommits*
|
||||
*:Commands* *:Maps* *:Helptags* *:Filetypes*
|
||||
|
||||
-----------------------+--------------------------------------------------------------------------------------
|
||||
Command | List ~
|
||||
-----------------------+--------------------------------------------------------------------------------------
|
||||
`:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined)
|
||||
`:GFiles [OPTS]` | Git files ( `git ls-files` )
|
||||
`:GFiles?` | Git files ( `git status` )
|
||||
`:Buffers` | Open buffers
|
||||
`:Colors` | Color schemes
|
||||
`:Ag [PATTERN]` | {ag}{6} search result ( `ALT-A` to select all, `ALT-D` to deselect all)
|
||||
`:Rg [PATTERN]` | {rg}{7} search result ( `ALT-A` to select all, `ALT-D` to deselect all)
|
||||
`:RG [PATTERN]` | {rg}{7} search result; relaunch ripgrep on every keystroke
|
||||
`:Lines [QUERY]` | Lines in loaded buffers
|
||||
`:BLines [QUERY]` | Lines in the current buffer
|
||||
`:Tags [QUERY]` | Tags in the project ( `ctags -R` )
|
||||
`:BTags [QUERY]` | Tags in the current buffer
|
||||
`:Changes` | Changelist across all open buffers
|
||||
`:Marks` | Marks
|
||||
`:Jumps` | Jumps
|
||||
`:Windows` | Windows
|
||||
`:Locate PATTERN` | `locate` command output
|
||||
`:History` | `v:oldfiles` and open buffers
|
||||
`:History:` | Command history
|
||||
`:History/` | Search history
|
||||
`:Snippets` | Snippets ({UltiSnips}{8})
|
||||
`:Commits [LOG_OPTS]` | Git commits (requires {fugitive.vim}{9})
|
||||
`:BCommits [LOG_OPTS]` | Git commits for the current buffer; visual-select lines to track changes in the range
|
||||
`:Commands` | Commands
|
||||
`:Maps` | Normal mode mappings
|
||||
`:Helptags` | Help tags [1]
|
||||
`:Filetypes` | File types
|
||||
-----------------------+--------------------------------------------------------------------------------------
|
||||
|
||||
*g:fzf_vim.command_prefix*
|
||||
|
||||
- Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new
|
||||
tab, a new split, or in a new vertical split
|
||||
- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen
|
||||
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
|
||||
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
|
||||
|
||||
(1: `Helptags` will shadow the command of the same name from {pathogen}{10}.
|
||||
But its functionality is still available via `call pathogen#helptags()`. [↩])
|
||||
|
||||
{6} https://github.com/ggreer/the_silver_searcher
|
||||
{7} https://github.com/BurntSushi/ripgrep
|
||||
{7} https://github.com/BurntSushi/ripgrep
|
||||
{8} https://github.com/SirVer/ultisnips
|
||||
{9} https://github.com/tpope/vim-fugitive
|
||||
{10} https://github.com/tpope/vim-pathogen
|
||||
|
||||
|
||||
CUSTOMIZATION *fzf-vim-customization*
|
||||
==============================================================================
|
||||
|
||||
|
||||
< Configuration options of the base plugin >__________________________________~
|
||||
*fzf-vim-configuration-options-of-the-base-plugin*
|
||||
|
||||
Every command in fzf.vim internally calls `fzf#wrap` function of the main
|
||||
repository which supports a set of global option variables. So please read
|
||||
through {README-VIM}{3} to learn more about them.
|
||||
|
||||
{3} https://github.com/junegunn/fzf/blob/master/README-VIM.md
|
||||
|
||||
|
||||
< Configuration options for fzf.vim >_________________________________________~
|
||||
*fzf-vim-configuration-options-for-fzf-vim*
|
||||
|
||||
*g:fzf_vim*
|
||||
|
||||
All configuration values for this plugin are stored in `g:fzf_vim` dictionary,
|
||||
so make sure to initialize it before assigning any configuration values to it.
|
||||
>
|
||||
" Initialize configuration dictionary
|
||||
let g:fzf_vim = {}
|
||||
<
|
||||
|
||||
Preview window~
|
||||
*fzf-vim-preview-window*
|
||||
|
||||
*g:fzf_vim.preview_window*
|
||||
|
||||
Some commands will show the preview window on the right. You can customize the
|
||||
behavior with `g:fzf_vim.preview_window`. Here are some examples:
|
||||
|
||||
*g:fzf_vim.preview_bash*
|
||||
>
|
||||
" This is the default option:
|
||||
" - Preview window on the right with 50% width
|
||||
" - CTRL-/ will toggle preview window.
|
||||
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
|
||||
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
|
||||
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
|
||||
|
||||
" Preview window is hidden by default. You can toggle it with ctrl-/.
|
||||
" It will show on the right with 50% width, but if the width is smaller
|
||||
" than 70 columns, it will show above the candidate list
|
||||
let g:fzf_vim.preview_window = ['hidden,right,50%,<70(up,40%)', 'ctrl-/']
|
||||
|
||||
" Empty value to disable preview window altogether
|
||||
let g:fzf_vim.preview_window = []
|
||||
|
||||
" fzf.vim needs bash to display the preview window.
|
||||
" On Windows, fzf.vim will first see if bash is in $PATH, then if
|
||||
" Git bash (C:\Program Files\Git\bin\bash.exe) is available.
|
||||
" If you want it to use a different bash, set this variable.
|
||||
" let g:fzf_vim = {}
|
||||
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
|
||||
<
|
||||
|
||||
Command-level options~
|
||||
*fzf-vim-command-level-options*
|
||||
|
||||
*g:fzf_vim.commands_expect* *g:fzf_vim.tags_command* *g:fzf_vim.commits_log_options*
|
||||
*g:fzf_vim.buffers_jump*
|
||||
>
|
||||
" [Buffers] Jump to the existing window if possible
|
||||
let g:fzf_vim.buffers_jump = 1
|
||||
|
||||
" [[B]Commits] Customize the options used by 'git log':
|
||||
let g:fzf_vim.commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
|
||||
|
||||
" [Tags] Command to generate tags file
|
||||
let g:fzf_vim.tags_command = 'ctags -R'
|
||||
|
||||
" [Commands] --expect expression for directly executing the command
|
||||
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'
|
||||
<
|
||||
|
||||
List type to handle multiple selections~
|
||||
*fzf-vim-list-type-to-handle-multiple-selections*
|
||||
|
||||
The following commands will fill the quickfix list when multiple entries are
|
||||
selected.
|
||||
|
||||
- `Ag`
|
||||
- `Rg` / `RG`
|
||||
- `Lines` / `BLines`
|
||||
- `Tags` / `BTags`
|
||||
|
||||
*g:fzf_vim.listproc*
|
||||
|
||||
By setting `g:fzf_vim.listproc`, you can make them use location list instead.
|
||||
>
|
||||
" Default: Use quickfix list
|
||||
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#quickfix(list) }
|
||||
|
||||
" Use location list instead of quickfix list
|
||||
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#location(list) }
|
||||
<
|
||||
You can customize the list type per command by defining variables named
|
||||
`g:fzf_vim.listproc_{command_name_in_lowercase}`.
|
||||
|
||||
*g:fzf_vim.listproc_rg* *g:fzf_vim.listproc_ag*
|
||||
>
|
||||
" Command-wise customization
|
||||
let g:fzf_vim.listproc_ag = { list -> fzf#vim#listproc#quickfix(list) }
|
||||
let g:fzf_vim.listproc_rg = { list -> fzf#vim#listproc#location(list) }
|
||||
<
|
||||
You can further customize the behavior by providing a custom function to
|
||||
process the list instead of using the predefined `fzf#vim#listproc#quickfix`
|
||||
or `fzf#vim#listproc#location`.
|
||||
>
|
||||
" A customized version of fzf#vim#listproc#quickfix.
|
||||
" The last two lines are commented out not to move to the first entry.
|
||||
function! g:fzf_vim.listproc(list)
|
||||
call setqflist(a:list)
|
||||
copen
|
||||
wincmd p
|
||||
" cfirst
|
||||
" normal! zvzz
|
||||
endfunction
|
||||
<
|
||||
|
||||
< Advanced customization >____________________________________________________~
|
||||
*fzf-vim-advanced-customization*
|
||||
|
||||
|
||||
Vim functions~
|
||||
*fzf-vim-vim-functions*
|
||||
|
||||
Each command in fzf.vim is backed by a Vim function. You can override a
|
||||
command or define a variation of it by calling its corresponding function.
|
||||
|
||||
----------+---------------------------------------------------------------------------------
|
||||
Command | Vim function ~
|
||||
----------+---------------------------------------------------------------------------------
|
||||
`Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])`
|
||||
`GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])`
|
||||
`GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])`
|
||||
`Buffers` | `fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])`
|
||||
`Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])`
|
||||
`Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])`
|
||||
`RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])`
|
||||
... | ...
|
||||
----------+---------------------------------------------------------------------------------
|
||||
|
||||
(We can see that the last two optional arguments of each function are
|
||||
identical. They are directly passed to `fzf#wrap` function. If you haven't
|
||||
read {README-VIM}{3} already, please read it before proceeding.)
|
||||
|
||||
{3} https://github.com/junegunn/fzf/blob/master/README-VIM.md
|
||||
|
||||
|
||||
Example: Customizing Files command~
|
||||
*fzf-vim-example-customizing-files-command*
|
||||
|
||||
This is the default definition of `Files` command:
|
||||
>
|
||||
command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)
|
||||
<
|
||||
Let's say you want to a variation of it called `ProjectFiles` that only
|
||||
searches inside `~/projects` directory. Then you can do it like this:
|
||||
>
|
||||
command! -bang ProjectFiles call fzf#vim#files('~/projects', <bang>0)
|
||||
<
|
||||
Or, if you want to override the command with different fzf options, just pass
|
||||
a custom spec to the function.
|
||||
>
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline']}, <bang>0)
|
||||
<
|
||||
Want a preview window?
|
||||
>
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)
|
||||
<
|
||||
It kind of works, but you probably want a nicer previewer program than `cat`.
|
||||
fzf.vim ships {a versatile preview script}{11} you can readily use. It
|
||||
internally executes {bat}{4} for syntax highlighting, so make sure to install
|
||||
it.
|
||||
>
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)
|
||||
<
|
||||
However, it's not ideal to hard-code the path to the script which can be
|
||||
different in different circumstances. So in order to make it easier to set up
|
||||
the previewer, fzf.vim provides `fzf#vim#with_preview` helper function.
|
||||
Similarly to `fzf#wrap`, it takes a spec dictionary and returns a copy of it
|
||||
with additional preview options.
|
||||
>
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
|
||||
<
|
||||
You can just omit the spec argument if you only want the previewer.
|
||||
>
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
|
||||
<
|
||||
{11} bin/preview.sh
|
||||
{4} https://github.com/sharkdp/bat
|
||||
|
||||
|
||||
Example: git grep wrapper~
|
||||
*fzf-vim-example-git-grep-wrapper*
|
||||
|
||||
The following example implements `GGrep` command that works similarly to
|
||||
predefined `Ag` or `Rg` using `fzf#vim#grep`.
|
||||
|
||||
*:LINE*
|
||||
|
||||
- We set the base directory to git root by setting `dir` attribute in spec
|
||||
dictionary.
|
||||
- {The preview script}{11} supports `grep` format (`FILE_PATH:LINE_NO:...`), so
|
||||
we can just wrap the spec with `fzf#vim#with_preview` as before to enable
|
||||
previewer.
|
||||
>
|
||||
command! -bang -nargs=* GGrep
|
||||
\ call fzf#vim#grep(
|
||||
\ 'git grep --line-number -- '.fzf#shellescape(<q-args>),
|
||||
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
||||
<
|
||||
{11} bin/preview.sh
|
||||
|
||||
|
||||
MAPPINGS *fzf-vim-mappings*
|
||||
==============================================================================
|
||||
|
||||
---------------------------------+------------------------------------------
|
||||
Mapping | Description ~
|
||||
---------------------------------+------------------------------------------
|
||||
<plug>(fzf-maps-n) | Normal mode mappings
|
||||
<plug>(fzf-maps-i) | Insert mode mappings
|
||||
<plug>(fzf-maps-x) | Visual mode mappings
|
||||
<plug>(fzf-maps-o) | Operator-pending mappings
|
||||
<plug>(fzf-complete-word) | `cat /usr/share/dict/words`
|
||||
<plug>(fzf-complete-path) | Path completion using `find` (file + dir)
|
||||
<plug>(fzf-complete-file) | File completion using `find`
|
||||
<plug>(fzf-complete-line) | Line completion (all open buffers)
|
||||
<plug>(fzf-complete-buffer-line) | Line completion (current buffer only)
|
||||
---------------------------------+------------------------------------------
|
||||
>
|
||||
" Mapping selecting mappings
|
||||
nmap <leader><tab> <plug>(fzf-maps-n)
|
||||
xmap <leader><tab> <plug>(fzf-maps-x)
|
||||
omap <leader><tab> <plug>(fzf-maps-o)
|
||||
|
||||
" Insert mode completion
|
||||
imap <c-x><c-k> <plug>(fzf-complete-word)
|
||||
imap <c-x><c-f> <plug>(fzf-complete-path)
|
||||
imap <c-x><c-l> <plug>(fzf-complete-line)
|
||||
<
|
||||
|
||||
COMPLETION FUNCTIONS *fzf-vim-completion-functions*
|
||||
==============================================================================
|
||||
|
||||
-----------------------------------------+--------------------------------------
|
||||
Function | Description ~
|
||||
-----------------------------------------+--------------------------------------
|
||||
`fzf#vim#complete#path(command, [spec])` | Path completion
|
||||
`fzf#vim#complete#word([spec])` | Word completion
|
||||
`fzf#vim#complete#line([spec])` | Line completion (all open buffers)
|
||||
`fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only)
|
||||
-----------------------------------------+--------------------------------------
|
||||
>
|
||||
" Path completion with custom source command
|
||||
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('fd')
|
||||
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files')
|
||||
|
||||
" Word completion with custom spec with popup layout option
|
||||
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
|
||||
<
|
||||
|
||||
CUSTOM COMPLETION *fzf-vim-custom-completion*
|
||||
==============================================================================
|
||||
|
||||
`fzf#vim#complete` is a helper function for creating custom fuzzy completion
|
||||
using fzf. If the first parameter is a command string or a Vim list, it will
|
||||
be used as the source.
|
||||
>
|
||||
" Replace the default dictionary completion with fzf-based fuzzy completion
|
||||
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')
|
||||
<
|
||||
For advanced uses, you can pass an options dictionary to the function. The set
|
||||
of options is pretty much identical to that for `fzf#run` only with the
|
||||
following exceptions:
|
||||
|
||||
- `reducer` (funcref)
|
||||
- Reducer transforms the output lines of fzf into a single string value
|
||||
- `prefix` (string or funcref; default: `\k*$`)
|
||||
- Regular expression pattern to extract the completion prefix
|
||||
- Or a function to extract completion prefix
|
||||
- Both `source` and `options` can be given as funcrefs that take the completion
|
||||
prefix as the argument and return the final value
|
||||
- `sink` or `sink*` are ignored
|
||||
>
|
||||
" Global line completion (not just open buffers. ripgrep required.)
|
||||
inoremap <expr> <c-x><c-l> fzf#vim#complete(fzf#wrap({
|
||||
\ 'prefix': '^.*$',
|
||||
\ 'source': 'rg -n ^ --color always',
|
||||
\ 'options': '--ansi --delimiter : --nth 3..',
|
||||
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
|
||||
<
|
||||
|
||||
< Reducer example >___________________________________________________________~
|
||||
*fzf-vim-reducer-example*
|
||||
>
|
||||
function! s:make_sentence(lines)
|
||||
return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.'
|
||||
endfunction
|
||||
|
||||
inoremap <expr> <c-x><c-s> fzf#vim#complete({
|
||||
\ 'source': 'cat /usr/share/dict/words',
|
||||
\ 'reducer': function('<sid>make_sentence'),
|
||||
\ 'options': '--multi --reverse --margin 15%,0',
|
||||
\ 'left': 20})
|
||||
<
|
||||
|
||||
STATUS LINE OF TERMINAL BUFFER *fzf-vim-status-line-of-terminal-buffer*
|
||||
==============================================================================
|
||||
|
||||
When fzf starts in a terminal buffer (see {fzf/README-VIM.md}{12}), you may
|
||||
want to customize the statusline of the containing buffer.
|
||||
|
||||
{12} https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzf-inside-terminal-buffer
|
||||
|
||||
|
||||
< Hide statusline >___________________________________________________________~
|
||||
*fzf-vim-hide-statusline*
|
||||
>
|
||||
autocmd! FileType fzf set laststatus=0 noshowmode noruler
|
||||
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
|
||||
<
|
||||
|
||||
< Custom statusline >_________________________________________________________~
|
||||
*fzf-vim-custom-statusline*
|
||||
>
|
||||
function! s:fzf_statusline()
|
||||
" Override statusline as you like
|
||||
highlight fzf1 ctermfg=161 ctermbg=251
|
||||
highlight fzf2 ctermfg=23 ctermbg=251
|
||||
highlight fzf3 ctermfg=237 ctermbg=251
|
||||
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
||||
endfunction
|
||||
|
||||
autocmd! User FzfStatusLine call <SID>fzf_statusline()
|
||||
<
|
||||
|
||||
LICENSE *fzf-vim-license*
|
||||
==============================================================================
|
||||
|
||||
MIT
|
||||
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:
|
63
.vim/pack/plugins/start/vim-fzf/doc/tags
Normal file
63
.vim/pack/plugins/start/vim-fzf/doc/tags
Normal file
@ -0,0 +1,63 @@
|
||||
:Ag fzf-vim.txt /*:Ag*
|
||||
:BCommits fzf-vim.txt /*:BCommits*
|
||||
:BLines fzf-vim.txt /*:BLines*
|
||||
:BTags fzf-vim.txt /*:BTags*
|
||||
:Buffers fzf-vim.txt /*:Buffers*
|
||||
:Changes fzf-vim.txt /*:Changes*
|
||||
:Colors fzf-vim.txt /*:Colors*
|
||||
:Commands fzf-vim.txt /*:Commands*
|
||||
:Commits fzf-vim.txt /*:Commits*
|
||||
:Files fzf-vim.txt /*:Files*
|
||||
:Filetypes fzf-vim.txt /*:Filetypes*
|
||||
:GFiles fzf-vim.txt /*:GFiles*
|
||||
:Helptags fzf-vim.txt /*:Helptags*
|
||||
:History fzf-vim.txt /*:History*
|
||||
:Jumps fzf-vim.txt /*:Jumps*
|
||||
:LINE fzf-vim.txt /*:LINE*
|
||||
:Lines fzf-vim.txt /*:Lines*
|
||||
:Locate fzf-vim.txt /*:Locate*
|
||||
:Maps fzf-vim.txt /*:Maps*
|
||||
:Marks fzf-vim.txt /*:Marks*
|
||||
:RG fzf-vim.txt /*:RG*
|
||||
:Rg fzf-vim.txt /*:Rg*
|
||||
:Snippets fzf-vim.txt /*:Snippets*
|
||||
:Tags fzf-vim.txt /*:Tags*
|
||||
:Windows fzf-vim.txt /*:Windows*
|
||||
fzf-vim fzf-vim.txt /*fzf-vim*
|
||||
fzf-vim-advanced-customization fzf-vim.txt /*fzf-vim-advanced-customization*
|
||||
fzf-vim-command-level-options fzf-vim.txt /*fzf-vim-command-level-options*
|
||||
fzf-vim-commands fzf-vim.txt /*fzf-vim-commands*
|
||||
fzf-vim-completion-functions fzf-vim.txt /*fzf-vim-completion-functions*
|
||||
fzf-vim-configuration-options-for-fzf-vim fzf-vim.txt /*fzf-vim-configuration-options-for-fzf-vim*
|
||||
fzf-vim-configuration-options-of-the-base-plugin fzf-vim.txt /*fzf-vim-configuration-options-of-the-base-plugin*
|
||||
fzf-vim-custom-completion fzf-vim.txt /*fzf-vim-custom-completion*
|
||||
fzf-vim-custom-statusline fzf-vim.txt /*fzf-vim-custom-statusline*
|
||||
fzf-vim-customization fzf-vim.txt /*fzf-vim-customization*
|
||||
fzf-vim-dependencies fzf-vim.txt /*fzf-vim-dependencies*
|
||||
fzf-vim-example-customizing-files-command fzf-vim.txt /*fzf-vim-example-customizing-files-command*
|
||||
fzf-vim-example-git-grep-wrapper fzf-vim.txt /*fzf-vim-example-git-grep-wrapper*
|
||||
fzf-vim-fzfheart-vim fzf-vim.txt /*fzf-vim-fzfheart-vim*
|
||||
fzf-vim-hide-statusline fzf-vim.txt /*fzf-vim-hide-statusline*
|
||||
fzf-vim-installation fzf-vim.txt /*fzf-vim-installation*
|
||||
fzf-vim-license fzf-vim.txt /*fzf-vim-license*
|
||||
fzf-vim-list-type-to-handle-multiple-selections fzf-vim.txt /*fzf-vim-list-type-to-handle-multiple-selections*
|
||||
fzf-vim-mappings fzf-vim.txt /*fzf-vim-mappings*
|
||||
fzf-vim-preview-window fzf-vim.txt /*fzf-vim-preview-window*
|
||||
fzf-vim-rationale fzf-vim.txt /*fzf-vim-rationale*
|
||||
fzf-vim-reducer-example fzf-vim.txt /*fzf-vim-reducer-example*
|
||||
fzf-vim-status-line-of-terminal-buffer fzf-vim.txt /*fzf-vim-status-line-of-terminal-buffer*
|
||||
fzf-vim-toc fzf-vim.txt /*fzf-vim-toc*
|
||||
fzf-vim-using-vim-plug fzf-vim.txt /*fzf-vim-using-vim-plug*
|
||||
fzf-vim-vim-functions fzf-vim.txt /*fzf-vim-vim-functions*
|
||||
fzf-vim-why-you-should-use-fzf-on-vim fzf-vim.txt /*fzf-vim-why-you-should-use-fzf-on-vim*
|
||||
g:fzf_vim fzf-vim.txt /*g:fzf_vim*
|
||||
g:fzf_vim.buffers_jump fzf-vim.txt /*g:fzf_vim.buffers_jump*
|
||||
g:fzf_vim.command_prefix fzf-vim.txt /*g:fzf_vim.command_prefix*
|
||||
g:fzf_vim.commands_expect fzf-vim.txt /*g:fzf_vim.commands_expect*
|
||||
g:fzf_vim.commits_log_options fzf-vim.txt /*g:fzf_vim.commits_log_options*
|
||||
g:fzf_vim.listproc fzf-vim.txt /*g:fzf_vim.listproc*
|
||||
g:fzf_vim.listproc_ag fzf-vim.txt /*g:fzf_vim.listproc_ag*
|
||||
g:fzf_vim.listproc_rg fzf-vim.txt /*g:fzf_vim.listproc_rg*
|
||||
g:fzf_vim.preview_bash fzf-vim.txt /*g:fzf_vim.preview_bash*
|
||||
g:fzf_vim.preview_window fzf-vim.txt /*g:fzf_vim.preview_window*
|
||||
g:fzf_vim.tags_command fzf-vim.txt /*g:fzf_vim.tags_command*
|
163
.vim/pack/plugins/start/vim-fzf/plugin/fzf.vim
Normal file
163
.vim/pack/plugins/start/vim-fzf/plugin/fzf.vim
Normal file
@ -0,0 +1,163 @@
|
||||
" Copyright (c) 2015 Junegunn Choi
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be
|
||||
" included in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
if exists('g:loaded_fzf_vim')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_fzf_vim = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
|
||||
function! s:conf(name, default)
|
||||
let conf = get(g:, 'fzf_vim', {})
|
||||
let val = get(conf, a:name, get(g:, 'fzf_' . a:name, a:default))
|
||||
return val
|
||||
endfunction
|
||||
|
||||
function! s:defs(commands)
|
||||
let prefix = s:conf('command_prefix', '')
|
||||
if prefix =~# '^[^A-Z]'
|
||||
echoerr 'g:fzf_command_prefix must start with an uppercase letter'
|
||||
return
|
||||
endif
|
||||
for command in a:commands
|
||||
let name = ':'.prefix.matchstr(command, '\C[A-Z]\S\+')
|
||||
if 2 != exists(name)
|
||||
execute substitute(command, '\ze\C[A-Z]', prefix, '')
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
call s:defs([
|
||||
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||
\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(<q-args>, fzf#vim#with_preview(<q-args> == "?" ? { "placeholder": "" } : {}), <bang>0)',
|
||||
\'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(<q-args>, fzf#vim#with_preview(<q-args> == "?" ? { "placeholder": "" } : {}), <bang>0)',
|
||||
\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(<q-args>, fzf#vim#with_preview({ "placeholder": "{1}" }), <bang>0)',
|
||||
\'command! -bang -nargs=* Lines call fzf#vim#lines(<q-args>, <bang>0)',
|
||||
\'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(<q-args>, <bang>0)',
|
||||
\'command! -bar -bang Colors call fzf#vim#colors(<bang>0)',
|
||||
\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||
\'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||
\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".fzf#shellescape(<q-args>), fzf#vim#with_preview(), <bang>0)',
|
||||
\'command! -bang -nargs=* RG call fzf#vim#grep2("rg --column --line-number --no-heading --color=always --smart-case -- ", <q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||
\'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, fzf#vim#with_preview({ "placeholder": "--tag {2}:{-1}:{3..}" }), <bang>0)',
|
||||
\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, fzf#vim#with_preview({ "placeholder": "{2}:{3..}" }), <bang>0)',
|
||||
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)',
|
||||
\'command! -bar -bang Commands call fzf#vim#commands(<bang>0)',
|
||||
\'command! -bar -bang Jumps call fzf#vim#jumps(<bang>0)',
|
||||
\'command! -bar -bang Marks call fzf#vim#marks(<bang>0)',
|
||||
\'command! -bar -bang Changes call fzf#vim#changes(<bang>0)',
|
||||
\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), <bang>0)',
|
||||
\'command! -bar -bang Windows call fzf#vim#windows(fzf#vim#with_preview({ "placeholder": "{2}" }), <bang>0)',
|
||||
\'command! -bar -bang -nargs=* -range=% -complete=file Commits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#commits(<q-args>, fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
|
||||
\'command! -bar -bang -nargs=* -range=% BCommits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#buffer_commits(<q-args>, fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
|
||||
\'command! -bar -bang Maps call fzf#vim#maps("n", <bang>0)',
|
||||
\'command! -bar -bang Filetypes call fzf#vim#filetypes(<bang>0)',
|
||||
\'command! -bang -nargs=* History call s:history(<q-args>, fzf#vim#with_preview(), <bang>0)'])
|
||||
|
||||
function! s:history(arg, extra, bang)
|
||||
let bang = a:bang || a:arg[len(a:arg)-1] == '!'
|
||||
if a:arg[0] == ':'
|
||||
call fzf#vim#command_history(bang)
|
||||
elseif a:arg[0] == '/'
|
||||
call fzf#vim#search_history(bang)
|
||||
else
|
||||
call fzf#vim#history(a:extra, bang)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! fzf#complete(...)
|
||||
return call('fzf#vim#complete', a:000)
|
||||
endfunction
|
||||
|
||||
if (has('nvim') || has('terminal') && has('patch-8.0.995')) && (s:conf('statusline', 1) || s:conf('nvim_statusline', 1))
|
||||
function! s:fzf_restore_colors()
|
||||
if exists('#User#FzfStatusLine')
|
||||
doautocmd User FzfStatusLine
|
||||
else
|
||||
if $TERM !~ "256color"
|
||||
highlight default fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656
|
||||
highlight default fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656
|
||||
highlight default fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656
|
||||
else
|
||||
highlight default fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656
|
||||
highlight default fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656
|
||||
highlight default fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656
|
||||
endif
|
||||
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:fzf_vim_term()
|
||||
if get(w:, 'airline_active', 0)
|
||||
let w:airline_disabled = 1
|
||||
autocmd BufWinLeave <buffer> let w:airline_disabled = 0
|
||||
endif
|
||||
autocmd WinEnter,ColorScheme <buffer> call s:fzf_restore_colors()
|
||||
|
||||
setlocal nospell
|
||||
call s:fzf_restore_colors()
|
||||
endfunction
|
||||
|
||||
augroup _fzf_statusline
|
||||
autocmd!
|
||||
autocmd FileType fzf call s:fzf_vim_term()
|
||||
augroup END
|
||||
endif
|
||||
|
||||
if !exists('g:fzf#vim#buffers')
|
||||
let g:fzf#vim#buffers = {}
|
||||
endif
|
||||
|
||||
augroup fzf_buffers
|
||||
autocmd!
|
||||
if exists('*reltimefloat')
|
||||
autocmd BufWinEnter,WinEnter * let g:fzf#vim#buffers[bufnr('')] = reltimefloat(reltime())
|
||||
else
|
||||
autocmd BufWinEnter,WinEnter * let g:fzf#vim#buffers[bufnr('')] = localtime()
|
||||
endif
|
||||
autocmd BufDelete * silent! call remove(g:fzf#vim#buffers, expand('<abuf>'))
|
||||
augroup END
|
||||
|
||||
inoremap <expr> <plug>(fzf-complete-word) fzf#vim#complete#word()
|
||||
if s:is_win
|
||||
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path('dir /s/b')
|
||||
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#path('dir /s/b/a:-d')
|
||||
else
|
||||
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'")
|
||||
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -type f -print -o -type l -print \| sed 's:^..::'")
|
||||
endif
|
||||
inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#path('ag -l -g ""')
|
||||
inoremap <expr> <plug>(fzf-complete-line) fzf#vim#complete#line()
|
||||
inoremap <expr> <plug>(fzf-complete-buffer-line) fzf#vim#complete#buffer_line()
|
||||
|
||||
nnoremap <silent> <plug>(fzf-maps-n) :<c-u>call fzf#vim#maps('n', 0)<cr>
|
||||
inoremap <silent> <plug>(fzf-maps-i) <c-o>:call fzf#vim#maps('i', 0)<cr>
|
||||
xnoremap <silent> <plug>(fzf-maps-x) :<c-u>call fzf#vim#maps('x', 0)<cr>
|
||||
onoremap <silent> <plug>(fzf-maps-o) <c-c>:<c-u>call fzf#vim#maps('o', 0)<cr>
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
1459
.vim/pack/plugins/start/vim-gnupg/plugin/gnupg.vim
Normal file
1459
.vim/pack/plugins/start/vim-gnupg/plugin/gnupg.vim
Normal file
File diff suppressed because it is too large
Load Diff
43
.vim/pack/plugins/start/vim-lucius/README.md
Normal file
43
.vim/pack/plugins/start/vim-lucius/README.md
Normal file
@ -0,0 +1,43 @@
|
||||
vim-lucius
|
||||
==========
|
||||
|
||||
This repository has the Lucius color scheme for Vim. It is already organized
|
||||
under a "colors" directory, so you can clone the repo into your own vimfiles
|
||||
(or under bundle, if you use Pathogen).
|
||||
|
||||
The color scheme is available for other applications, as well. They can be
|
||||
found here:
|
||||
|
||||
https://github.com/jonathanfilip/lucius
|
||||
|
||||
Some sample screenshots of the different configurations:
|
||||
|
||||
### Dark
|
||||
![LuciusDark](http://i.imgur.com/LsZbF.png "LuciusDark (default)")
|
||||
|
||||
### Dark High Contrast
|
||||
![LuciusDarkHighContrast](http://i.imgur.com/e70i9.png "LuciusDarkHighContrast")
|
||||
|
||||
### Dark Low Contrast
|
||||
![LuciusDarkLowContrast](http://i.imgur.com/Hmw8s.png "LuciusDarkLowContrast")
|
||||
|
||||
### Black
|
||||
![LuciusBlack](http://i.imgur.com/iD4ri.png "LuciusBlack")
|
||||
|
||||
### Black High Contrast
|
||||
![LuciusBlackHighContrast](http://i.imgur.com/lHvTJ.png "LuciusBlackHighContrast")
|
||||
|
||||
### Black Low Contrast
|
||||
![LuciusBlackLowContrast](http://i.imgur.com/oZLkg.png "LuciusBlackLowContrast")
|
||||
|
||||
### Light
|
||||
![LuciusLight](http://i.imgur.com/soYD8.png "LuciusLight (light default)")
|
||||
|
||||
### Light Low Contrast
|
||||
![LuciusLightLowContrast](http://i.imgur.com/95I86.png "LuciusLightLowContrast")
|
||||
|
||||
### White
|
||||
![LuciusWhite](http://i.imgur.com/wDzkz.png "LuciusWhite")
|
||||
|
||||
### White Low Contrast
|
||||
![LuciusWhiteLowContrast](http://i.imgur.com/jlUf4.png "LuciusWhiteLowContrast")
|
805
.vim/pack/plugins/start/vim-lucius/colors/lucius.vim
Normal file
805
.vim/pack/plugins/start/vim-lucius/colors/lucius.vim
Normal file
@ -0,0 +1,805 @@
|
||||
" ============================================================================
|
||||
" Name: Lucius vim color scheme
|
||||
" Author: Jonathan Filip <jfilip1024@gmail.com>
|
||||
" Version: 8.1.7
|
||||
" ----------------------------------------------------------------------------
|
||||
"
|
||||
" Light and dark color scheme for GUI and 256 color terminal.
|
||||
"
|
||||
" There are several options available to customize the color scheme to your
|
||||
" own tastes. This is particularly useful when you have to work in different
|
||||
" environments at different times (home, work, day, night, etc).
|
||||
"
|
||||
" The GUI and 256 color terminal versions of this color scheme are identical.
|
||||
"
|
||||
" You can set up the color scheme by manually setting the options you want or
|
||||
" by choosing one of the presets defined. These presets are loaded after you
|
||||
" first source the color scheme file and are all commands that start with
|
||||
" 'Lucius'.
|
||||
"
|
||||
" I have also started to create color schemes for different applications. I
|
||||
" have been using them for PuTTY, iTerm2, and Visual Studio, but will keep
|
||||
" adding more as I go along. You can find the files for these on Github:
|
||||
"
|
||||
" https://github.com/jonathanfilip/lucius
|
||||
"
|
||||
" You can also clone the following repository if you use Pathogen or something
|
||||
" similar. It holds the vim color scheme in a 'colors' directory:
|
||||
"
|
||||
" https://github.com/jonathanfilip/vim-lucius
|
||||
"
|
||||
"
|
||||
"
|
||||
" Presets:
|
||||
"
|
||||
" There are several presets available that will set all the options for you.
|
||||
" There are screenshots of each preset below:
|
||||
"
|
||||
" * LuciusDark (dark default): http://i.imgur.com/LsZbF.png
|
||||
" * LuciusDarkHighContrast: http://i.imgur.com/e70i9.png
|
||||
" * LuciusDarkLowContrast: http://i.imgur.com/Hmw8s.png
|
||||
" * LuciusBlack: http://i.imgur.com/iD4ri.png
|
||||
" * LuciusBlackHighContrast: http://i.imgur.com/lHvTJ.png
|
||||
" * LuciusBlackLowContrast: http://i.imgur.com/oZLkg.png
|
||||
"
|
||||
" * LuciusLight (light default): http://i.imgur.com/soYD8.png
|
||||
" * LuciusLightLowContrast: http://i.imgur.com/95I86.png
|
||||
" * LuciusWhite: http://i.imgur.com/wDzkz.png
|
||||
" * LuciusWhiteLowContrast: http://i.imgur.com/jlUf4.png
|
||||
"
|
||||
" To use the presets, you just need to set the color scheme first. In your
|
||||
" vimrc, you can just do this:
|
||||
"
|
||||
" colorscheme lucius
|
||||
" LuciusBlack
|
||||
"
|
||||
" You can still just set the background variable and then set the color
|
||||
" scheme. This will default to LuciusDark for 'dark' and LuciusLight for
|
||||
" 'light'.
|
||||
"
|
||||
"
|
||||
" Options:
|
||||
"
|
||||
" The presets available cover most of the options. You can, however, customize
|
||||
" things by setting the following variables yourself:
|
||||
"
|
||||
" g:lucius_style (default: 'dark')
|
||||
"
|
||||
" Set this option to either 'light' or 'dark' for your desired color scheme.
|
||||
" It has the same effect as setting the background.
|
||||
"
|
||||
" g:lucius_contrast (default: 'normal')
|
||||
"
|
||||
" This option determines the contrast to use for text/ui elements. It can be
|
||||
" set to 'low', 'normal', or 'high'. At this time there is no 'high' for the
|
||||
" light scheme.
|
||||
"
|
||||
" g:lucius_contrast_bg (default: 'normal')
|
||||
"
|
||||
" Setting this option makes the background a higher contrast. Current settings
|
||||
" are 'normal' and 'high'.
|
||||
"
|
||||
" g:lucius_use_bold (default: 1)
|
||||
"
|
||||
" Setting this will cause the color scheme to use bold fonts for some items.
|
||||
"
|
||||
" g:lucius_use_underline (default: 1)
|
||||
"
|
||||
" Setting this will cause the color scheme to use underlined fonts for some
|
||||
" items.
|
||||
"
|
||||
" g:lucius_no_term_bg (default: 0)
|
||||
"
|
||||
" Setting this will cause the color scheme to not set a background color in
|
||||
" the terminal (useful for transparency or terminals with different background
|
||||
" colors).
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (c) 2015 Jonathan Filip
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to deal
|
||||
" in the Software without restriction, including without limitation the rights
|
||||
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
" copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
" THE SOFTWARE.
|
||||
"
|
||||
" ============================================================================
|
||||
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Options:
|
||||
" ============================================================================
|
||||
|
||||
unlet! g:colors_name
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
if exists("g:lucius_style")
|
||||
let s:style = g:lucius_style
|
||||
else
|
||||
let s:style = &background
|
||||
endif
|
||||
|
||||
if exists("g:lucius_contrast")
|
||||
let s:contrast = g:lucius_contrast
|
||||
else
|
||||
let s:contrast = "normal"
|
||||
endif
|
||||
|
||||
if exists("g:lucius_contrast_bg")
|
||||
let s:contrast_bg = g:lucius_contrast_bg
|
||||
else
|
||||
let s:contrast_bg = "normal"
|
||||
endif
|
||||
|
||||
if exists("g:lucius_use_bold")
|
||||
let s:use_bold = g:lucius_use_bold
|
||||
else
|
||||
let s:use_bold = 1
|
||||
endif
|
||||
|
||||
if exists("g:lucius_use_underline")
|
||||
let s:use_underline = g:lucius_use_underline
|
||||
else
|
||||
let s:use_underline = 1
|
||||
endif
|
||||
|
||||
if exists("g:lucius_no_term_bg")
|
||||
let s:no_term_bg = g:lucius_no_term_bg
|
||||
else
|
||||
let s:no_term_bg = 0
|
||||
endif
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Color Map:
|
||||
" ============================================================================
|
||||
|
||||
let s:color_map = {
|
||||
\ 'bg': 'bg', 'fg': 'fg', 'NONE': 'NONE',
|
||||
\ '#000000': '16', '#00005f': '17', '#000087': '18', '#0000af': '19',
|
||||
\ '#0000d7': '20', '#0000ff': '21', '#005f00': '22', '#005f5f': '23',
|
||||
\ '#005f87': '24', '#005faf': '25', '#005fd7': '26', '#005fff': '27',
|
||||
\ '#008700': '28', '#00875f': '29', '#008787': '30', '#0087af': '31',
|
||||
\ '#0087d7': '32', '#0087ff': '33', '#00af00': '34', '#00af5f': '35',
|
||||
\ '#00af87': '36', '#00afaf': '37', '#00afd7': '38', '#00afff': '39',
|
||||
\ '#00d700': '40', '#00d75f': '41', '#00d787': '42', '#00d7af': '43',
|
||||
\ '#00d7d7': '44', '#00d7ff': '45', '#00ff00': '46', '#00ff5f': '47',
|
||||
\ '#00ff87': '48', '#00ffaf': '49', '#00ffd7': '50', '#00ffff': '51',
|
||||
\ '#5f0000': '52', '#5f005f': '53', '#5f0087': '54', '#5f00af': '55',
|
||||
\ '#5f00d7': '56', '#5f00ff': '57', '#5f5f00': '58', '#5f5f5f': '59',
|
||||
\ '#5f5f87': '60', '#5f5faf': '61', '#5f5fd7': '62', '#5f5fff': '63',
|
||||
\ '#5f8700': '64', '#5f875f': '65', '#5f8787': '66', '#5f87af': '67',
|
||||
\ '#5f87d7': '68', '#5f87ff': '69', '#5faf00': '70', '#5faf5f': '71',
|
||||
\ '#5faf87': '72', '#5fafaf': '73', '#5fafd7': '74', '#5fafff': '75',
|
||||
\ '#5fd700': '76', '#5fd75f': '77', '#5fd787': '78', '#5fd7af': '79',
|
||||
\ '#5fd7d7': '80', '#5fd7ff': '81', '#5fff00': '82', '#5fff5f': '83',
|
||||
\ '#5fff87': '84', '#5fffaf': '85', '#5fffd7': '86', '#5fffff': '87',
|
||||
\ '#870000': '88', '#87005f': '89', '#870087': '90', '#8700af': '91',
|
||||
\ '#8700d7': '92', '#8700ff': '93', '#875f00': '94', '#875f5f': '95',
|
||||
\ '#875f87': '96', '#875faf': '97', '#875fd7': '98', '#875fff': '99',
|
||||
\ '#878700': '100', '#87875f': '101', '#878787': '102', '#8787af': '103',
|
||||
\ '#8787d7': '104', '#8787ff': '105', '#87af00': '106', '#87af5f': '107',
|
||||
\ '#87af87': '108', '#87afaf': '109', '#87afd7': '110', '#87afff': '111',
|
||||
\ '#87d700': '112', '#87d75f': '113', '#87d787': '114', '#87d7af': '115',
|
||||
\ '#87d7d7': '116', '#87d7ff': '117', '#87ff00': '118', '#87ff5f': '119',
|
||||
\ '#87ff87': '120', '#87ffaf': '121', '#87ffd7': '122', '#87ffff': '123',
|
||||
\ '#af0000': '124', '#af005f': '125', '#af0087': '126', '#af00af': '127',
|
||||
\ '#af00d7': '128', '#af00ff': '129', '#af5f00': '130', '#af5f5f': '131',
|
||||
\ '#af5f87': '132', '#af5faf': '133', '#af5fd7': '134', '#af5fff': '135',
|
||||
\ '#af8700': '136', '#af875f': '137', '#af8787': '138', '#af87af': '139',
|
||||
\ '#af87d7': '140', '#af87ff': '141', '#afaf00': '142', '#afaf5f': '143',
|
||||
\ '#afaf87': '144', '#afafaf': '145', '#afafd7': '146', '#afafff': '147',
|
||||
\ '#afd700': '148', '#afd75f': '149', '#afd787': '150', '#afd7af': '151',
|
||||
\ '#afd7d7': '152', '#afd7ff': '153', '#afff00': '154', '#afff5f': '155',
|
||||
\ '#afff87': '156', '#afffaf': '157', '#afffd7': '158', '#afffff': '159',
|
||||
\ '#d70000': '160', '#d7005f': '161', '#d70087': '162', '#d700af': '163',
|
||||
\ '#d700d7': '164', '#d700ff': '165', '#d75f00': '166', '#d75f5f': '167',
|
||||
\ '#d75f87': '168', '#d75faf': '169', '#d75fd7': '170', '#d75fff': '171',
|
||||
\ '#d78700': '172', '#d7875f': '173', '#d78787': '174', '#d787af': '175',
|
||||
\ '#d787d7': '176', '#d787ff': '177', '#d7af00': '178', '#d7af5f': '179',
|
||||
\ '#d7af87': '180', '#d7afaf': '181', '#d7afd7': '182', '#d7afff': '183',
|
||||
\ '#d7d700': '184', '#d7d75f': '185', '#d7d787': '186', '#d7d7af': '187',
|
||||
\ '#d7d7d7': '188', '#d7d7ff': '189', '#d7ff00': '190', '#d7ff5f': '191',
|
||||
\ '#d7ff87': '192', '#d7ffaf': '193', '#d7ffd7': '194', '#d7ffff': '195',
|
||||
\ '#ff0000': '196', '#ff005f': '197', '#ff0087': '198', '#ff00af': '199',
|
||||
\ '#ff00d7': '200', '#ff00ff': '201', '#ff5f00': '202', '#ff5f5f': '203',
|
||||
\ '#ff5f87': '204', '#ff5faf': '205', '#ff5fd7': '206', '#ff5fff': '207',
|
||||
\ '#ff8700': '208', '#ff875f': '209', '#ff8787': '210', '#ff87af': '211',
|
||||
\ '#ff87d7': '212', '#ff87ff': '213', '#ffaf00': '214', '#ffaf5f': '215',
|
||||
\ '#ffaf87': '216', '#ffafaf': '217', '#ffafd7': '218', '#ffafff': '219',
|
||||
\ '#ffd700': '220', '#ffd75f': '221', '#ffd787': '222', '#ffd7af': '223',
|
||||
\ '#ffd7d7': '224', '#ffd7ff': '225', '#ffff00': '226', '#ffff5f': '227',
|
||||
\ '#ffff87': '228', '#ffffaf': '229', '#ffffd7': '230', '#ffffff': '231',
|
||||
\ '#080808': '232', '#121212': '233', '#1c1c1c': '234', '#262626': '235',
|
||||
\ '#303030': '236', '#3a3a3a': '237', '#444444': '238', '#4e4e4e': '239',
|
||||
\ '#585858': '240', '#626262': '241', '#6c6c6c': '242', '#767676': '243',
|
||||
\ '#808080': '244', '#8a8a8a': '245', '#949494': '246', '#9e9e9e': '247',
|
||||
\ '#a8a8a8': '248', '#b2b2b2': '249', '#bcbcbc': '250', '#c6c6c6': '251',
|
||||
\ '#d0d0d0': '252', '#dadada': '253', '#e4e4e4': '254', '#eeeeee': '255',
|
||||
\ }
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Functions:
|
||||
" ============================================================================
|
||||
|
||||
function! s:AddCterm(name)
|
||||
exec "let l:gfg = synIDattr(synIDtrans(hlID('" . a:name .
|
||||
\ "')), 'fg', 'gui')"
|
||||
exec "let l:gbg = synIDattr(synIDtrans(hlID('" . a:name .
|
||||
\ "')), 'bg', 'gui')"
|
||||
let l:gfg = l:gfg == "" ? "NONE" : l:gfg
|
||||
let l:gbg = l:gbg == "" ? "NONE" : l:gbg
|
||||
exec "hi " . a:name . " ctermfg=" . s:color_map[l:gfg] .
|
||||
\ " ctermbg=" . s:color_map[l:gbg]
|
||||
endfunction
|
||||
|
||||
function! s:AddSpCterm(name)
|
||||
exec "let l:gsp = synIDattr(synIDtrans(hlID('" . a:name .
|
||||
\ "')), 'sp', 'gui')"
|
||||
let l:gsp = l:gsp == "" ? "NONE" : l:gsp
|
||||
exec "hi " . a:name . " ctermfg=" . s:color_map[l:gsp]
|
||||
endfunction
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Text Groups:
|
||||
" ============================================================================
|
||||
|
||||
let s:normal_items = [
|
||||
\ "ColorColumn", "Comment", "Conceal", "Constant", "Cursor", "CursorColumn",
|
||||
\ "CursorIM", "CursorLine", "CursorLineNr", "DiffAdd", "DiffChange",
|
||||
\ "DiffDelete", "Directory", "Error", "ErrorMsg", "Identifier",
|
||||
\ "IncSearch", "LineNr", "MatchParen", "ModeMsg", "MoreMsg",
|
||||
\ "NonText", "Pmenu", "PmenuSbar", "PmenuSel",
|
||||
\ "PmenuThumb", "PreProc", "Question", "Search", "SignColumn",
|
||||
\ "Special", "SpecialKey", "Statement", "StatusLineNC", "TabLine",
|
||||
\ "TabLineFill", "Todo", "Type", "VertSplit", "Visual",
|
||||
\ "WarningMsg", "WildMenu",
|
||||
\ ]
|
||||
|
||||
let s:bold_items = [
|
||||
\ "DiffText", "FoldColumn", "Folded", "StatusLine", "TabLineSel",
|
||||
\ "Title", "CursorLineNr",
|
||||
\ ]
|
||||
|
||||
let s:underline_items = [
|
||||
\ "Underlined", "VisualNOS"
|
||||
\ ]
|
||||
|
||||
let s:undercurl_items = [
|
||||
\ "SpellBad", "SpellCap", "SpellLocal", "SpellRare"
|
||||
\ ]
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Color Definitions:
|
||||
" ============================================================================
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" 'Normal' Colors:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
hi clear Normal
|
||||
hi Normal gui=none cterm=none term=none
|
||||
|
||||
if s:style == "light"
|
||||
if s:contrast == "high"
|
||||
hi Normal guifg=#000000
|
||||
elseif s:contrast == "low"
|
||||
hi Normal guifg=#626262
|
||||
else
|
||||
hi Normal guifg=#444444
|
||||
endif
|
||||
else
|
||||
if s:contrast == "high"
|
||||
hi Normal guifg=#eeeeee
|
||||
elseif s:contrast == "low"
|
||||
hi Normal guifg=#bcbcbc
|
||||
else
|
||||
hi Normal guifg=#d7d7d7
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:style == "light"
|
||||
if s:contrast_bg == "high"
|
||||
hi Normal guibg=#ffffff
|
||||
else
|
||||
hi Normal guibg=#eeeeee
|
||||
endif
|
||||
else
|
||||
if s:contrast_bg == "high"
|
||||
hi Normal guibg=#121212
|
||||
else
|
||||
hi Normal guibg=#303030
|
||||
endif
|
||||
endif
|
||||
|
||||
call s:AddCterm("Normal")
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Extra setup
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
exec "set background=" . s:style
|
||||
|
||||
" Clear default settings
|
||||
for s:item in s:normal_items + s:bold_items + s:underline_items + s:undercurl_items
|
||||
exec "hi " . s:item . " guifg=NONE guibg=NONE gui=none"
|
||||
\ . " ctermfg=NONE ctermbg=NONE cterm=none term=none"
|
||||
endfor
|
||||
|
||||
let g:colors_name="lucius"
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Text Markup:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
if s:style == "light"
|
||||
hi NonText guifg=#afafd7
|
||||
hi SpecialKey guifg=#afd7af
|
||||
if s:contrast == "low"
|
||||
hi Comment guifg=#9e9e9e
|
||||
hi Conceal guifg=#9e9e9e
|
||||
hi Constant guifg=#d78700
|
||||
hi Directory guifg=#00af87
|
||||
hi Identifier guifg=#00af00
|
||||
hi PreProc guifg=#00afaf
|
||||
hi Special guifg=#af00af
|
||||
hi Statement guifg=#0087d7
|
||||
hi Title guifg=#0087d7
|
||||
hi Type guifg=#0087af
|
||||
else
|
||||
hi Comment guifg=#808080
|
||||
hi Conceal guifg=#808080
|
||||
hi Constant guifg=#af5f00
|
||||
hi Directory guifg=#00875f
|
||||
hi Identifier guifg=#008700
|
||||
hi PreProc guifg=#008787
|
||||
hi Special guifg=#870087
|
||||
hi Statement guifg=#005faf
|
||||
hi Title guifg=#005faf
|
||||
hi Type guifg=#005f87
|
||||
endif
|
||||
else
|
||||
hi NonText guifg=#5f5f87
|
||||
hi SpecialKey guifg=#5f875f
|
||||
if s:contrast == "low"
|
||||
hi Comment guifg=#6c6c6c
|
||||
hi Conceal guifg=#6c6c6c
|
||||
hi Constant guifg=#afaf87
|
||||
hi Directory guifg=#87af87
|
||||
hi Identifier guifg=#87af5f
|
||||
hi PreProc guifg=#5faf87
|
||||
hi Special guifg=#af87af
|
||||
hi Statement guifg=#5fafd7
|
||||
hi Title guifg=#00afd7
|
||||
hi Type guifg=#5fafaf
|
||||
elseif s:contrast == "high"
|
||||
hi Comment guifg=#8a8a8a
|
||||
hi Conceal guifg=#8a8a8a
|
||||
hi Constant guifg=#ffffd7
|
||||
hi Directory guifg=#d7ffd7
|
||||
hi Identifier guifg=#d7ffaf
|
||||
hi PreProc guifg=#afffd7
|
||||
hi Special guifg=#ffd7ff
|
||||
hi Statement guifg=#afffff
|
||||
hi Title guifg=#87d7ff
|
||||
hi Type guifg=#afffff
|
||||
else
|
||||
hi Comment guifg=#808080
|
||||
hi Conceal guifg=#808080
|
||||
hi Constant guifg=#d7d7af
|
||||
hi Directory guifg=#afd7af
|
||||
hi Identifier guifg=#afd787
|
||||
hi PreProc guifg=#87d7af
|
||||
hi Special guifg=#d7afd7
|
||||
hi Statement guifg=#87d7ff
|
||||
hi Title guifg=#5fafd7
|
||||
hi Type guifg=#87d7d7
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Highlighting:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
hi Cursor guifg=bg
|
||||
hi CursorColumn guifg=NONE
|
||||
hi CursorIM guifg=bg
|
||||
hi CursorLine guifg=NONE
|
||||
hi Visual guifg=NONE
|
||||
hi VisualNOS guifg=fg guibg=NONE
|
||||
if s:style == "light"
|
||||
hi CursorColumn guibg=#dadada
|
||||
hi CursorLine guibg=#dadada
|
||||
hi IncSearch guifg=fg guibg=#5fd7d7
|
||||
hi MatchParen guifg=NONE guibg=#5fd7d7
|
||||
hi Search guifg=fg guibg=#ffaf00
|
||||
hi Visual guibg=#afd7ff
|
||||
if s:contrast == "low"
|
||||
hi Cursor guibg=#87afd7
|
||||
hi CursorIM guibg=#87afd7
|
||||
hi Error guifg=#d70000 guibg=#ffd7d7
|
||||
hi Todo guifg=#af8700 guibg=#ffffaf
|
||||
else
|
||||
hi Cursor guibg=#5f87af
|
||||
hi CursorIM guibg=#5f87af
|
||||
hi Error guifg=#af0000 guibg=#d7afaf
|
||||
hi Todo guifg=#875f00 guibg=#ffffaf
|
||||
endif
|
||||
else
|
||||
hi CursorColumn guibg=#444444
|
||||
hi CursorLine guibg=#444444
|
||||
hi IncSearch guifg=bg
|
||||
hi MatchParen guifg=fg guibg=#87af00
|
||||
hi Search guifg=bg
|
||||
hi Visual guibg=#005f87
|
||||
if s:contrast == "low"
|
||||
hi Cursor guibg=#5f87af
|
||||
hi CursorIM guibg=#5f87af
|
||||
hi Error guifg=#d75f5f guibg=#870000
|
||||
hi IncSearch guibg=#00afaf
|
||||
hi Search guibg=#d78700
|
||||
hi Todo guifg=#afaf00 guibg=#5f5f00
|
||||
elseif s:contrast == "high"
|
||||
hi Cursor guibg=#afd7ff
|
||||
hi CursorIM guibg=#afd7ff
|
||||
hi Error guifg=#ffafaf guibg=#af0000
|
||||
hi IncSearch guibg=#87ffff
|
||||
hi Search guibg=#ffaf5f
|
||||
hi Todo guifg=#ffff87 guibg=#87875f
|
||||
else
|
||||
hi Cursor guibg=#87afd7
|
||||
hi CursorIM guibg=#87afd7
|
||||
hi Error guifg=#ff8787 guibg=#870000
|
||||
hi IncSearch guibg=#5fd7d7
|
||||
hi Search guibg=#d78700
|
||||
hi Todo guifg=#d7d75f guibg=#5f5f00
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Messages:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
hi Question guifg=fg
|
||||
if s:style == "light"
|
||||
if s:contrast == "low"
|
||||
hi ErrorMsg guifg=#d70000
|
||||
hi ModeMsg guifg=#0087ff
|
||||
hi MoreMsg guifg=#0087ff
|
||||
hi WarningMsg guifg=#d78700
|
||||
else
|
||||
hi ErrorMsg guifg=#af0000
|
||||
hi ModeMsg guifg=#005faf
|
||||
hi MoreMsg guifg=#005faf
|
||||
hi WarningMsg guifg=#af5f00
|
||||
endif
|
||||
else
|
||||
if s:contrast == "low"
|
||||
hi ErrorMsg guifg=#d75f5f
|
||||
hi ModeMsg guifg=#87afaf
|
||||
hi MoreMsg guifg=#87afaf
|
||||
hi WarningMsg guifg=#af875f
|
||||
elseif s:contrast == "high"
|
||||
hi ErrorMsg guifg=#ff8787
|
||||
hi ModeMsg guifg=#afffff
|
||||
hi MoreMsg guifg=#afffff
|
||||
hi WarningMsg guifg=#ffaf87
|
||||
else
|
||||
hi ErrorMsg guifg=#ff5f5f
|
||||
hi ModeMsg guifg=#afd7d7
|
||||
hi MoreMsg guifg=#afd7d7
|
||||
hi WarningMsg guifg=#d7875f
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" UI:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
hi ColorColumn guifg=NONE
|
||||
hi Pmenu guifg=bg
|
||||
hi PmenuSel guifg=fg
|
||||
hi PmenuThumb guifg=fg
|
||||
hi StatusLine guifg=bg
|
||||
hi TabLine guifg=bg
|
||||
hi TabLineSel guifg=fg
|
||||
hi WildMenu guifg=fg
|
||||
if s:style == "light"
|
||||
hi ColorColumn guibg=#e4e4e4
|
||||
hi CursorLineNr guifg=#626262 guibg=#dadada
|
||||
hi FoldColumn guibg=#bcbcbc
|
||||
hi Folded guibg=#bcbcbc
|
||||
hi LineNr guifg=#9e9e9e guibg=#dadada
|
||||
hi PmenuSel guibg=#afd7ff
|
||||
hi SignColumn guibg=#d0d0d0
|
||||
hi StatusLineNC guifg=#dadada
|
||||
hi TabLineFill guifg=#dadada
|
||||
hi VertSplit guifg=#e4e4e4
|
||||
hi WildMenu guibg=#afd7ff
|
||||
if s:contrast == "low"
|
||||
hi FoldColumn guifg=#808080
|
||||
hi Folded guifg=#808080
|
||||
hi Pmenu guibg=#9e9e9e
|
||||
hi PmenuSbar guifg=#9e9e9e guibg=#626262
|
||||
hi PmenuThumb guibg=#9e9e9e
|
||||
hi SignColumn guifg=#808080
|
||||
hi StatusLine guibg=#9e9e9e
|
||||
hi StatusLineNC guibg=#9e9e9e
|
||||
hi TabLine guibg=#9e9e9e
|
||||
hi TabLineFill guibg=#9e9e9e
|
||||
hi TabLineSel guibg=#afd7ff
|
||||
hi VertSplit guibg=#9e9e9e
|
||||
else
|
||||
hi FoldColumn guifg=#626262
|
||||
hi Folded guifg=#626262
|
||||
hi Pmenu guibg=#808080
|
||||
hi PmenuSbar guifg=#808080 guibg=#444444
|
||||
hi PmenuThumb guibg=#9e9e9e
|
||||
hi SignColumn guifg=#626262
|
||||
hi StatusLine guibg=#808080
|
||||
hi StatusLineNC guibg=#808080
|
||||
hi TabLine guibg=#808080
|
||||
hi TabLineFill guibg=#808080
|
||||
hi TabLineSel guibg=#afd7ff
|
||||
hi VertSplit guibg=#808080
|
||||
endif
|
||||
else
|
||||
hi ColorColumn guibg=#3a3a3a
|
||||
hi CursorLineNr guifg=#9e9e9e guibg=#444444
|
||||
hi FoldColumn guibg=#4e4e4e
|
||||
hi Folded guibg=#4e4e4e
|
||||
hi LineNr guifg=#626262 guibg=#444444
|
||||
hi PmenuSel guibg=#005f87
|
||||
hi SignColumn guibg=#4e4e4e
|
||||
hi StatusLineNC guifg=#4e4e4e
|
||||
hi TabLineFill guifg=#4e4e4e
|
||||
hi VertSplit guifg=#626262
|
||||
hi WildMenu guibg=#005f87
|
||||
if s:contrast == "low"
|
||||
hi FoldColumn guifg=#a8a8a8
|
||||
hi Folded guifg=#a8a8a8
|
||||
hi Pmenu guibg=#8a8a8a
|
||||
hi PmenuSbar guifg=#8a8a8a guibg=#bcbcbc
|
||||
hi PmenuThumb guibg=#585858
|
||||
hi SignColumn guifg=#8a8a8a
|
||||
hi StatusLine guibg=#8a8a8a
|
||||
hi StatusLineNC guibg=#8a8a8a
|
||||
hi TabLine guibg=#8a8a8a
|
||||
hi TabLineFill guibg=#8a8a8a
|
||||
hi TabLineSel guibg=#005f87
|
||||
hi VertSplit guibg=#8a8a8a
|
||||
elseif s:contrast == "high"
|
||||
hi FoldColumn guifg=#c6c6c6
|
||||
hi Folded guifg=#c6c6c6
|
||||
hi Pmenu guibg=#bcbcbc
|
||||
hi PmenuSbar guifg=#bcbcbc guibg=#dadada
|
||||
hi PmenuThumb guibg=#8a8a8a
|
||||
hi SignColumn guifg=#bcbcbc
|
||||
hi StatusLine guibg=#bcbcbc
|
||||
hi StatusLineNC guibg=#bcbcbc
|
||||
hi TabLine guibg=#bcbcbc
|
||||
hi TabLineFill guibg=#bcbcbc
|
||||
hi TabLineSel guibg=#0087af
|
||||
hi VertSplit guibg=#bcbcbc
|
||||
else
|
||||
hi FoldColumn guifg=#bcbcbc
|
||||
hi Folded guifg=#bcbcbc
|
||||
hi Pmenu guibg=#b2b2b2
|
||||
hi PmenuSbar guifg=#b2b2b2 guibg=#d0d0d0
|
||||
hi PmenuThumb guibg=#808080
|
||||
hi SignColumn guifg=#b2b2b2
|
||||
hi StatusLine guibg=#b2b2b2
|
||||
hi StatusLineNC guibg=#b2b2b2
|
||||
hi TabLine guibg=#b2b2b2
|
||||
hi TabLineFill guibg=#b2b2b2
|
||||
hi TabLineSel guibg=#005f87
|
||||
hi VertSplit guibg=#b2b2b2
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Diff:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
hi DiffAdd guifg=fg
|
||||
hi DiffChange guifg=fg
|
||||
hi DiffDelete guifg=fg
|
||||
|
||||
if s:style == "light"
|
||||
hi DiffAdd guibg=#afd7af
|
||||
hi DiffChange guibg=#d7d7af
|
||||
hi DiffDelete guibg=#d7afaf
|
||||
hi DiffText guibg=#d7d7af
|
||||
if s:contrast == "low"
|
||||
hi DiffText guifg=#ff8700
|
||||
else
|
||||
hi DiffText guifg=#d75f00
|
||||
endif
|
||||
else
|
||||
hi DiffAdd guibg=#5f875f
|
||||
hi DiffChange guibg=#87875f
|
||||
hi DiffDelete guibg=#875f5f
|
||||
hi DiffText guibg=#87875f
|
||||
if s:contrast == "low"
|
||||
hi DiffText guifg=#d7d75f
|
||||
else
|
||||
hi DiffText guifg=#ffff87
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Spelling:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
if s:style == "light"
|
||||
hi SpellBad guisp=#d70000
|
||||
hi SpellCap guisp=#00afd7
|
||||
hi SpellLocal guisp=#d7af00
|
||||
hi SpellRare guisp=#5faf00
|
||||
else
|
||||
hi SpellBad guisp=#ff5f5f
|
||||
hi SpellCap guisp=#5fafd7
|
||||
hi SpellLocal guisp=#d7af5f
|
||||
hi SpellRare guisp=#5faf5f
|
||||
endif
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Miscellaneous:
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
hi Ignore guifg=bg
|
||||
hi Underlined guifg=fg
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Text Emphasis:
|
||||
" ============================================================================
|
||||
|
||||
if s:use_bold == 1
|
||||
for s:item in s:bold_items
|
||||
exec "hi " . s:item . " gui=bold cterm=bold term=none"
|
||||
endfor
|
||||
endif
|
||||
|
||||
if s:use_underline == 1
|
||||
for s:item in s:underline_items
|
||||
exec "hi " . s:item . " gui=underline cterm=underline term=none"
|
||||
endfor
|
||||
for s:item in s:undercurl_items
|
||||
exec "hi " . s:item . " cterm=underline"
|
||||
endfor
|
||||
endif
|
||||
|
||||
for s:item in s:undercurl_items
|
||||
exec "hi " . s:item . " gui=undercurl term=none"
|
||||
endfor
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Cterm Colors:
|
||||
" ============================================================================
|
||||
|
||||
for s:item in s:normal_items + s:bold_items + s:underline_items
|
||||
call s:AddCterm(s:item)
|
||||
endfor
|
||||
|
||||
for s:item in s:undercurl_items
|
||||
call s:AddSpCterm(s:item)
|
||||
endfor
|
||||
|
||||
if s:no_term_bg == 1
|
||||
hi Normal ctermbg=NONE
|
||||
endif
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Alternative Bold Definitions:
|
||||
" ============================================================================
|
||||
|
||||
let s:alternative_bold_items = ["Identifier", "PreProc", "Statement",
|
||||
\ "Special", "Constant", "Type"]
|
||||
|
||||
for s:item in s:alternative_bold_items
|
||||
exec "let s:temp_gui_fg = synIDattr(synIDtrans(hlID('" . s:item .
|
||||
\ "')), 'fg', 'gui')"
|
||||
exec "let s:temp_cterm_fg = synIDattr(synIDtrans(hlID('" . s:item .
|
||||
\ "')), 'fg', 'cterm')"
|
||||
exec "hi B" . s:item . " guifg=" . s:temp_gui_fg . " ctermfg=" .
|
||||
\ s:temp_cterm_fg . " gui=bold cterm=bold term=none"
|
||||
endfor
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" Plugin Specific Colors:
|
||||
" ============================================================================
|
||||
|
||||
" Tagbar:
|
||||
hi link TagbarAccessPublic Constant
|
||||
hi link TagbarAccessProtected Type
|
||||
hi link TagbarAccessPrivate PreProc
|
||||
|
||||
" Vimwiki:
|
||||
hi link VimwikiHeader1 BIdentifier
|
||||
hi link VimwikiHeader2 BPreProc
|
||||
hi link VimwikiHeader3 BStatement
|
||||
hi link VimwikiHeader4 BSpecial
|
||||
hi link VimwikiHeader5 BConstant
|
||||
hi link VimwikiHeader6 BType
|
||||
|
||||
" CoC:
|
||||
hi link CocErrorSign ErrorMsg
|
||||
hi link CocErrorFloat Pmenu
|
||||
hi link CocWarningSign WarningMsg
|
||||
hi link CocWarningFloat Pmenu
|
||||
hi link CocInfoSign MoreMsg
|
||||
hi link CocInfoFloat Pmenu
|
||||
hi link CocHintFloat Directory
|
||||
hi link CocHintFloat Pmenu
|
||||
|
||||
" ============================================================================
|
||||
" Preset Commands:
|
||||
" ============================================================================
|
||||
|
||||
function! SetLucius(style, contrast, contrast_bg)
|
||||
let g:lucius_style = a:style
|
||||
let g:lucius_contrast = a:contrast
|
||||
let g:lucius_contrast_bg = a:contrast_bg
|
||||
endfunction
|
||||
|
||||
command! LuciusLight call SetLucius("light", "normal", "normal")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusLightLowContrast call SetLucius("light", "low", "normal")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusLightHighContrast call SetLucius("light", "high", "normal")
|
||||
\ | colorscheme lucius
|
||||
|
||||
command! LuciusWhite call SetLucius("light", "normal", "high")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusWhiteLowContrast call SetLucius("light", "low", "high")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusWhiteHighContrast call SetLucius("light", "high", "high")
|
||||
\ | colorscheme lucius
|
||||
|
||||
command! LuciusDark call SetLucius("dark", "normal", "normal")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusDarkLowContrast call SetLucius("dark", "low", "normal")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusDarkHighContrast call SetLucius("dark", "high", "normal")
|
||||
\ | colorscheme lucius
|
||||
|
||||
command! LuciusBlack call SetLucius("dark", "normal", "high")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusBlackLowContrast call SetLucius("dark", "low", "high")
|
||||
\ | colorscheme lucius
|
||||
command! LuciusBlackHighContrast call SetLucius("dark", "high", "high")
|
||||
\ | colorscheme lucius
|
||||
|
||||
" vim: tw=78
|
38
.vim/pack/plugins/start/vim-mail/ftplugin/mail.vim
Normal file
38
.vim/pack/plugins/start/vim-mail/ftplugin/mail.vim
Normal file
@ -0,0 +1,38 @@
|
||||
setl wrap " softwrap the text
|
||||
setl linebreak " don't break in the middle of the word
|
||||
"setl nolist " list disables linebreak
|
||||
setl textwidth=72
|
||||
setl formatprg=par\ -B+.,\\-\\!\\?\\\"\\\'\\*\\<\ -w72qie
|
||||
setl enc=utf-8
|
||||
setl nojs
|
||||
setl nosmartindent
|
||||
setl spell
|
||||
|
||||
setl comments=n:>
|
||||
setl formatoptions=
|
||||
setl fo+=r " Insert the current comment leader after hitting <Enter> in Insert mode.
|
||||
setl fo+=o " Insert the current comment leader after hitting 'o' or 'O' in Normal mode.
|
||||
setl fo+=q " Allow formatting of comments with "gq".
|
||||
setl fo+=w " Trailing white space indicates a paragraph continues in the next line.
|
||||
setl fo+=b " Like 'v', but only auto-wrap if you enter a blank at or before the wrap margin.
|
||||
setl fo+=j " Where it makes sense, remove a comment leader when joining lines.
|
||||
|
||||
match ErrorMsg '\s\s\+$'
|
||||
|
||||
syn match quote0 "^>"
|
||||
syn match quote1 "^> *>"
|
||||
syn match quote2 "^> *> *>"
|
||||
syn match quote3 "^> *> *> *>"
|
||||
syn match quote4 "^> *> *> *> *>"
|
||||
syn match quote5 "^> *> *> *> *> *>"
|
||||
syn match quote6 "^> *> *> *> *> *> *>"
|
||||
syn match quote7 "^> *> *> *> *> *> *> *>"
|
||||
|
||||
hi quote0 ctermfg=magenta
|
||||
hi quote1 ctermfg=cyan
|
||||
hi quote2 ctermfg=blue
|
||||
hi quote3 ctermfg=yellow
|
||||
hi quote4 ctermfg=magenta
|
||||
hi quote5 ctermfg=cyan
|
||||
hi quote6 ctermfg=blue
|
||||
hi quote7 ctermfg=yellow
|
@ -0,0 +1,35 @@
|
||||
" These are the mappings for snipMate.vim. Putting it here ensures that it
|
||||
" will be mapped after other plugins such as supertab.vim.
|
||||
if !exists('loaded_snips') || exists('s:did_snips_mappings')
|
||||
finish
|
||||
endif
|
||||
let s:did_snips_mappings = 1
|
||||
|
||||
ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
|
||||
snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr>
|
||||
snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr>
|
||||
ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<cr>
|
||||
|
||||
" The default mappings for these are annoying & sometimes break snipMate.
|
||||
" You can change them back if you want, I've put them here for convenience.
|
||||
snor <bs> b<bs>
|
||||
snor <right> <esc>a
|
||||
snor <left> <esc>bi
|
||||
snor ' b<bs>'
|
||||
snor ` b<bs>`
|
||||
snor % b<bs>%
|
||||
snor U b<bs>U
|
||||
snor ^ b<bs>^
|
||||
snor \ b<bs>\
|
||||
snor <c-x> b<bs><c-x>
|
||||
|
||||
" By default load snippets in snippets_dir
|
||||
if empty(snippets_dir)
|
||||
finish
|
||||
endif
|
||||
|
||||
call GetSnippets(snippets_dir, '_') " Get global snippets
|
||||
|
||||
au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
433
.vim/pack/plugins/start/vim-snipmate/autoload/snipMate.vim
Normal file
433
.vim/pack/plugins/start/vim-snipmate/autoload/snipMate.vim
Normal file
@ -0,0 +1,433 @@
|
||||
fun! Filename(...)
|
||||
let filename = expand('%:t:r')
|
||||
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
|
||||
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
|
||||
endf
|
||||
|
||||
fun s:RemoveSnippet()
|
||||
unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen
|
||||
\ s:lastBuf s:oldWord
|
||||
if exists('s:update')
|
||||
unl s:startCol s:origWordLen s:update
|
||||
if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif
|
||||
endif
|
||||
aug! snipMateAutocmds
|
||||
endf
|
||||
|
||||
fun snipMate#expandSnip(snip, col)
|
||||
let lnum = line('.') | let col = a:col
|
||||
|
||||
let snippet = s:ProcessSnippet(a:snip)
|
||||
" Avoid error if eval evaluates to nothing
|
||||
if snippet == '' | return '' | endif
|
||||
|
||||
" Expand snippet onto current position with the tab stops removed
|
||||
let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1)
|
||||
|
||||
let line = getline(lnum)
|
||||
let afterCursor = strpart(line, col - 1)
|
||||
" Keep text after the cursor
|
||||
if afterCursor != "\t" && afterCursor != ' '
|
||||
let line = strpart(line, 0, col - 1)
|
||||
let snipLines[-1] .= afterCursor
|
||||
else
|
||||
let afterCursor = ''
|
||||
" For some reason the cursor needs to move one right after this
|
||||
if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore'
|
||||
let col += 1
|
||||
endif
|
||||
endif
|
||||
|
||||
call setline(lnum, line.snipLines[0])
|
||||
|
||||
" Autoindent snippet according to previous indentation
|
||||
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
|
||||
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
|
||||
|
||||
" Open any folds snippet expands into
|
||||
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
|
||||
|
||||
let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent)
|
||||
|
||||
if s:snipLen
|
||||
aug snipMateAutocmds
|
||||
au CursorMovedI * call s:UpdateChangedSnip(0)
|
||||
au InsertEnter * call s:UpdateChangedSnip(1)
|
||||
aug END
|
||||
let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer
|
||||
let s:curPos = 0
|
||||
let s:endCol = g:snipPos[s:curPos][1]
|
||||
let s:endLine = g:snipPos[s:curPos][0]
|
||||
|
||||
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif
|
||||
else
|
||||
unl g:snipPos s:snipLen
|
||||
" Place cursor at end of snippet if no tab stop is given
|
||||
let newlines = len(snipLines) - 1
|
||||
call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor)
|
||||
\ + (newlines ? 0: col - 1))
|
||||
endif
|
||||
return ''
|
||||
endf
|
||||
|
||||
" Prepare snippet to be processed by s:BuildTabStops
|
||||
fun s:ProcessSnippet(snip)
|
||||
let snippet = a:snip
|
||||
" Evaluate eval (`...`) expressions.
|
||||
" Using a loop here instead of a regex fixes a bug with nested "\=".
|
||||
if stridx(snippet, '`') != -1
|
||||
while match(snippet, '`.\{-}`') != -1
|
||||
let snippet = substitute(snippet, '`.\{-}`',
|
||||
\ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
|
||||
\ "\n\\%$", '', ''), '')
|
||||
endw
|
||||
let snippet = substitute(snippet, "\r", "\n", 'g')
|
||||
endif
|
||||
|
||||
" Place all text after a colon in a tab stop after the tab stop
|
||||
" (e.g. "${#:foo}" becomes "${:foo}foo").
|
||||
" This helps tell the position of the tab stops later.
|
||||
let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g')
|
||||
|
||||
" Update the a:snip so that all the $# become the text after
|
||||
" the colon in their associated ${#}.
|
||||
" (e.g. "${1:foo}" turns all "$1"'s into "foo")
|
||||
let i = 1
|
||||
while stridx(snippet, '${'.i) != -1
|
||||
let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}')
|
||||
if s != ''
|
||||
let snippet = substitute(snippet, '$'.i, s.'&', 'g')
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
|
||||
if &et " Expand tabs to spaces if 'expandtab' is set.
|
||||
return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g')
|
||||
endif
|
||||
return snippet
|
||||
endf
|
||||
|
||||
" Counts occurences of haystack in needle
|
||||
fun s:Count(haystack, needle)
|
||||
let counter = 0
|
||||
let index = stridx(a:haystack, a:needle)
|
||||
while index != -1
|
||||
let index = stridx(a:haystack, a:needle, index+1)
|
||||
let counter += 1
|
||||
endw
|
||||
return counter
|
||||
endf
|
||||
|
||||
" Builds a list of a list of each tab stop in the snippet containing:
|
||||
" 1.) The tab stop's line number.
|
||||
" 2.) The tab stop's column number
|
||||
" (by getting the length of the string between the last "\n" and the
|
||||
" tab stop).
|
||||
" 3.) The length of the text after the colon for the current tab stop
|
||||
" (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned.
|
||||
" 4.) If the "${#:}" construct is given, another list containing all
|
||||
" the matches of "$#", to be replaced with the placeholder. This list is
|
||||
" composed the same way as the parent; the first item is the line number,
|
||||
" and the second is the column.
|
||||
fun s:BuildTabStops(snip, lnum, col, indent)
|
||||
let snipPos = []
|
||||
let i = 1
|
||||
let withoutVars = substitute(a:snip, '$\d\+', '', 'g')
|
||||
while stridx(a:snip, '${'.i) != -1
|
||||
let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D')
|
||||
let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g')
|
||||
|
||||
let j = i - 1
|
||||
call add(snipPos, [0, 0, -1])
|
||||
let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n")
|
||||
let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D'))
|
||||
if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif
|
||||
|
||||
" Get all $# matches in another list, if ${#:name} is given
|
||||
if stridx(withoutVars, '${'.i.':') != -1
|
||||
let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}'))
|
||||
let dots = repeat('.', snipPos[j][2])
|
||||
call add(snipPos[j], [])
|
||||
let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g')
|
||||
while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1
|
||||
let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)')
|
||||
call add(snipPos[j][3], [0, 0])
|
||||
let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n")
|
||||
let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum
|
||||
\ ? len(matchstr(beforeMark, '.*\n\zs.*'))
|
||||
\ : a:col + len(beforeMark))
|
||||
let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '')
|
||||
endw
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
return [snipPos, i - 1]
|
||||
endf
|
||||
|
||||
fun snipMate#jumpTabStop(backwards)
|
||||
let leftPlaceholder = exists('s:origWordLen')
|
||||
\ && s:origWordLen != g:snipPos[s:curPos][2]
|
||||
if leftPlaceholder && exists('s:oldEndCol')
|
||||
let startPlaceholder = s:oldEndCol + 1
|
||||
endif
|
||||
|
||||
if exists('s:update')
|
||||
call s:UpdatePlaceholderTabStops()
|
||||
else
|
||||
call s:UpdateTabStops()
|
||||
endif
|
||||
|
||||
" Don't reselect placeholder if it has been modified
|
||||
if leftPlaceholder && g:snipPos[s:curPos][2] != -1
|
||||
if exists('startPlaceholder')
|
||||
let g:snipPos[s:curPos][1] = startPlaceholder
|
||||
else
|
||||
let g:snipPos[s:curPos][1] = col('.')
|
||||
let g:snipPos[s:curPos][2] = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
let s:curPos += a:backwards ? -1 : 1
|
||||
" Loop over the snippet when going backwards from the beginning
|
||||
if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif
|
||||
|
||||
if s:curPos == s:snipLen
|
||||
let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2]
|
||||
call s:RemoveSnippet()
|
||||
return sMode ? "\<tab>" : TriggerSnippet()
|
||||
endif
|
||||
|
||||
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
|
||||
|
||||
let s:endLine = g:snipPos[s:curPos][0]
|
||||
let s:endCol = g:snipPos[s:curPos][1]
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
|
||||
return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord()
|
||||
endf
|
||||
|
||||
fun s:UpdatePlaceholderTabStops()
|
||||
let changeLen = s:origWordLen - g:snipPos[s:curPos][2]
|
||||
unl s:startCol s:origWordLen s:update
|
||||
if !exists('s:oldVars') | return | endif
|
||||
" Update tab stops in snippet if text has been added via "$#"
|
||||
" (e.g., in "${1:foo}bar$1${2}").
|
||||
if changeLen != 0
|
||||
let curLine = line('.')
|
||||
|
||||
for pos in g:snipPos
|
||||
if pos == g:snipPos[s:curPos] | continue | endif
|
||||
let changed = pos[0] == curLine && pos[1] > s:oldEndCol
|
||||
let changedVars = 0
|
||||
let endPlaceholder = pos[2] - 1 + pos[1]
|
||||
" Subtract changeLen from each tab stop that was after any of
|
||||
" the current tab stop's placeholders.
|
||||
for [lnum, col] in s:oldVars
|
||||
if lnum > pos[0] | break | endif
|
||||
if pos[0] == lnum
|
||||
if pos[1] > col || (pos[2] == -1 && pos[1] == col)
|
||||
let changed += 1
|
||||
elseif col < endPlaceholder
|
||||
let changedVars += 1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let pos[1] -= changeLen * changed
|
||||
let pos[2] -= changeLen * changedVars " Parse variables within placeholders
|
||||
" e.g., "${1:foo} ${2:$1bar}"
|
||||
|
||||
if pos[2] == -1 | continue | endif
|
||||
" Do the same to any placeholders in the other tab stops.
|
||||
for nPos in pos[3]
|
||||
let changed = nPos[0] == curLine && nPos[1] > s:oldEndCol
|
||||
for [lnum, col] in s:oldVars
|
||||
if lnum > nPos[0] | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
let changed += 1
|
||||
endif
|
||||
endfor
|
||||
let nPos[1] -= changeLen * changed
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
unl s:endCol s:oldVars s:oldEndCol
|
||||
endf
|
||||
|
||||
fun s:UpdateTabStops()
|
||||
let changeLine = s:endLine - g:snipPos[s:curPos][0]
|
||||
let changeCol = s:endCol - g:snipPos[s:curPos][1]
|
||||
if exists('s:origWordLen')
|
||||
let changeCol -= s:origWordLen
|
||||
unl s:origWordLen
|
||||
endif
|
||||
let lnum = g:snipPos[s:curPos][0]
|
||||
let col = g:snipPos[s:curPos][1]
|
||||
" Update the line number of all proceeding tab stops if <cr> has
|
||||
" been inserted.
|
||||
if changeLine != 0
|
||||
let changeLine -= 1
|
||||
for pos in g:snipPos
|
||||
if pos[0] >= lnum
|
||||
if pos[0] == lnum | let pos[1] += changeCol | endif
|
||||
let pos[0] += changeLine
|
||||
endif
|
||||
if pos[2] == -1 | continue | endif
|
||||
for nPos in pos[3]
|
||||
if nPos[0] >= lnum
|
||||
if nPos[0] == lnum | let nPos[1] += changeCol | endif
|
||||
let nPos[0] += changeLine
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
elseif changeCol != 0
|
||||
" Update the column of all proceeding tab stops if text has
|
||||
" been inserted/deleted in the current line.
|
||||
for pos in g:snipPos
|
||||
if pos[1] >= col && pos[0] == lnum
|
||||
let pos[1] += changeCol
|
||||
endif
|
||||
if pos[2] == -1 | continue | endif
|
||||
for nPos in pos[3]
|
||||
if nPos[0] > lnum | break | endif
|
||||
if nPos[0] == lnum && nPos[1] >= col
|
||||
let nPos[1] += changeCol
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endf
|
||||
|
||||
fun s:SelectWord()
|
||||
let s:origWordLen = g:snipPos[s:curPos][2]
|
||||
let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1,
|
||||
\ s:origWordLen)
|
||||
let s:prevLen[1] -= s:origWordLen
|
||||
if !empty(g:snipPos[s:curPos][3])
|
||||
let s:update = 1
|
||||
let s:endCol = -1
|
||||
let s:startCol = g:snipPos[s:curPos][1] - 1
|
||||
endif
|
||||
if !s:origWordLen | return '' | endif
|
||||
let l = col('.') != 1 ? 'l' : ''
|
||||
if &sel == 'exclusive'
|
||||
return "\<esc>".l.'v'.s:origWordLen."l\<c-g>"
|
||||
endif
|
||||
return s:origWordLen == 1 ? "\<esc>".l.'gh'
|
||||
\ : "\<esc>".l.'v'.(s:origWordLen - 1)."l\<c-g>"
|
||||
endf
|
||||
|
||||
" This updates the snippet as you type when text needs to be inserted
|
||||
" into multiple places (e.g. in "${1:default text}foo$1bar$1",
|
||||
" "default text" would be highlighted, and if the user types something,
|
||||
" UpdateChangedSnip() would be called so that the text after "foo" & "bar"
|
||||
" are updated accordingly)
|
||||
"
|
||||
" It also automatically quits the snippet if the cursor is moved out of it
|
||||
" while in insert mode.
|
||||
fun s:UpdateChangedSnip(entering)
|
||||
if exists('g:snipPos') && bufnr(0) != s:lastBuf
|
||||
call s:RemoveSnippet()
|
||||
elseif exists('s:update') " If modifying a placeholder
|
||||
if !exists('s:oldVars') && s:curPos + 1 < s:snipLen
|
||||
" Save the old snippet & word length before it's updated
|
||||
" s:startCol must be saved too, in case text is added
|
||||
" before the snippet (e.g. in "foo$1${2}bar${1:foo}").
|
||||
let s:oldEndCol = s:startCol
|
||||
let s:oldVars = deepcopy(g:snipPos[s:curPos][3])
|
||||
endif
|
||||
let col = col('.') - 1
|
||||
|
||||
if s:endCol != -1
|
||||
let changeLen = col('$') - s:prevLen[1]
|
||||
let s:endCol += changeLen
|
||||
else " When being updated the first time, after leaving select mode
|
||||
if a:entering | return | endif
|
||||
let s:endCol = col - 1
|
||||
endif
|
||||
|
||||
" If the cursor moves outside the snippet, quit it
|
||||
if line('.') != g:snipPos[s:curPos][0] || col < s:startCol ||
|
||||
\ col - 1 > s:endCol
|
||||
unl! s:startCol s:origWordLen s:oldVars s:update
|
||||
return s:RemoveSnippet()
|
||||
endif
|
||||
|
||||
call s:UpdateVars()
|
||||
let s:prevLen[1] = col('$')
|
||||
elseif exists('g:snipPos')
|
||||
if !a:entering && g:snipPos[s:curPos][2] != -1
|
||||
let g:snipPos[s:curPos][2] = -2
|
||||
endif
|
||||
|
||||
let col = col('.')
|
||||
let lnum = line('.')
|
||||
let changeLine = line('$') - s:prevLen[0]
|
||||
|
||||
if lnum == s:endLine
|
||||
let s:endCol += col('$') - s:prevLen[1]
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
endif
|
||||
if changeLine != 0
|
||||
let s:endLine += changeLine
|
||||
let s:endCol = col
|
||||
endif
|
||||
|
||||
" Delete snippet if cursor moves out of it in insert mode
|
||||
if (lnum == s:endLine && (col > s:endCol || col < g:snipPos[s:curPos][1]))
|
||||
\ || lnum > s:endLine || lnum < g:snipPos[s:curPos][0]
|
||||
call s:RemoveSnippet()
|
||||
endif
|
||||
endif
|
||||
endf
|
||||
|
||||
" This updates the variables in a snippet when a placeholder has been edited.
|
||||
" (e.g., each "$1" in "${1:foo} $1bar $1bar")
|
||||
fun s:UpdateVars()
|
||||
let newWordLen = s:endCol - s:startCol + 1
|
||||
let newWord = strpart(getline('.'), s:startCol, newWordLen)
|
||||
if newWord == s:oldWord || empty(g:snipPos[s:curPos][3])
|
||||
return
|
||||
endif
|
||||
|
||||
let changeLen = g:snipPos[s:curPos][2] - newWordLen
|
||||
let curLine = line('.')
|
||||
let startCol = col('.')
|
||||
let oldStartSnip = s:startCol
|
||||
let updateTabStops = changeLen != 0
|
||||
let i = 0
|
||||
|
||||
for [lnum, col] in g:snipPos[s:curPos][3]
|
||||
if updateTabStops
|
||||
let start = s:startCol
|
||||
if lnum == curLine && col <= start
|
||||
let s:startCol -= changeLen
|
||||
let s:endCol -= changeLen
|
||||
endif
|
||||
for nPos in g:snipPos[s:curPos][3][(i):]
|
||||
" This list is in ascending order, so quit if we've gone too far.
|
||||
if nPos[0] > lnum | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
let nPos[1] -= changeLen
|
||||
endif
|
||||
endfor
|
||||
if lnum == curLine && col > start
|
||||
let col -= changeLen
|
||||
let g:snipPos[s:curPos][3][i][1] = col
|
||||
endif
|
||||
let i += 1
|
||||
endif
|
||||
|
||||
" "Very nomagic" is used here to allow special characters.
|
||||
call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'.
|
||||
\ escape(s:oldWord, '\'), escape(newWord, '\&'), ''))
|
||||
endfor
|
||||
if oldStartSnip != s:startCol
|
||||
call cursor(0, startCol + s:startCol - oldStartSnip)
|
||||
endif
|
||||
|
||||
let s:oldWord = newWord
|
||||
let g:snipPos[s:curPos][2] = newWordLen
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
286
.vim/pack/plugins/start/vim-snipmate/doc/snipMate.txt
Normal file
286
.vim/pack/plugins/start/vim-snipmate/doc/snipMate.txt
Normal file
@ -0,0 +1,286 @@
|
||||
*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
|
||||
|
||||
snipMate *snippet* *snippets* *snipMate*
|
||||
Last Change: July 13, 2009
|
||||
|
||||
|snipMate-description| Description
|
||||
|snipMate-syntax| Snippet syntax
|
||||
|snipMate-usage| Usage
|
||||
|snipMate-settings| Settings
|
||||
|snipMate-features| Features
|
||||
|snipMate-disadvantages| Disadvantages to TextMate
|
||||
|snipMate-contact| Contact
|
||||
|
||||
For Vim version 7.0 or later.
|
||||
This plugin only works if 'compatible' is not set.
|
||||
{Vi does not have any of these features.}
|
||||
|
||||
==============================================================================
|
||||
DESCRIPTION *snipMate-description*
|
||||
|
||||
snipMate.vim implements some of TextMate's snippets features in Vim. A
|
||||
snippet is a piece of often-typed text that you can insert into your
|
||||
document using a trigger word followed by a <tab>.
|
||||
|
||||
For instance, in a C file using the default installation of snipMate.vim, if
|
||||
you type "for<tab>" in insert mode, it will expand a typical for loop in C: >
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
To go to the next item in the loop, simply <tab> over to it; if there is
|
||||
repeated code, such as the "i" variable in this example, you can simply
|
||||
start typing once it's highlighted and all the matches specified in the
|
||||
snippet will be updated. To go in reverse, use <shift-tab>.
|
||||
|
||||
==============================================================================
|
||||
SYNTAX *snippet-syntax*
|
||||
|
||||
Snippets can be defined in two ways. They can be in their own file, named
|
||||
after their trigger in 'snippets/<filetype>/<trigger>.snippet', or they can be
|
||||
defined together in a 'snippets/<filetype>.snippets' file. Note that dotted
|
||||
'filetype' syntax is supported -- e.g., you can use >
|
||||
|
||||
:set ft=html.eruby
|
||||
|
||||
to activate snippets for both HTML and eRuby for the current file.
|
||||
|
||||
The syntax for snippets in *.snippets files is the following: >
|
||||
|
||||
snippet trigger
|
||||
expanded text
|
||||
more expanded text
|
||||
|
||||
Note that the first hard tab after the snippet trigger is required, and not
|
||||
expanded in the actual snippet. The syntax for *.snippet files is the same,
|
||||
only without the trigger declaration and starting indentation.
|
||||
|
||||
Also note that snippets must be defined using hard tabs. They can be expanded
|
||||
to spaces later if desired (see |snipMate-indenting|).
|
||||
|
||||
"#" is used as a line-comment character in *.snippets files; however, they can
|
||||
only be used outside of a snippet declaration. E.g.: >
|
||||
|
||||
# this is a correct comment
|
||||
snippet trigger
|
||||
expanded text
|
||||
snippet another_trigger
|
||||
# this isn't a comment!
|
||||
expanded text
|
||||
<
|
||||
This should hopefully be obvious with the included syntax highlighting.
|
||||
|
||||
*snipMate-${#}*
|
||||
Tab stops ~
|
||||
|
||||
By default, the cursor is placed at the end of a snippet. To specify where the
|
||||
cursor is to be placed next, use "${#}", where the # is the number of the tab
|
||||
stop. E.g., to place the cursor first on the id of a <div> tag, and then allow
|
||||
the user to press <tab> to go to the middle of it:
|
||||
>
|
||||
snippet div
|
||||
<div id="${1}">
|
||||
${2}
|
||||
</div>
|
||||
<
|
||||
*snipMate-placeholders* *snipMate-${#:}* *snipMate-$#*
|
||||
Placeholders ~
|
||||
|
||||
Placeholder text can be supplied using "${#:text}", where # is the number of
|
||||
the tab stop. This text then can be copied throughout the snippet using "$#",
|
||||
given # is the same number as used before. So, to make a C for loop: >
|
||||
|
||||
snippet for
|
||||
for (${2:i}; $2 < ${1:count}; $1++) {
|
||||
${4}
|
||||
}
|
||||
|
||||
This will cause "count" to first be selected and change if the user starts
|
||||
typing. When <tab> is pressed, the "i" in ${2}'s position will be selected;
|
||||
all $2 variables will default to "i" and automatically be updated if the user
|
||||
starts typing.
|
||||
NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate.
|
||||
|
||||
Variables within variables are also possible. For instance: >
|
||||
|
||||
snippet opt
|
||||
<option value="${1:option}">${2:$1}</option>
|
||||
|
||||
Will, as usual, cause "option" to first be selected and update all the $1
|
||||
variables if the user starts typing. Since one of these variables is inside of
|
||||
${2}, this text will then be used as a placeholder for the next tab stop,
|
||||
allowing the user to change it if he wishes.
|
||||
|
||||
To copy a value throughout a snippet without supplying default text, simply
|
||||
use the "${#:}" construct without the text; e.g.: >
|
||||
|
||||
snippet foo
|
||||
${1:}bar$1
|
||||
< *snipMate-commands*
|
||||
Interpolated Vim Script ~
|
||||
|
||||
Snippets can also contain Vim script commands that are executed (via |eval()|)
|
||||
when the snippet is inserted. Commands are given inside backticks (`...`); for
|
||||
TextMates's functionality, use the |system()| function. E.g.: >
|
||||
|
||||
snippet date
|
||||
`system("date +%Y-%m-%d")`
|
||||
|
||||
will insert the current date, assuming you are on a Unix system. Note that you
|
||||
can also (and should) use |strftime()| for this example.
|
||||
|
||||
Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
|
||||
|
||||
Since the current filename is used often in snippets, a default function
|
||||
has been defined for it in snipMate.vim, appropriately called Filename().
|
||||
|
||||
With no arguments, the default filename without an extension is returned;
|
||||
the first argument specifies what to place before or after the filename,
|
||||
and the second argument supplies the default text to be used if the file
|
||||
has not been named. "$1" in the first argument is replaced with the filename;
|
||||
if you only want the filename to be returned, the first argument can be left
|
||||
blank. Examples: >
|
||||
|
||||
snippet filename
|
||||
`Filename()`
|
||||
snippet filename_with_default
|
||||
`Filename('', 'name')`
|
||||
snippet filename_foo
|
||||
`filename('$1_foo')`
|
||||
|
||||
The first example returns the filename if it the file has been named, and an
|
||||
empty string if it hasn't. The second returns the filename if it's been named,
|
||||
and "name" if it hasn't. The third returns the filename followed by "_foo" if
|
||||
it has been named, and an empty string if it hasn't.
|
||||
|
||||
*multi_snip*
|
||||
To specify that a snippet can have multiple matches in a *.snippets file, use
|
||||
this syntax: >
|
||||
|
||||
snippet trigger A description of snippet #1
|
||||
expand this text
|
||||
snippet trigger A description of snippet #2
|
||||
expand THIS text!
|
||||
|
||||
In this example, when "trigger<tab>" is typed, a numbered menu containing all
|
||||
of the descriptions of the "trigger" will be shown; when the user presses the
|
||||
corresponding number, that snippet will then be expanded.
|
||||
|
||||
To create a snippet with multiple matches using *.snippet files,
|
||||
simply place all the snippets in a subdirectory with the trigger name:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet'.
|
||||
|
||||
==============================================================================
|
||||
USAGE *snipMate-usage*
|
||||
|
||||
*'snippets'* *g:snippets_dir*
|
||||
Snippets are by default looked for any 'snippets' directory in your
|
||||
'runtimepath'. Typically, it is located at '~/.vim/snippets/' on *nix or
|
||||
'$HOME\vimfiles\snippets\' on Windows. To change that location or add another
|
||||
one, change the g:snippets_dir variable in your |.vimrc| to your preferred
|
||||
directory, or use the |ExtractSnips()|function. This will be used by the
|
||||
|globpath()| function, and so accepts the same syntax as it (e.g.,
|
||||
comma-separated paths).
|
||||
|
||||
ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets*
|
||||
|
||||
ExtractSnipsFile() extracts the specified *.snippets file for the given
|
||||
filetype. A .snippets file contains multiple snippet declarations for the
|
||||
filetype. It is further explained above, in |snippet-syntax|.
|
||||
|
||||
ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet*
|
||||
|
||||
ExtractSnips() extracts *.snippet files from the specified directory and
|
||||
defines them as snippets for the given filetype. The directory tree should
|
||||
look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has
|
||||
multiple matches, it should look like this:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
||||
|
||||
*ResetSnippets()*
|
||||
The ResetSnippets() function removes all snippets from memory. This is useful
|
||||
to put at the top of a snippet setup file for if you would like to |:source|
|
||||
it multiple times.
|
||||
|
||||
*list-snippets* *i_CTRL-R_<Tab>*
|
||||
If you would like to see what snippets are available, simply type <c-r><tab>
|
||||
in the current buffer to show a list via |popupmenu-completion|.
|
||||
|
||||
==============================================================================
|
||||
SETTINGS *snipMate-settings* *g:snips_author*
|
||||
|
||||
The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set
|
||||
to your name; it can then be used in snippets to automatically add it. E.g.: >
|
||||
|
||||
let g:snips_author = 'Hubert Farnsworth'
|
||||
snippet name
|
||||
`g:snips_author`
|
||||
<
|
||||
*snipMate-expandtab* *snipMate-indenting*
|
||||
If you would like your snippets to be expanded using spaces instead of tabs,
|
||||
just enable 'expandtab' and set 'softtabstop' to your preferred amount of
|
||||
spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead.
|
||||
|
||||
*snipMate-remap*
|
||||
snipMate does not come with a setting to customize the trigger key, but you
|
||||
can remap it easily in the two lines it's defined in the 'after' directory
|
||||
under 'plugin/snipMate.vim'. For instance, to change the trigger key
|
||||
to CTRL-J, just change this: >
|
||||
|
||||
ino <tab> <c-r>=TriggerSnippet()<cr>
|
||||
snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
|
||||
to this: >
|
||||
ino <c-j> <c-r>=TriggerSnippet()<cr>
|
||||
snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
|
||||
==============================================================================
|
||||
FEATURES *snipMate-features*
|
||||
|
||||
snipMate.vim has the following features among others:
|
||||
- The syntax of snippets is very similar to TextMate's, allowing
|
||||
easy conversion.
|
||||
- The position of the snippet is kept transparently (i.e. it does not use
|
||||
markers/placeholders written to the buffer), which allows you to escape
|
||||
out of an incomplete snippet, something particularly useful in Vim.
|
||||
- Variables in snippets are updated as-you-type.
|
||||
- Snippets can have multiple matches.
|
||||
- Snippets can be out of order. For instance, in a do...while loop, the
|
||||
condition can be added before the code.
|
||||
- [New] File-based snippets are supported.
|
||||
- [New] Triggers after non-word delimiters are expanded, e.g. "foo"
|
||||
in "bar.foo".
|
||||
- [New] <shift-tab> can now be used to jump tab stops in reverse order.
|
||||
|
||||
==============================================================================
|
||||
DISADVANTAGES *snipMate-disadvantages*
|
||||
|
||||
snipMate.vim currently has the following disadvantages to TextMate's snippets:
|
||||
- There is no $0; the order of tab stops must be explicitly stated.
|
||||
- Placeholders within placeholders are not possible. E.g.: >
|
||||
|
||||
'<div${1: id="${2:some_id}}">${3}</div>'
|
||||
<
|
||||
In TextMate this would first highlight ' id="some_id"', and if
|
||||
you hit delete it would automatically skip ${2} and go to ${3}
|
||||
on the next <tab>, but if you didn't delete it it would highlight
|
||||
"some_id" first. You cannot do this in snipMate.vim.
|
||||
- Regex cannot be performed on variables, such as "${1/.*/\U&}"
|
||||
- Placeholders cannot span multiple lines.
|
||||
- Activating snippets in different scopes of the same file is
|
||||
not possible.
|
||||
|
||||
Perhaps some of these features will be added in a later release.
|
||||
|
||||
==============================================================================
|
||||
CONTACT *snipMate-contact* *snipMate-author*
|
||||
|
||||
To contact the author (Michael Sanders), please email:
|
||||
msanders42+snipmate <at> gmail <dot> com
|
||||
|
||||
I greatly appreciate any suggestions or improvements offered for the script.
|
||||
|
||||
==============================================================================
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
33
.vim/pack/plugins/start/vim-snipmate/doc/tags
Normal file
33
.vim/pack/plugins/start/vim-snipmate/doc/tags
Normal file
@ -0,0 +1,33 @@
|
||||
'snippets' snipMate.txt /*'snippets'*
|
||||
.snippet snipMate.txt /*.snippet*
|
||||
.snippets snipMate.txt /*.snippets*
|
||||
ExtractSnips() snipMate.txt /*ExtractSnips()*
|
||||
ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()*
|
||||
Filename() snipMate.txt /*Filename()*
|
||||
ResetSnippets() snipMate.txt /*ResetSnippets()*
|
||||
g:snippets_dir snipMate.txt /*g:snippets_dir*
|
||||
g:snips_author snipMate.txt /*g:snips_author*
|
||||
i_CTRL-R_<Tab> snipMate.txt /*i_CTRL-R_<Tab>*
|
||||
list-snippets snipMate.txt /*list-snippets*
|
||||
multi_snip snipMate.txt /*multi_snip*
|
||||
snipMate snipMate.txt /*snipMate*
|
||||
snipMate-$# snipMate.txt /*snipMate-$#*
|
||||
snipMate-${#:} snipMate.txt /*snipMate-${#:}*
|
||||
snipMate-${#} snipMate.txt /*snipMate-${#}*
|
||||
snipMate-author snipMate.txt /*snipMate-author*
|
||||
snipMate-commands snipMate.txt /*snipMate-commands*
|
||||
snipMate-contact snipMate.txt /*snipMate-contact*
|
||||
snipMate-description snipMate.txt /*snipMate-description*
|
||||
snipMate-disadvantages snipMate.txt /*snipMate-disadvantages*
|
||||
snipMate-expandtab snipMate.txt /*snipMate-expandtab*
|
||||
snipMate-features snipMate.txt /*snipMate-features*
|
||||
snipMate-filename snipMate.txt /*snipMate-filename*
|
||||
snipMate-indenting snipMate.txt /*snipMate-indenting*
|
||||
snipMate-placeholders snipMate.txt /*snipMate-placeholders*
|
||||
snipMate-remap snipMate.txt /*snipMate-remap*
|
||||
snipMate-settings snipMate.txt /*snipMate-settings*
|
||||
snipMate-usage snipMate.txt /*snipMate-usage*
|
||||
snipMate.txt snipMate.txt /*snipMate.txt*
|
||||
snippet snipMate.txt /*snippet*
|
||||
snippet-syntax snipMate.txt /*snippet-syntax*
|
||||
snippets snipMate.txt /*snippets*
|
@ -0,0 +1,10 @@
|
||||
" Helper function for (x)html snippets
|
||||
if exists('s:did_snip_helper') || &cp || !exists('loaded_snips')
|
||||
finish
|
||||
endif
|
||||
let s:did_snip_helper = 1
|
||||
|
||||
" Automatically closes tag if in xhtml
|
||||
fun! Close()
|
||||
return stridx(&ft, 'xhtml') == -1 ? '' : ' /'
|
||||
endf
|
247
.vim/pack/plugins/start/vim-snipmate/plugin/snipMate.vim
Normal file
247
.vim/pack/plugins/start/vim-snipmate/plugin/snipMate.vim
Normal file
@ -0,0 +1,247 @@
|
||||
" File: snipMate.vim
|
||||
" Author: Michael Sanders
|
||||
" Last Updated: July 13, 2009
|
||||
" Version: 0.83
|
||||
" Description: snipMate.vim implements some of TextMate's snippets features in
|
||||
" Vim. A snippet is a piece of often-typed text that you can
|
||||
" insert into your document using a trigger word followed by a "<tab>".
|
||||
"
|
||||
" For more help see snipMate.txt; you can do this by using:
|
||||
" :helptags ~/.vim/doc
|
||||
" :h snipMate.txt
|
||||
|
||||
if exists('loaded_snips') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
let loaded_snips = 1
|
||||
if !exists('snips_author') | let snips_author = 'Me' | endif
|
||||
|
||||
au BufRead,BufNewFile *.snippets\= set ft=snippet
|
||||
au FileType snippet setl noet fdm=indent
|
||||
|
||||
let s:snippets = {} | let s:multi_snips = {}
|
||||
|
||||
if !exists('snippets_dir')
|
||||
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
|
||||
endif
|
||||
|
||||
fun! MakeSnip(scope, trigger, content, ...)
|
||||
let multisnip = a:0 && a:1 != ''
|
||||
let var = multisnip ? 's:multi_snips' : 's:snippets'
|
||||
if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif
|
||||
if !has_key({var}[a:scope], a:trigger)
|
||||
let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content
|
||||
elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]]
|
||||
else
|
||||
echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.'
|
||||
\ .' See :h multi_snip for help on snippets with multiple matches.'
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! ExtractSnips(dir, ft)
|
||||
for path in split(globpath(a:dir, '*'), "\n")
|
||||
if isdirectory(path)
|
||||
let pathname = fnamemodify(path, ':t')
|
||||
for snipFile in split(globpath(path, '*.snippet'), "\n")
|
||||
call s:ProcessFile(snipFile, a:ft, pathname)
|
||||
endfor
|
||||
elseif fnamemodify(path, ':e') == 'snippet'
|
||||
call s:ProcessFile(path, a:ft)
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Processes a single-snippet file; optionally add the name of the parent
|
||||
" directory for a snippet with multiple matches.
|
||||
fun s:ProcessFile(file, ft, ...)
|
||||
let keyword = fnamemodify(a:file, ':t:r')
|
||||
if keyword == '' | return | endif
|
||||
try
|
||||
let text = join(readfile(a:file), "\n")
|
||||
catch /E484/
|
||||
echom "Error in snipMate.vim: couldn't read file: ".a:file
|
||||
endtry
|
||||
return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
|
||||
\ : MakeSnip(a:ft, keyword, text)
|
||||
endf
|
||||
|
||||
fun! ExtractSnipsFile(file, ft)
|
||||
if !filereadable(a:file) | return | endif
|
||||
let text = readfile(a:file)
|
||||
let inSnip = 0
|
||||
for line in text + ["\n"]
|
||||
if inSnip && (line[0] == "\t" || line == '')
|
||||
let content .= strpart(line, 1)."\n"
|
||||
continue
|
||||
elseif inSnip
|
||||
call MakeSnip(a:ft, trigger, content[:-2], name)
|
||||
let inSnip = 0
|
||||
endif
|
||||
|
||||
if line[:6] == 'snippet'
|
||||
let inSnip = 1
|
||||
let trigger = strpart(line, 8)
|
||||
let name = ''
|
||||
let space = stridx(trigger, ' ') + 1
|
||||
if space " Process multi snip
|
||||
let name = strpart(trigger, space)
|
||||
let trigger = strpart(trigger, 0, space - 1)
|
||||
endif
|
||||
let content = ''
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
fun! ResetSnippets()
|
||||
let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {}
|
||||
endf
|
||||
|
||||
let g:did_ft = {}
|
||||
fun! GetSnippets(dir, filetypes)
|
||||
for ft in split(a:filetypes, '\.')
|
||||
if has_key(g:did_ft, ft) | continue | endif
|
||||
call s:DefineSnips(a:dir, ft, ft)
|
||||
if ft == 'objc' || ft == 'cpp' || ft == 'cs'
|
||||
call s:DefineSnips(a:dir, 'c', ft)
|
||||
elseif ft == 'xhtml'
|
||||
call s:DefineSnips(a:dir, 'html', 'xhtml')
|
||||
endif
|
||||
let g:did_ft[ft] = 1
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Define "aliasft" snippets for the filetype "realft".
|
||||
fun s:DefineSnips(dir, aliasft, realft)
|
||||
for path in split(globpath(a:dir, a:aliasft.'/')."\n".
|
||||
\ globpath(a:dir, a:aliasft.'-*/'), "\n")
|
||||
call ExtractSnips(path, a:realft)
|
||||
endfor
|
||||
for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n".
|
||||
\ globpath(a:dir, a:aliasft.'-*.snippets'), "\n")
|
||||
call ExtractSnipsFile(path, a:realft)
|
||||
endfor
|
||||
endf
|
||||
|
||||
fun! TriggerSnippet()
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingForward == "<tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
elseif g:SuperTabMappingBackward == "<tab>"
|
||||
let SuperTabKey = "\<c-p>"
|
||||
endif
|
||||
endif
|
||||
|
||||
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey) | return ''
|
||||
endif
|
||||
call feedkeys("\<esc>a", 'n') " Close completion menu
|
||||
call feedkeys("\<tab>") | return ''
|
||||
endif
|
||||
|
||||
if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif
|
||||
|
||||
let word = matchstr(getline('.'), '\S\+\%'.col('.').'c')
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
let [trigger, snippet] = s:GetSnippet(word, scope)
|
||||
" If word is a trigger for a snippet, delete the trigger & expand
|
||||
" the snippet.
|
||||
if snippet != ''
|
||||
let col = col('.') - len(trigger)
|
||||
sil exe 's/\V'.escape(trigger, '/.').'\%#//'
|
||||
return snipMate#expandSnip(snippet, col)
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
return ''
|
||||
endif
|
||||
return "\<tab>"
|
||||
endf
|
||||
|
||||
fun! BackwardsSnippet()
|
||||
if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif
|
||||
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingBackward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-p>"
|
||||
elseif g:SuperTabMappingForward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
endif
|
||||
endif
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
return ''
|
||||
endif
|
||||
return "\<s-tab>"
|
||||
endf
|
||||
|
||||
" Check if word under cursor is snippet trigger; if it isn't, try checking if
|
||||
" the text after non-word characters is (e.g. check for "foo" in "bar.foo")
|
||||
fun s:GetSnippet(word, scope)
|
||||
let word = a:word | let snippet = ''
|
||||
while snippet == ''
|
||||
if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]')
|
||||
let snippet = s:snippets[a:scope][word]
|
||||
elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]')
|
||||
let snippet = s:ChooseSnippet(a:scope, word)
|
||||
if snippet == '' | break | endif
|
||||
else
|
||||
if match(word, '\W') == -1 | break | endif
|
||||
let word = substitute(word, '.\{-}\W', '', '')
|
||||
endif
|
||||
endw
|
||||
if word == '' && a:word != '.' && stridx(a:word, '.') != -1
|
||||
let [word, snippet] = s:GetSnippet('.', a:scope)
|
||||
endif
|
||||
return [word, snippet]
|
||||
endf
|
||||
|
||||
fun s:ChooseSnippet(scope, trigger)
|
||||
let snippet = []
|
||||
let i = 1
|
||||
for snip in s:multi_snips[a:scope][a:trigger]
|
||||
let snippet += [i.'. '.snip[0]]
|
||||
let i += 1
|
||||
endfor
|
||||
if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif
|
||||
let num = inputlist(snippet) - 1
|
||||
return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
|
||||
endf
|
||||
|
||||
fun! ShowAvailableSnips()
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let word = matchstr(getline('.'), '\S\+\%'.col.'c')
|
||||
let words = [word]
|
||||
if stridx(word, '.')
|
||||
let words += split(word, '\.', 1)
|
||||
endif
|
||||
let matchlen = 0
|
||||
let matches = []
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : []
|
||||
if has_key(s:multi_snips, scope)
|
||||
let triggers += keys(s:multi_snips[scope])
|
||||
endif
|
||||
for trigger in triggers
|
||||
for word in words
|
||||
if word == ''
|
||||
let matches += [trigger] " Show all matches if word is empty
|
||||
elseif trigger =~ '^'.word
|
||||
let matches += [trigger]
|
||||
let len = len(word)
|
||||
if len > matchlen | let matchlen = len | endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
|
||||
" This is to avoid a bug with Vim when using complete(col - matchlen, matches)
|
||||
" (Issue#46 on the Google Code snipMate issue tracker).
|
||||
call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', ''))
|
||||
call complete(col, matches)
|
||||
return ''
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
35
.vim/pack/plugins/start/vim-snipmate/snippets/_.snippets
Normal file
35
.vim/pack/plugins/start/vim-snipmate/snippets/_.snippets
Normal file
@ -0,0 +1,35 @@
|
||||
# Global snippets
|
||||
|
||||
# (c) holds no legal value ;)
|
||||
snippet c)
|
||||
`&enc[:2] == "utf" ? "©" : "(c)"` Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}
|
||||
snippet date
|
||||
`strftime("%Y-%m-%d")`
|
||||
snippet mfg
|
||||
Mit freundlichen Grüßen,
|
||||
Stefan Hagen
|
||||
snippet mailf
|
||||
Sehr geehrte Frau ${1:Name},
|
||||
|
||||
${2:Text}
|
||||
|
||||
Mit freundlichen Grüßen,
|
||||
Stefan Hagen
|
||||
snippet mailh
|
||||
Sehr geehrter Herr ${1:Name},
|
||||
|
||||
${2:Text}
|
||||
|
||||
Mit freundlichen Grüßen,
|
||||
Stefan Hagen
|
||||
snippet sig
|
||||
--
|
||||
Stefan Hagen
|
||||
T: +49 (0)176 64292517
|
||||
M: sh@codevoid.de
|
||||
snippet je
|
||||
`strftime("%A %d.%m.%d %H:%M")`:
|
||||
snippet tel
|
||||
017664292517
|
||||
snippet worktel
|
||||
015162345601
|
110
.vim/pack/plugins/start/vim-snipmate/snippets/c.snippets
Normal file
110
.vim/pack/plugins/start/vim-snipmate/snippets/c.snippets
Normal file
@ -0,0 +1,110 @@
|
||||
# main()
|
||||
snippet main
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
${1}
|
||||
return 0;
|
||||
}
|
||||
# #include <...>
|
||||
snippet inc
|
||||
#include <${1:stdio}.h>${2}
|
||||
# #include "..."
|
||||
snippet Inc
|
||||
#include "${1:`Filename("$1.h")`}"${2}
|
||||
# #ifndef ... #define ... #endif
|
||||
snippet Def
|
||||
#ifndef $1
|
||||
#define ${1:SYMBOL} ${2:value}
|
||||
#endif${3}
|
||||
snippet def
|
||||
#define
|
||||
snippet ifdef
|
||||
#ifdef ${1:FOO}
|
||||
${2:#define }
|
||||
#endif
|
||||
snippet #if
|
||||
#if ${1:FOO}
|
||||
${2}
|
||||
#endif
|
||||
# Header Include-Guard
|
||||
# (the randomizer code is taken directly from TextMate; it could probably be
|
||||
# cleaner, I don't know how to do it in vim script)
|
||||
snippet once
|
||||
#ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`}
|
||||
|
||||
#define $1
|
||||
|
||||
${2}
|
||||
|
||||
#endif /* end of include guard: $1 */
|
||||
# If Condition
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
snippet el
|
||||
else {
|
||||
${1}
|
||||
}
|
||||
# Tertiary conditional
|
||||
snippet t
|
||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||
# Do While Loop
|
||||
snippet do
|
||||
do {
|
||||
${2:/* code */}
|
||||
} while (${1:/* condition */});
|
||||
# While Loop
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
# For Loop
|
||||
snippet for
|
||||
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||
${4:/* code */}
|
||||
}
|
||||
# Custom For Loop
|
||||
snippet forr
|
||||
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
|
||||
${5:/* code */}
|
||||
}
|
||||
# Function
|
||||
snippet fun
|
||||
${1:void} ${2:function_name}(${3})
|
||||
{
|
||||
${4:/* code */}
|
||||
}
|
||||
# Function Declaration
|
||||
snippet fund
|
||||
${1:void} ${2:function_name}(${3});${4}
|
||||
# Typedef
|
||||
snippet td
|
||||
typedef ${1:int} ${2:MyCustomType};${3}
|
||||
# Struct
|
||||
snippet st
|
||||
struct ${1:`Filename('$1_t', 'name')`} {
|
||||
${2:/* data */}
|
||||
}${3: /* optional variable list */};${4}
|
||||
# Typedef struct
|
||||
snippet tds
|
||||
typedef struct ${2:_$1 }{
|
||||
${3:/* data */}
|
||||
} ${1:`Filename('$1_t', 'name')`};
|
||||
# Typdef enum
|
||||
snippet tde
|
||||
typedef enum {
|
||||
${1:/* data */}
|
||||
} ${2:foo};
|
||||
# printf
|
||||
# unfortunately version this isn't as nice as TextMates's, given the lack of a
|
||||
# dynamic `...`
|
||||
snippet pr
|
||||
printf("${1:%s}\n"${2});${3}
|
||||
# fprintf (again, this isn't as nice as TextMate's version, but it works)
|
||||
snippet fpr
|
||||
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
|
||||
snippet .
|
||||
[${1}]${2}
|
||||
snippet un
|
||||
unsigned
|
30
.vim/pack/plugins/start/vim-snipmate/snippets/cpp.snippets
Normal file
30
.vim/pack/plugins/start/vim-snipmate/snippets/cpp.snippets
Normal file
@ -0,0 +1,30 @@
|
||||
# Read File Into Vector
|
||||
snippet readfile
|
||||
std::vector<char> v;
|
||||
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
|
||||
char buf[1024];
|
||||
while (size_t len = fread(buf, 1, sizeof(buf), $2))
|
||||
v.insert(v.end(), buf, buf + len);
|
||||
fclose($2);
|
||||
}${3}
|
||||
# std::map
|
||||
snippet map
|
||||
std::map<${1:key}, ${2:value}> map${3};
|
||||
# std::vector
|
||||
snippet vector
|
||||
std::vector<${1:char}> v${2};
|
||||
# Namespace
|
||||
snippet ns
|
||||
namespace ${1:`Filename('', 'my')`} {
|
||||
${2}
|
||||
} /* $1 */
|
||||
# Class
|
||||
snippet cl
|
||||
class ${1:`Filename('$1_t', 'name')`} {
|
||||
public:
|
||||
$1 (${2:arguments});
|
||||
virtual ~$1 ();
|
||||
|
||||
private:
|
||||
${3:/* data */}
|
||||
};
|
190
.vim/pack/plugins/start/vim-snipmate/snippets/html.snippets
Normal file
190
.vim/pack/plugins/start/vim-snipmate/snippets/html.snippets
Normal file
@ -0,0 +1,190 @@
|
||||
# Some useful Unicode entities
|
||||
# Non-Breaking Space
|
||||
snippet nbs
|
||||
|
||||
# ←
|
||||
snippet left
|
||||
←
|
||||
# →
|
||||
snippet right
|
||||
→
|
||||
# ↑
|
||||
snippet up
|
||||
↑
|
||||
# ↓
|
||||
snippet down
|
||||
↓
|
||||
# ↩
|
||||
snippet return
|
||||
↩
|
||||
# ⇤
|
||||
snippet backtab
|
||||
⇤
|
||||
# ⇥
|
||||
snippet tab
|
||||
⇥
|
||||
# ⇧
|
||||
snippet shift
|
||||
⇧
|
||||
# ⌃
|
||||
snippet control
|
||||
⌃
|
||||
# ⌅
|
||||
snippet enter
|
||||
⌅
|
||||
# ⌘
|
||||
snippet command
|
||||
⌘
|
||||
# ⌥
|
||||
snippet option
|
||||
⌥
|
||||
# ⌦
|
||||
snippet delete
|
||||
⌦
|
||||
# ⌫
|
||||
snippet backspace
|
||||
⌫
|
||||
# ⎋
|
||||
snippet escape
|
||||
⎋
|
||||
# Generic Doctype
|
||||
snippet doctype HTML 4.01 Strict
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
snippet doctype HTML 4.01 Transitional
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
snippet doctype HTML 5
|
||||
<!DOCTYPE HTML>
|
||||
snippet doctype XHTML 1.0 Frameset
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
snippet doctype XHTML 1.0 Strict
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
snippet doctype XHTML 1.0 Transitional
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
snippet doctype XHTML 1.1
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
# HTML Doctype 4.01 Strict
|
||||
snippet docts
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
# HTML Doctype 4.01 Transitional
|
||||
snippet doct
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
# HTML Doctype 5
|
||||
snippet doct5
|
||||
<!DOCTYPE HTML>
|
||||
# XHTML Doctype 1.0 Frameset
|
||||
snippet docxf
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
# XHTML Doctype 1.0 Strict
|
||||
snippet docxs
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
# XHTML Doctype 1.0 Transitional
|
||||
snippet docxt
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
# XHTML Doctype 1.1
|
||||
snippet docx
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
snippet html
|
||||
<html>
|
||||
${1}
|
||||
</html>
|
||||
snippet xhtml
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
${1}
|
||||
</html>
|
||||
snippet body
|
||||
<body>
|
||||
${1}
|
||||
</body>
|
||||
snippet head
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"`Close()`>
|
||||
|
||||
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||
${2}
|
||||
</head>
|
||||
snippet title
|
||||
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>${2}
|
||||
snippet script
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
${1}
|
||||
</script>${2}
|
||||
snippet scriptsrc
|
||||
<script src="${1}.js" type="text/javascript" charset="utf-8"></script>${2}
|
||||
snippet style
|
||||
<style type="text/css" media="${1:screen}">
|
||||
${2}
|
||||
</style>${3}
|
||||
snippet base
|
||||
<base href="${1}" target="${2}"`Close()`>
|
||||
snippet r
|
||||
<br`Close()[1:]`>
|
||||
snippet div
|
||||
<div id="${1:name}">
|
||||
${2}
|
||||
</div>
|
||||
# Embed QT Movie
|
||||
snippet movie
|
||||
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
|
||||
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||
<param name="src" value="$1"`Close()`>
|
||||
<param name="controller" value="$4"`Close()`>
|
||||
<param name="autoplay" value="$5"`Close()`>
|
||||
<embed src="${1:movie.mov}"
|
||||
width="${2:320}" height="${3:240}"
|
||||
controller="${4:true}" autoplay="${5:true}"
|
||||
scale="tofit" cache="true"
|
||||
pluginspage="http://www.apple.com/quicktime/download/"
|
||||
`Close()[1:]`>
|
||||
</object>${6}
|
||||
snippet fieldset
|
||||
<fieldset id="$1">
|
||||
<legend>${1:name}</legend>
|
||||
|
||||
${3}
|
||||
</fieldset>
|
||||
snippet form
|
||||
<form action="${1:`Filename('$1_submit')`}" method="${2:get}" accept-charset="utf-8">
|
||||
${3}
|
||||
|
||||
|
||||
<p><input type="submit" value="Continue →"`Close()`></p>
|
||||
</form>
|
||||
snippet h1
|
||||
<h1 id="${1:heading}">${2:$1}</h1>
|
||||
snippet input
|
||||
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"`Close()`>${4}
|
||||
snippet label
|
||||
<label for="${2:$1}">${1:name}</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="${5}" id="${6:$2}"`Close()`>${7}
|
||||
snippet link
|
||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"`Close()`>${4}
|
||||
snippet mailto
|
||||
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
|
||||
snippet meta
|
||||
<meta name="${1:name}" content="${2:content}"`Close()`>${3}
|
||||
snippet opt
|
||||
<option value="${1:option}">${2:$1}</option>${3}
|
||||
snippet optt
|
||||
<option>${1:option}</option>${2}
|
||||
snippet select
|
||||
<select name="${1:some_name}" id="${2:$1}">
|
||||
<option value="${3:option}">${4:$3}</option>
|
||||
</select>${5}
|
||||
snippet table
|
||||
<table border="${1:0}">
|
||||
<tr><th>${2:Header}</th></tr>
|
||||
<tr><th>${3:Data}</th></tr>
|
||||
</table>${4}
|
||||
snippet textarea
|
||||
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}
|
78
.vim/pack/plugins/start/vim-snipmate/snippets/java.snippets
Normal file
78
.vim/pack/plugins/start/vim-snipmate/snippets/java.snippets
Normal file
@ -0,0 +1,78 @@
|
||||
snippet main
|
||||
public static void main (String [] args)
|
||||
{
|
||||
${1:/* code */}
|
||||
}
|
||||
snippet pu
|
||||
public
|
||||
snippet po
|
||||
protected
|
||||
snippet pr
|
||||
private
|
||||
snippet st
|
||||
static
|
||||
snippet fi
|
||||
final
|
||||
snippet ab
|
||||
abstract
|
||||
snippet re
|
||||
return
|
||||
snippet br
|
||||
break;
|
||||
snippet de
|
||||
default:
|
||||
${1}
|
||||
snippet ca
|
||||
catch(${1:Exception} ${2:e}) ${3}
|
||||
snippet th
|
||||
throw
|
||||
snippet sy
|
||||
synchronized
|
||||
snippet im
|
||||
import
|
||||
snippet j.u
|
||||
java.util
|
||||
snippet j.i
|
||||
java.io.
|
||||
snippet j.b
|
||||
java.beans.
|
||||
snippet j.n
|
||||
java.net.
|
||||
snippet j.m
|
||||
java.math.
|
||||
snippet if
|
||||
if (${1}) ${2}
|
||||
snippet el
|
||||
else
|
||||
snippet elif
|
||||
else if (${1}) ${2}
|
||||
snippet wh
|
||||
while (${1}) ${2}
|
||||
snippet for
|
||||
for (${1}; ${2}; ${3}) ${4}
|
||||
snippet fore
|
||||
for (${1} : ${2}) ${3}
|
||||
snippet sw
|
||||
switch (${1}) ${2}
|
||||
snippet cs
|
||||
case ${1}:
|
||||
${2}
|
||||
${3}
|
||||
snippet tc
|
||||
public class ${1:`Filename()`} extends ${2:TestCase}
|
||||
snippet t
|
||||
public void test${1:Name}() throws Exception ${2}
|
||||
snippet cl
|
||||
class ${1:`Filename("", "untitled")`} ${2}
|
||||
snippet in
|
||||
interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}
|
||||
snippet m
|
||||
${1:void} ${2:method}(${3}) ${4:throws }${5}
|
||||
snippet v
|
||||
${1:String} ${2:var}${3: = null}${4};${5}
|
||||
snippet co
|
||||
static public final ${1:String} ${2:var} = ${3};${4}
|
||||
snippet cos
|
||||
static public final String ${1:var} = "${2}";${3}
|
||||
snippet as
|
||||
assert ${1:test} : "${2:Failure message}";${3}
|
@ -0,0 +1,74 @@
|
||||
# Prototype
|
||||
snippet proto
|
||||
${1:class_name}.prototype.${2:method_name} =
|
||||
function(${3:first_argument}) {
|
||||
${4:// body...}
|
||||
};
|
||||
# Function
|
||||
snippet fun
|
||||
function ${1:function_name} (${2:argument}) {
|
||||
${3:// body...}
|
||||
}
|
||||
# Anonymous Function
|
||||
snippet f
|
||||
function(${1}) {${2}};
|
||||
# if
|
||||
snippet if
|
||||
if (${1:true}) {${2}};
|
||||
# if ... else
|
||||
snippet ife
|
||||
if (${1:true}) {${2}}
|
||||
else{${3}};
|
||||
# tertiary conditional
|
||||
snippet t
|
||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||
# switch
|
||||
snippet switch
|
||||
switch(${1:expression}) {
|
||||
case '${3:case}':
|
||||
${4:// code}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${2:// code}
|
||||
}
|
||||
# case
|
||||
snippet case
|
||||
case '${1:case}':
|
||||
${2:// code}
|
||||
break;
|
||||
${3}
|
||||
# for (...) {...}
|
||||
snippet for
|
||||
for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {
|
||||
${4:$1[$2]}
|
||||
};
|
||||
# for (...) {...} (Improved Native For-Loop)
|
||||
snippet forr
|
||||
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {
|
||||
${4:$1[$2]}
|
||||
};
|
||||
# while (...) {...}
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
# do...while
|
||||
snippet do
|
||||
do {
|
||||
${2:/* code */}
|
||||
} while (${1:/* condition */});
|
||||
# Object Method
|
||||
snippet :f
|
||||
${1:method_name}: function(${2:attribute}) {
|
||||
${4}
|
||||
}${3:,}
|
||||
# setTimeout function
|
||||
snippet timeout
|
||||
setTimeout(function() {${3}}${2}, ${1:10};
|
||||
# Get Elements
|
||||
snippet get
|
||||
getElementsBy${1:TagName}('${2}')${3}
|
||||
# Get Element
|
||||
snippet gett
|
||||
getElementBy${1:Id}('${2}')${3}
|
91
.vim/pack/plugins/start/vim-snipmate/snippets/perl.snippets
Normal file
91
.vim/pack/plugins/start/vim-snipmate/snippets/perl.snippets
Normal file
@ -0,0 +1,91 @@
|
||||
# #!/usr/bin/perl
|
||||
snippet #!
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Hash Pointer
|
||||
snippet .
|
||||
=>
|
||||
# Function
|
||||
snippet sub
|
||||
sub ${1:function_name} {
|
||||
${2:#body ...}
|
||||
}
|
||||
# Conditional
|
||||
snippet if
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# Conditional if..else
|
||||
snippet ife
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
} else {
|
||||
${3:# else...}
|
||||
}
|
||||
# Conditional if..elsif..else
|
||||
snippet ifee
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
} elsif (${3}) {
|
||||
${4:# elsif...}
|
||||
} else {
|
||||
${5:# else...}
|
||||
}
|
||||
# Conditional One-line
|
||||
snippet xif
|
||||
${1:expression} if ${2:condition};${3}
|
||||
# Unless conditional
|
||||
snippet unless
|
||||
unless (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# Unless conditional One-line
|
||||
snippet xunless
|
||||
${1:expression} unless ${2:condition};${3}
|
||||
# Try/Except
|
||||
snippet eval
|
||||
eval {
|
||||
${1:# do something risky...}
|
||||
};
|
||||
if ($@) {
|
||||
${2:# handle failure...}
|
||||
}
|
||||
# While Loop
|
||||
snippet wh
|
||||
while (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# While Loop One-line
|
||||
snippet xwh
|
||||
${1:expression} while ${2:condition};${3}
|
||||
# For Loop
|
||||
snippet for
|
||||
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||
${4:# body...}
|
||||
}
|
||||
# Foreach Loop
|
||||
snippet fore
|
||||
foreach my $${1:x} (@${2:array}) {
|
||||
${3:# body...}
|
||||
}
|
||||
# Foreach Loop One-line
|
||||
snippet xfore
|
||||
${1:expression} foreach @${2:array};${3}
|
||||
# Package
|
||||
snippet cl
|
||||
package ${1:ClassName};
|
||||
|
||||
use base qw(${2:ParentClass});
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
$class = ref $class if ref $class;
|
||||
my $self = bless {}, $class;
|
||||
$self;
|
||||
}
|
||||
|
||||
1;${3}
|
||||
# Read File
|
||||
snippet slurp
|
||||
my $${1:var};
|
||||
{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${3}
|
216
.vim/pack/plugins/start/vim-snipmate/snippets/php.snippets
Normal file
216
.vim/pack/plugins/start/vim-snipmate/snippets/php.snippets
Normal file
@ -0,0 +1,216 @@
|
||||
snippet php
|
||||
<?php
|
||||
${1}
|
||||
?>
|
||||
snippet ec
|
||||
echo "${1:string}"${2};
|
||||
snippet inc
|
||||
include '${1:file}';${2}
|
||||
snippet inc1
|
||||
include_once '${1:file}';${2}
|
||||
snippet req
|
||||
require '${1:file}';${2}
|
||||
snippet req1
|
||||
require_once '${1:file}';${2}
|
||||
# $GLOBALS['...']
|
||||
snippet globals
|
||||
$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}
|
||||
snippet $_ COOKIE['...']
|
||||
$_COOKIE['${1:variable}']${2}
|
||||
snippet $_ ENV['...']
|
||||
$_ENV['${1:variable}']${2}
|
||||
snippet $_ FILES['...']
|
||||
$_FILES['${1:variable}']${2}
|
||||
snippet $_ Get['...']
|
||||
$_GET['${1:variable}']${2}
|
||||
snippet $_ POST['...']
|
||||
$_POST['${1:variable}']${2}
|
||||
snippet $_ REQUEST['...']
|
||||
$_REQUEST['${1:variable}']${2}
|
||||
snippet $_ SERVER['...']
|
||||
$_SERVER['${1:variable}']${2}
|
||||
snippet $_ SESSION['...']
|
||||
$_SESSION['${1:variable}']${2}
|
||||
# Start Docblock
|
||||
snippet /*
|
||||
/**
|
||||
* ${1}
|
||||
**/
|
||||
# Class - post doc
|
||||
snippet doc_cp
|
||||
/**
|
||||
* ${1:undocumented class}
|
||||
*
|
||||
* @package ${2:default}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Class Variable - post doc
|
||||
snippet doc_vp
|
||||
/**
|
||||
* ${1:undocumented class variable}
|
||||
*
|
||||
* @var ${2:string}
|
||||
**/${3}
|
||||
# Class Variable
|
||||
snippet doc_v
|
||||
/**
|
||||
* ${3:undocumented class variable}
|
||||
*
|
||||
* @var ${4:string}
|
||||
**/
|
||||
${1:var} $${2};${5}
|
||||
# Class
|
||||
snippet doc_c
|
||||
/**
|
||||
* ${3:undocumented class}
|
||||
*
|
||||
* @packaged ${4:default}
|
||||
* @author ${5:`g:snips_author`}
|
||||
**/
|
||||
${1:}class ${2:}
|
||||
{${6}
|
||||
} // END $1class $2
|
||||
# Constant Definition - post doc
|
||||
snippet doc_dp
|
||||
/**
|
||||
* ${1:undocumented constant}
|
||||
**/${2}
|
||||
# Constant Definition
|
||||
snippet doc_d
|
||||
/**
|
||||
* ${3:undocumented constant}
|
||||
**/
|
||||
define(${1}, ${2});${4}
|
||||
# Function - post doc
|
||||
snippet doc_fp
|
||||
/**
|
||||
* ${1:undocumented function}
|
||||
*
|
||||
* @return ${2:void}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Function signature
|
||||
snippet doc_s
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3});${7}
|
||||
# Function
|
||||
snippet doc_f
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3})
|
||||
{${7}
|
||||
}
|
||||
# Header
|
||||
snippet doc_h
|
||||
/**
|
||||
* ${1}
|
||||
*
|
||||
* @author ${2:`g:snips_author`}
|
||||
* @version ${3:$Id$}
|
||||
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
||||
* @package ${5:default}
|
||||
**/
|
||||
|
||||
/**
|
||||
* Define DocBlock
|
||||
*//
|
||||
# Interface
|
||||
snippet doc_i
|
||||
/**
|
||||
* ${2:undocumented class}
|
||||
*
|
||||
* @package ${3:default}
|
||||
* @author ${4:`g:snips_author`}
|
||||
**/
|
||||
interface ${1:}
|
||||
{${5}
|
||||
} // END interface $1
|
||||
# class ...
|
||||
snippet class
|
||||
/**
|
||||
* ${1}
|
||||
**/
|
||||
class ${2:ClassName}
|
||||
{
|
||||
${3}
|
||||
function ${4:__construct}(${5:argument})
|
||||
{
|
||||
${6:// code...}
|
||||
}
|
||||
}
|
||||
# define(...)
|
||||
snippet def
|
||||
define('${1}'${2});${3}
|
||||
# defined(...)
|
||||
snippet def?
|
||||
${1}defined('${2}')${3}
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# do ... while
|
||||
snippet do
|
||||
do {
|
||||
${2:// code... }
|
||||
} while (${1:/* condition */});
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
snippet ife
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
} else {
|
||||
${3:// code...}
|
||||
}
|
||||
${4}
|
||||
snippet else
|
||||
else {
|
||||
${1:// code...}
|
||||
}
|
||||
snippet elseif
|
||||
elseif (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# Tertiary conditional
|
||||
snippet t
|
||||
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
|
||||
snippet switch
|
||||
switch ($${1:variable}) {
|
||||
case '${2:value}':
|
||||
${3:// code...}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${4:// code...}
|
||||
break;
|
||||
}
|
||||
snippet case
|
||||
case '${1:value}':
|
||||
${2:// code...}
|
||||
break;${3}
|
||||
snippet for
|
||||
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||
${4: // code...}
|
||||
}
|
||||
snippet foreach
|
||||
foreach ($${1:variable} as $${2:key}) {
|
||||
${3:// code...}
|
||||
}
|
||||
snippet fun
|
||||
${1:public }function ${2:FunctionName}(${3})
|
||||
{
|
||||
${4:// code...}
|
||||
}
|
||||
# $... = array (...)
|
||||
snippet array
|
||||
$${1:arrayName} = array('${2}' => ${3});${4}
|
@ -0,0 +1,86 @@
|
||||
snippet #!
|
||||
#!/usr/bin/python
|
||||
|
||||
snippet imp
|
||||
import ${1:module}
|
||||
# Module Docstring
|
||||
snippet docs
|
||||
'''
|
||||
File: ${1:`Filename('$1.py', 'foo.py')`}
|
||||
Author: ${2:`g:snips_author`}
|
||||
Description: ${3}
|
||||
'''
|
||||
snippet wh
|
||||
while ${1:condition}:
|
||||
${2:# code...}
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}:
|
||||
${3:# code...}
|
||||
# New Class
|
||||
snippet cl
|
||||
class ${1:ClassName}(${2:object}):
|
||||
"""${3:docstring for $1}"""
|
||||
def __init__(self, ${4:arg}):
|
||||
${5:super($1, self).__init__()}
|
||||
self.$4 = $4
|
||||
${6}
|
||||
# New Function
|
||||
snippet def
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
"""${3:docstring for $1}"""
|
||||
${4:pass}
|
||||
snippet deff
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
${3}
|
||||
# New Method
|
||||
snippet defs
|
||||
def ${1:mname}(self, ${2:arg}):
|
||||
${3:pass}
|
||||
# New Property
|
||||
snippet property
|
||||
def ${1:foo}():
|
||||
doc = "${2:The $1 property.}"
|
||||
def fget(self):
|
||||
${3:return self._$1}
|
||||
def fset(self, value):
|
||||
${4:self._$1 = value}
|
||||
# Lambda
|
||||
snippet ld
|
||||
${1:var} = lambda ${2:vars} : ${3:action}
|
||||
snippet .
|
||||
self.
|
||||
snippet try Try/Except
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
snippet try Try/Except/Else
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
finally:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Else/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
finally:
|
||||
${6:pass}
|
||||
# if __name__ == '__main__':
|
||||
snippet ifmain
|
||||
if __name__ == '__main__':
|
||||
${1:main()}
|
||||
# __magic__
|
||||
snippet _
|
||||
__${1:init}__${2}
|
420
.vim/pack/plugins/start/vim-snipmate/snippets/ruby.snippets
Normal file
420
.vim/pack/plugins/start/vim-snipmate/snippets/ruby.snippets
Normal file
@ -0,0 +1,420 @@
|
||||
# #!/usr/bin/ruby
|
||||
snippet #!
|
||||
#!/usr/bin/ruby
|
||||
|
||||
# New Block
|
||||
snippet =b
|
||||
=begin rdoc
|
||||
${1}
|
||||
=end
|
||||
snippet y
|
||||
:yields: ${1:arguments}
|
||||
snippet rb
|
||||
#!/usr/bin/env ruby -wKU
|
||||
|
||||
snippet req
|
||||
require "${1}"${2}
|
||||
snippet #
|
||||
# =>
|
||||
snippet end
|
||||
__END__
|
||||
snippet case
|
||||
case ${1:object}
|
||||
when ${2:condition}
|
||||
${3}
|
||||
end
|
||||
snippet when
|
||||
when ${1:condition}
|
||||
${2}
|
||||
snippet def
|
||||
def ${1:method_name}
|
||||
${2}
|
||||
end
|
||||
snippet deft
|
||||
def test_${1:case_name}
|
||||
${2}
|
||||
end
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
end
|
||||
snippet elsif
|
||||
elsif ${1:condition}
|
||||
${2}
|
||||
snippet unless
|
||||
unless ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet while
|
||||
while ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet until
|
||||
until ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet cla class .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
${2}
|
||||
end
|
||||
snippet cla class .. initialize .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
def initialize(${2:args})
|
||||
${3}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla class .. < ParentClass .. initialize .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass}
|
||||
def initialize(${3:args})
|
||||
${4}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla ClassName = Struct .. do .. end
|
||||
${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do
|
||||
def ${3:method_name}
|
||||
${4}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla class BlankSlate .. initialize .. end
|
||||
class ${1:BlankSlate}
|
||||
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
|
||||
snippet cla class << self .. end
|
||||
class << ${1:self}
|
||||
${2}
|
||||
end
|
||||
# class .. < DelegateClass .. initialize .. end
|
||||
snippet cla-
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass})
|
||||
def initialize(${3:args})
|
||||
super(${4:del_obj})
|
||||
|
||||
${5}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet mod module .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
${2}
|
||||
end
|
||||
snippet mod module .. module_function .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
module_function
|
||||
|
||||
${2}
|
||||
end
|
||||
snippet mod module .. ClassMethods .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
module ClassMethods
|
||||
${2}
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
end
|
||||
|
||||
def self.included(receiver)
|
||||
receiver.extend ClassMethods
|
||||
receiver.send :include, InstanceMethods
|
||||
end
|
||||
end
|
||||
# attr_reader
|
||||
snippet r
|
||||
attr_reader :${1:attr_names}
|
||||
# attr_writer
|
||||
snippet w
|
||||
attr_writer :${1:attr_names}
|
||||
# attr_accessor
|
||||
snippet rw
|
||||
attr_accessor :${1:attr_names}
|
||||
# include Enumerable
|
||||
snippet Enum
|
||||
include Enumerable
|
||||
|
||||
def each(&block)
|
||||
${1}
|
||||
end
|
||||
# include Comparable
|
||||
snippet Comp
|
||||
include Comparable
|
||||
|
||||
def <=>(other)
|
||||
${1}
|
||||
end
|
||||
# extend Forwardable
|
||||
snippet Forw-
|
||||
extend Forwardable
|
||||
# def self
|
||||
snippet defs
|
||||
def self.${1:class_method_name}
|
||||
${2}
|
||||
end
|
||||
# def method_missing
|
||||
snippet defmm
|
||||
def method_missing(meth, *args, &blk)
|
||||
${1}
|
||||
end
|
||||
snippet defd
|
||||
def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}
|
||||
snippet defds
|
||||
def_delegators :${1:@del_obj}, :${2:del_methods}
|
||||
snippet am
|
||||
alias_method :${1:new_name}, :${2:old_name}
|
||||
snippet app
|
||||
if __FILE__ == $PROGRAM_NAME
|
||||
${1}
|
||||
end
|
||||
# usage_if()
|
||||
snippet usai
|
||||
if ARGV.${1}
|
||||
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
|
||||
end
|
||||
# usage_unless()
|
||||
snippet usau
|
||||
unless ARGV.${1}
|
||||
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
|
||||
end
|
||||
snippet array
|
||||
Array.new(${1:10}) { |${2:i}| ${3} }
|
||||
snippet hash
|
||||
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }
|
||||
snippet file File.foreach() { |line| .. }
|
||||
File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }
|
||||
snippet file File.read()
|
||||
File.read(${1:"path/to/file"})${2}
|
||||
snippet Dir Dir.global() { |file| .. }
|
||||
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }
|
||||
snippet Dir Dir[".."]
|
||||
Dir[${1:"glob/**/*.rb"}]${2}
|
||||
snippet dir
|
||||
Filename.dirname(__FILE__)
|
||||
snippet deli
|
||||
delete_if { |${1:e}| ${2} }
|
||||
snippet fil
|
||||
fill(${1:range}) { |${2:i}| ${3} }
|
||||
# flatten_once()
|
||||
snippet flao
|
||||
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}
|
||||
snippet zip
|
||||
zip(${1:enums}) { |${2:row}| ${3} }
|
||||
# downto(0) { |n| .. }
|
||||
snippet dow
|
||||
downto(${1:0}) { |${2:n}| ${3} }
|
||||
snippet ste
|
||||
step(${1:2}) { |${2:n}| ${3} }
|
||||
snippet tim
|
||||
times { |${1:n}| ${2} }
|
||||
snippet upt
|
||||
upto(${1:1.0/0.0}) { |${2:n}| ${3} }
|
||||
snippet loo
|
||||
loop { ${1} }
|
||||
snippet ea
|
||||
each { |${1:e}| ${2} }
|
||||
snippet eab
|
||||
each_byte { |${1:byte}| ${2} }
|
||||
snippet eac- each_char { |chr| .. }
|
||||
each_char { |${1:chr}| ${2} }
|
||||
snippet eac- each_cons(..) { |group| .. }
|
||||
each_cons(${1:2}) { |${2:group}| ${3} }
|
||||
snippet eai
|
||||
each_index { |${1:i}| ${2} }
|
||||
snippet eak
|
||||
each_key { |${1:key}| ${2} }
|
||||
snippet eal
|
||||
each_line { |${1:line}| ${2} }
|
||||
snippet eap
|
||||
each_pair { |${1:name}, ${2:val}| ${3} }
|
||||
snippet eas-
|
||||
each_slice(${1:2}) { |${2:group}| ${3} }
|
||||
snippet eav
|
||||
each_value { |${1:val}| ${2} }
|
||||
snippet eawi
|
||||
each_with_index { |${1:e}, ${2:i}| ${3} }
|
||||
snippet reve
|
||||
reverse_each { |${1:e}| ${2} }
|
||||
snippet inj
|
||||
inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }
|
||||
snippet map
|
||||
map { |${1:e}| ${2} }
|
||||
snippet mapwi-
|
||||
enum_with_index.map { |${1:e}, ${2:i}| ${3} }
|
||||
snippet sor
|
||||
sort { |a, b| ${1} }
|
||||
snippet sorb
|
||||
sort_by { |${1:e}| ${2} }
|
||||
snippet ran
|
||||
sort_by { rand }
|
||||
snippet all
|
||||
all? { |${1:e}| ${2} }
|
||||
snippet any
|
||||
any? { |${1:e}| ${2} }
|
||||
snippet cl
|
||||
classify { |${1:e}| ${2} }
|
||||
snippet col
|
||||
collect { |${1:e}| ${2} }
|
||||
snippet det
|
||||
detect { |${1:e}| ${2} }
|
||||
snippet fet
|
||||
fetch(${1:name}) { |${2:key}| ${3} }
|
||||
snippet fin
|
||||
find { |${1:e}| ${2} }
|
||||
snippet fina
|
||||
find_all { |${1:e}| ${2} }
|
||||
snippet gre
|
||||
grep(${1:/pattern/}) { |${2:match}| ${3} }
|
||||
snippet sub
|
||||
${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }
|
||||
snippet sca
|
||||
scan(${1:/pattern/}) { |${2:match}| ${3} }
|
||||
snippet max
|
||||
max { |a, b|, ${1} }
|
||||
snippet min
|
||||
min { |a, b|, ${1} }
|
||||
snippet par
|
||||
partition { |${1:e}|, ${2} }
|
||||
snippet rej
|
||||
reject { |${1:e}|, ${2} }
|
||||
snippet sel
|
||||
select { |${1:e}|, ${2} }
|
||||
snippet lam
|
||||
lambda { |${1:args}| ${2} }
|
||||
snippet do
|
||||
do |${1:variable}|
|
||||
${2}
|
||||
end
|
||||
snippet :
|
||||
:${1:key} => ${2:"value"}${3}
|
||||
snippet ope
|
||||
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
|
||||
# path_from_here()
|
||||
snippet patfh
|
||||
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
|
||||
# unix_filter {}
|
||||
snippet unif
|
||||
ARGF.each_line${1} do |${2:line}|
|
||||
${3}
|
||||
end
|
||||
# option_parse {}
|
||||
snippet optp
|
||||
require "optparse"
|
||||
|
||||
options = {${1:default => "args"}}
|
||||
|
||||
ARGV.options do |opts|
|
||||
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
|
||||
snippet opt
|
||||
opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
|
||||
"${4:Option description.}") do |${5:opt}|
|
||||
${6}
|
||||
end
|
||||
snippet tc
|
||||
require "test/unit"
|
||||
|
||||
require "${1:library_file_name}"
|
||||
|
||||
class Test${2:$1} < Test::Unit::TestCase
|
||||
def test_${3:case_name}
|
||||
${4}
|
||||
end
|
||||
end
|
||||
snippet ts
|
||||
require "test/unit"
|
||||
|
||||
require "tc_${1:test_case_file}"
|
||||
require "tc_${2:test_case_file}"${3}
|
||||
snippet as
|
||||
assert(${1:test}, "${2:Failure message.}")${3}
|
||||
snippet ase
|
||||
assert_equal(${1:expected}, ${2:actual})${3}
|
||||
snippet asne
|
||||
assert_not_equal(${1:unexpected}, ${2:actual})${3}
|
||||
snippet asid
|
||||
assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
|
||||
snippet asio
|
||||
assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
|
||||
snippet asko
|
||||
assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
|
||||
snippet asn
|
||||
assert_nil(${1:instance})${2}
|
||||
snippet asnn
|
||||
assert_not_nil(${1:instance})${2}
|
||||
snippet asm
|
||||
assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
|
||||
snippet asnm
|
||||
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
|
||||
snippet aso
|
||||
assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
|
||||
snippet asr
|
||||
assert_raise(${1:Exception}) { ${2} }
|
||||
snippet asnr
|
||||
assert_nothing_raised(${1:Exception}) { ${2} }
|
||||
snippet asrt
|
||||
assert_respond_to(${1:object}, :${2:method})${3}
|
||||
snippet ass assert_same(..)
|
||||
assert_same(${1:expected}, ${2:actual})${3}
|
||||
snippet ass assert_send(..)
|
||||
assert_send([${1:object}, :${2:message}, ${3:args}])${4}
|
||||
snippet asns
|
||||
assert_not_same(${1:unexpected}, ${2:actual})${3}
|
||||
snippet ast
|
||||
assert_throws(:${1:expected}) { ${2} }
|
||||
snippet asnt
|
||||
assert_nothing_thrown { ${1} }
|
||||
snippet fl
|
||||
flunk("${1:Failure message.}")${2}
|
||||
# Benchmark.bmbm do .. end
|
||||
snippet bm-
|
||||
TESTS = ${1:10_000}
|
||||
Benchmark.bmbm do |results|
|
||||
${2}
|
||||
end
|
||||
snippet rep
|
||||
results.report("${1:name}:") { TESTS.times { ${2} }}
|
||||
# Marshal.dump(.., file)
|
||||
snippet Md
|
||||
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}
|
||||
# Mashal.load(obj)
|
||||
snippet Ml
|
||||
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}
|
||||
# deep_copy(..)
|
||||
snippet deec
|
||||
Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}
|
||||
snippet Pn-
|
||||
PStore.new(${1:"file_name.pstore"})${2}
|
||||
snippet tra
|
||||
transaction(${1:true}) { ${2} }
|
||||
# xmlread(..)
|
||||
snippet xml-
|
||||
REXML::Document.new(File.read(${1:"path/to/file"}))${2}
|
||||
# xpath(..) { .. }
|
||||
snippet xpa
|
||||
elements.each(${1:"//Xpath"}) do |${2:node}|
|
||||
${3}
|
||||
end
|
||||
# class_from_name()
|
||||
snippet clafn
|
||||
split("::").inject(Object) { |par, const| par.const_get(const) }
|
||||
# singleton_class()
|
||||
snippet sinc
|
||||
class << self; self end
|
||||
snippet nam
|
||||
namespace :${1:`Filename()`} do
|
||||
${2}
|
||||
end
|
||||
snippet tas
|
||||
desc "${1:Task description\}"
|
||||
task :${2:task_name => [:dependent, :tasks]} do
|
||||
${3}
|
||||
end
|
39
.vim/pack/plugins/start/vim-snipmate/snippets/sh.snippets
Normal file
39
.vim/pack/plugins/start/vim-snipmate/snippets/sh.snippets
Normal file
@ -0,0 +1,39 @@
|
||||
# #!/bin/sh
|
||||
snippet #!
|
||||
#!/bin/sh
|
||||
|
||||
snippet if
|
||||
if [[ ${1:condition} ]]; then
|
||||
${2:#statements}
|
||||
fi
|
||||
snippet elif
|
||||
elif [[ ${1:condition} ]]; then
|
||||
${2:#statements}
|
||||
snippet for
|
||||
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||
${3:#statements}
|
||||
done
|
||||
snippet wh
|
||||
while [[ ${1:condition} ]]; do
|
||||
${2:#statements}
|
||||
done
|
||||
snippet until
|
||||
until [[ ${1:condition} ]]; do
|
||||
${2:#statements}
|
||||
done
|
||||
snippet case
|
||||
case ${1:word} in
|
||||
${2:pattern})
|
||||
${3};;
|
||||
esac
|
||||
snippet getopt
|
||||
while getopts ao: name
|
||||
do
|
||||
case $name in
|
||||
a) flag=1 ;;
|
||||
o) oarg=$OPTARG ;;
|
||||
?) echo "Usage: ..."; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
echo "Non-option arguments: " "$@"
|
@ -0,0 +1,7 @@
|
||||
# snippets for making snippets :)
|
||||
snippet snip
|
||||
snippet ${1:trigger}
|
||||
${2}
|
||||
snippet msnip
|
||||
snippet ${1:trigger} ${2:description}
|
||||
${3}
|
92
.vim/pack/plugins/start/vim-snipmate/snippets/tcl.snippets
Normal file
92
.vim/pack/plugins/start/vim-snipmate/snippets/tcl.snippets
Normal file
@ -0,0 +1,92 @@
|
||||
# #!/usr/bin/tclsh
|
||||
snippet #!
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Process
|
||||
snippet pro
|
||||
proc ${1:function_name} {${2:args}} {
|
||||
${3:#body ...}
|
||||
}
|
||||
#xif
|
||||
snippet xif
|
||||
${1:expr}? ${2:true} : ${3:false}
|
||||
# Conditional
|
||||
snippet if
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
}
|
||||
# Conditional if..else
|
||||
snippet ife
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
} else {
|
||||
${3:# else...}
|
||||
}
|
||||
# Conditional if..elsif..else
|
||||
snippet ifee
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
} elseif {${3}} {
|
||||
${4:# elsif...}
|
||||
} else {
|
||||
${5:# else...}
|
||||
}
|
||||
# If catch then
|
||||
snippet ifc
|
||||
if { [catch {${1:#do something...}} ${2:err}] } {
|
||||
${3:# handle failure...}
|
||||
}
|
||||
# Catch
|
||||
snippet catch
|
||||
catch {${1}} ${2:err} ${3:options}
|
||||
# While Loop
|
||||
snippet wh
|
||||
while {${1}} {
|
||||
${2:# body...}
|
||||
}
|
||||
# For Loop
|
||||
snippet for
|
||||
for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
|
||||
${4:# body...}
|
||||
}
|
||||
# Foreach Loop
|
||||
snippet fore
|
||||
foreach ${1:x} {${2:#list}} {
|
||||
${3:# body...}
|
||||
}
|
||||
# after ms script...
|
||||
snippet af
|
||||
after ${1:ms} ${2:#do something}
|
||||
# after cancel id
|
||||
snippet afc
|
||||
after cancel ${1:id or script}
|
||||
# after idle
|
||||
snippet afi
|
||||
after idle ${1:script}
|
||||
# after info id
|
||||
snippet afin
|
||||
after info ${1:id}
|
||||
# Expr
|
||||
snippet exp
|
||||
expr {${1:#expression here}}
|
||||
# Switch
|
||||
snippet sw
|
||||
switch ${1:var} {
|
||||
${3:pattern 1} {
|
||||
${4:#do something}
|
||||
}
|
||||
default {
|
||||
${2:#do something}
|
||||
}
|
||||
}
|
||||
# Case
|
||||
snippet ca
|
||||
${1:pattern} {
|
||||
${2:#do something}
|
||||
}${3}
|
||||
# Namespace eval
|
||||
snippet ns
|
||||
namespace eval ${1:path} {${2:#script...}}
|
||||
# Namespace current
|
||||
snippet nsc
|
||||
namespace current
|
115
.vim/pack/plugins/start/vim-snipmate/snippets/tex.snippets
Normal file
115
.vim/pack/plugins/start/vim-snipmate/snippets/tex.snippets
Normal file
@ -0,0 +1,115 @@
|
||||
# \begin{}...\end{}
|
||||
snippet begin
|
||||
\begin{${1:env}}
|
||||
${2}
|
||||
\end{$1}
|
||||
# Tabular
|
||||
snippet tab
|
||||
\begin{${1:tabular}}{${2:c}}
|
||||
${3}
|
||||
\end{$1}
|
||||
# Align(ed)
|
||||
snippet ali
|
||||
\begin{align${1:ed}}
|
||||
${2}
|
||||
\end{align$1}
|
||||
# Gather(ed)
|
||||
snippet gat
|
||||
\begin{gather${1:ed}}
|
||||
${2}
|
||||
\end{gather$1}
|
||||
# Equation
|
||||
snippet eq
|
||||
\begin{equation}
|
||||
${1}
|
||||
\end{equation}
|
||||
# Unnumbered Equation
|
||||
snippet \
|
||||
\\[
|
||||
${1}
|
||||
\\]
|
||||
# Enumerate
|
||||
snippet enum
|
||||
\begin{enumerate}
|
||||
\item ${1}
|
||||
\end{enumerate}
|
||||
# Itemize
|
||||
snippet item
|
||||
\begin{itemize}
|
||||
\item ${1}
|
||||
\end{itemize}
|
||||
# Description
|
||||
snippet desc
|
||||
\begin{description}
|
||||
\item[${1}] ${2}
|
||||
\end{description}
|
||||
# Matrix
|
||||
snippet mat
|
||||
\begin{${1:p/b/v/V/B/small}matrix}
|
||||
${2}
|
||||
\end{$1matrix}
|
||||
# Cases
|
||||
snippet cas
|
||||
\begin{cases}
|
||||
${1:equation}, &\text{ if }${2:case}\\
|
||||
${3}
|
||||
\end{cases}
|
||||
# Split
|
||||
snippet spl
|
||||
\begin{split}
|
||||
${1}
|
||||
\end{split}
|
||||
# Part
|
||||
snippet part
|
||||
\part{${1:part name}} % (fold)
|
||||
\label{prt:${2:$1}}
|
||||
${3}
|
||||
% part $2 (end)
|
||||
# Chapter
|
||||
snippet cha
|
||||
\chapter{${1:chapter name}} % (fold)
|
||||
\label{cha:${2:$1}}
|
||||
${3}
|
||||
% chapter $2 (end)
|
||||
# Section
|
||||
snippet sec
|
||||
\section{${1:section name}} % (fold)
|
||||
\label{sec:${2:$1}}
|
||||
${3}
|
||||
% section $2 (end)
|
||||
# Sub Section
|
||||
snippet sub
|
||||
\subsection{${1:subsection name}} % (fold)
|
||||
\label{sub:${2:$1}}
|
||||
${3}
|
||||
% subsection $2 (end)
|
||||
# Sub Sub Section
|
||||
snippet subs
|
||||
\subsubsection{${1:subsubsection name}} % (fold)
|
||||
\label{ssub:${2:$1}}
|
||||
${3}
|
||||
% subsubsection $2 (end)
|
||||
# Paragraph
|
||||
snippet par
|
||||
\paragraph{${1:paragraph name}} % (fold)
|
||||
\label{par:${2:$1}}
|
||||
${3}
|
||||
% paragraph $2 (end)
|
||||
# Sub Paragraph
|
||||
snippet subp
|
||||
\subparagraph{${1:subparagraph name}} % (fold)
|
||||
\label{subp:${2:$1}}
|
||||
${3}
|
||||
% subparagraph $2 (end)
|
||||
snippet itd
|
||||
\item[${1:description}] ${2:item}
|
||||
snippet figure
|
||||
${1:Figure}~\ref{${2:fig:}}${3}
|
||||
snippet table
|
||||
${1:Table}~\ref{${2:tab:}}${3}
|
||||
snippet listing
|
||||
${1:Listing}~\ref{${2:list}}${3}
|
||||
snippet section
|
||||
${1:Section}~\ref{${2:sec:}}${3}
|
||||
snippet page
|
||||
${1:page}~\pageref{${2}}${3}
|
32
.vim/pack/plugins/start/vim-snipmate/snippets/vim.snippets
Normal file
32
.vim/pack/plugins/start/vim-snipmate/snippets/vim.snippets
Normal file
@ -0,0 +1,32 @@
|
||||
snippet header
|
||||
" File: ${1:`expand('%:t')`}
|
||||
" Author: ${2:`g:snips_author`}
|
||||
" Description: ${3}
|
||||
${4:" Last Modified: `strftime("%B %d, %Y")`}
|
||||
snippet guard
|
||||
if exists('${1:did_`Filename()`}') || &cp${2: || version < 700}
|
||||
finish
|
||||
endif
|
||||
let $1 = 1${3}
|
||||
snippet f
|
||||
fun ${1:function_name}(${2})
|
||||
${3:" code}
|
||||
endf
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}
|
||||
${3:" code}
|
||||
endfor
|
||||
snippet wh
|
||||
while ${1:condition}
|
||||
${2:" code}
|
||||
endw
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2:" code}
|
||||
endif
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
endif
|
19
.vim/pack/plugins/start/vim-snipmate/syntax/snippet.vim
Normal file
19
.vim/pack/plugins/start/vim-snipmate/syntax/snippet.vim
Normal file
@ -0,0 +1,19 @@
|
||||
" Syntax highlighting for snippet files (used for snipMate.vim)
|
||||
" Hopefully this should make snippets a bit nicer to write!
|
||||
syn match snipComment '^#.*'
|
||||
syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
|
||||
syn match tabStop '\$\d\+'
|
||||
syn match snipCommand '`.\{-}`'
|
||||
syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword
|
||||
syn match multiSnipText '\S\+ \zs.*' contained
|
||||
syn match snipKeyword '^snippet'me=s+8 contained
|
||||
syn match snipError "^[^#s\t].*$"
|
||||
|
||||
hi link snipComment Comment
|
||||
hi link multiSnipText String
|
||||
hi link snipKeyword Keyword
|
||||
hi link snipComment Comment
|
||||
hi link placeHolder Special
|
||||
hi link tabStop Special
|
||||
hi link snipCommand String
|
||||
hi link snipError Error
|
3508
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar.vim
Normal file
3508
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar.vim
Normal file
File diff suppressed because it is too large
Load Diff
62
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar/debug.vim
Normal file
62
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar/debug.vim
Normal file
@ -0,0 +1,62 @@
|
||||
function! tagbar#debug#start_debug(...) abort
|
||||
let filename = a:0 > 0 ? a:1 : ''
|
||||
|
||||
if empty(filename)
|
||||
let s:debug_file = 'tagbardebug.log'
|
||||
else
|
||||
let s:debug_file = filename
|
||||
endif
|
||||
|
||||
" Clear log file and start it with version info
|
||||
exe 'redir! > ' . s:debug_file
|
||||
silent version
|
||||
redir END
|
||||
|
||||
" Check whether the log file could be created
|
||||
if !filewritable(s:debug_file)
|
||||
echomsg 'Tagbar: Unable to create log file ' . s:debug_file
|
||||
let s:debug_file = ''
|
||||
return
|
||||
endif
|
||||
|
||||
let s:debug_enabled = 1
|
||||
endfunction
|
||||
|
||||
function! tagbar#debug#stop_debug() abort
|
||||
let s:debug_enabled = 0
|
||||
let s:debug_file = ''
|
||||
endfunction
|
||||
|
||||
function! tagbar#debug#log(msg) abort
|
||||
if s:debug_enabled
|
||||
execute 'redir >> ' . s:debug_file
|
||||
silent echon s:gettime() . ': ' . a:msg . "\n"
|
||||
redir END
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! tagbar#debug#log_ctags_output(output) abort
|
||||
if s:debug_enabled
|
||||
exe 'redir! > ' . s:debug_file . '.ctags_out'
|
||||
silent echon a:output
|
||||
redir END
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! tagbar#debug#enabled() abort
|
||||
return s:debug_enabled
|
||||
endfunction
|
||||
|
||||
if has('reltime')
|
||||
function! s:gettime() abort
|
||||
let time = split(reltimestr(reltime()), '\.')
|
||||
return strftime('%Y-%m-%d %H:%M:%S.', time[0]) . time[1]
|
||||
endfunction
|
||||
else
|
||||
function! s:gettime() abort
|
||||
return strftime('%Y-%m-%d %H:%M:%S')
|
||||
endfunction
|
||||
endif
|
||||
|
||||
let s:debug_enabled = 0
|
||||
let s:debug_file = ''
|
@ -0,0 +1,237 @@
|
||||
let s:visibility_symbols = {
|
||||
\ 'public' : '+',
|
||||
\ 'protected' : '#',
|
||||
\ 'private' : '-'
|
||||
\ }
|
||||
|
||||
function! tagbar#prototypes#basetag#new(name) abort
|
||||
let newobj = {}
|
||||
|
||||
let newobj.name = a:name
|
||||
let newobj.fields = {}
|
||||
let newobj.fields.line = 0
|
||||
let newobj.fields.column = 0
|
||||
let newobj.prototype = ''
|
||||
let newobj.path = ''
|
||||
let newobj.fullpath = a:name
|
||||
let newobj.depth = 0
|
||||
let newobj.parent = {}
|
||||
let newobj.tline = -1
|
||||
let newobj.fileinfo = {}
|
||||
let newobj.typeinfo = {}
|
||||
let newobj._childlist = []
|
||||
let newobj._childdict = {}
|
||||
|
||||
let newobj.isNormalTag = function(s:add_snr('s:isNormalTag'))
|
||||
let newobj.isPseudoTag = function(s:add_snr('s:isPseudoTag'))
|
||||
let newobj.isSplitTag = function(s:add_snr('s:isSplitTag'))
|
||||
let newobj.isKindheader = function(s:add_snr('s:isKindheader'))
|
||||
let newobj.getPrototype = function(s:add_snr('s:getPrototype'))
|
||||
let newobj._getPrefix = function(s:add_snr('s:_getPrefix'))
|
||||
let newobj.initFoldState = function(s:add_snr('s:initFoldState'))
|
||||
let newobj.getClosedParentTline = function(s:add_snr('s:getClosedParentTline'))
|
||||
let newobj.isFoldable = function(s:add_snr('s:isFoldable'))
|
||||
let newobj.isFolded = function(s:add_snr('s:isFolded'))
|
||||
let newobj.openFold = function(s:add_snr('s:openFold'))
|
||||
let newobj.closeFold = function(s:add_snr('s:closeFold'))
|
||||
let newobj.setFolded = function(s:add_snr('s:setFolded'))
|
||||
let newobj.openParents = function(s:add_snr('s:openParents'))
|
||||
let newobj.addChild = function(s:add_snr('s:addChild'))
|
||||
let newobj.getChildren = function(s:add_snr('s:getChildren'))
|
||||
let newobj.getChildrenByName = function(s:add_snr('s:getChildrenByName'))
|
||||
let newobj.removeChild = function(s:add_snr('s:removeChild'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
" s:isNormalTag() {{{1
|
||||
function! s:isNormalTag() abort dict
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" s:isPseudoTag() {{{1
|
||||
function! s:isPseudoTag() abort dict
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" s:isSplitTag {{{1
|
||||
function! s:isSplitTag() abort dict
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" s:isKindheader() {{{1
|
||||
function! s:isKindheader() abort dict
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" s:getPrototype() {{{1
|
||||
function! s:getPrototype(short) abort dict
|
||||
return self.prototype
|
||||
endfunction
|
||||
|
||||
" s:_getPrefix() {{{1
|
||||
function! s:_getPrefix() abort dict
|
||||
let fileinfo = self.fileinfo
|
||||
|
||||
if !empty(self._childlist)
|
||||
if fileinfo.tagfolds[self.fields.kind][self.fullpath]
|
||||
let prefix = g:tagbar#icon_closed
|
||||
else
|
||||
let prefix = g:tagbar#icon_open
|
||||
endif
|
||||
else
|
||||
let prefix = ' '
|
||||
endif
|
||||
" Visibility is called 'access' in the ctags output
|
||||
if g:tagbar_show_visibility
|
||||
if has_key(self.fields, 'access')
|
||||
let prefix .= get(s:visibility_symbols, self.fields.access, ' ')
|
||||
elseif has_key(self.fields, 'file')
|
||||
let prefix .= s:visibility_symbols.private
|
||||
else
|
||||
let prefix .= ' '
|
||||
endif
|
||||
endif
|
||||
|
||||
return prefix
|
||||
endfunction
|
||||
|
||||
" s:initFoldState() {{{1
|
||||
function! s:initFoldState(known_files) abort dict
|
||||
let fileinfo = self.fileinfo
|
||||
|
||||
if a:known_files.has(fileinfo.fpath) &&
|
||||
\ has_key(fileinfo, '_tagfolds_old') &&
|
||||
\ has_key(fileinfo._tagfolds_old[self.fields.kind], self.fullpath)
|
||||
" The file has been updated and the tag was there before, so copy its
|
||||
" old fold state
|
||||
let fileinfo.tagfolds[self.fields.kind][self.fullpath] =
|
||||
\ fileinfo._tagfolds_old[self.fields.kind][self.fullpath]
|
||||
elseif self.depth >= fileinfo.foldlevel
|
||||
let fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1
|
||||
else
|
||||
let fileinfo.tagfolds[self.fields.kind][self.fullpath] =
|
||||
\ fileinfo.kindfolds[self.fields.kind]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:getClosedParentTline() {{{1
|
||||
function! s:getClosedParentTline() abort dict
|
||||
let tagline = self.tline
|
||||
|
||||
" Find the first closed parent, starting from the top of the hierarchy.
|
||||
let parents = []
|
||||
let curparent = self.parent
|
||||
while !empty(curparent)
|
||||
call add(parents, curparent)
|
||||
let curparent = curparent.parent
|
||||
endwhile
|
||||
for parent in reverse(parents)
|
||||
if parent.isFolded()
|
||||
let tagline = parent.tline
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
return tagline
|
||||
endfunction
|
||||
|
||||
" s:isFoldable() {{{1
|
||||
function! s:isFoldable() abort dict
|
||||
return !empty(self._childlist)
|
||||
endfunction
|
||||
|
||||
" s:isFolded() {{{1
|
||||
function! s:isFolded() abort dict
|
||||
return self.fileinfo.tagfolds[self.fields.kind][self.fullpath]
|
||||
endfunction
|
||||
|
||||
" s:openFold() {{{1
|
||||
function! s:openFold() abort dict
|
||||
if self.isFoldable()
|
||||
let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:closeFold() {{{1
|
||||
function! s:closeFold() abort dict
|
||||
let newline = line('.')
|
||||
|
||||
if !empty(self.parent) && self.parent.isKindheader()
|
||||
" Tag is child of generic 'kind'
|
||||
call self.parent.closeFold()
|
||||
let newline = self.parent.tline
|
||||
elseif self.isFoldable() && !self.isFolded()
|
||||
" Tag is parent of a scope and is not folded
|
||||
let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1
|
||||
let newline = self.tline
|
||||
elseif !empty(self.parent)
|
||||
" Tag is normal child, so close parent
|
||||
let parent = self.parent
|
||||
let self.fileinfo.tagfolds[parent.fields.kind][parent.fullpath] = 1
|
||||
let newline = parent.tline
|
||||
endif
|
||||
|
||||
return newline
|
||||
endfunction
|
||||
|
||||
" s:setFolded() {{{1
|
||||
function! s:setFolded(folded) abort dict
|
||||
let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = a:folded
|
||||
endfunction
|
||||
|
||||
" s:openParents() {{{1
|
||||
function! s:openParents() abort dict
|
||||
let parent = self.parent
|
||||
|
||||
while !empty(parent)
|
||||
call parent.openFold()
|
||||
let parent = parent.parent
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
" s:addChild() {{{1
|
||||
function! s:addChild(tag) abort dict
|
||||
call add(self._childlist, a:tag)
|
||||
|
||||
if has_key(self._childdict, a:tag.name)
|
||||
call add(self._childdict[a:tag.name], a:tag)
|
||||
else
|
||||
let self._childdict[a:tag.name] = [a:tag]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:getChildren() {{{1
|
||||
function! s:getChildren() dict abort
|
||||
return self._childlist
|
||||
endfunction
|
||||
|
||||
" s:getChildrenByName() {{{1
|
||||
function! s:getChildrenByName(tagname) dict abort
|
||||
return get(self._childdict, a:tagname, [])
|
||||
endfunction
|
||||
|
||||
" s:removeChild() {{{1
|
||||
function! s:removeChild(tag) dict abort
|
||||
let idx = index(self._childlist, a:tag)
|
||||
if idx >= 0
|
||||
call remove(self._childlist, idx)
|
||||
endif
|
||||
|
||||
let namelist = get(self._childdict, a:tag.name, [])
|
||||
let idx = index(namelist, a:tag)
|
||||
if idx >= 0
|
||||
call remove(namelist, idx)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:add_snr() {{{1
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,146 @@
|
||||
function! tagbar#prototypes#fileinfo#new(fname, ftype, typeinfo) abort
|
||||
let newobj = {}
|
||||
|
||||
" The complete file path
|
||||
let newobj.fpath = a:fname
|
||||
|
||||
let newobj.bufnr = bufnr(a:fname)
|
||||
|
||||
" File modification time
|
||||
let newobj.mtime = getftime(a:fname)
|
||||
|
||||
" The vim file type
|
||||
let newobj.ftype = a:ftype
|
||||
|
||||
" List of the tags that are present in the file, sorted according to the
|
||||
" value of 'g:tagbar_sort'
|
||||
let newobj._taglist = []
|
||||
let newobj._tagdict = {}
|
||||
|
||||
" Dictionary of the tags, indexed by line number in the file
|
||||
let newobj.fline = {}
|
||||
|
||||
" Dictionary of the tags, indexed by line number in the tagbar
|
||||
let newobj.tline = {}
|
||||
|
||||
" Dictionary of the folding state of 'kind's, indexed by short name
|
||||
let newobj.kindfolds = {}
|
||||
let newobj.typeinfo = a:typeinfo
|
||||
" copy the default fold state from the type info
|
||||
for kind in a:typeinfo.kinds
|
||||
let newobj.kindfolds[kind.short] =
|
||||
\ g:tagbar_foldlevel == 0 ? 1 : kind.fold
|
||||
endfor
|
||||
|
||||
" Dictionary of dictionaries of the folding state of individual tags,
|
||||
" indexed by kind and full path
|
||||
let newobj.tagfolds = {}
|
||||
for kind in a:typeinfo.kinds
|
||||
let newobj.tagfolds[kind.short] = {}
|
||||
endfor
|
||||
|
||||
" The current foldlevel of the file
|
||||
let newobj.foldlevel = g:tagbar_foldlevel
|
||||
|
||||
let newobj.addTag = function(s:add_snr('s:addTag'))
|
||||
let newobj.getTags = function(s:add_snr('s:getTags'))
|
||||
let newobj.getTagsByName = function(s:add_snr('s:getTagsByName'))
|
||||
let newobj.removeTag = function(s:add_snr('s:removeTag'))
|
||||
let newobj.reset = function(s:add_snr('s:reset'))
|
||||
let newobj.clearOldFolds = function(s:add_snr('s:clearOldFolds'))
|
||||
let newobj.sortTags = function(s:add_snr('s:sortTags'))
|
||||
let newobj.openKindFold = function(s:add_snr('s:openKindFold'))
|
||||
let newobj.closeKindFold = function(s:add_snr('s:closeKindFold'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
" s:addTag() {{{1
|
||||
function! s:addTag(tag) abort dict
|
||||
call add(self._taglist, a:tag)
|
||||
|
||||
if has_key(self._tagdict, a:tag.name)
|
||||
call add(self._tagdict[a:tag.name], a:tag)
|
||||
else
|
||||
let self._tagdict[a:tag.name] = [a:tag]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:getTags() {{{1
|
||||
function! s:getTags() dict abort
|
||||
return self._taglist
|
||||
endfunction
|
||||
|
||||
" s:getTagsByName() {{{1
|
||||
function! s:getTagsByName(tagname) dict abort
|
||||
return get(self._tagdict, a:tagname, [])
|
||||
endfunction
|
||||
|
||||
" s:removeTag() {{{1
|
||||
function! s:removeTag(tag) dict abort
|
||||
let idx = index(self._taglist, a:tag)
|
||||
if idx >= 0
|
||||
call remove(self._taglist, idx)
|
||||
endif
|
||||
|
||||
let namelist = get(self._tagdict, a:tag.name, [])
|
||||
let idx = index(namelist, a:tag)
|
||||
if idx >= 0
|
||||
call remove(namelist, idx)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:reset() {{{1
|
||||
" Reset stuff that gets regenerated while processing a file and save the old
|
||||
" tag folds
|
||||
function! s:reset() abort dict
|
||||
let self.mtime = getftime(self.fpath)
|
||||
let self._taglist = []
|
||||
let self._tagdict = {}
|
||||
let self.fline = {}
|
||||
let self.tline = {}
|
||||
|
||||
let self._tagfolds_old = self.tagfolds
|
||||
let self.tagfolds = {}
|
||||
|
||||
for kind in self.typeinfo.kinds
|
||||
let self.tagfolds[kind.short] = {}
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" s:clearOldFolds() {{{1
|
||||
function! s:clearOldFolds() abort dict
|
||||
if exists('self._tagfolds_old')
|
||||
unlet self._tagfolds_old
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:sortTags() {{{1
|
||||
function! s:sortTags(compare_typeinfo) abort dict
|
||||
if get(a:compare_typeinfo, 'sort', g:tagbar_sort)
|
||||
call tagbar#sorting#sort(self._taglist, 'kind', a:compare_typeinfo)
|
||||
else
|
||||
call tagbar#sorting#sort(self._taglist, 'line', a:compare_typeinfo)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:openKindFold() {{{1
|
||||
function! s:openKindFold(kind) abort dict
|
||||
let self.kindfolds[a:kind.short] = 0
|
||||
endfunction
|
||||
|
||||
" s:closeKindFold() {{{1
|
||||
function! s:closeKindFold(kind) abort dict
|
||||
let self.kindfolds[a:kind.short] = 1
|
||||
endfunction
|
||||
|
||||
" s:add_snr() {{{1
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,61 @@
|
||||
function! tagbar#prototypes#kindheadertag#new(name) abort
|
||||
let newobj = tagbar#prototypes#basetag#new(a:name)
|
||||
|
||||
let newobj.isKindheader = function(s:add_snr('s:isKindheader'))
|
||||
let newobj.getPrototype = function(s:add_snr('s:getPrototype'))
|
||||
let newobj.isFoldable = function(s:add_snr('s:isFoldable'))
|
||||
let newobj.isFolded = function(s:add_snr('s:isFolded'))
|
||||
let newobj.openFold = function(s:add_snr('s:openFold'))
|
||||
let newobj.closeFold = function(s:add_snr('s:closeFold'))
|
||||
let newobj.toggleFold = function(s:add_snr('s:toggleFold'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
" s:isKindheader() {{{1
|
||||
function! s:isKindheader() abort dict
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" s:getPrototype() {{{1
|
||||
function! s:getPrototype(short) abort dict
|
||||
return self.name . ': ' .
|
||||
\ self.numtags . ' ' . (self.numtags > 1 ? 'tags' : 'tag')
|
||||
endfunction
|
||||
|
||||
" s:isFoldable() {{{1
|
||||
function! s:isFoldable() abort dict
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" s:isFolded() {{{1
|
||||
function! s:isFolded() abort dict
|
||||
return self.fileinfo.kindfolds[self.short]
|
||||
endfunction
|
||||
|
||||
" s:openFold() {{{1
|
||||
function! s:openFold() abort dict
|
||||
let self.fileinfo.kindfolds[self.short] = 0
|
||||
endfunction
|
||||
|
||||
" s:closeFold() {{{1
|
||||
function! s:closeFold() abort dict
|
||||
let self.fileinfo.kindfolds[self.short] = 1
|
||||
return line('.')
|
||||
endfunction
|
||||
|
||||
" s:toggleFold() {{{1
|
||||
function! s:toggleFold(fileinfo) abort dict
|
||||
let a:fileinfo.kindfolds[self.short] = !a:fileinfo.kindfolds[self.short]
|
||||
endfunction
|
||||
|
||||
" s:add_snr() {{{1
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,119 @@
|
||||
function! tagbar#prototypes#normaltag#new(name) abort
|
||||
let newobj = tagbar#prototypes#basetag#new(a:name)
|
||||
|
||||
let newobj.isNormalTag = function(s:add_snr('s:isNormalTag'))
|
||||
let newobj.strfmt = function(s:add_snr('s:strfmt'))
|
||||
let newobj.str = function(s:add_snr('s:str'))
|
||||
let newobj.getPrototype = function(s:add_snr('s:getPrototype'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
" s:isNormalTag() {{{1
|
||||
function! s:isNormalTag() abort dict
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" s:strfmt() {{{1
|
||||
function! s:strfmt() abort dict
|
||||
let typeinfo = self.typeinfo
|
||||
|
||||
let suffix = get(self.fields, 'signature', '')
|
||||
if has_key(self.fields, 'type')
|
||||
let suffix .= ' : ' . self.fields.type
|
||||
elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind)
|
||||
let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind]
|
||||
endif
|
||||
|
||||
return self._getPrefix() . self.name . suffix
|
||||
endfunction
|
||||
|
||||
" s:str() {{{1
|
||||
function! s:str(longsig, full) abort dict
|
||||
if a:full && self.path !=# ''
|
||||
let str = self.path . self.typeinfo.sro . self.name
|
||||
else
|
||||
let str = self.name
|
||||
endif
|
||||
|
||||
if has_key(self.fields, 'signature')
|
||||
if a:longsig
|
||||
let str .= self.fields.signature
|
||||
else
|
||||
let str .= '()'
|
||||
endif
|
||||
endif
|
||||
|
||||
return str
|
||||
endfunction
|
||||
|
||||
" s:getPrototype() {{{1
|
||||
function! s:getPrototype(short) abort dict
|
||||
if self.prototype !=# ''
|
||||
let prototype = self.prototype
|
||||
else
|
||||
let bufnr = self.fileinfo.bufnr
|
||||
|
||||
if self.fields.line == 0 || !bufloaded(bufnr)
|
||||
" No linenumber available or buffer not loaded (probably due to
|
||||
" 'nohidden'), try the pattern instead
|
||||
return substitute(self.pattern, '^\\M\\^\\C\s*\(.*\)\\$$', '\1', '')
|
||||
endif
|
||||
|
||||
let line = getbufline(bufnr, self.fields.line)[0]
|
||||
let list = split(line, '\zs')
|
||||
|
||||
let start = index(list, '(')
|
||||
if start == -1
|
||||
return substitute(line, '^\s\+', '', '')
|
||||
endif
|
||||
|
||||
let opening = count(list, '(', 0, start)
|
||||
let closing = count(list, ')', 0, start)
|
||||
if closing >= opening
|
||||
return substitute(line, '^\s\+', '', '')
|
||||
endif
|
||||
|
||||
let balance = opening - closing
|
||||
|
||||
let prototype = line
|
||||
let curlinenr = self.fields.line + 1
|
||||
while balance > 0
|
||||
let curline = getbufline(bufnr, curlinenr)[0]
|
||||
let curlist = split(curline, '\zs')
|
||||
let balance += count(curlist, '(')
|
||||
let balance -= count(curlist, ')')
|
||||
let prototype .= "\n" . curline
|
||||
let curlinenr += 1
|
||||
endwhile
|
||||
|
||||
let self.prototype = prototype
|
||||
endif
|
||||
|
||||
if a:short
|
||||
" join all lines and remove superfluous spaces
|
||||
let prototype = substitute(prototype, '^\s\+', '', '')
|
||||
let prototype = substitute(prototype, '\_s\+', ' ', 'g')
|
||||
let prototype = substitute(prototype, '(\s\+', '(', 'g')
|
||||
let prototype = substitute(prototype, '\s\+)', ')', 'g')
|
||||
" Avoid hit-enter prompts
|
||||
let maxlen = &columns - 12
|
||||
if len(prototype) > maxlen
|
||||
let prototype = prototype[:maxlen - 1 - 3]
|
||||
let prototype .= '...'
|
||||
endif
|
||||
endif
|
||||
|
||||
return prototype
|
||||
endfunction
|
||||
|
||||
" s:add_snr() {{{1
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,36 @@
|
||||
function! tagbar#prototypes#pseudotag#new(name) abort
|
||||
let newobj = tagbar#prototypes#basetag#new(a:name)
|
||||
|
||||
let newobj.isPseudoTag = function(s:add_snr('s:isPseudoTag'))
|
||||
let newobj.strfmt = function(s:add_snr('s:strfmt'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
" s:isPseudoTag() {{{1
|
||||
function! s:isPseudoTag() abort dict
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" s:strfmt() {{{1
|
||||
function! s:strfmt() abort dict
|
||||
let typeinfo = self.typeinfo
|
||||
|
||||
let suffix = get(self.fields, 'signature', '')
|
||||
if has_key(typeinfo.kind2scope, self.fields.kind)
|
||||
let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind]
|
||||
endif
|
||||
|
||||
return self._getPrefix() . self.name . '*' . suffix
|
||||
endfunction
|
||||
|
||||
" s:add_snr() {{{1
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,26 @@
|
||||
" A tag that was created because of a tag name that covers multiple scopes
|
||||
" Inherits the fields of the "main" tag it was split from.
|
||||
" May be replaced during tag processing if it appears as a normal tag later,
|
||||
" just like a pseudo tag.
|
||||
|
||||
function! tagbar#prototypes#splittag#new(name) abort
|
||||
let newobj = tagbar#prototypes#normaltag#new(a:name)
|
||||
|
||||
let newobj.isSplitTag = function(s:add_snr('s:isSplitTag'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
function! s:isSplitTag() abort dict
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,42 @@
|
||||
function! tagbar#prototypes#typeinfo#new(...) abort
|
||||
let newobj = {}
|
||||
|
||||
let newobj.kinddict = {}
|
||||
|
||||
if a:0 > 0
|
||||
call extend(newobj, a:1)
|
||||
endif
|
||||
|
||||
let newobj.getKind = function(s:add_snr('s:getKind'))
|
||||
let newobj.createKinddict = function(s:add_snr('s:createKinddict'))
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
" s:getKind() {{{1
|
||||
function! s:getKind(kind) abort dict
|
||||
let idx = self.kinddict[a:kind]
|
||||
return self.kinds[idx]
|
||||
endfunction
|
||||
|
||||
" s:createKinddict() {{{1
|
||||
" Create a dictionary of the kind order for fast access in sorting functions
|
||||
function! s:createKinddict() abort dict
|
||||
let i = 0
|
||||
for kind in self.kinds
|
||||
let self.kinddict[kind.short] = i
|
||||
let i += 1
|
||||
endfor
|
||||
let self.kinddict['?'] = i
|
||||
endfunction
|
||||
|
||||
" s:add_snr() {{{1
|
||||
function! s:add_snr(funcname) abort
|
||||
if !exists('s:snr')
|
||||
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
|
||||
endif
|
||||
return s:snr . a:funcname
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,57 @@
|
||||
" Script-local variable needed since compare functions can't
|
||||
" take additional arguments
|
||||
let s:compare_typeinfo = {}
|
||||
|
||||
function! tagbar#sorting#sort(tags, compareby, compare_typeinfo) abort
|
||||
let s:compare_typeinfo = a:compare_typeinfo
|
||||
|
||||
let comparemethod =
|
||||
\ a:compareby ==# 'kind' ? 's:compare_by_kind' : 's:compare_by_line'
|
||||
|
||||
call sort(a:tags, comparemethod)
|
||||
|
||||
for tag in a:tags
|
||||
if !empty(tag.getChildren())
|
||||
call tagbar#sorting#sort(tag.getChildren(), a:compareby,
|
||||
\ a:compare_typeinfo)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:compare_by_kind(tag1, tag2) abort
|
||||
let typeinfo = s:compare_typeinfo
|
||||
|
||||
if typeinfo.kinddict[a:tag1.fields.kind] <#
|
||||
\ typeinfo.kinddict[a:tag2.fields.kind]
|
||||
return -1
|
||||
elseif typeinfo.kinddict[a:tag1.fields.kind] >#
|
||||
\ typeinfo.kinddict[a:tag2.fields.kind]
|
||||
return 1
|
||||
else
|
||||
" Ignore '~' prefix for C++ destructors to sort them directly under
|
||||
" the constructors
|
||||
if a:tag1.name[0] ==# '~'
|
||||
let name1 = a:tag1.name[1:]
|
||||
else
|
||||
let name1 = a:tag1.name
|
||||
endif
|
||||
if a:tag2.name[0] ==# '~'
|
||||
let name2 = a:tag2.name[1:]
|
||||
else
|
||||
let name2 = a:tag2.name
|
||||
endif
|
||||
|
||||
let ci = g:tagbar_case_insensitive
|
||||
if (((!ci) && (name1 <=# name2)) || (ci && (name1 <=? name2)))
|
||||
return -1
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:compare_by_line(tag1, tag2) abort
|
||||
return a:tag1.fields.line - a:tag2.fields.line
|
||||
endfunction
|
||||
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
51
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar/state.vim
Normal file
51
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar/state.vim
Normal file
@ -0,0 +1,51 @@
|
||||
function! tagbar#state#get_current_file(force_current) abort
|
||||
return s:get().getCurrent(a:force_current)
|
||||
endfunction
|
||||
|
||||
function! tagbar#state#set_current_file(fileinfo) abort
|
||||
call s:get().setCurrentFile(a:fileinfo)
|
||||
endfunction
|
||||
|
||||
function! tagbar#state#set_paused() abort
|
||||
call s:get().setPaused()
|
||||
endfunction
|
||||
|
||||
function! s:get() abort
|
||||
if !exists('t:tagbar_state')
|
||||
let t:tagbar_state = s:State.New()
|
||||
endif
|
||||
|
||||
return t:tagbar_state
|
||||
endfunction
|
||||
|
||||
let s:State = {
|
||||
\ '_current' : {},
|
||||
\ '_paused' : {},
|
||||
\ }
|
||||
|
||||
" s:state.New() {{{1
|
||||
function! s:State.New() abort dict
|
||||
return deepcopy(self)
|
||||
endfunction
|
||||
|
||||
" s:state.getCurrent() {{{1
|
||||
function! s:State.getCurrent(force_current) abort dict
|
||||
if !tagbar#is_paused() || a:force_current
|
||||
return self._current
|
||||
else
|
||||
return self._paused
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:state.setCurrentFile() {{{1
|
||||
function! s:State.setCurrentFile(fileinfo) abort dict
|
||||
let self._current = a:fileinfo
|
||||
endfunction
|
||||
|
||||
" s:state.setPaused() {{{1
|
||||
function! s:State.setPaused() abort dict
|
||||
let self._paused = self._current
|
||||
endfunction
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
@ -0,0 +1,773 @@
|
||||
" Type definitions for standard Exuberant Ctags
|
||||
|
||||
function! tagbar#types#ctags#init(supported_types) abort
|
||||
let types = {}
|
||||
|
||||
" Ant {{{1
|
||||
let type_ant = tagbar#prototypes#typeinfo#new()
|
||||
let type_ant.ctagstype = 'ant'
|
||||
let type_ant.kinds = [
|
||||
\ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.ant = type_ant
|
||||
" Asm {{{1
|
||||
let type_asm = tagbar#prototypes#typeinfo#new()
|
||||
let type_asm.ctagstype = 'asm'
|
||||
let type_asm.kinds = [
|
||||
\ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.asm = type_asm
|
||||
" ASP {{{1
|
||||
let type_aspvbs = tagbar#prototypes#typeinfo#new()
|
||||
let type_aspvbs.ctagstype = 'asp'
|
||||
let type_aspvbs.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.aspvbs = type_aspvbs
|
||||
" Asymptote {{{1
|
||||
" Asymptote gets parsed well using filetype = c
|
||||
let type_asy = tagbar#prototypes#typeinfo#new()
|
||||
let type_asy.ctagstype = 'c'
|
||||
let type_asy.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_asy.sro = '::'
|
||||
let type_asy.kind2scope = {
|
||||
\ 'g' : 'enum',
|
||||
\ 's' : 'struct',
|
||||
\ 'u' : 'union'
|
||||
\ }
|
||||
let type_asy.scope2kind = {
|
||||
\ 'enum' : 'g',
|
||||
\ 'struct' : 's',
|
||||
\ 'union' : 'u'
|
||||
\ }
|
||||
let types.asy = type_asy
|
||||
" Awk {{{1
|
||||
let type_awk = tagbar#prototypes#typeinfo#new()
|
||||
let type_awk.ctagstype = 'awk'
|
||||
let type_awk.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.awk = type_awk
|
||||
" Basic {{{1
|
||||
let type_basic = tagbar#prototypes#typeinfo#new()
|
||||
let type_basic.ctagstype = 'basic'
|
||||
let type_basic.kinds = [
|
||||
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.basic = type_basic
|
||||
" BETA {{{1
|
||||
let type_beta = tagbar#prototypes#typeinfo#new()
|
||||
let type_beta.ctagstype = 'beta'
|
||||
let type_beta.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.beta = type_beta
|
||||
" C {{{1
|
||||
let type_c = tagbar#prototypes#typeinfo#new()
|
||||
let type_c.ctagstype = 'c'
|
||||
let type_c.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_c.sro = '::'
|
||||
let type_c.kind2scope = {
|
||||
\ 'g' : 'enum',
|
||||
\ 's' : 'struct',
|
||||
\ 'u' : 'union'
|
||||
\ }
|
||||
let type_c.scope2kind = {
|
||||
\ 'enum' : 'g',
|
||||
\ 'struct' : 's',
|
||||
\ 'union' : 'u'
|
||||
\ }
|
||||
let types.c = type_c
|
||||
" C++ {{{1
|
||||
let type_cpp = tagbar#prototypes#typeinfo#new()
|
||||
let type_cpp.ctagstype = 'c++'
|
||||
let type_cpp.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_cpp.sro = '::'
|
||||
let type_cpp.kind2scope = {
|
||||
\ 'g' : 'enum',
|
||||
\ 'n' : 'namespace',
|
||||
\ 'c' : 'class',
|
||||
\ 's' : 'struct',
|
||||
\ 'u' : 'union'
|
||||
\ }
|
||||
let type_cpp.scope2kind = {
|
||||
\ 'enum' : 'g',
|
||||
\ 'namespace' : 'n',
|
||||
\ 'class' : 'c',
|
||||
\ 'struct' : 's',
|
||||
\ 'union' : 'u'
|
||||
\ }
|
||||
let types.cpp = type_cpp
|
||||
let types.cuda = type_cpp
|
||||
" C# {{{1
|
||||
let type_cs = tagbar#prototypes#typeinfo#new()
|
||||
let type_cs.ctagstype = 'c#'
|
||||
let type_cs.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_cs.sro = '.'
|
||||
let type_cs.kind2scope = {
|
||||
\ 'n' : 'namespace',
|
||||
\ 'i' : 'interface',
|
||||
\ 'c' : 'class',
|
||||
\ 's' : 'struct',
|
||||
\ 'g' : 'enum'
|
||||
\ }
|
||||
let type_cs.scope2kind = {
|
||||
\ 'namespace' : 'n',
|
||||
\ 'interface' : 'i',
|
||||
\ 'class' : 'c',
|
||||
\ 'struct' : 's',
|
||||
\ 'enum' : 'g'
|
||||
\ }
|
||||
let types.cs = type_cs
|
||||
" COBOL {{{1
|
||||
let type_cobol = tagbar#prototypes#typeinfo#new()
|
||||
let type_cobol.ctagstype = 'cobol'
|
||||
let type_cobol.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.cobol = type_cobol
|
||||
" DOS Batch {{{1
|
||||
let type_dosbatch = tagbar#prototypes#typeinfo#new()
|
||||
let type_dosbatch.ctagstype = 'dosbatch'
|
||||
let type_dosbatch.kinds = [
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.dosbatch = type_dosbatch
|
||||
" Eiffel {{{1
|
||||
let type_eiffel = tagbar#prototypes#typeinfo#new()
|
||||
let type_eiffel.ctagstype = 'eiffel'
|
||||
let type_eiffel.kinds = [
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_eiffel.sro = '.' " Not sure, is nesting even possible?
|
||||
let type_eiffel.kind2scope = {
|
||||
\ 'c' : 'class',
|
||||
\ 'f' : 'feature'
|
||||
\ }
|
||||
let type_eiffel.scope2kind = {
|
||||
\ 'class' : 'c',
|
||||
\ 'feature' : 'f'
|
||||
\ }
|
||||
let types.eiffel = type_eiffel
|
||||
" Erlang {{{1
|
||||
let type_erlang = tagbar#prototypes#typeinfo#new()
|
||||
let type_erlang.ctagstype = 'erlang'
|
||||
let type_erlang.kinds = [
|
||||
\ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_erlang.sro = '.' " Not sure, is nesting even possible?
|
||||
let type_erlang.kind2scope = {
|
||||
\ 'm' : 'module'
|
||||
\ }
|
||||
let type_erlang.scope2kind = {
|
||||
\ 'module' : 'm'
|
||||
\ }
|
||||
let types.erlang = type_erlang
|
||||
" Flex {{{1
|
||||
" Vim doesn't support Flex out of the box, this is based on rough
|
||||
" guesses and probably requires
|
||||
" http://www.vim.org/scripts/script.php?script_id=2909
|
||||
" Improvements welcome!
|
||||
let type_as = tagbar#prototypes#typeinfo#new()
|
||||
let type_as.ctagstype = 'flex'
|
||||
let type_as.kinds = [
|
||||
\ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_as.sro = '.'
|
||||
let type_as.kind2scope = {
|
||||
\ 'c' : 'class'
|
||||
\ }
|
||||
let type_as.scope2kind = {
|
||||
\ 'class' : 'c'
|
||||
\ }
|
||||
let types.mxml = type_as
|
||||
let types.actionscript = type_as
|
||||
" Fortran {{{1
|
||||
let type_fortran = tagbar#prototypes#typeinfo#new()
|
||||
let type_fortran.ctagstype = 'fortran'
|
||||
let type_fortran.kinds = [
|
||||
\ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0,
|
||||
\ 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_fortran.sro = '.' " Not sure, is nesting even possible?
|
||||
let type_fortran.kind2scope = {
|
||||
\ 'm' : 'module',
|
||||
\ 'p' : 'program',
|
||||
\ 'f' : 'function',
|
||||
\ 's' : 'subroutine'
|
||||
\ }
|
||||
let type_fortran.scope2kind = {
|
||||
\ 'module' : 'm',
|
||||
\ 'program' : 'p',
|
||||
\ 'function' : 'f',
|
||||
\ 'subroutine' : 's'
|
||||
\ }
|
||||
let types.fortran = type_fortran
|
||||
" Go {{{1
|
||||
let type_go = tagbar#prototypes#typeinfo#new()
|
||||
let type_go.ctagstype = 'go'
|
||||
let type_go.kinds = [
|
||||
\ {'short' : 'p', 'long' : 'packages', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'struct members', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_go.sro = '.'
|
||||
let type_go.kind2scope = {
|
||||
\ 's' : 'struct'
|
||||
\ }
|
||||
let type_go.scope2kind = {
|
||||
\ 'struct' : 's'
|
||||
\ }
|
||||
let types.go = type_go
|
||||
" HTML {{{1
|
||||
let type_html = tagbar#prototypes#typeinfo#new()
|
||||
let type_html.ctagstype = 'html'
|
||||
let type_html.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'JavaScript functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.html = type_html
|
||||
" Java {{{1
|
||||
let type_java = tagbar#prototypes#typeinfo#new()
|
||||
let type_java.ctagstype = 'java'
|
||||
let type_java.kinds = [
|
||||
\ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_java.sro = '.'
|
||||
let type_java.kind2scope = {
|
||||
\ 'g' : 'enum',
|
||||
\ 'i' : 'interface',
|
||||
\ 'c' : 'class'
|
||||
\ }
|
||||
let type_java.scope2kind = {
|
||||
\ 'enum' : 'g',
|
||||
\ 'interface' : 'i',
|
||||
\ 'class' : 'c'
|
||||
\ }
|
||||
let types.java = type_java
|
||||
" JavaScript {{{1
|
||||
let type_javascript = tagbar#prototypes#typeinfo#new()
|
||||
let type_javascript.ctagstype = 'javascript'
|
||||
let type_javascript.kinds = [
|
||||
\ {'short': 'v', 'long': 'global variables', 'fold': 0, 'stl': 0},
|
||||
\ {'short': 'c', 'long': 'classes', 'fold': 0, 'stl': 1},
|
||||
\ {'short': 'p', 'long': 'properties', 'fold': 0, 'stl': 0},
|
||||
\ {'short': 'm', 'long': 'methods', 'fold': 0, 'stl': 1},
|
||||
\ {'short': 'f', 'long': 'functions', 'fold': 0, 'stl': 1},
|
||||
\ ]
|
||||
let type_javascript.sro = '.'
|
||||
let type_javascript.kind2scope = {
|
||||
\ 'c' : 'class',
|
||||
\ 'f' : 'function',
|
||||
\ 'm' : 'method',
|
||||
\ 'p' : 'property',
|
||||
\ }
|
||||
let type_javascript.scope2kind = {
|
||||
\ 'class' : 'c',
|
||||
\ 'function' : 'f',
|
||||
\ }
|
||||
let types.javascript = type_javascript
|
||||
" Lisp {{{1
|
||||
let type_lisp = tagbar#prototypes#typeinfo#new()
|
||||
let type_lisp.ctagstype = 'lisp'
|
||||
let type_lisp.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.lisp = type_lisp
|
||||
let types.clojure = type_lisp
|
||||
" Lua {{{1
|
||||
let type_lua = tagbar#prototypes#typeinfo#new()
|
||||
let type_lua.ctagstype = 'lua'
|
||||
let type_lua.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.lua = type_lua
|
||||
" Make {{{1
|
||||
let type_make = tagbar#prototypes#typeinfo#new()
|
||||
let type_make.ctagstype = 'make'
|
||||
let type_make.kinds = [
|
||||
\ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.make = type_make
|
||||
" Matlab {{{1
|
||||
let type_matlab = tagbar#prototypes#typeinfo#new()
|
||||
let type_matlab.ctagstype = 'matlab'
|
||||
let type_matlab.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.matlab = type_matlab
|
||||
" ObjectiveC {{{1
|
||||
let type_objc = tagbar#prototypes#typeinfo#new()
|
||||
let type_objc.ctagstype = 'objectivec'
|
||||
let type_objc.kinds = [
|
||||
\ {'short' : 'M', 'long' : 'preprocessor macros', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'i', 'long' : 'class interfaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'I', 'long' : 'class implementations', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'class methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'F', 'long' : 'object fields', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'm', 'long' : 'object methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'type structures', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'type aliases', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 0},
|
||||
\ ]
|
||||
let type_objc.sro = ':'
|
||||
let type_objc.kind2scope = {
|
||||
\ 'i' : 'interface',
|
||||
\ 'I' : 'implementation',
|
||||
\ 's' : 'struct',
|
||||
\ }
|
||||
let type_objc.scope2kind = {
|
||||
\ 'interface' : 'i',
|
||||
\ 'implementation' : 'I',
|
||||
\ 'struct' : 's',
|
||||
\ }
|
||||
let types.objc = type_objc
|
||||
let types.objcpp = type_objc
|
||||
" Ocaml {{{1
|
||||
let type_ocaml = tagbar#prototypes#typeinfo#new()
|
||||
let type_ocaml.ctagstype = 'ocaml'
|
||||
let type_ocaml.kinds = [
|
||||
\ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_ocaml.sro = '.' " Not sure, is nesting even possible?
|
||||
let type_ocaml.kind2scope = {
|
||||
\ 'M' : 'Module',
|
||||
\ 'c' : 'class',
|
||||
\ 't' : 'type'
|
||||
\ }
|
||||
let type_ocaml.scope2kind = {
|
||||
\ 'Module' : 'M',
|
||||
\ 'class' : 'c',
|
||||
\ 'type' : 't'
|
||||
\ }
|
||||
let types.ocaml = type_ocaml
|
||||
" Pascal {{{1
|
||||
let type_pascal = tagbar#prototypes#typeinfo#new()
|
||||
let type_pascal.ctagstype = 'pascal'
|
||||
let type_pascal.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.pascal = type_pascal
|
||||
" Perl {{{1
|
||||
let type_perl = tagbar#prototypes#typeinfo#new()
|
||||
let type_perl.ctagstype = 'perl'
|
||||
let type_perl.kinds = [
|
||||
\ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.perl = type_perl
|
||||
" PHP {{{1
|
||||
let type_php = tagbar#prototypes#typeinfo#new()
|
||||
let type_php.ctagstype = 'php'
|
||||
let type_php.kinds = [
|
||||
\ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.php = type_php
|
||||
" Python {{{1
|
||||
let type_python = tagbar#prototypes#typeinfo#new()
|
||||
let type_python.ctagstype = 'python'
|
||||
let type_python.kinds = [
|
||||
\ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_python.sro = '.'
|
||||
let type_python.kind2scope = {
|
||||
\ 'c' : 'class',
|
||||
\ 'f' : 'function',
|
||||
\ 'm' : 'function'
|
||||
\ }
|
||||
let type_python.scope2kind = {
|
||||
\ 'class' : 'c',
|
||||
\ 'function' : 'f'
|
||||
\ }
|
||||
let types.python = type_python
|
||||
let types.pyrex = type_python
|
||||
let types.cython = type_python
|
||||
" REXX {{{1
|
||||
let type_rexx = tagbar#prototypes#typeinfo#new()
|
||||
let type_rexx.ctagstype = 'rexx'
|
||||
let type_rexx.kinds = [
|
||||
\ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.rexx = type_rexx
|
||||
" Ruby {{{1
|
||||
let type_ruby = tagbar#prototypes#typeinfo#new()
|
||||
let type_ruby.ctagstype = 'ruby'
|
||||
let type_ruby.kinds = [
|
||||
\ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_ruby.sro = '.'
|
||||
let type_ruby.kind2scope = {
|
||||
\ 'c' : 'class',
|
||||
\ 'm' : 'class',
|
||||
\ 'f' : 'class'
|
||||
\ }
|
||||
let type_ruby.scope2kind = {
|
||||
\ 'class' : 'c'
|
||||
\ }
|
||||
let types.ruby = type_ruby
|
||||
" Scheme {{{1
|
||||
let type_scheme = tagbar#prototypes#typeinfo#new()
|
||||
let type_scheme.ctagstype = 'scheme'
|
||||
let type_scheme.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.scheme = type_scheme
|
||||
let types.racket = type_scheme
|
||||
" Shell script {{{1
|
||||
let type_sh = tagbar#prototypes#typeinfo#new()
|
||||
let type_sh.ctagstype = 'sh'
|
||||
let type_sh.kinds = [
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.sh = type_sh
|
||||
let types.csh = type_sh
|
||||
let types.zsh = type_sh
|
||||
" SLang {{{1
|
||||
let type_slang = tagbar#prototypes#typeinfo#new()
|
||||
let type_slang.ctagstype = 'slang'
|
||||
let type_slang.kinds = [
|
||||
\ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.slang = type_slang
|
||||
" SML {{{1
|
||||
let type_sml = tagbar#prototypes#typeinfo#new()
|
||||
let type_sml.ctagstype = 'sml'
|
||||
let type_sml.kinds = [
|
||||
\ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let types.sml = type_sml
|
||||
" SQL {{{1
|
||||
" The SQL ctags parser seems to be buggy for me, so this just uses the
|
||||
" normal kinds even though scopes should be available. Improvements
|
||||
" welcome!
|
||||
let type_sql = tagbar#prototypes#typeinfo#new()
|
||||
let type_sql.ctagstype = 'sql'
|
||||
let type_sql.kinds = [
|
||||
\ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1},
|
||||
\ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.sql = type_sql
|
||||
" Tcl {{{1
|
||||
let type_tcl = tagbar#prototypes#typeinfo#new()
|
||||
let type_tcl.ctagstype = 'tcl'
|
||||
let type_tcl.kinds = [
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.tcl = type_tcl
|
||||
" LaTeX {{{1
|
||||
let type_tex = tagbar#prototypes#typeinfo#new()
|
||||
let type_tex.ctagstype = 'tex'
|
||||
let type_tex.kinds = [
|
||||
\ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_tex.sro = '""'
|
||||
let type_tex.kind2scope = {
|
||||
\ 'p' : 'part',
|
||||
\ 'c' : 'chapter',
|
||||
\ 's' : 'section',
|
||||
\ 'u' : 'subsection',
|
||||
\ 'b' : 'subsubsection'
|
||||
\ }
|
||||
let type_tex.scope2kind = {
|
||||
\ 'part' : 'p',
|
||||
\ 'chapter' : 'c',
|
||||
\ 'section' : 's',
|
||||
\ 'subsection' : 'u',
|
||||
\ 'subsubsection' : 'b'
|
||||
\ }
|
||||
let type_tex.sort = 0
|
||||
let types.tex = type_tex
|
||||
" Vala {{{1
|
||||
" Vala is supported by the ctags fork provided by Anjuta, so only add the
|
||||
" type if the fork is used to prevent error messages otherwise
|
||||
if has_key(a:supported_types, 'vala') || executable('anjuta-tags')
|
||||
let type_vala = tagbar#prototypes#typeinfo#new()
|
||||
let type_vala.ctagstype = 'vala'
|
||||
let type_vala.kinds = [
|
||||
\ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_vala.sro = '.'
|
||||
" 'enum' doesn't seem to be used as a scope, but it can't hurt to have
|
||||
" it here
|
||||
let type_vala.kind2scope = {
|
||||
\ 's' : 'struct',
|
||||
\ 'i' : 'interface',
|
||||
\ 'c' : 'class',
|
||||
\ 'e' : 'enum'
|
||||
\ }
|
||||
let type_vala.scope2kind = {
|
||||
\ 'struct' : 's',
|
||||
\ 'interface' : 'i',
|
||||
\ 'class' : 'c',
|
||||
\ 'enum' : 'e'
|
||||
\ }
|
||||
let types.vala = type_vala
|
||||
endif
|
||||
if !has_key(a:supported_types, 'vala') && executable('anjuta-tags')
|
||||
let types.vala.ctagsbin = 'anjuta-tags'
|
||||
endif
|
||||
" Vera {{{1
|
||||
" Why are variables 'virtual'?
|
||||
let type_vera = tagbar#prototypes#typeinfo#new()
|
||||
let type_vera.ctagstype = 'vera'
|
||||
let type_vera.kinds = [
|
||||
\ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let type_vera.sro = '.' " Nesting doesn't seem to be possible
|
||||
let type_vera.kind2scope = {
|
||||
\ 'g' : 'enum',
|
||||
\ 'c' : 'class',
|
||||
\ 'v' : 'virtual'
|
||||
\ }
|
||||
let type_vera.scope2kind = {
|
||||
\ 'enum' : 'g',
|
||||
\ 'class' : 'c',
|
||||
\ 'virtual' : 'v'
|
||||
\ }
|
||||
let types.vera = type_vera
|
||||
" Verilog {{{1
|
||||
let type_verilog = tagbar#prototypes#typeinfo#new()
|
||||
let type_verilog.ctagstype = 'verilog'
|
||||
let type_verilog.kinds = [
|
||||
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.verilog = type_verilog
|
||||
" VHDL {{{1
|
||||
" The VHDL ctags parser unfortunately doesn't generate proper scopes
|
||||
let type_vhdl = tagbar#prototypes#typeinfo#new()
|
||||
let type_vhdl.ctagstype = 'vhdl'
|
||||
let type_vhdl.kinds = [
|
||||
\ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.vhdl = type_vhdl
|
||||
" Vim {{{1
|
||||
let type_vim = tagbar#prototypes#typeinfo#new()
|
||||
let type_vim.ctagstype = 'vim'
|
||||
let type_vim.kinds = [
|
||||
\ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0}
|
||||
\ ]
|
||||
let types.vim = type_vim
|
||||
" YACC {{{1
|
||||
let type_yacc = tagbar#prototypes#typeinfo#new()
|
||||
let type_yacc.ctagstype = 'yacc'
|
||||
let type_yacc.kinds = [
|
||||
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let types.yacc = type_yacc
|
||||
" }}}1
|
||||
|
||||
for [type, typeinfo] in items(types)
|
||||
let typeinfo.ftype = type
|
||||
endfor
|
||||
|
||||
for typeinfo in values(types)
|
||||
call typeinfo.createKinddict()
|
||||
endfor
|
||||
|
||||
return types
|
||||
endfunction
|
||||
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
1124
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar/types/uctags.vim
Normal file
1124
.vim/pack/plugins/start/vim-tagbar/autoload/tagbar/types/uctags.vim
Normal file
File diff suppressed because it is too large
Load Diff
1622
.vim/pack/plugins/start/vim-tagbar/doc/tagbar.txt
Normal file
1622
.vim/pack/plugins/start/vim-tagbar/doc/tagbar.txt
Normal file
File diff suppressed because it is too large
Load Diff
62
.vim/pack/plugins/start/vim-tagbar/doc/tags
Normal file
62
.vim/pack/plugins/start/vim-tagbar/doc/tags
Normal file
@ -0,0 +1,62 @@
|
||||
:TagbarClose tagbar.txt /*:TagbarClose*
|
||||
:TagbarCurrentTag tagbar.txt /*:TagbarCurrentTag*
|
||||
:TagbarDebug tagbar.txt /*:TagbarDebug*
|
||||
:TagbarDebugEnd tagbar.txt /*:TagbarDebugEnd*
|
||||
:TagbarGetTypeConfig tagbar.txt /*:TagbarGetTypeConfig*
|
||||
:TagbarOpen tagbar.txt /*:TagbarOpen*
|
||||
:TagbarOpenAutoClose tagbar.txt /*:TagbarOpenAutoClose*
|
||||
:TagbarSetFoldlevel tagbar.txt /*:TagbarSetFoldlevel*
|
||||
:TagbarShowTag tagbar.txt /*:TagbarShowTag*
|
||||
:TagbarToggle tagbar.txt /*:TagbarToggle*
|
||||
:TagbarTogglePause tagbar.txt /*:TagbarTogglePause*
|
||||
g:tagbar_autoclose tagbar.txt /*g:tagbar_autoclose*
|
||||
g:tagbar_autofocus tagbar.txt /*g:tagbar_autofocus*
|
||||
g:tagbar_autopreview tagbar.txt /*g:tagbar_autopreview*
|
||||
g:tagbar_autoshowtag tagbar.txt /*g:tagbar_autoshowtag*
|
||||
g:tagbar_case_insensitive tagbar.txt /*g:tagbar_case_insensitive*
|
||||
g:tagbar_compact tagbar.txt /*g:tagbar_compact*
|
||||
g:tagbar_ctags_bin tagbar.txt /*g:tagbar_ctags_bin*
|
||||
g:tagbar_ctags_options tagbar.txt /*g:tagbar_ctags_options*
|
||||
g:tagbar_expand tagbar.txt /*g:tagbar_expand*
|
||||
g:tagbar_foldlevel tagbar.txt /*g:tagbar_foldlevel*
|
||||
g:tagbar_hide_nonpublic tagbar.txt /*g:tagbar_hide_nonpublic*
|
||||
g:tagbar_iconchars tagbar.txt /*g:tagbar_iconchars*
|
||||
g:tagbar_indent tagbar.txt /*g:tagbar_indent*
|
||||
g:tagbar_left tagbar.txt /*g:tagbar_left*
|
||||
g:tagbar_previewwin_pos tagbar.txt /*g:tagbar_previewwin_pos*
|
||||
g:tagbar_show_balloon tagbar.txt /*g:tagbar_show_balloon*
|
||||
g:tagbar_show_linenumbers tagbar.txt /*g:tagbar_show_linenumbers*
|
||||
g:tagbar_show_visibility tagbar.txt /*g:tagbar_show_visibility*
|
||||
g:tagbar_silent tagbar.txt /*g:tagbar_silent*
|
||||
g:tagbar_singleclick tagbar.txt /*g:tagbar_singleclick*
|
||||
g:tagbar_sort tagbar.txt /*g:tagbar_sort*
|
||||
g:tagbar_status_func tagbar.txt /*g:tagbar_status_func*
|
||||
g:tagbar_systemenc tagbar.txt /*g:tagbar_systemenc*
|
||||
g:tagbar_updateonsave_maxlines tagbar.txt /*g:tagbar_updateonsave_maxlines*
|
||||
g:tagbar_vertical tagbar.txt /*g:tagbar_vertical*
|
||||
g:tagbar_width tagbar.txt /*g:tagbar_width*
|
||||
g:tagbar_zoomwidth tagbar.txt /*g:tagbar_zoomwidth*
|
||||
tagbar tagbar.txt /*tagbar*
|
||||
tagbar#StopAutoUpdate() tagbar.txt /*tagbar#StopAutoUpdate()*
|
||||
tagbar-autoopen tagbar.txt /*tagbar-autoopen*
|
||||
tagbar-commands tagbar.txt /*tagbar-commands*
|
||||
tagbar-configuration tagbar.txt /*tagbar-configuration*
|
||||
tagbar-contents tagbar.txt /*tagbar-contents*
|
||||
tagbar-credits tagbar.txt /*tagbar-credits*
|
||||
tagbar-extend tagbar.txt /*tagbar-extend*
|
||||
tagbar-features tagbar.txt /*tagbar-features*
|
||||
tagbar-functions tagbar.txt /*tagbar-functions*
|
||||
tagbar-highlight tagbar.txt /*tagbar-highlight*
|
||||
tagbar-history tagbar.txt /*tagbar-history*
|
||||
tagbar-ignore tagbar.txt /*tagbar-ignore*
|
||||
tagbar-installation tagbar.txt /*tagbar-installation*
|
||||
tagbar-intro tagbar.txt /*tagbar-intro*
|
||||
tagbar-issues tagbar.txt /*tagbar-issues*
|
||||
tagbar-keys tagbar.txt /*tagbar-keys*
|
||||
tagbar-other tagbar.txt /*tagbar-other*
|
||||
tagbar-pseudotags tagbar.txt /*tagbar-pseudotags*
|
||||
tagbar-requirements tagbar.txt /*tagbar-requirements*
|
||||
tagbar-statusline tagbar.txt /*tagbar-statusline*
|
||||
tagbar-todo tagbar.txt /*tagbar-todo*
|
||||
tagbar-usage tagbar.txt /*tagbar-usage*
|
||||
tagbar.txt tagbar.txt /*tagbar.txt*
|
153
.vim/pack/plugins/start/vim-tagbar/plugin/tagbar.vim
Normal file
153
.vim/pack/plugins/start/vim-tagbar/plugin/tagbar.vim
Normal file
@ -0,0 +1,153 @@
|
||||
" ============================================================================
|
||||
" File: tagbar.vim
|
||||
" Description: List the current file's tags in a sidebar, ordered by class etc
|
||||
" Author: Jan Larres <jan@majutsushi.net>
|
||||
" Licence: Vim licence
|
||||
" Website: http://majutsushi.github.com/tagbar/
|
||||
" Version: 2.7
|
||||
" Note: This plugin was heavily inspired by the 'Taglist' plugin by
|
||||
" Yegappan Lakshmanan and uses a small amount of code from it.
|
||||
"
|
||||
" Original taglist copyright notice:
|
||||
" Permission is hereby granted to use and distribute this code,
|
||||
" with or without modifications, provided that this copyright
|
||||
" notice is copied with it. Like anything else that's free,
|
||||
" taglist.vim is provided *as is* and comes with no warranty of
|
||||
" any kind, either expressed or implied. In no event will the
|
||||
" copyright holder be liable for any damamges resulting from the
|
||||
" use of this software.
|
||||
" ============================================================================
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
if &compatible || exists('g:loaded_tagbar')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Basic init {{{1
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg
|
||||
echomsg 'Tagbar: Vim version is too old, Tagbar requires at least 7.0'
|
||||
echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version == 700 && !has('patch167')
|
||||
echohl WarningMsg
|
||||
echomsg 'Tagbar: Vim versions lower than 7.0.167 have a bug'
|
||||
\ 'that prevents this version of Tagbar from working.'
|
||||
\ 'Please use the alternate version posted on the website.'
|
||||
echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:init_var(var, value) abort
|
||||
if !exists('g:tagbar_' . a:var)
|
||||
execute 'let g:tagbar_' . a:var . ' = ' . string(a:value)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:setup_options() abort
|
||||
if !exists('g:tagbar_vertical') || g:tagbar_vertical == 0
|
||||
let previewwin_pos = 'topleft'
|
||||
else
|
||||
let previewwin_pos = 'rightbelow vertical'
|
||||
endif
|
||||
let options = [
|
||||
\ ['autoclose', 0],
|
||||
\ ['autofocus', 0],
|
||||
\ ['autopreview', 0],
|
||||
\ ['autoshowtag', 0],
|
||||
\ ['case_insensitive', 0],
|
||||
\ ['compact', 0],
|
||||
\ ['expand', 0],
|
||||
\ ['foldlevel', 99],
|
||||
\ ['hide_nonpublic', 0],
|
||||
\ ['indent', 2],
|
||||
\ ['left', 0],
|
||||
\ ['previewwin_pos', previewwin_pos],
|
||||
\ ['show_balloon', 1],
|
||||
\ ['show_visibility', 1],
|
||||
\ ['show_linenumbers', 0],
|
||||
\ ['singleclick', 0],
|
||||
\ ['sort', 1],
|
||||
\ ['systemenc', &encoding],
|
||||
\ ['vertical', 0],
|
||||
\ ['width', 40],
|
||||
\ ['zoomwidth', 1],
|
||||
\ ['silent', 0],
|
||||
\ ]
|
||||
|
||||
for [opt, val] in options
|
||||
call s:init_var(opt, val)
|
||||
endfor
|
||||
endfunction
|
||||
call s:setup_options()
|
||||
|
||||
if !exists('g:tagbar_iconchars')
|
||||
if has('multi_byte') && has('unix') && &encoding ==# 'utf-8' &&
|
||||
\ (!exists('+termencoding') || empty(&termencoding) || &termencoding ==# 'utf-8')
|
||||
let g:tagbar_iconchars = ['▶', '▼']
|
||||
else
|
||||
let g:tagbar_iconchars = ['+', '-']
|
||||
endif
|
||||
endif
|
||||
|
||||
function! s:setup_keymaps() abort
|
||||
let keymaps = [
|
||||
\ ['jump', '<CR>'],
|
||||
\ ['preview', 'p'],
|
||||
\ ['previewwin', 'P'],
|
||||
\ ['nexttag', '<C-N>'],
|
||||
\ ['prevtag', '<C-P>'],
|
||||
\ ['showproto', '<Space>'],
|
||||
\ ['hidenonpublic', 'v'],
|
||||
\
|
||||
\ ['openfold', ['+', '<kPlus>', 'zo']],
|
||||
\ ['closefold', ['-', '<kMinus>', 'zc']],
|
||||
\ ['togglefold', ['o', 'za']],
|
||||
\ ['openallfolds', ['*', '<kMultiply>', 'zR']],
|
||||
\ ['closeallfolds', ['=', 'zM']],
|
||||
\ ['incrementfolds', ['zr']],
|
||||
\ ['decrementfolds', ['zm']],
|
||||
\ ['nextfold', 'zj'],
|
||||
\ ['prevfold', 'zk'],
|
||||
\
|
||||
\ ['togglesort', 's'],
|
||||
\ ['togglecaseinsensitive', 'i'],
|
||||
\ ['toggleautoclose', 'c'],
|
||||
\ ['togglepause', 't'],
|
||||
\ ['zoomwin', 'x'],
|
||||
\ ['close', 'q'],
|
||||
\ ['help', ['<F1>', '?']],
|
||||
\ ]
|
||||
|
||||
for [map, key] in keymaps
|
||||
call s:init_var('map_' . map, key)
|
||||
unlet key
|
||||
endfor
|
||||
endfunction
|
||||
call s:setup_keymaps()
|
||||
|
||||
augroup TagbarSession
|
||||
autocmd!
|
||||
autocmd SessionLoadPost * nested call tagbar#RestoreSession()
|
||||
augroup END
|
||||
|
||||
" Commands {{{1
|
||||
command! -nargs=0 Tagbar call tagbar#ToggleWindow()
|
||||
command! -nargs=0 TagbarToggle call tagbar#ToggleWindow()
|
||||
command! -nargs=? TagbarOpen call tagbar#OpenWindow(<f-args>)
|
||||
command! -nargs=0 TagbarOpenAutoClose call tagbar#OpenWindow('fcj')
|
||||
command! -nargs=0 TagbarClose call tagbar#CloseWindow()
|
||||
command! -nargs=1 -bang TagbarSetFoldlevel call tagbar#SetFoldLevel(<args>, <bang>0)
|
||||
command! -nargs=0 TagbarShowTag call tagbar#highlighttag(1, 1)
|
||||
command! -nargs=? TagbarCurrentTag echo tagbar#currenttag('%s', 'No current tag', <f-args>)
|
||||
command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig(<f-args>)
|
||||
command! -nargs=? TagbarDebug call tagbar#debug#start_debug(<f-args>)
|
||||
command! -nargs=0 TagbarDebugEnd call tagbar#debug#stop_debug()
|
||||
command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause()
|
||||
|
||||
" Modeline {{{1
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
64
.vim/pack/plugins/start/vim-tagbar/syntax/tagbar.vim
Normal file
64
.vim/pack/plugins/start/vim-tagbar/syntax/tagbar.vim
Normal file
@ -0,0 +1,64 @@
|
||||
" File: tagbar.vim
|
||||
" Description: Tagbar syntax settings
|
||||
" Author: Jan Larres <jan@majutsushi.net>
|
||||
" Licence: Vim licence
|
||||
" Website: http://majutsushi.github.com/tagbar/
|
||||
" Version: 2.7
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:ics = escape(join(g:tagbar_iconchars, ''), ']^\-')
|
||||
|
||||
let s:pattern = '\(^[' . s:ics . '] \?\)\@3<=[^-+: ]\+[^:]\+$'
|
||||
execute "syntax match TagbarKind '" . s:pattern . "'"
|
||||
|
||||
let s:pattern = '\(\S\@<![' . s:ics . '][-+# ]\?\)\@<=[^*(]\+\(\*\?\(([^)]\+)\)\? :\)\@='
|
||||
execute "syntax match TagbarScope '" . s:pattern . "'"
|
||||
|
||||
let s:pattern = '\S\@<![' . s:ics . ']\([-+# ]\?\)\@='
|
||||
execute "syntax match TagbarFoldIcon '" . s:pattern . "'"
|
||||
|
||||
let s:pattern = '\(\S\@<![' . s:ics . ' ]\)\@<=+\([^-+# ]\)\@='
|
||||
execute "syntax match TagbarVisibilityPublic '" . s:pattern . "'"
|
||||
let s:pattern = '\(\S\@<![' . s:ics . ' ]\)\@<=#\([^-+# ]\)\@='
|
||||
execute "syntax match TagbarVisibilityProtected '" . s:pattern . "'"
|
||||
let s:pattern = '\(\S\@<![' . s:ics . ' ]\)\@<=-\([^-+# ]\)\@='
|
||||
execute "syntax match TagbarVisibilityPrivate '" . s:pattern . "'"
|
||||
|
||||
unlet s:pattern
|
||||
|
||||
syntax match TagbarHelp '^".*' contains=TagbarHelpKey,TagbarHelpTitle
|
||||
syntax match TagbarHelpKey '" \zs.*\ze:' contained
|
||||
syntax match TagbarHelpTitle '" \zs-\+ \w\+ -\+' contained
|
||||
|
||||
syntax match TagbarNestedKind '^\s\+\[[^]]\+\]$'
|
||||
syntax match TagbarType ' : \zs.*'
|
||||
syntax match TagbarSignature '(.*)'
|
||||
syntax match TagbarPseudoID '\*\ze :'
|
||||
|
||||
highlight default link TagbarHelp Comment
|
||||
highlight default link TagbarHelpKey Identifier
|
||||
highlight default link TagbarHelpTitle PreProc
|
||||
highlight default link TagbarKind Identifier
|
||||
highlight default link TagbarNestedKind TagbarKind
|
||||
highlight default link TagbarScope Title
|
||||
highlight default link TagbarType Type
|
||||
highlight default link TagbarSignature SpecialKey
|
||||
highlight default link TagbarPseudoID NonText
|
||||
highlight default link TagbarFoldIcon Statement
|
||||
highlight default link TagbarHighlight Search
|
||||
|
||||
highlight default TagbarAccessPublic guifg=Green ctermfg=Green
|
||||
highlight default TagbarAccessProtected guifg=Blue ctermfg=Blue
|
||||
highlight default TagbarAccessPrivate guifg=Red ctermfg=Red
|
||||
highlight default link TagbarVisibilityPublic TagbarAccessPublic
|
||||
highlight default link TagbarVisibilityProtected TagbarAccessProtected
|
||||
highlight default link TagbarVisibilityPrivate TagbarAccessPrivate
|
||||
|
||||
let b:current_syntax = 'tagbar'
|
||||
|
||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
Loading…
Reference in New Issue
Block a user