fix(Save-/LoadMarks): add opt to keep original file-ext#29
fix(Save-/LoadMarks): add opt to keep original file-ext#29juanMarinero wants to merge 3 commits intolpinilla:masterfrom
Conversation
If no arg passed then l:aux is still expand("%:e")
otherwise extension depends on arg passed
g:codepainter_file_keep_original_extension to keep (1) or not (0) original file extension in JSON file to store markers. Also: - added error-msg if file to store markers is current JSON - 'silent' removed from PainterSaveMarks to see those error-msgs
|
Amend. I said
Though to be auto it would need alike: au BufReadPost * if empty(&buftype) | call SourceCodePaintersFromJSON() | endif
au BufUnload * if empty(&buftype) | call SaveCodePaintersToJSON() | endif
au BufUnload * if empty(&buftype) | call SaveCodePaintersToJSON(expand('<afile>:p')) | endif
function! SetCodePaintersFile(...)
[...]
" replaced next: let l:current_file = expand('%:p')
let l:current_file = a:0 > 0 ? a:1 : expand('%:p')
[...]
endfunction
function! SaveCodePaintersToJSON(...)
[...]
" replaced next: let l:codepaints_file = SetCodePaintersFile()
let l:codepaints_file = a:0 == 0 ? SetCodePaintersFile() : SetCodePaintersFile(a:1)
[...]
endfunctionBut
Alike happens with the
Please help. To fix Maybe vim-bookmarks approach can be replicated here (way beyond my vimscript skills though). This plugin offers different strategies to save bookmarks:
Maybe all this auto-stuff goes beyond this PR and if this PR is accepted then I should create an issue (feature request). |
let l:path = substitute(l:path, expand("%:e"), "json", "")did replace first extension match. E.g.filepy.pywould befilejson.pymain.jsandmain.html, then now withlet g:codepainter_file_keep_original_extension = 1I can have 2 different codepainter JSONs (main.js.jsonandmain.html.json). Or if set to0justmain.jsonas previous to this PRcodepainter#SaveMarks()echoes a warning, thussilentremoved fromPainterSaveMarksdeclaration to see those error-msgsNext is an example of what now can be achieved. TLDR: create JSON files for auto-save/load codepainter-marks with a regex that matches
.gitignore. Example of how to use:vim filepy.py:call SaveCodePaintersToJSON()createsfilepy.py__noGit_vim-codePainters.json. Which is awesome sincepyoffilepyis not renamed bylet l:path = substitute(l:path, expand("%:e"), "json", "")and adds_noGit_for the.gitignorevim filepy.py:call SourceCodePaintersFromJSON()loadsfilepy.py__noGit_vim-codePainters.json