Mercurial > vim_plugins > core
changeset 1:7c5bd18befd2 default tip
Some basic usage
| author | Luka Sitas <lsitas@avatarasoftware.com> |
|---|---|
| date | Tue, 10 Mar 2026 21:31:17 -0400 |
| parents | 7bb5f650cfb7 |
| children | |
| files | autoload/core.vim doc/core.txt plugin/core.vim |
| diffstat | 3 files changed, 29 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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*
--- 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()
