Skip to content

Commit 7cf53d4

Browse files
committed
Pass bufnr to g:OmniSharp_find_solution()
1 parent 9883fe5 commit 7cf53d4

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

autoload/OmniSharp.vim

+9-9
Original file line numberDiff line numberDiff line change
@@ -108,16 +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-
if g:OmniSharp_sln_resolve_function != v:null
113-
let sln = call(g:OmniSharp_sln_resolve_function, [])
114-
else
111+
if exists('g:OmniSharp_find_solution')
112+
let sln = call(g:OmniSharp_find_solution, [bufnr])
113+
else
114+
try
115115
let sln = s:FindSolution(interactive, bufnr)
116-
endif
117-
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
118-
catch
119-
return ''
120-
endtry
116+
catch
117+
return ''
118+
endtry
119+
endif
120+
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
121121
endif
122122
return getbufvar(bufnr, 'OmniSharp_buf_server')
123123
endfunction

doc/omnisharp-vim.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,16 @@ Default: {} >
190190
\ 'C:\path\to\other\project': 2004,
191191
\}
192192
<
193-
*g:OmniSharp_sln_resolve_function*
193+
*g:OmniSharp_find_solution*
194194
Function used to resolve the solution file anytime it needs to be resolved
195195
based on the currently opened file.
196196

197197
This can be used in various ways, but one particular use case might be when
198198
you need Omnisharp to stick to a given solution file that would contain all
199199
the projects that you need to work with even though you navigate to
200200
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" }
201+
could pass a value along the following lines: >
202+
let g:OmniSharp_find_solution = {bufnr -> "/path/to/main_project.sln"}
205203
<
206204

207205
This is a lambda expression that always evaluates to the string

plugin/OmniSharp.vim

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ 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-
5755
command! -bar -nargs=? OmniSharpInstall call OmniSharp#Install(<f-args>)
5856
command! -bar -nargs=? OmniSharpOpenLog call OmniSharp#log#Open(<q-args>)
5957
command! -bar -bang OmniSharpStatus call OmniSharp#Status(<bang>0)

0 commit comments

Comments
 (0)