From 57cea17bcaa498153f4929fe9ac324f1b5f8ad7a Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Wed, 20 Dec 2023 20:40:43 +0000 Subject: [PATCH] meh --- vim/.vim/lua/config/blaze.lua | 40 +++++++++ vim/.vim/lua/config/google.lua | 138 ------------------------------- vim/.vim/lua/plugins/google.lua | 28 +++++-- vim/.vim/lua/plugins/lualine.lua | 36 -------- vim/.vimrc | 42 +--------- 5 files changed, 61 insertions(+), 223 deletions(-) create mode 100644 vim/.vim/lua/config/blaze.lua diff --git a/vim/.vim/lua/config/blaze.lua b/vim/.vim/lua/config/blaze.lua new file mode 100644 index 0000000..4c6ee6a --- /dev/null +++ b/vim/.vim/lua/config/blaze.lua @@ -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 blazeExec("blaze run", blaze#GetTargets()) +endfunction + +function BlazeBuild() abort + call blazeExec("blaze build", blaze#GetTargets()) +endfunction + +function BlazeTest() abort + call blazeExec("blaze test", blaze#GetTargets()) +endfunction + +function BlazeTestDebug() abort + call 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 bc :call BuildCleanerFile() +nnoremap ud :call UnusedDeps() +]]) diff --git a/vim/.vim/lua/config/google.lua b/vim/.vim/lua/config/google.lua index 0aa2c28..e69de29 100644 --- a/vim/.vim/lua/config/google.lua +++ b/vim/.vim/lua/config/google.lua @@ -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 blazeExec("blaze run", blaze#GetTargets()) -endfunction - -function BlazeBuild() abort - call blazeExec("blaze build", blaze#GetTargets()) -endfunction - -function BlazeTest() abort - call blazeExec("blaze test", blaze#GetTargets()) -endfunction - -function BlazeTestDebug() abort - call 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 br :call BlazeRun() -nnoremap bb :call BlazeBuild() -nnoremap bt :call BlazeTest() -nnoremap btd :call BlazeTestDebug() -nnoremap bc :call BuildCleanerFile() -nnoremap ud :call UnusedDeps() - -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 AsyncBlaze("blaze build", blaze#GetTargets()) -endfunction - -function AsyncBlazeTest() abort - call 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 \\" - " 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() - -nnoremap cc :CritiqueUnresolvedComments - -nmap yb :let t = join(blaze#GetTargets(), ' ') \| echo t \| let @+ = t -]]) -end diff --git a/vim/.vim/lua/plugins/google.lua b/vim/.vim/lua/plugins/google.lua index ca1795a..6fa8b5e 100644 --- a/vim/.vim/lua/plugins/google.lua +++ b/vim/.vim/lua/plugins/google.lua @@ -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 { { "b", desc = "Blaze" }, - { "be", runCmd("call blaze#LoadErrors()"), desc = "Blaze load errors" }, - { "bl", runCmd("call blaze#ViewCommandLog()"), desc = "Blaze view build log" }, - { "bs", runCmd("BlazeGoToSponge"), desc = "Blaze go to sponge" }, - { "bc", runCmd("Blaze"), desc = "Blaze build on targets" }, - { "bb", runCmd("Blaze build"), desc = "Blaze build" }, - { "bt", runCmd("Blaze test"), desc = "Blaze test" }, + -- { "be", runCmd("call blaze#LoadErrors()"), desc = "Blaze load errors" }, + -- { "bl", runCmd("call blaze#ViewCommandLog()"), desc = "Blaze view build log" }, + -- { "bs", runCmd("BlazeGoToSponge"), desc = "Blaze go to sponge" }, + -- { "bc", runCmd("Blaze"), desc = "Blaze build on targets" }, + -- { "bb", runCmd("Blaze build"), desc = "Blaze build" }, + { "bt", ":call BlazeTest()", desc = "Blaze Test" }, + { "bb", ":call BlazeBuild()", desc = "Blaze Build" }, + { "br", ":call BlazeRun()", desc = "Blaze Run" }, + { + "yb", + ":let t = join(blaze#GetTargets(), ' ') | echo t | let @+ = t ", + desc = "Yank Blaze Target", + }, { "bf", runCmd("call blaze#TestCurrentFile()"), desc = "Blaze test current file" }, { "bm", runCmd("call blaze#TestCurrentMethod()"), desc = "Blaze test current method" }, { "bd", desc = "Blaze debug" }, diff --git a/vim/.vim/lua/plugins/lualine.lua b/vim/.vim/lua/plugins/lualine.lua index 3d87958..629eabf 100644 --- a/vim/.vim/lua/plugins/lualine.lua +++ b/vim/.vim/lua/plugins/lualine.lua @@ -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, } diff --git a/vim/.vimrc b/vim/.vimrc index d7a017a..295ad04 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -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 -" noremap -" noremap -" noremap -" inoremap -" inoremap -" inoremap -" inoremap - -lua require("config.google")