Giter VIP home page Giter VIP logo

vim-bazel's Introduction

Vim Bazel

vim-bazel is a plugin for invoking bazel and interacting with bazel artifacts.

If you're looking for the Syntax and Filetype settings, that lives in vim-ft-bzl and has been integrated directly into the core-Vim syntax and filetype configuration.

Vim-bazel is currently in early development (see Development status).

For details, see the executable documentation in the vroom/ directory or the helpfiles in the doc/ directory. The helpfiles are also available via :help bazel if bazel is installed (and helptags have been generated).

DISCLAIMER: This is not an official Google product.

Commands

Use :Bazel {command} [argument...] to invoke bazel.

Usage example

:Bazel build //some/package:sometarget
INFO: Found 1 target...
Target //pkg/api:go_default_library up-to-date:
  bazel-bin/pkg/api/go_default_library.a
INFO: Elapsed time: 19.443s, Critical Path: 13.79s

Press ENTER or type command to continue

Installation

This example uses vim-plug, whose plugin-adding command is Plug.

.vimrc:

" Add maktaba and bazel to the runtimepath.
" (The latter must be installed before it can be used.)
Plug 'google/vim-maktaba'
Plug 'bazelbuild/vim-bazel'

Start vim and run

:PlugInstall

Development status

Travis Build Status

Major missing features:

  • Import build errors into vim (#1, see note below)
  • Asynchronous build support (#2)

See the full list of open issues at https://github.com/bazelbuild/vim-bazel/issues.

NOTE: If you're eager for some basic form of jump-to-error support and comfortable making some local modifications to the plugin to customize, you can try patching #11. Follow up on #1 if you're interested in getting maintainable jump-to-file functionality incorporated into the plugin.

FAQ

:Bazel vs. X

Why not just use :!bazel?

The :Bazel command is currently a thin wrapper around :!bazel that supports tab completion. Upcoming improvements will offer many more features that vim's built-in shell support won't be able to offer.

Why not just use :make?

It doesn't add significant benefits for bazel usage in practice.

You can configure vim's built-in :make command to invoke "bazel build" with :set makeprg=bazel\ build. The key benefit of vim's :make command is that it can import errors from the build tool as entries in vim's quickfix list, but limitations in vim's errorformat setting make it tricky or impossible to actually cleanly parse bazel's output for a given build.

It also doesn't add any benefit related to other bazel functionality like "test" and "query" commands.

How does it compare to dispatch.vim?

dispatch.vim's :Make command has the same limitations as :make, above, just with some asynchronous execution strategies.

You can use

:Start -wait=always bazel {command}

to shell out to bazel via dispatch.vim, which works just like :!bazel (mentioned above) but with dispatch.vim's asynchronous execution. Doesn't block vim while executing long builds, but doesn't offer tab completion.

How does it compare to Neomake?

Neomake doesn't seem to add significant benefits for bazel usage in practice.

Like :make, it doesn't support bazel's specific functionality very well and the quickfix support is tricky or impossible to configure properly.

vim-bazel's People

Contributors

alexander-born avatar artasparks avatar dbarnett avatar dslomov avatar malcolmr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-bazel's Issues

Allow users to set `bash_completion_path`

Let users set the completion file path, in current format it needs us to manually move the file to specific location.

I have installed bazel with linuxbrew and it sits somewhere in /home/linuxbrew/.linuxbrew.

Instead I can keep a copy of bazel-completion.bash somewhere like ~/.config/bash and just set bash_completion_path in vimrc

vim 8.2, vim-go, vim-bazel, errcheck, & rules_go

Hi,

I'm using vim 8.2, vim-go (latest), errcheck (latest), and vim-bazel (latest) on macOS Catalina. I'm using go_proto_library() to compile a protobuf, but vim-go flags my import as being not found despite Bazel successfully compiling it.

It's not that big of a deal because it's a warning I can ignore, but I was wondering if there's something quick and easy I can do to make it go away.

Thanks!

Import build errors into vim w/ jump-to-file support

If a :Bazel build command fails, users should be able to browse the individual error messages from within vim and jump to the referenced file locations via something like the quickfix list.

Note that actually processing bazel output and extracting file location information from any given message will be surprisingly complex. We may want a helper tool to that we can pipe bazel's output to parse log output, handling the idiosyncracies of different kinds of tool output and converting them to a single machine-readable format.

Default path to bazel-complete.bash not aligned with bazel docs

The target completion did not work without explicitly setting the path via

bazel#SetBashCompletionPath('/etc/bash_completion.d/bazel-complete.bash')

I would suggest to change the default path according to the docs https://docs.bazel.build/versions/main/completion.html:

 if !exists('s:bash_completion_path')
-  let s:bash_completion_path = '/etc/bash_completion.d/bazel'
+  let s:bash_completion_path = '/etc/bash_completion.d/bazel-complete.bash'
 endif

See:

let s:bash_completion_path = '/etc/bash_completion.d/bazel'

Asynchronous build support

If you invoke a slow bazel build that takes seconds or minutes, the build will currently steal focus and execute in the foreground, preventing you from doing anything else in your vim session until it finishes. It would be nice to have the build continue in the background and leave vim fully usable while it's running (possibly in some kind of interactive shell mode where you can see the bazel cli output as it's printed).

Vim 8's new job support looks like it will suit our needs. In Neovim, there's probably a native API to do what we want.

Add a Readme section for Bazelisk users

Hi, all. Thank you for this plugin.
Today came across issue that Bazel binary cant be found by this plugin.
That was because i was using plain alias bazel='bazelisk' in my ~/.zshrc.
The fix of this was just a simple sudo ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel. I think this could augment the readme of this plugin pretty well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.