Skip to content

Commit

Permalink
detect workspace fix
Browse files Browse the repository at this point in the history
  • Loading branch information
noscript committed Aug 18, 2023
1 parent e99c1fa commit 984dd2e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions autoload/bazel.vim
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ export def DetectWorkspace()
return
endif

var cwd = getcwd()
var workspace_file = findfile('WORKSPACE', cwd .. ';')
var dir = getcwd()
if empty(&bt)
dir = bufname()->resolve()->fnamemodify(':p:h')->fnameescape()
endif
var workspace_file = findfile('WORKSPACE', dir .. ';')
if empty(workspace_file)
g:bazel.status = s_NOT_BAZEL
return
endif

g:bazel.status = s_DETECTED
g:bazel.info.workspace = workspace_file->fnamemodify(':h')
g:bazel.info.workspace = workspace_file->fnamemodify(':p:h')

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

echo 'Configuring bazel...'
var output = systemlist($'bazel info {s_extra_args}')
var output = systemlist($'cd "{g:bazel.info.workspace}"; bazel info {s_extra_args}')
echo '' | redraw
if v:shell_error != 0
g:bazel.status = s_FAILED
Expand Down

0 comments on commit 984dd2e

Please sign in to comment.