mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 15:19:12 +08:00
feat(cheat): ignore readfile error
This commit is contained in:
parent
c2ba2eb63d
commit
e22871492f
@ -280,6 +280,8 @@ EOT
|
||||
_detact_bundle vim-cheat README.md
|
||||
_detact_bundle vim-cheat .travis.yml
|
||||
_detact_bundle vim-cheat .vintrc.yaml
|
||||
_checkdir doc/
|
||||
_detact_bundle vim-cheat doc/vim-cheat.txt
|
||||
git add .
|
||||
git config user.email "wsdjeg@qq.com"
|
||||
git config user.name "SpaceVimBot"
|
||||
|
@ -452,6 +452,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
return '%#SpaceVim_statusline_a_bold# Find %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'rst' && bufname('%') == '__doc__'
|
||||
return '%#SpaceVim_statusline_a_bold# Python Doc %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif bufname('%') == '__cheat_output__'
|
||||
return '%#SpaceVim_statusline_a_bold# Vim Cheat %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'gista-list'
|
||||
return '%#SpaceVim_statusline_ia#'
|
||||
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
||||
|
12
bundle/vim-cheat/autoload/cheat.vim
vendored
12
bundle/vim-cheat/autoload/cheat.vim
vendored
@ -1,8 +1,10 @@
|
||||
" vim-cheat
|
||||
"
|
||||
" Maintainer: Wang Shidong <wsdjeg@outlook.com>
|
||||
" License: MIT
|
||||
" Version: 0.1.0
|
||||
"=============================================================================
|
||||
" cheat.vim --- cheat plugin
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! s:_update_git() abort
|
||||
echom "Update git"
|
||||
|
6
bundle/vim-cheat/plugin/addon-info.json
vendored
Normal file
6
bundle/vim-cheat/plugin/addon-info.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "vim-cheat",
|
||||
"description": "chect plugin for neovim and vim",
|
||||
"author": "Wang Shidong"
|
||||
}
|
||||
|
69
bundle/vim-cheat/plugin/cheat.vim
vendored
69
bundle/vim-cheat/plugin/cheat.vim
vendored
@ -1,16 +1,21 @@
|
||||
" vim-cheat
|
||||
"
|
||||
" Maintainer: Wang Shidong <wsdjeg@outlook.com>
|
||||
" License: MIT
|
||||
" Version: 0.1.0
|
||||
"=============================================================================
|
||||
" cheat.vim --- cheat plugin
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
if exists('g:loaded_cheat')
|
||||
finish
|
||||
endif
|
||||
|
||||
""
|
||||
" Set the path to the cheat sheets cache file, can be overriden from
|
||||
" .vimrc with:
|
||||
" let g:cheats_dir = '/path/to/your/cache/file'
|
||||
" >
|
||||
" let g:cheats_dir = '/path/to/your/cache/file'
|
||||
" <
|
||||
let g:cheats_dir = get(g:, 'cheats_dir', $HOME . '/.cheat/')
|
||||
|
||||
" Set the split direction for the output buffer.
|
||||
@ -24,45 +29,49 @@ let s:cheat_options = {"-add" : "add new cheatsheet" , "-update" : "update curre
|
||||
|
||||
" Func Defs
|
||||
func! FindOrCreateOutWin(bufName)
|
||||
let l:outWinNr = bufwinnr(a:bufName)
|
||||
let l:outBufNr = bufnr(a:bufName)
|
||||
let outWinNr = bufwinnr(a:bufName)
|
||||
let outBufNr = bufnr(a:bufName)
|
||||
|
||||
" Find or create a window for the bufName
|
||||
if l:outWinNr == -1
|
||||
if outWinNr == -1
|
||||
" Create a new window
|
||||
exec s:splitCmdMap[s:cheats_split]
|
||||
|
||||
let l:outWinNr = bufwinnr('%')
|
||||
if l:outBufNr != -1
|
||||
let outWinNr = bufwinnr('%')
|
||||
if outBufNr != -1
|
||||
" The buffer already exists. Open it here.
|
||||
exec 'b'.l:outBufNr
|
||||
exec 'b'.outBufNr
|
||||
endif
|
||||
" Jump back to the previous window the user was editing in.
|
||||
exec 'wincmd p'
|
||||
endif
|
||||
|
||||
" Find the buffer number or create one for bufName
|
||||
if l:outBufNr == -1
|
||||
if outBufNr == -1
|
||||
" Jump to the output window
|
||||
exec l:outWinNr.' wincmd w'
|
||||
exec outWinNr.' wincmd w'
|
||||
" Open a new output buffer
|
||||
exec 'e '.a:bufName
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
setlocal wrap
|
||||
let l:outBufNr = bufnr('%')
|
||||
setlocal nobuflisted
|
||||
let outBufNr = bufnr('%')
|
||||
" Jump back to the previous window the user was editing in.
|
||||
exec 'wincmd p'
|
||||
endif
|
||||
return l:outBufNr
|
||||
return outBufNr
|
||||
endf
|
||||
|
||||
func! RunAndRedirectOut(cheatName, bufName)
|
||||
func! s:RunAndRedirectOut(cheatName, bufName)
|
||||
" Change to the output buffer window
|
||||
let l:outWinNr = bufwinnr(a:bufName)
|
||||
exec l:outWinNr.' wincmd w'
|
||||
let outWinNr = bufwinnr(a:bufName)
|
||||
exec outWinNr.' wincmd w'
|
||||
let f = fnameescape(g:cheats_dir . a:cheatName)
|
||||
|
||||
call append(0, readfile(fnameescape(g:cheats_dir . a:cheatName)))
|
||||
if filereadable(f)
|
||||
call append(0, readfile(f))
|
||||
end
|
||||
normal! gg
|
||||
endf
|
||||
|
||||
@ -75,18 +84,18 @@ func! CheatCompletion(ArgLead, CmdLine, CursorPos)
|
||||
endf
|
||||
|
||||
func! Cheat(...)
|
||||
let l:c = a:0 != 0 ? a:000 : split(input('Cheat Sheet: ', '', 'custom,CheatCompletion'),' ')
|
||||
if len(l:c) == 1 && l:c[0] !~ '^-\w*'
|
||||
let l:outBuf = FindOrCreateOutWin('-cheat_output-')
|
||||
call RunAndRedirectOut(l:c[0], l:outBuf)
|
||||
elseif len(l:c) == 2 && l:c[0] ==# '-add' && l:c[1] !~ '^-\w*'
|
||||
if index(cheat#List_sheets(), l:c[1]) == -1
|
||||
exe "split ". g:cheats_dir . fnameescape(l:c[1])
|
||||
let c = a:0 != 0 ? a:000 : split(input('Cheat Sheet: ', '', 'custom,CheatCompletion'),' ')
|
||||
if len(c) == 1 && c[0] !~ '^-\w*'
|
||||
let outBuf = FindOrCreateOutWin('__cheat_output__')
|
||||
call s:RunAndRedirectOut(c[0], outBuf)
|
||||
elseif len(c) == 2 && c[0] ==# '-add' && c[1] !~ '^-\w*'
|
||||
if index(cheat#List_sheets(), c[1]) == -1
|
||||
exe "split ". g:cheats_dir . fnameescape(c[1])
|
||||
else
|
||||
echohl WarningMsg | echom "cheets " . l:c[1] . " already exists" | echohl None
|
||||
echohl WarningMsg | echom "cheets " . c[1] . " already exists" | echohl None
|
||||
endif
|
||||
elseif len(l:c) == 2 && l:c[0] ==# '-update' && l:c[1] !~ '^-\w*'
|
||||
call cheat#Update(l:c[1])
|
||||
elseif len(c) == 2 && c[0] ==# '-update' && c[1] !~ '^-\w*'
|
||||
call cheat#Update(c[1])
|
||||
endif
|
||||
endf
|
||||
|
||||
|
19
bundle/vim-cheat/plugin/doc/vim-cheat.txt
vendored
Normal file
19
bundle/vim-cheat/plugin/doc/vim-cheat.txt
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
*vim-cheat.txt* chect plugin for neovim and vim
|
||||
Wang Shidong *vim-cheat*
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *vim-cheat-contents*
|
||||
1. Configuration..........................................|vim-cheat-config|
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *vim-cheat-config*
|
||||
|
||||
*g:cheats_dir*
|
||||
Set the path to the cheat sheets cache file, can be overriden from .vimrc
|
||||
with:
|
||||
>
|
||||
let g:cheats_dir = '/path/to/your/cache/file'
|
||||
<
|
||||
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
Loading…
x
Reference in New Issue
Block a user