Skip to content

Commit

Permalink
Merge pull request #870 from sim590/solution-resolve-function
Browse files Browse the repository at this point in the history
autoload: resolving the solution file based on a function
  • Loading branch information
nickspoons authored Jan 30, 2025
2 parents 2205888 + 7cf53d4 commit cdbf65b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 10 additions & 6 deletions autoload/OmniSharp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ function! OmniSharp#FindSolutionOrDir(...) abort
let interactive = a:0 ? a:1 : 1
let bufnr = a:0 > 1 ? a:2 : bufnr('%')
if empty(getbufvar(bufnr, 'OmniSharp_buf_server'))
try
let sln = s:FindSolution(interactive, bufnr)
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
catch
return ''
endtry
if exists('g:OmniSharp_find_solution')
let sln = call(g:OmniSharp_find_solution, [bufnr])
else
try
let sln = s:FindSolution(interactive, bufnr)
catch
return ''
endtry
endif
call setbufvar(bufnr, 'OmniSharp_buf_server', sln)
endif
return getbufvar(bufnr, 'OmniSharp_buf_server')
endfunction
Expand Down
16 changes: 16 additions & 0 deletions doc/omnisharp-vim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,22 @@ Default: {} >
\ 'C:\path\to\other\project': 2004,
\}
<
*g:OmniSharp_find_solution*
Function used to resolve the solution file anytime it needs to be resolved
based on the currently opened file.

This can be used in various ways, but one particular use case might be when
you need Omnisharp to stick to a given solution file that would contain all
the projects that you need to work with even though you navigate to
subprojects where other solution files could be found there. In that case, one
could pass a value along the following lines: >
let g:OmniSharp_find_solution = {bufnr -> "/path/to/main_project.sln"}
<

This is a lambda expression that always evaluates to the string
`/the/path/to/my/main_project.sln`. One could imagine more complexed cases.
It's up to the user to use this as he sees fit.

-------------------------------------------------------------------------------
3.2 DIAGNOSTICS *omnisharp-diagnostic-options*

Expand Down

0 comments on commit cdbf65b

Please sign in to comment.