weixin_39574388
weixin_39574388
2020-11-29 15:04

Swap File for Preview

Problems summary

Preview window create swap files, what cause problems when open preview for same file again.
an attempt to solve it, was to add this to my vimrc and disable swap files for file type denite. This leads to continous error messages, cause no swap file could been created.

vim
if has ("autocmd")
  autocmd FileType denite setlocal directory=''
endif

Expected

Preview window does not use swap files.

Environment Information (Required!)

  • denite version(SHA1): 0.5
  • OS: Win7
  • Vim/neovim version: VIM - Vi IMproved 8.0
  • :checkhealth or :CheckHealth result(neovim only): E492: Not an editor command: checkhealth

Provide a minimal init.vim with less than 50 lines (Required!)

vim
" Backup/Swap stuff
set backup
set backupdir=$HOME/.vim/files/backup/
set backupext=-vimbackup
set directory=$HOME/.vim/files/swap/
set updatetime=1000
set updatecount=100
set undofile
set undodir=$HOME/.vim/files/undo/
set viminfo='100,n$HOME/.vim/files/info/viminfo


" Denite Suff
call denite#custom#filter('matcher_ignore_globs', 'ignore_globs', ['.git/'])

call denite#custom#option('default', {
      \ 'prompt': '➭',
      \ 'highlight_matched_char': 'None',
      \ 'highlight_matched_range': 'None',
      \ 'auto_preview': 'true',
      \ 'auto_resize': 'true',
      \ 'auto_resume': 'true',
      \ })

call denite#custom#map('insert', '<esc>', '<normal>', 'noremap') " Normal Vim behavior of change the mode.
call denite#custom#map('normal', '<esc>', '<suspend>') " Suspend on escape, when are in normal mode. (so double escape close the window) 
call denite#custom#map('insert', '<c-j>', '<move_to_next_line>', 'noremap') " Suspend on escape, when are in normal mode. (so double escape close the window) 
call denite#custom#map('insert', '<c-k>', '<move_to_previous_line>', 'noremap') " Suspend on escape, when are in normal mode. (so double escape close the window) 
</move_to_previous_line></c-k></move_to_next_line></c-j></suspend></esc></normal></esc>

The reproduce ways from neovim starting (Required!)

  • open the denite buffer (e.g.: Denite file_rec)
  • make sure the the preview window is open and show the first default match (do not type anything)
  • close the denite window
  • reopen the denite window -> Error Message

该提问来源于开源项目:Shougo/denite.nvim

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39770311 weixin_39770311 5月前

    I cannot reproduce the problem.

    • Minimal vimrc
    vim
    set runtimepath+=~/work/denite.nvim/
    
    • Reproduce ways

    • Denite file -auto-preview

    • make sure the the preview window is open and show the first default match (do not type anything)

    • close the denite window

    • reopen the denite window -> No error message

    Please test my minimal vimrc and the reproduce ways.

    If not, I will close the issue. Because, I don't reproduce the problem.

    点赞 评论 复制链接分享
  • weixin_39574388 weixin_39574388 5月前

    Sry, but something in my environment here is completely fc*** up. Normaly I'm working with a Linux OS, but have to use Windows elsewhere. I get this big error here:

    vim
    [denite] Traceback (most recent call last):
    [denite]   File "<string>", line 9, in _temporary_scope
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\ui\default.py", line 71, in start
    [denite]     self._start(context['sources_queue'][0], context)
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\ui\default.py", line 136, in _start
    [denite]     status = self._prompt.start()
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\prompt\prompt.py", line 201, in start
    [denite]     raise e
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\prompt\prompt.py", line 191, in start
    [denite]     interval=self.harvest_interval,
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\prompt\keymap.py", line 337, in harvest
    [denite]     interval=interval,
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\prompt\keymap.py", line 387, in _getcode
    [denite]     callback()
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\ui\prompt.py", line 75, in on_harvest
    [denite]     self.denite.update_buffer()
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\ui\default.py", line 405, in update_buffer
    [denite]     self.move_cursor()
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\ui\default.py", line 520, in move_cursor
    [denite]     self.do_action('preview')
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\ui\default.py", line 680, in do_action
    [denite]     self._denite.do_action(self._context, action_name, candidates)
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim/rplugin/python3\denite\denite.py", line 286, in do_action
    [denite]     return action['func'](context) if action['func'] else self._vim.call(
    [denite]   File "C:\Users\weilb00t\vimfiles\bundle\denite.nvim\rplugin/python3/denite\kind\buffer.py", line 41, in action_preview
    [denite]     self.vim.command('pedit')
    [denite] vim.error: Vim(pedit):E37: No write since last change (add ! to override)
    [denite] Please execute :messages command.
    </string>
    点赞 评论 复制链接分享
  • weixin_39770311 weixin_39770311 5月前

    It is not Swap file error.

    Please see :help E37.

    
                                *E37* *E89*  >
      No write since last change (add ! to override)
      No write since last change for buffer {N} (add ! to override)
    
    You are trying to |abandon| a file that has changes.  Vim protects you from
    losing your work.  You can either write the changed file with ":w", or, if you
    are sure, |abandon| it anyway, and lose all the changes.  This can be done by
    adding a '!' character just after the command you used.  Example: >
        :e other_file
    changes to: >
        :e! other_file
    <
    

    I think you have changed the preview buffer. You should check the modified flag.

    点赞 评论 复制链接分享
  • weixin_39574388 weixin_39574388 5月前

    I know it isn't. Of cause this error occur, if I have a minimal vimrc without the hidden option set. But I will do some analysis for this. Maybe I can use the preview label to prevent this.

    点赞 评论 复制链接分享
  • weixin_39574388 weixin_39574388 5月前

    For anyone who is interested into this problem by add this to my .vimrc:

    vim
    if has ("autocmd")
      autocmd FileType denite setlocal noswapfile
    endif
    
    点赞 评论 复制链接分享

相关推荐