From 1c2b35cf8d3e4425b7cb13cbee9fba6c9619ae82 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Mon, 12 Jun 2023 16:15:34 -0500 Subject: [PATCH] stuff --- vim/.vim/lua/config/lsp.lua | 6 +- vim/.vim/lua/plugins/google.lua | 136 +++++++++++++++++++++++++++++++ vim/.vim/prefs/google.vim | 138 -------------------------------- zsh/.aliases.sh | 7 ++ 4 files changed, 147 insertions(+), 140 deletions(-) delete mode 100644 vim/.vim/prefs/google.vim diff --git a/vim/.vim/lua/config/lsp.lua b/vim/.vim/lua/config/lsp.lua index a09c2f4..9f514c6 100644 --- a/vim/.vim/lua/config/lsp.lua +++ b/vim/.vim/lua/config/lsp.lua @@ -126,7 +126,7 @@ end cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { - { name = 'buffer' } + { name = 'buffer', max_item_count = 5 } } }) @@ -150,7 +150,7 @@ local conditionalSources = { { name = "treesitter" }, { name = "crates" }, { name = "vim_vsnip" }, - { name = "buffer", keyword_length = 5, group_index = 2 }, + { name = "buffer", max_item_count = 5, keyword_length = 5, group_index = 2 }, { name = 'spell', option = { @@ -163,6 +163,8 @@ local conditionalSources = { } if use_google() then + require('cmp_nvim_ciderlsp').setup() + local cider_lsp_handlers = { ["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { diff --git a/vim/.vim/lua/plugins/google.lua b/vim/.vim/lua/plugins/google.lua index 24da718..4cc41ce 100644 --- a/vim/.vim/lua/plugins/google.lua +++ b/vim/.vim/lua/plugins/google.lua @@ -116,3 +116,139 @@ if use_google() then else return {} end + +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 BuildCleanerTarget() +nnoremap bcf :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 + +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 google-java-format + -- autocmd FileType kotlin AutoFormatBuffer ktfmt + " 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('g4 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 rbs ss rb + +nmap yb :let @+ = join(blaze#GetTargets(), ' ') +]]) diff --git a/vim/.vim/prefs/google.vim b/vim/.vim/prefs/google.vim deleted file mode 100644 index b66a6e2..0000000 --- a/vim/.vim/prefs/google.vim +++ /dev/null @@ -1,138 +0,0 @@ -source /usr/share/vim/google/glug/bootstrap.vim -source /usr/share/vim/google/core.vim - -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 BuildCleanerTarget() -nnoremap bcf :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 - -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 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('g4 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 rbs ss rb - -nmap yb :let @+ = join(blaze#GetTargets(), ' ') - -Glug corpweb -nnoremap csw :CorpWebCsFile diff --git a/zsh/.aliases.sh b/zsh/.aliases.sh index 5294afe..7df34ad 100644 --- a/zsh/.aliases.sh +++ b/zsh/.aliases.sh @@ -39,3 +39,10 @@ alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\ # recursively delete .DS_Store files alias ds_clean='find ./ -name ".DS_Store" -depth -exec rm {} \;' + +swap_files () { + tmp_name=$(TMPDIR=$(dirname -- "$1") mktemp) && + mv -f -- "$1" "$tmp_name" && + mv -f -- "$2" "$1" && + mv -f -- "$tmp_name" "$2" +}