spacevim/bundle/defx.nvim/autoload/defx/init.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

152 lines
4.2 KiB
VimL

"=============================================================================
" FILE: init.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
function! defx#init#_initialize() abort
if exists('g:defx#_channel_id')
return
endif
call defx#init#_channel()
augroup defx
autocmd!
augroup END
let g:defx#_histories = []
let g:defx#_previewed_buffers = {}
endfunction
function! defx#init#_channel() abort
if !has('python3')
call defx#util#print_error(
\ 'defx requires Python3 support("+python3").')
return v:true
endif
if has('nvim') && !has('nvim-0.4.0')
call defx#util#print_error('defx requires nvim 0.4.0+.')
return v:true
endif
if !has('nvim') && !defx#util#has_textprop()
call defx#util#print_error('defx requires Vim 8.2+ with textprop.')
return v:true
endif
try
if defx#util#has_yarp()
let g:defx#_yarp = yarp#py3('defx')
call g:defx#_yarp.request('_defx_init')
let g:defx#_channel_id = 1
else
" rplugin.vim may not be loaded on VimEnter
if !exists('g:loaded_remote_plugins')
runtime! plugin/rplugin.vim
endif
call _defx_init()
endif
catch
call defx#util#print_error(v:exception)
call defx#util#print_error(v:throwpoint)
let python_version_check = defx#init#_python_version_check()
if python_version_check
call defx#util#print_error(
\ 'defx requires Python 3.6.1+.')
endif
if defx#util#has_yarp()
if !has('nvim') && !exists('*neovim_rpc#serveraddr')
call defx#util#print_error(
\ 'defx requires vim-hug-neovim-rpc plugin in Vim.')
endif
if !exists('*yarp#py3')
call defx#util#print_error(
\ 'defx requires nvim-yarp plugin.')
endif
else
call defx#util#print_error(
\ 'defx failed to load. '
\ .'Try the :UpdateRemotePlugins command and restart Neovim. '
\ .'See also :checkhealth.')
endif
return v:true
endtry
endfunction
function! defx#init#_check_channel() abort
return exists('g:defx#_channel_id')
endfunction
function! defx#init#_python_version_check() abort
python3 << EOF
import vim
import sys
vim.vars['defx#_python_version_check'] = (
sys.version_info.major,
sys.version_info.minor,
sys.version_info.micro) < (3, 6, 1)
EOF
return g:defx#_python_version_check
endfunction
function! defx#init#_user_options() abort
return {
\ 'auto_cd': v:false,
\ 'auto_recursive_level': 0,
\ 'buffer_name': 'default',
\ 'close': v:false,
\ 'columns': 'mark:indent:icon:filename:type',
\ 'direction': '',
\ 'filtered_files': '',
\ 'floating_preview': v:false,
\ 'focus': v:true,
\ 'ignored_files': '.*',
\ 'listed': v:false,
\ 'new': v:false,
\ 'preview_height': &previewheight,
\ 'preview_width': 40,
\ 'profile': v:false,
\ 'resume': v:false,
\ 'root_marker': '[in] ',
\ 'search': '',
\ 'session_file': '',
\ 'show_ignored_files': v:false,
\ 'sort': 'filename',
\ 'split': 'no',
\ 'toggle': v:false,
\ 'wincol': &columns / 4,
\ 'winheight': 30,
\ 'winrelative': 'editor',
\ 'winrow': &lines / 3,
\ 'winwidth': 90,
\ 'vertical_preview': v:false,
\ }
endfunction
function! s:internal_options() abort
return {
\ 'cursor': line('.'),
\ 'drives': [],
\ 'prev_bufnr': bufnr('%'),
\ 'prev_last_bufnr': bufnr('#'),
\ 'prev_winid': win_getid(),
\ 'visual_start': getpos("'<")[1],
\ 'visual_end': getpos("'>")[1],
\ }
endfunction
function! defx#init#_context(user_context) abort
let buffer_name = get(a:user_context, 'buffer_name', 'default')
let context = s:internal_options()
call extend(context, defx#init#_user_options())
let custom = defx#custom#_get()
if has_key(custom.option, '_')
call extend(context, custom.option['_'])
endif
if has_key(custom.option, buffer_name)
call extend(context, custom.option[buffer_name])
endif
call extend(context, a:user_context)
return context
endfunction