From 89aff8fc53d702069afbb513c18ff31d586f2d22 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Fri, 3 Jun 2022 17:52:18 +0000 Subject: [PATCH] Update vim prefs --- config/.config/nvim/lua/diagnostics.lua | 2 +- config/.config/nvim/lua/lsp.lua | 4 +- fzf/fzf-at-google.zsh | 18 +++++++ vim/.vim/prefs/google.vim | 18 ++++++- vim/.vim/prefs/google_comments.vim | 8 ++- vim/.vim/prefs/init.vim | 64 ----------------------- vim/.vim/prefs/mappings.vim | 1 - vim/.vim/prefs/plugins.vim | 8 +-- vim/.vim/prefs/ripgrep.vim | 13 +++++ vim/.vimrc | 67 +++++++++++++++++++++++-- zsh/.aliases.sh | 2 +- 11 files changed, 127 insertions(+), 78 deletions(-) create mode 100644 vim/.vim/prefs/ripgrep.vim diff --git a/config/.config/nvim/lua/diagnostics.lua b/config/.config/nvim/lua/diagnostics.lua index c2fae9f..5844f82 100644 --- a/config/.config/nvim/lua/diagnostics.lua +++ b/config/.config/nvim/lua/diagnostics.lua @@ -53,4 +53,4 @@ vim.api.nvim_set_keymap("n", "xx", "Trouble", { silent = true, vim.api.nvim_set_keymap("n", "xw", "Trouble workspace_diagnostics", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "xd", "Trouble document_diagnostics", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "xl", "Trouble loclist", { silent = true, noremap = true }) -vim.api.nvim_set_keymap("n", "xq", "Trouble quick`ix", { silent = true, noremap = true }) +vim.api.nvim_set_keymap("n", "xq", "Trouble quickfix", { silent = true, noremap = true }) diff --git a/config/.config/nvim/lua/lsp.lua b/config/.config/nvim/lua/lsp.lua index 3944c09..6e30109 100644 --- a/config/.config/nvim/lua/lsp.lua +++ b/config/.config/nvim/lua/lsp.lua @@ -154,8 +154,10 @@ local on_attach = function(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) -- diagnostics controls references vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.signature_help()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "i", "", "lua vim.lsp.buf.signature_help()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gt", "lua vim.lsp.buf.type_definition()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "[g", "lua vim.diagnostic.goto_prev()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "]g", "lua vim.diagnostic.goto_next()", opts) diff --git a/fzf/fzf-at-google.zsh b/fzf/fzf-at-google.zsh index c7fe189..cf0fb3a 100644 --- a/fzf/fzf-at-google.zsh +++ b/fzf/fzf-at-google.zsh @@ -2,6 +2,24 @@ export FZF_SOURCE="${HOME}/fzf-relevant-files.zsh" +# General fzf settings. +export FZF_DEFAULT_OPTS=" \ + --inline-info \ + --reverse \ + --exact \ + --color=fg+:#F8F8F8,bg+:#515559,pointer:#F8F8F8,marker:226 \ + --bind=ctrl-e:select-all+accept \ + --bind=ctrl-d:half-page-down \ + --bind=ctrl-e:half-page-up + --bind=ctrl-t:toggle+down + --bind=ctrl-b:toggle+up + --bind=ctrl-g:select-all+accept \ + " +# Preview code with pygmentize. +# export FZF_CS_PREVIEW_COMMAND="python /google/src/files/head/depot/google3/third_party/py/pygments/google/google_pygmentize.py -f terminal16m -O style=native" +# Preview highlight: foreground: RG(248, 248, 248) = #F8F8F8, background: RGB(81, 85, 89) = #515559. +export FZF_CS_PREVIEW_HIGHLIGHT="\x1b[38;2;248;248;248m\x1b[48;2;81;85;89m" + function create_fzf_command() { rg --files $(${FZF_SOURCE}) } diff --git a/vim/.vim/prefs/google.vim b/vim/.vim/prefs/google.vim index 5e6d068..84758ce 100644 --- a/vim/.vim/prefs/google.vim +++ b/vim/.vim/prefs/google.vim @@ -38,8 +38,8 @@ Glug relatedfiles plugin[mappings] Glug g4 Glug corpweb Glug google-csimporter -Glug blazedeps +" Update the current file's build deps Plug 'junegunn/fzf', { 'do': { -> fzf#install() }, 'commit': '3f75a83' } Plug 'junegunn/fzf.vim' Glug outline-window @@ -47,12 +47,16 @@ Glug fzf-query function s:blazeExec(cmd, targets) if len(a:targets) == 0 - exe VimuxRunCommand("build_target.py " . expand('%:p') . " " . a:cmd) + 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 @@ -65,9 +69,15 @@ function BlazeTestDebug() abort call blazeExec("blaze test --java_debug", blaze#GetTargets()) endfunction +function BuildCleaner() abort + exe VimuxRunCommand("build_cleaner " . expand('%')) +endfunction + +nnoremap br :call BlazeRun() nnoremap bb :call BlazeBuild() nnoremap bt :call BlazeTest() nnoremap btd :call BlazeTestDebug() +nnoremap bc :call BuildCleaner() let g:asyncrun_open = 1 @@ -154,6 +164,10 @@ endfunction com! -nargs=? -complete=file Blame :call G4Blame() nnoremap cs :FzfCs +" The buffer n can be replaced by any other unused buffer. +" removes the visual range because csearch doesn't support ranges. +" Removes newlines to allow the entire line search using V-LINE mode. +vnoremap cs "ny:FzfCs "=substitute(@n, '\n', '', '')" nnoremap csi :CsImporter nnoremap CS :FzfCs nnoremap cc :CritiqueUnresolvedComments diff --git a/vim/.vim/prefs/google_comments.vim b/vim/.vim/prefs/google_comments.vim index 06dde13..a438632 100644 --- a/vim/.vim/prefs/google_comments.vim +++ b/vim/.vim/prefs/google_comments.vim @@ -3,7 +3,8 @@ lua << EOF require('google.comments').setup { -- The command for fetching comments, refer to `get_comments.par --help` to -- see all the options. - command = {'/google/bin/releases/editor-devtools/get_comments.par', '--full', '--noresolved', '--json', "-x=''"}, + -- command = {'/google/bin/releases/editor-devtools/get_comments.par', '--full', '--noresolved', '--json', "-x=''"}, + command = {'/google/bin/releases/editor-devtools/get_comments.par', '--nofull', '-u', '--json', "-x=''"}, -- Define your own icon by `vim.fn.sign_define('ICON_NAME', {text = ' '})`. -- See :help sign_define -- The sign property passed to setup should be the 'ICON_NAME' in the define @@ -29,8 +30,11 @@ vim.api.nvim_set_keymap('n', 'lc', [[lua require('google.comments').toggle_line_comments()]], { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', 'ac', - [[lua require('google.comments').show_all_comments()]], + [[lua require('google.comments').toggle_all_comments()]], { noremap = true, silent = true }) vim.fn.sign_define('COMMENT_ICON', {text = ''}) EOF + +autocmd InsertLeave * :lua require('google.comments').update_signs() +autocmd FileType * :lua require('google.comments').fetch_comments() diff --git a/vim/.vim/prefs/init.vim b/vim/.vim/prefs/init.vim index 2d00278..e69de29 100644 --- a/vim/.vim/prefs/init.vim +++ b/vim/.vim/prefs/init.vim @@ -1,64 +0,0 @@ -set directory=/tmp -set undodir=/tmp -set nobackup -set nowritebackup -au BufWritePre * let &bex = '@' . strftime("%F.%H:%M") - -autocmd BufWritePre * StripWhitespace -set termguicolors -let &t_8f = "\[38;2;%lu;%lu;%lum" -let &t_8b = "\[48;2;%lu;%lu;%lum" -let &t_AB="\e[48;5;%dm" -let &t_AF="\e[38;5;%dm" -syntax on - - -set laststatus=2 -set cmdheight=1 -set ttyfast -set relativenumber -set copyindent -set preserveindent -set lazyredraw " Enable if running slow... -set autoindent - -set wrap -set linebreak -set textwidth=79 -set showbreak=⇇ - -" use intelligent indentation for C -" configure tabwidth and insert spaces instead of tabs -set tabstop=4 " tab width is 4 spaces -set shiftwidth=4 " indent also with 4 spaces -set expandtab " expand tabs to spaces - -set number -set showcmd -set cursorline -set showmatch -set visualbell " don't beep -set history=6000 " remember more commands and search history -set undolevels=6000 " use many levels of undo - -" ------------------------------------------------ -" -------------------SEARCHING-------------------- -" ------------------------------------------------ -set ignorecase " ignore case when searching -set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise -set incsearch " search as characters are entered -set hlsearch " highlight matches - -set splitright " Puts new vsplit windows to the right of the current -set splitbelow " Puts new split windows to the bottom of the current - -set scrolljump=5 " Line to scroll when cursor leaves screen -set scrolloff=3 " Minumum lines to keep above and below cursor - -" makes sure that when opening, files are normal, i.e. not folded. -set nofoldenable - -" set clipboard=unnamed -set shortmess=A - -set updatetime=100 diff --git a/vim/.vim/prefs/mappings.vim b/vim/.vim/prefs/mappings.vim index 00b7ba1..4f64a88 100644 --- a/vim/.vim/prefs/mappings.vim +++ b/vim/.vim/prefs/mappings.vim @@ -23,7 +23,6 @@ tnoremap l inoremap " Fox for Ack -cnoreabbrev Ack Ack! cnoremap %% =fnameescape(expand("%:p:h")."/") " move vertically by visual line diff --git a/vim/.vim/prefs/plugins.vim b/vim/.vim/prefs/plugins.vim index a800179..6135e67 100644 --- a/vim/.vim/prefs/plugins.vim +++ b/vim/.vim/prefs/plugins.vim @@ -20,9 +20,11 @@ Plug 'junegunn/fzf.vim' Plug 'vim-airline/vim-airline' " ... Plug 'nathanaelkane/vim-indent-guides' Plug 'Konfekt/vim-scratchpad' -Plug 'kyazdani42/nvim-web-devicons' +" Plug 'kyazdani42/nvim-web-devicons' +" Plug 'ryanoasis/vim-devicons' " INTEGRATION +Plug 'AndrewRadev/linediff.vim' Plug 'tpope/vim-fugitive' " git Plug 'junegunn/gv.vim' " git commit browser Plug 'tpope/vim-git' @@ -49,10 +51,10 @@ Plug 'christoomey/vim-titlecase' Plug 'chiedo/vim-case-convert' " FILE INTERACTIONS -Plug 'mileszs/ack.vim' " Ack bindings +" Plug 'mileszs/ack.vim' " Ack bindings +Plug 'jremmen/vim-ripgrep' Plug 'preservim/nerdtree' " File Tree -Plug 'ryanoasis/vim-devicons' Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " LANGUAGE PLUGINS diff --git a/vim/.vim/prefs/ripgrep.vim b/vim/.vim/prefs/ripgrep.vim new file mode 100644 index 0000000..f16b2b9 --- /dev/null +++ b/vim/.vim/prefs/ripgrep.vim @@ -0,0 +1,13 @@ +Plug 'kyoh86/vim-ripgrep' + +" command! -nargs=+ -complete=file Rg :call ripgrep#search() +command! -nargs=+ -complete=file Rg :call s:ripgrep() +function s:ripgrep(searchterm) + let l:dir = fnameescape(expand("%:p:h")."/") + let l:rel = ripgrep#path#rel(l:dir) + " echomsg 'DIR: ' . l:dir . '\tREL: ' . l:rel + call ripgrep#call('rg --smart-case --json ' . a:searchterm, l:dir, l:rel) +endfunction +nnoremap rg :Rg + +let g:rg_root_marks = ['BUILD', 'METADATA', '.git'] diff --git a/vim/.vimrc b/vim/.vimrc index 9ec49d0..da639a7 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -4,21 +4,82 @@ let mapleader="," " BEST LEADER OF ALL TIME (BLOT) filetype off " required set rtp+=~/.vim/after -" ----------------------------------------------------------- -" ------------------------PLUGINS---------------------------- -" ----------------------------------------------------------- +set directory=/tmp +set undodir=/tmp +set nobackup +set nowritebackup +au BufWritePre * let &bex = '@' . strftime("%F.%H:%M") + +autocmd BufWritePre * StripWhitespace +set termguicolors +let &t_8f = "\[38;2;%lu;%lu;%lum" +let &t_8b = "\[48;2;%lu;%lu;%lum" +let &t_AB="\e[48;5;%dm" +let &t_AF="\e[38;5;%dm" +syntax on + + +set laststatus=2 +set cmdheight=1 +set ttyfast +set relativenumber +set copyindent +set preserveindent +set lazyredraw " Enable if running slow... +set autoindent + +set wrap +set linebreak +set textwidth=79 +set showbreak=⇇ + +" use intelligent indentation for C +" configure tabwidth and insert spaces instead of tabs +set tabstop=4 " tab width is 4 spaces +set shiftwidth=4 " indent also with 4 spaces +set expandtab " expand tabs to spaces + +set number +set showcmd +set cursorline +set showmatch +set visualbell " don't beep +set history=6000 " remember more commands and search history +set undolevels=6000 " use many levels of undo + +set ignorecase " ignore case when searching +set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise +set incsearch " search as characters are entered +set hlsearch " highlight matches + +set splitright " Puts new vsplit windows to the right of the current +set splitbelow " Puts new split windows to the bottom of the current + +set scrolljump=5 " Line to scroll when cursor leaves screen +set scrolloff=3 " Minumum lines to keep above and below cursor + +" makes sure that when opening, files are normal, i.e. not folded. +set nofoldenable + +" set clipboard=unnamed +set shortmess=A + +set updatetime=100 + call plug#begin('~/.vim/plugged') source ~/.vim/prefs/plugins.vim source ~/.vim/prefs/init.vim if filereadable(expand("~/.vimrc.local")) source ~/.vim/prefs/google.vim endif + source ~/.vim/prefs/mappings.vim source ~/.vim/prefs/leader.vim source ~/.vim/prefs/plug_prefs.vim source ~/.vim/prefs/ui.vim source ~/.vim/prefs/golang.vim source ~/.vim/prefs/ultisnips.vim + source ~/.vim/prefs/ripgrep.vim " source ~/.vim/prefs/coc.vim " source ~/.vim/prefs/asynclsp.vim " source ~/.vim/prefs/ycm.vim diff --git a/zsh/.aliases.sh b/zsh/.aliases.sh index 1132c66..a6c0ee7 100644 --- a/zsh/.aliases.sh +++ b/zsh/.aliases.sh @@ -89,7 +89,7 @@ get_current_activity() { } cl_search() { - hg whatsout | xargs -i sh -c "echo {} && rg $1 {}" + hg whatsout | xargs -i sh -c "echo {} && grep $1 {}" } cl_replace() {