Skip to content

Commit 984dd2e

Browse files
committed
detect workspace fix
1 parent e99c1fa commit 984dd2e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

autoload/bazel.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,18 @@ export def DetectWorkspace()
169169
return
170170
endif
171171

172-
var cwd = getcwd()
173-
var workspace_file = findfile('WORKSPACE', cwd .. ';')
172+
var dir = getcwd()
173+
if empty(&bt)
174+
dir = bufname()->resolve()->fnamemodify(':p:h')->fnameescape()
175+
endif
176+
var workspace_file = findfile('WORKSPACE', dir .. ';')
174177
if empty(workspace_file)
175178
g:bazel.status = s_NOT_BAZEL
176179
return
177180
endif
178181

179182
g:bazel.status = s_DETECTED
180-
g:bazel.info.workspace = workspace_file->fnamemodify(':h')
183+
g:bazel.info.workspace = workspace_file->fnamemodify(':p:h')
181184

182185
command! -nargs=+ -complete=customlist,bazel#CompleteList Bazel S__run_command(<q-args>)
183186
command! -nargs=1 -complete=customlist,bazel#CompleteList BazelDefinition S__jump_to_label(<q-args>)
@@ -200,7 +203,7 @@ def S__configure()
200203
g:bazel.status = s_PENDING
201204

202205
echo 'Configuring bazel...'
203-
var output = systemlist($'bazel info {s_extra_args}')
206+
var output = systemlist($'cd "{g:bazel.info.workspace}"; bazel info {s_extra_args}')
204207
echo '' | redraw
205208
if v:shell_error != 0
206209
g:bazel.status = s_FAILED

0 commit comments

Comments
 (0)