Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoload: resolving the solution file based on a function #870

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading