Skip to content

Commit cdbf65b

Browse files
authored
Merge pull request #870 from sim590/solution-resolve-function
autoload: resolving the solution file based on a function
2 parents 2205888 + 7cf53d4 commit cdbf65b

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

autoload/OmniSharp.vim

+10-6
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,16 @@ function! OmniSharp#FindSolutionOrDir(...) abort
108108
let interactive = a:0 ? a:1 : 1
109109
let bufnr = a:0 > 1 ? a:2 : bufnr('%')
110110
if empty(getbufvar(bufnr, 'OmniSharp_buf_server'))
111-
try
112-
let sln = s:FindSolution(interactive, bufnr)
113-
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
114-
catch
115-
return ''
116-
endtry
111+
if exists('g:OmniSharp_find_solution')
112+
let sln = call(g:OmniSharp_find_solution, [bufnr])
113+
else
114+
try
115+
let sln = s:FindSolution(interactive, bufnr)
116+
catch
117+
return ''
118+
endtry
119+
endif
120+
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
117121
endif
118122
return getbufvar(bufnr, 'OmniSharp_buf_server')
119123
endfunction

doc/omnisharp-vim.txt

+16
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ Default: {} >
190190
\ 'C:\path\to\other\project': 2004,
191191
\}
192192
<
193+
*g:OmniSharp_find_solution*
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+
let g:OmniSharp_find_solution = {bufnr -> "/path/to/main_project.sln"}
203+
<
204+
205+
This is a lambda expression that always evaluates to the string
206+
`/the/path/to/my/main_project.sln`. One could imagine more complexed cases.
207+
It's up to the user to use this as he sees fit.
208+
193209
-------------------------------------------------------------------------------
194210
3.2 DIAGNOSTICS *omnisharp-diagnostic-options*
195211

0 commit comments

Comments
 (0)