# HG changeset patch # User Luka Sitas # Date 1773192677 14400 # Node ID 7c5bd18befd2e6553f5c1eb815c44908e52bc6ba # Parent 7bb5f650cfb7fe79ec97dc395f288eb67d6764d9 Some basic usage diff -r 7bb5f650cfb7 -r 7c5bd18befd2 autoload/core.vim --- a/autoload/core.vim Tue Mar 10 20:28:16 2026 -0400 +++ b/autoload/core.vim Tue Mar 10 21:31:17 2026 -0400 @@ -1,10 +1,25 @@ " autoload/core.vim " Functions are loaded on demand - -if exists('*core#greet') +if exists('g:loaded_core') finish endif +let g:loaded_core = 1 -function! core#greet() abort - echo g:core_greeting +function! core#PopupCommand(command) + let buf = term_start(a:command, {'hidden': 1, 'term_finish': 'close'}) + let winid = popup_create(buf, {'minwidth': 120, 'minheight': 28}) endfunction + +function! core#ReadOnlyPopup(content) + let lines = split(a:content, "\n") + let winid = popup_create(lines, {'minwidth':120, 'minheight':28}) + let buf = winbufnr(winid) + call setbufvar(buf, '&modifiable', 0) + call setbufvar(buf, '&bufhidden', 'wipe') + return winid +endfunction + +function! core#ExecuteCommand(command) + " a:command is a shell command string, e.g. 'hg status' + return system(a:command . ' 2>&1') +endfunction diff -r 7bb5f650cfb7 -r 7c5bd18befd2 doc/core.txt --- a/doc/core.txt Tue Mar 10 20:28:16 2026 -0400 +++ b/doc/core.txt Tue Mar 10 21:31:17 2026 -0400 @@ -2,15 +2,20 @@ INTRODUCTION *core* -core is a minimal example plugin. +core is a minimal plugin providing some consistent and +re-usable functionality. USAGE *core-usage* - :CoreGreet - Echo a greeting message. You can customize it with - g:core_greeting: +function core#PopupCommand({command}) + Create a popup that runs a terminal {command} - > let g:core_greeting = 'Hi there!' +function core#ReadOnlyPopup(content) + Create a read only popup with the {contents}. + There is currently no easy way to close this buffer. + +function core#ExecuteCommand(command) + Executes {command} and returns the results. INSTALLATION *core-install* diff -r 7bb5f650cfb7 -r 7c5bd18befd2 plugin/core.vim --- a/plugin/core.vim Tue Mar 10 20:28:16 2026 -0400 +++ b/plugin/core.vim Tue Mar 10 21:31:17 2026 -0400 @@ -1,15 +1,2 @@ " plugin/core.vim " Basic plugin entry point - -if exists('g:loaded_core') - finish -endif -let g:loaded_core = 1 - -" Default configuration option -if !exists('g:core_greeting') - let g:core_greeting = 'Hello from core!' -endif - -" Command that calls an autoloaded function -command! CoreGreet call core#greet()