This commit is contained in:
Christian Nieves
2023-12-20 20:40:43 +00:00
parent 4389d94876
commit 57cea17bca
5 changed files with 61 additions and 223 deletions

View File

@ -0,0 +1,40 @@
vim.cmd([[
function s:blazeExec(cmd, targets)
if len(a:targets) == 0
exe VimuxRunCommand("build_target.py " . expand('%:p') . " " . a:cmd)
else
exe VimuxRunCommand(a:cmd . " " . join(a:targets, ' '))
endif
endfunction
function BlazeRun() abort
call <SID>blazeExec("blaze run", blaze#GetTargets())
endfunction
function BlazeBuild() abort
call <SID>blazeExec("blaze build", blaze#GetTargets())
endfunction
function BlazeTest() abort
call <SID>blazeExec("blaze test", blaze#GetTargets())
endfunction
function BlazeTestDebug() abort
call <SID>blazeExec("blaze test --java_debug", blaze#GetTargets())
endfunction
function BuildCleanerFile() abort
exe VimuxRunCommand("build_cleaner " . expand('%'))
endfunction
function UnusedDeps() abort
exe VimuxRunCommand("unused_deps --nouse_build_api --blaze_options='--config=gmscore_tap' " . join(blaze#GetTargets(), ' '))
endfunction
function BuildCleanerTarget() abort
exe VimuxRunCommand("build_cleaner " . join(blaze#GetTargets(), ' '))
endfunction
nnoremap <Leader>bc :call BuildCleanerFile()<cr>
nnoremap <Leader>ud :call UnusedDeps()<cr>
]])

View File

@ -1,138 +0,0 @@
local use_google = require("utils").use_google
if use_google() then
vim.cmd([[
let g:VCSCommandDisableMappings = 1
let g:signify_skip_filename_pattern = ['\.pipertmp.*']
function s:blazeExec(cmd, targets)
if len(a:targets) == 0
exe VimuxRunCommand("build_target.py " . expand('%:p') . " " . a:cmd)
else
exe VimuxRunCommand(a:cmd . " " . join(a:targets, ' '))
endif
endfunction
function BlazeRun() abort
call <SID>blazeExec("blaze run", blaze#GetTargets())
endfunction
function BlazeBuild() abort
call <SID>blazeExec("blaze build", blaze#GetTargets())
endfunction
function BlazeTest() abort
call <SID>blazeExec("blaze test", blaze#GetTargets())
endfunction
function BlazeTestDebug() abort
call <SID>blazeExec("blaze test --java_debug", blaze#GetTargets())
endfunction
function BuildCleanerFile() abort
exe VimuxRunCommand("build_cleaner " . expand('%'))
endfunction
function UnusedDeps() abort
exe VimuxRunCommand("unused_deps --nouse_build_api --blaze_options='--config=gmscore_tap' " . join(blaze#GetTargets(), ' '))
endfunction
function BuildCleanerTarget() abort
exe VimuxRunCommand("build_cleaner " . join(blaze#GetTargets(), ' '))
endfunction
nnoremap <Leader>br :call BlazeRun()<cr>
nnoremap <Leader>bb :call BlazeBuild()<cr>
nnoremap <Leader>bt :call BlazeTest()<cr>
nnoremap <Leader>btd :call BlazeTestDebug()<cr>
nnoremap <Leader>bc :call BuildCleanerFile()<cr>
nnoremap <Leader>ud :call UnusedDeps()<cr>
let g:asyncrun_open = 1
function! s:AsyncBlaze(cmd, targets) abort
"open cwindow manually and immediately when blaze starts.
"simulate the same behavior from google-emacs blaze plugin.
let l:aro = g:asyncrun_open
let g:asyncrun_open = 0
let l:target = ':'.expand('%:r')
call setqflist([]) | copen 15
" don't use !, so we scrolling the output.
call asyncrun#run("", {"rows": 15}, a:cmd . ' ' . join(a:targets, ' '))
let g:asyncrun_open = l:aro
endfunction
function AsyncBlazeBuild() abort
call <SID>AsyncBlaze("blaze build", blaze#GetTargets())
endfunction
function AsyncBlazeTest() abort
call <SID>AsyncBlaze("blaze test", blaze#GetTargets())
endfunction
autocmd bufreadpre *.sh setlocal textwidth=80
augroup autoformat_settings
autocmd FileType borg,gcl,patchpanel AutoFormatBuffer gclfmt
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,javascript,typescript AutoFormatBuffer clang-format
autocmd FileType dart AutoFormatBuffer dartfmt
autocmd FileType go AutoFormatBuffer gofmt
autocmd FileType java AutoFormatBuffer google-java-format
autocmd FileType jslayout AutoFormatBuffer jslfmt
autocmd FileType markdown AutoFormatBuffer mdformat
autocmd FileType ncl AutoFormatBuffer nclfmt
autocmd FileType python AutoFormatBuffer pyformat
autocmd FileType soy AutoFormatBuffer soyfmt
autocmd FileType textpb AutoFormatBuffer text-proto-format
autocmd FileType proto AutoFormatBuffer protofmt
autocmd FileType sql AutoFormatBuffer format_sql
autocmd FileType kotlin AutoFormatBuffer ktfmt
autocmd FileType soy AutoFormatBuffer soyfmt
" autocmd FileType html,css,json AutoFormatBuffer js-beautify
augroup END
function! CitCWorkspace()
let l:workspace = substitute(getcwd(), '/google/src/cloud/[^/]\+/\([^/]\+\)/.*', '\1', 'g')
return l:workspace
endfunction
function! G4Blame(...)
" Grab the filename from the argument, use expand() to expand '%'.
if a:0 > 0
let file = expand(a:1)
else
let file = expand('%')
endif
" Lock scrolling in right pane
setl scb
" Create left pane
vnew
" It's 37 columns wide
vert res 37
" Get the output, split it on newline and keep empty lines, skip the first 2
" lines because they're headers we don't need, and put it in starting on line
" 1 of the left pane
call setline(1, split(system('hg blame ' . file), '\n', 1)[2:])
" Lock scrolling in left pane, turn off word wrap, set the buffer as
" not-modified, remove any listchars highlighting (common in google code), set
" it readonly (to make modifications slightly more annoying).
setl scb nowrap nomod nolist ro
" Move back to the right pane (not sure if there's a better way to do this?)
exe "normal \<c-w>\<right>"
" if a file was specified, open it
if a:0 > 0
execute "e ". file
endif
" Get the non-active pane scrolled to the same relative offset.
syncbind
endfunction
com! -nargs=? -complete=file Blame :call G4Blame(<f-args>)
nnoremap <leader>cc :CritiqueUnresolvedComments<space><cr>
nmap <leader>yb :let t = join(blaze#GetTargets(), ' ') \| echo t \| let @+ = t <CR>
]])
end

View File

@ -192,9 +192,9 @@ return {
-- Run blaze commands
glug("blaze", {
opts = {
execution_mode = "async",
},
-- opts = {
-- execution_mode = "async",
-- },
dependencies = {
glug("blazedeps"),
},
@ -210,6 +210,9 @@ return {
"BlazeDebugFinish",
"BlazeDepsUpdate",
},
config = function()
require("config.blaze")
end,
keys = function()
local function runCmd(cmd)
return function()
@ -224,12 +227,19 @@ return {
end
return {
{ "<leader>b", desc = "Blaze" },
{ "<leader>be", runCmd("call blaze#LoadErrors()"), desc = "Blaze load errors" },
{ "<leader>bl", runCmd("call blaze#ViewCommandLog()"), desc = "Blaze view build log" },
{ "<leader>bs", runCmd("BlazeGoToSponge"), desc = "Blaze go to sponge" },
{ "<leader>bc", runCmd("Blaze"), desc = "Blaze build on targets" },
{ "<leader>bb", runCmd("Blaze build"), desc = "Blaze build" },
{ "<leader>bt", runCmd("Blaze test"), desc = "Blaze test" },
-- { "<leader>be", runCmd("call blaze#LoadErrors()"), desc = "Blaze load errors" },
-- { "<leader>bl", runCmd("call blaze#ViewCommandLog()"), desc = "Blaze view build log" },
-- { "<leader>bs", runCmd("BlazeGoToSponge"), desc = "Blaze go to sponge" },
-- { "<leader>bc", runCmd("Blaze"), desc = "Blaze build on targets" },
-- { "<leader>bb", runCmd("Blaze build"), desc = "Blaze build" },
{ "<leader>bt", ":call BlazeTest()<CR>", desc = "Blaze Test" },
{ "<leader>bb", ":call BlazeBuild()<CR>", desc = "Blaze Build" },
{ "<leader>br", ":call BlazeRun()<CR>", desc = "Blaze Run" },
{
"<leader>yb",
":let t = join(blaze#GetTargets(), ' ') | echo t | let @+ = t <CR>",
desc = "Yank Blaze Target",
},
{ "<leader>bf", runCmd("call blaze#TestCurrentFile()"), desc = "Blaze test current file" },
{ "<leader>bm", runCmd("call blaze#TestCurrentMethod()"), desc = "Blaze test current method" },
{ "<leader>bd", desc = "Blaze debug" },

View File

@ -79,42 +79,6 @@ return {
lualine_y = { "progress" },
lualine_z = { "location" },
},
-- tabline = {
-- lualine_a = {
-- {
-- "tabs",
-- mode = 1,
-- use_mode_colors = true,
-- max_length = (vim.o.columns / 5) * 4,
-- fmt = function(name, context)
-- -- Show + if buffer is modified in tab
-- local buflist = vim.fn.tabpagebuflist(context.tabnr)
-- local winnr = vim.fn.tabpagewinnr(context.tabnr)
-- local bufnr = buflist[winnr]
-- local mod = vim.fn.getbufvar(bufnr, "&mod")
--
-- return name .. (mod == 1 and " +" or "")
-- end,
-- },
-- },
-- lualine_b = { "branch" },
-- -- lualine_c = { "filename" },
-- lualine_c = {
-- {
-- "diagnostics",
-- sources = { "nvim_workspace_diagnostic" },
-- symbols = { error = " ", warn = " ", info = " ", hint = " " },
-- },
-- },
-- -- lualine_y = { getLGTMs }
-- lualine_z = {
-- {
-- "filename",
-- file_status = false, -- displays file status (readonly status, modified status)
-- path = 2, -- 0 = just filename, 1 = relative path, 2 = absolute path
-- },
-- },
-- },
})
end,
}

View File

@ -27,7 +27,7 @@ set ttyfast
set relativenumber
set copyindent
set preserveindent
set lazyredraw " Enable if running slow...
" set lazyredraw " Enable if running slow...
set autoindent
set wrap
@ -65,7 +65,6 @@ lua require('plugin_init')
source ~/.vim/prefs/mappings.vim
source ~/.vim/prefs/leader.vim
set noshowmode
set encoding=utf-8
set t_Co=256
@ -103,9 +102,6 @@ function! GenerateUnicode(first, last)
endwhile
endfunction
set colorcolumn=80
set mouse=
" makes sure that when opening, files are normal, i.e. not folded.
set nofoldenable
@ -125,41 +121,7 @@ let g:loaded_netrwPlugin = 1
let g:loaded_tutor_mode_plugin = 1
let g:loaded_remote_plugins = 1
function! TabMultiDiff()
let s:tab_multi_diff = 0
argdo call s:AddBufferToTab()
tabclose
endfun
" Helper function used by TabMultiDiff(). Adds current buffer to new tab
" or last tab as appropriate, and sets new window's "diff" option.
function! s:AddBufferToTab()
let buf = bufnr("%")
if s:tab_multi_diff
tablast
vsplit
wincmd w
else
tab split
tabmove
endif
let s:tab_multi_diff = ! s:tab_multi_diff
exe 'b ' . buf
diffthis
tabfirst
endfun
set mouse=nv
filetype plugin indent on
syntax on
" noremap <Up> <Nop>
" noremap <Down> <Nop>
" noremap <Left> <Nop>
" noremap <Right> <Nop>
" inoremap <Up> <Nop>
" inoremap <Down> <Nop>
" inoremap <Left> <Nop>
" inoremap <Right> <Nop>
lua require("config.google")