1- " -*- text -*-
21" oracle.vim -- Vim integration for the Go oracle.
32"
43" Part of this plugin was taken directly from the oracle repo, however it's
4645" via regex.
4746func ! s: qflistSecond (output)
4847 " backup users errorformat, will be restored once we are finished
49- let old_errorformat = &errorformat
48+ let old_errorformat = &errorformat
5049
5150 " match two possible styles of errorformats:
5251 "
@@ -56,13 +55,13 @@ func! s:qflistSecond(output)
5655 " We discard line2 and col2 for the first errorformat, because it's not
5756 " useful and quickfix only has the ability to show one line and column
5857 " number
59- let &errorformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m"
58+ let &errorformat = " %f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m"
6059
6160 " create the quickfix list and open it
6261 cgetexpr split (a: output , " \n " )
6362 cwindow
6463
65- let &errorformat = old_errorformat
64+ let &errorformat = old_errorformat
6665endfun
6766
6867func ! s: getpos (l , c )
@@ -85,7 +84,7 @@ func! s:RunOracle(mode, selected) range abort
8584 let unescaped_scopes = split (get (g: , ' go_oracle_scope' ))
8685 let scopes = []
8786 for unescaped_scope in unescaped_scopes
88- call add(scopes, shellescape(unescaped_scope))
87+ call add (scopes, shellescape (unescaped_scope))
8988 endfor
9089 elseif exists (' g:go_oracle_include_tests' ) && pkg != -1
9190 " give import path so it includes all _test.go files too
@@ -120,7 +119,7 @@ func! s:RunOracle(mode, selected) range abort
120119 " info check Oracle's User Manual section about scopes:
121120 " https://docs.google.com/document/d/1SLk36YRjjMgKqe490mSRzOPYEDe0Y_WQNRv-EiFYUyw/view#heading=h.nwso96pj07q8
122121 for scope in scopes
123- let cmd .= ' ' . scope
122+ let cmd .= ' ' . scope
124123 endfor
125124
126125 echon " vim-go: " | echohl Identifier | echon " analysing ..." | echohl None
@@ -138,11 +137,30 @@ func! s:RunOracle(mode, selected) range abort
138137 " package which doesn't build.
139138 redraw | echon " vim-go: " | echohl Statement | echon out | echohl None
140139 return " "
141- else
140+ endif
142141
143142 return out
144- endfun
143+ endfunc
144+
145+ function ! go#oracle#Scope (... )
146+ if len (a: 000 )
147+ if len (a: 000 ) == 1 && a: 1 == ' ""'
148+ let g: go_oracle_scope = " "
149+ echon " vim-go: " | echohl Function | echon " oracle scope is cleared" | echohl None
150+ else
151+ let g: go_oracle_scope = join (a: 000 , ' ' )
152+ echon " vim-go: " | echohl Function | echon " oracle scope changed to: '" . g: go_oracle_scope ." '" | echohl None
153+ endif
154+
155+ return
156+ endif
145157
158+ if ! exists (g: go_oracle_scope )
159+ echon " vim-go: " | echohl Function | echon " oracle scope is not set" | echohl None
160+ else
161+ echon " vim-go: " | echohl Function | echon " current oracle scope: '" . g: go_oracle_scope ." '" | echohl None
162+ endif
163+ endfunction
146164
147165" Show 'implements' relation for selected package
148166function ! go#oracle#Implements (selected)
@@ -193,3 +211,4 @@ function! go#oracle#Referrers(selected)
193211endfunction
194212
195213" vim:ts = 4 :sw = 4 :et
214+ "
0 commit comments