Skip to content

Commit c098bda

Browse files
author
skywind3000
committed
remove CPatchEdit command
1 parent 49221dc commit c098bda

File tree

2 files changed

+1
-145
lines changed

2 files changed

+1
-145
lines changed

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ hi! VertSplit term=reverse ctermfg=239 ctermbg=233 guifg=#64645e guibg=#211F1C
9595

9696
And `VertSplit` style in `gruvbox` will be overrided.
9797

98-
## Command
99-
100-
```VimL
101-
:CPatchEdit [NAME]
102-
```
103-
104-
Edit patch file for a colorscheme, if `[NAME]` is omitted, the name of current colorscheme is used.
10598

10699
## Configuration
107100

@@ -124,11 +117,6 @@ Default value: `"~/.vim/cpatch"`.
124117

125118
Can accept a list or a comma separated string.
126119

127-
#### g:cpatch_edit
128-
129-
Path for `:CPatchEdit`, it may equal to `g:cpatch_path`, but `g:cpatch_path` can accept a list for multiple search pathes and this option can only provide one path.
130-
131-
Default value: `"~/.vim/cpatch"` .
132120

133121
#### g:cpatch_disable_lua
134122

plugin/cpatch.vim

Lines changed: 1 addition & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
" cpatch.vim - load colorscheme patch automatically
55
"
66
" Created by skywind on 2024/01/05
7-
" Last Modified: 2024/01/07 21:03
7+
" Last Modified: 2024/01/08 14:47
88
"
99
" Homepage: https://github.com/skywind3000/vim-color-patch
1010
"
@@ -44,12 +44,6 @@ let g:cpatch_name = get(g:, 'cpatch_name', '')
4444
" runtime bang
4545
let g:cpatch_bang = get(g:, 'cpatch_bang', 0)
4646

47-
" color patch edit path: for CPatchEdit
48-
let g:cpatch_edit = get(g:, 'cpatch_edit', '~/.vim/cpatch')
49-
50-
" split mode
51-
let g:cpatch_split = get(g:, 'cpatch_split', 'auto')
52-
5347
" don't load .lua files
5448
let g:cpatch_disable_lua = get(g:, 'cpatch_disable_lua', 0)
5549

@@ -155,129 +149,3 @@ augroup END
155149

156150

157151

158-
"----------------------------------------------------------------------
159-
" edit patch
160-
"----------------------------------------------------------------------
161-
function! s:CPatchEdit(mods, name) abort
162-
let name = a:name
163-
if name == ''
164-
let name = get(g:, 'colors_name', '')
165-
endif
166-
if name == ''
167-
let name = '__init__'
168-
endif
169-
let home = fnamemodify(expand(g:cpatch_edit), ':p')
170-
if !isdirectory(home)
171-
try
172-
call mkdir(home, 'p')
173-
catch
174-
echohl ErrorMsg
175-
echo v:exception
176-
echohl None
177-
return 3
178-
endtry
179-
endif
180-
let home = (home =~ '\v[\/\\]$')? home : (home .. '/')
181-
let home = tr(home, '\', '/')
182-
let path = printf("%s%s", home, name)
183-
if name !~ '\v\.vim$' && name !~ '\v\.lua$'
184-
let path = path .. '.vim'
185-
endif
186-
let name = fnameescape(path)
187-
let mods = g:cpatch_split
188-
let newfile = (filereadable(path) == 0)? 1 : 0
189-
if a:mods != ''
190-
if a:mods != 'auto'
191-
exec a:mods . ' split ' . name
192-
elseif winwidth(0) >= 160
193-
exec 'vert split ' . name
194-
else
195-
exec 'split ' . name
196-
endif
197-
elseif mods == ''
198-
exec 'split ' . name
199-
elseif mods == 'auto'
200-
if winwidth(0) >= 160
201-
exec 'vert split ' . name
202-
else
203-
exec 'split ' . name
204-
endif
205-
elseif mods == 'tab'
206-
exec 'tabe ' . name
207-
else
208-
exec mods . ' split ' . name
209-
endif
210-
if newfile
211-
let content = []
212-
let n = fnamemodify(name, ':t:r')
213-
let u = 'https://github.com/skywind3000/vim-color-patch'
214-
if name =~ '\.vim$'
215-
let content += [printf('" edit patch for %s', n)]
216-
let content += ['" ' .. u]
217-
elseif name =~ '\.lua$'
218-
let content += [printf('-- edit patch for %s', n)]
219-
let content += ['-- ' .. u]
220-
endif
221-
if len(content) > 0 && line('$') == 1
222-
call append(0, content)
223-
exec 'set nomodified'
224-
endif
225-
endif
226-
return 0
227-
endfunc
228-
229-
230-
"----------------------------------------------------------------------
231-
" completion
232-
"----------------------------------------------------------------------
233-
function! s:complete(ArgLead, CmdLine, CursorPos)
234-
let candidate = []
235-
let result = []
236-
let items = {}
237-
let home = fnamemodify(expand(g:cpatch_edit), ':p')
238-
if home !~ '\v[\/\\]$'
239-
let home = home .. '/'
240-
endif
241-
let part = glob(home .. '*', 1)
242-
for n in split(part, "\n")
243-
if n =~ '\.vim$'
244-
let t = fnamemodify(n, ':t:r')
245-
let items[t] = 1
246-
elseif n =~ '\.lua$'
247-
let t = fnamemodify(n, ':t')
248-
let items[t] = 1
249-
endif
250-
endfor
251-
let cname = get(g:, 'colors_name', '')
252-
if cname != ''
253-
let items[cname] = 1
254-
endif
255-
let items['__init__'] = 1
256-
let names = keys(items)
257-
call sort(names)
258-
let hidden = (a:ArgLead =~ '^_')? 1 : 0
259-
if a:ArgLead == ''
260-
for name in names
261-
if name !~ '^__'
262-
let candidate += [name]
263-
endif
264-
endfor
265-
else
266-
for name in names
267-
if stridx(name, a:ArgLead) == 0
268-
let candidate += [name]
269-
endif
270-
endfor
271-
endif
272-
return candidate
273-
endfunc
274-
275-
276-
"----------------------------------------------------------------------
277-
" command definition
278-
"----------------------------------------------------------------------
279-
command! -nargs=? -range=0 -complete=customlist,s:complete
280-
\ CPatchEdit call s:CPatchEdit('<mods>', <q-args>)
281-
282-
283-

0 commit comments

Comments
 (0)