From 4df98cd3d7225ca92b1b7e0e40eb6b7f824e6b22 Mon Sep 17 00:00:00 2001 From: JamesOBrien2 Date: Wed, 10 Jun 2026 20:23:14 +0100 Subject: [PATCH 1/2] Added %compound .cmp file completion; fixed inline directives swallowing highlighting ftplugin: %compound now behaves like %moinp - first space auto-inserts quotes and completes *.cmp files from the buffer directory; closing quote added after accepting a completion. Added to inline directives so block-name completion no longer inserts an end skeleton. syntax: %moinp and the file form of %compound no longer open the methodBlock region, which previously swallowed all highlighting until the next column-0 'end'. The inline-script block form (%compound ... end) keeps the region via a dedicated start pattern. --- ftplugin/orca.vim | 40 +++++++++++++++++++++++++++++++++++++++- syntax/orca.vim | 10 +++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/ftplugin/orca.vim b/ftplugin/orca.vim index b0ce8ce..0e6ede4 100644 --- a/ftplugin/orca.vim +++ b/ftplugin/orca.vim @@ -525,7 +525,7 @@ function! s:DetectBlock() endfunction " Inline directives that look like blocks but have no 'end' and no skeleton. -let s:inline_directives = ['maxcore', 'moinp', 'moread'] +let s:inline_directives = ['compound', 'maxcore', 'moinp', 'moread'] " Completion items for block names. Full blocks carry user_data so MaybeSkeleton " inserts the skeleton; inline directives don't. @@ -556,6 +556,12 @@ function! s:IsMOInpLine() return before =~? '^\s*%moinp\s' endfunction +" True when cursor is past %compound (ready for the .cmp filename). +function! s:IsCompoundLine() + let before = strpart(getline('.'), 0, col('.') - 1) + return before =~? '^\s*%compound\s' +endfunction + " Candidates for the current cursor context (bang line or inside a block). function! s:Candidates(base) let line = getline('.') @@ -570,6 +576,11 @@ function! s:Candidates(base) return map(glob(dir . '/' . a:base . '*.gbw', 0, 1), {_, f -> fnamemodify(f, ':t')}) endif + if s:IsCompoundLine() + let dir = expand('%:p:h') + return map(glob(dir . '/' . a:base . '*.cmp', 0, 1), {_, f -> fnamemodify(f, ':t')}) + endif + let block = s:DetectBlock() if !empty(block) && has_key(g:orca_block_params, block) return s:FilterList(g:orca_block_params[block], a:base) @@ -678,6 +689,25 @@ function! s:AutoTrigger() " which calls s:Candidates → s:IsMOInpLine path for prefix filtering endif + " %compound line: auto-insert "" on first space, then complete .cmp inside them + if s:IsCompoundLine() + if ch ==# ' ' && getline('.') =~? '^\s*%compound\s*$' + " First space after %compound: insert "", park cursor inside, trigger omni + call feedkeys('""' . "\" . "\\", 'n') + return + endif + if ch ==# '"' + " Opening quote typed manually: show all cmp files + let matches = s:Candidates('') + if !empty(matches) + call complete(col + 1, matches) + endif + return + endif + " \w chars inside quotes fall through to the general handler below, + " which calls s:Candidates → s:IsCompoundLine path for prefix filtering + endif + " Block solvent-value context triggered by space: 'smdsolvent |' if ch ==# ' ' let m = matchlist(strpart(line, 0, col - 1), '^\s*\(\w\+\)\s*$\c') @@ -757,6 +787,14 @@ function! s:MaybeSkeleton() return endif + " After a .cmp completion on a %compound line, add closing " if not present + if getline('.') =~? '^\s*%compound\s' + if !empty(get(item, 'word', '')) && getline('.')[col('.') - 1] !=# '"' + call feedkeys('"', 'n') + endif + return + endif + if get(item, 'user_data', '') !~# '^block:' | return | endif let lnum = line('.') call append(lnum, [repeat(' ', shiftwidth()), 'end']) diff --git a/syntax/orca.vim b/syntax/orca.vim index 75bd6ac..91f9712 100644 --- a/syntax/orca.vim +++ b/syntax/orca.vim @@ -1257,7 +1257,9 @@ syn keyword orcaBasis contained PCH-1 PCH-2 PCH-3 PCH-4 AUG-PCH-1 AUG-PCH-2 AUG- " ============================================================ " Block directives (% ... end) -" - Inline directives: %maxcore, %moread (no end) +" - Inline directives: %maxcore, %moread, %moinp, and the file form of +" %compound (no end). These must NOT appear in the methodBlock start= +" alternation, or the region swallows everything until the next col-0 'end'. " - Paired regions: all others " To add a new block: " 1. append its name to the methodBlock start= alternation below @@ -1266,6 +1268,7 @@ syn keyword orcaBasis contained PCH-1 PCH-2 PCH-3 PCH-4 AUG-PCH-1 AUG-PCH-2 AUG- syn match orcaBlock "%maxcore\>" contains=startBlock syn match orcaBlock "%moread\>" contains=startBlock syn match orcaBlock "%moinp\>" contains=startBlock +syn match orcaBlock "%compound\>" contains=startBlock " block directive regions " end= matches 'end' only at column 0 (no leading whitespace), so indented @@ -1273,11 +1276,12 @@ syn match orcaBlock "%moinp\>" contains=startBlock " do not close the outer block region. " To add a new block: add its name to the alternation below AND to orcaBlock above. syn region methodBlock - \ start="%\(method\|basis\|scf\|mp2\|cis\|tddft\|mrci\|geom\|freq\|vpt2\|esd\|dftmrci\|moinp\)" + \ start="%\(method\|basis\|scf\|mp2\|cis\|tddft\|mrci\|geom\|freq\|vpt2\|esd\|dftmrci\)" \ start="%\(coords\|output\|ci\|plots\|parameters\|ndoparas\|rel\|dkh\|pal\|cosmo\|rr\)" \ start="%\(eprnmr\|loc\|elprop\|casscf\|mcrpa\|mdci\|dlpnocc\|mm\|mtr\|xes\|chelpg\)" \ start="%\(numgrad\|mecp\|ecp\|rocis\|mrcc\|cipsi\|ice\|iceci\|md\|nbo\|lft\|autoci\)" - \ start="%\(cpcm\|cim\|compound\|neb\|irc\|anmr\|cregen\|confscript\|anmrrc\|qmmm\)" + \ start="%\(cpcm\|cim\|neb\|irc\|anmr\|cregen\|confscript\|anmrrc\|qmmm\)" + \ start="%compound\s*$" \ start="%\(conical\|ecrism\|shark\|symmetry\|sym\|xtb\|goat\|docker\|solvator\)" \ start="%\(casresp\|frag\|casdft\|mcd\|qgprop\|magrelax\|eda\)" \ end="^end\>" From 198ec27159bcad220fa59d80ffb5ac29816dc111 Mon Sep 17 00:00:00 2001 From: JamesOBrien2 Date: Wed, 10 Jun 2026 20:25:53 +0100 Subject: [PATCH 2/2] Added inline directive examples (%maxcore, %moinp, %compound) to example.inp --- test/example.inp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/example.inp b/test/example.inp index d34386d..15cb88c 100644 --- a/test/example.inp +++ b/test/example.inp @@ -14,6 +14,13 @@ H 0.630 -0.630 -0.630 * +# ------------------------------------------------------------------------------ +# Inline directives (no end) - must not swallow highlighting of lines below +# ------------------------------------------------------------------------------ +%maxcore 4000 +%moinp "previous.gbw" +%compound "workflow.cmp" + # ------------------------------------------------------------------------------ %pal nprocs 8