gpt4 book ai didi

macos - 使 session 设置保存功能与 ultisnips 配合良好

转载 作者:行者123 更新时间:2023-12-01 19:59:03 26 4
gpt4 key购买 nike

我正在使用 go away and come back script 中的以下函数当我退出并启动 vim 时保存和加载 session 。它基本上将我的所有设置、缓冲区中的文件等保存在我打开 vim 的目录中的 session.vim 文件中。

function! MakeSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
endif
let b:filename = b:sessiondir . '/session.vim'
exe "mksession! " . b:filename
endfunction

function! LoadSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
let b:sessionfile = b:sessiondir . "/session.vim"
if (filereadable(b:sessionfile))
exe 'source ' b:sessionfile
else
echo "No session loaded."
endif
endfunction
au VimEnter * nested :call LoadSession()
au VimLeave * :call MakeSession()

最近我添加了ultisnips插件。

"Snippet engine
Plugin 'SirVer/ultisnips'
"Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'

现在,当创建 session.vim 并随后打开 vim 时,我会收到此错误跟踪。当我尝试编辑时,也会在 insert 模式下发生这种情况。

".vim/vimrc" 287L, 9566C Error detected while processing /Users/sudobangbang/.vim/bundle/ultisnips/autoload/UltiSnips.vim: line 15: Traceback (most recent call last):

Error detected while processing /Users/sudobangbang/.vim/bundle/ultisnips/autoload/UltiSnips.vim: line 15: File "", line 1, in Press ENTER or type command to continue Error detected while processing /Users/sudobangbang/.vim/bundle/ultisnips/autoload/UltiSnips.vim: line 15: ImportError: No module named UltiSnips

Error detected while processing function UltiSnips#FileTypeChanged: line 1: Traceback (most recent call last): Error detected while processing function UltiSnips#FileTypeChanged: line 1: NameError: name 'UltiSnips_Manager' is not defined

Error detected while processing function UltiSnips#TrackChange: line 1: Traceback (most recent call last):

如果我删除加载 session 的功能,它工作正常。这里还有 session.vim 中包含 ultisnips 的所有行。

inoremap <silent> <C-Tab> ^V^R=UltiSnips#ListSnippets()^V^M
xnoremap <silent> ^V :call UltiSnips#SaveLastVisualSelection()^V^Mgvs
snoremap <silent> ^V ^V^[:call UltiSnips#ExpandSnippet()^V^M
snoremap <silent> <C-Tab> ^V^[:call UltiSnips#ListSnippets()^V^M


set runtimepath=~/.vim,~/.vim/bundle/Vundle.vim,~/.vim/bundle/syntastic,~/.vim/bundle/nerdtree,~/.vim/bundle/vim-colorschemes,~/.vim/bundle/YouCompleteMe,~/.vim/bundle/supertab,~/.vim/bundle/ultisnips ,~/.vim/bundle/vim-snippets,~/.vim/bundle/ctrlp.vim,~/.vim/bundle/vim-go,~/.vim/bundle/vim-commentary,~/.vim/bundle/vim-surround,~/.vim/bundle/vim-fugitive,~/.vim/bundle/vim-unimpaired,~/.vim/bundle/v im-repeat,~/.vim/bundle/vim-airline,~/.vim/bundle/vim-airline-themes,~/.vim/bundle/gundo.vim,~/.vim/bundle/emmet-vim,~/.vim/bundle/html5.vim,~/.vim/bundle/vim-css-color,~/.vim/bundle/python-mode,~/.vi m/bundle/vim-flake8,~/.vim/bundle/vim-ruby,~/.vim/bundle/vim-endwise,~/.vim/bundle/vim-rails,~/.vim/bundle/vim-bundler,~/.vim/bundle/vim-rake,~/.vim/bundle/vim-ruby-refactoring,~/.vim/bundle/apidock.v im,~/.vim/bundle/blockle.vim,~/.vim/bundle/vim-rspec,~/.vim/bundle/javascript-libraries-syntax.vim,~/.vim/bundle/tern_for_vim,~/.vim/bundle/vim-javascript,/usr/local/share/vim/vimfiles,/usr/local/shar e/vim/vim74,/usr/local/share/vim/vimfil

如何更改 session 函数以便 vim 正确加载 ultisnips

vim --version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 4 2016 11:48:12)
MacOS X (unix) version
Included patches: 1-1864
Compiled by Homebrew

最佳答案

我进行了修复,但同时牺牲了一些功能。

我从 session 加载中删除了这一行

au VimEnter * nested :call LoadSession()

并进行了键映射以手动加载 session

map <leader>l :call LoadSession()<CR>

@Sato Katsura 评论中的假设似乎是有效的。
现在我正在研究是否可以进入自动化部分,在加载所有插件时调用此函数。

关于macos - 使 session 设置保存功能与 ultisnips 配合良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37984348/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com