Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
bzl.vim102 linesDownload Raw Back to ftplugin
1" Vim filetype plugin file2" Language:	Bazel (http://bazel.io)3" Maintainer:	David Barnett (https://github.com/google/vim-ft-bzl)4" Last Change:	2021 Jan 195" 		2023 Aug 28 by Vim Project (undo_ftplugin)6 7""8" @section Introduction, intro9" Core settings for the bzl filetype, used for BUILD and *.bzl files for the10" Bazel build system (http://bazel.io/).11 12if exists('b:did_ftplugin')13  finish14endif15 16 17" Vim 7.4.051 has opinionated settings in ftplugin/python.vim that try to force18" PEP8 conventions on every python file, but these conflict with Google's19" indentation guidelines. As a workaround, we explicitly source the system20" ftplugin, but save indentation settings beforehand and restore them after.21let s:save_expandtab = &l:expandtab22let s:save_shiftwidth = &l:shiftwidth23let s:save_softtabstop = &l:softtabstop24let s:save_tabstop = &l:tabstop25 26" NOTE: Vim versions before 7.3.511 had a ftplugin/python.vim that was broken27" for compatible mode.28let s:save_cpo = &cpo29set cpo&vim30 31" Load base python ftplugin (also defines b:did_ftplugin).32source $VIMRUNTIME/ftplugin/python.vim33 34" NOTE: Vim versions before 7.4.104 and later set this in ftplugin/python.vim.35setlocal comments=b:#,fb:-36 37" Restore pre-existing indentation settings.38let &l:expandtab = s:save_expandtab39let &l:shiftwidth = s:save_shiftwidth40let &l:softtabstop = s:save_softtabstop41let &l:tabstop = s:save_tabstop42 43setlocal formatoptions-=t44 45" Initially defined in the python ftplugin sourced above46let b:undo_ftplugin .= " | setlocal fo<"47 48" Make gf work with imports in BUILD files.49setlocal includeexpr=substitute(v:fname,'//','','')50 51" Enable syntax-based folding, if specified.52if get(g:, 'ft_bzl_fold', 0)53  setlocal foldmethod=syntax54  setlocal foldtext=BzlFoldText()55  let b:undo_ftplugin .= " | setlocal fdm< fdt<"56endif57 58if exists('*BzlFoldText')59  let &cpo = s:save_cpo60  unlet s:save_cpo61  finish62endif63 64function BzlFoldText() abort65  let l:start_num = nextnonblank(v:foldstart)66  let l:end_num = prevnonblank(v:foldend)67 68  if l:end_num <= l:start_num + 169    " If the fold is empty, don't print anything for the contents.70    let l:content = ''71  else72    " Otherwise look for something matching the content regex.73    " And if nothing matches, print an ellipsis.74    let l:content = '...'75    for l:line in getline(l:start_num + 1, l:end_num - 1)76      let l:content_match = matchstr(l:line, '\m\C^\s*name = \zs.*\ze,$')77      if !empty(l:content_match)78        let l:content = l:content_match79        break80      endif81    endfor82  endif83 84  " Enclose content with start and end85  let l:start_text = getline(l:start_num)86  let l:end_text = substitute(getline(l:end_num), '^\s*', '', '')87  let l:text = l:start_text . ' ' . l:content . ' ' . l:end_text88 89  " Compute the available width for the displayed text.90  let l:width = winwidth(0) - &foldcolumn - (&number ? &numberwidth : 0)91  let l:lines_folded = ' ' . string(1 + v:foldend - v:foldstart) . ' lines'92 93  " Expand tabs, truncate, pad, and concatenate94  let l:text = substitute(l:text, '\t', repeat(' ', &tabstop), 'g')95  let l:text = strpart(l:text, 0, l:width - len(l:lines_folded))96  let l:padding = repeat(' ', l:width - len(l:lines_folded) - len(l:text))97  return l:text . l:padding . l:lines_folded98endfunction99 100let &cpo = s:save_cpo101unlet s:save_cpo102 
codekingpro/portable-devtools · Team Ai