Skip to content

Commit 9883fe5

Browse files
committed
autoload: resolving the solution file based on a function
Passed by the user.
1 parent 2205888 commit 9883fe5

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

autoload/OmniSharp.vim

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ function! OmniSharp#FindSolutionOrDir(...) abort
109109
let bufnr = a:0 > 1 ? a:2 : bufnr('%')
110110
if empty(getbufvar(bufnr, 'OmniSharp_buf_server'))
111111
try
112-
let sln = s:FindSolution(interactive, bufnr)
112+
if g:OmniSharp_sln_resolve_function != v:null
113+
let sln = call(g:OmniSharp_sln_resolve_function, [])
114+
else
115+
let sln = s:FindSolution(interactive, bufnr)
116+
endif
113117
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
114118
catch
115119
return ''

doc/omnisharp-vim.txt

+18
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@ Default: {} >
190190
\ 'C:\path\to\other\project': 2004,
191191
\}
192192
<
193+
*g:OmniSharp_sln_resolve_function*
194+
Function used to resolve the solution file anytime it needs to be resolved
195+
based on the currently opened file.
196+
197+
This can be used in various ways, but one particular use case might be when
198+
you need Omnisharp to stick to a given solution file that would contain all
199+
the projects that you need to work with even though you navigate to
200+
subprojects where other solution files could be found there. In that case, one
201+
could pass a value along the following lines:
202+
203+
>
204+
let g:OmniSharp_sln_resolve_function = { -> "/the/path/to/my/main_project.sln" }
205+
<
206+
207+
This is a lambda expression that always evaluates to the string
208+
`/the/path/to/my/main_project.sln`. One could imagine more complexed cases.
209+
It's up to the user to use this as he sees fit.
210+
193211
-------------------------------------------------------------------------------
194212
3.2 DIAGNOSTICS *omnisharp-diagnostic-options*
195213

plugin/OmniSharp.vim

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ let g:OmniSharp_coc_snippet = get(g:, 'OmniSharp_coc_snippet', 0)
5252

5353
let g:omnicomplete_fetch_full_documentation = get(g:, 'omnicomplete_fetch_full_documentation', 1)
5454

55+
let g:OmniSharp_sln_resolve_function = get(g:, 'OmniSharp_sln_resolve_function', v:null)
56+
5557
command! -bar -nargs=? OmniSharpInstall call OmniSharp#Install(<f-args>)
5658
command! -bar -nargs=? OmniSharpOpenLog call OmniSharp#log#Open(<q-args>)
5759
command! -bar -bang OmniSharpStatus call OmniSharp#Status(<bang>0)

0 commit comments

Comments
 (0)