From 71968f89a45c4f2551c0d6deca37bea4a25f83f0 Mon Sep 17 00:00:00 2001 From: Elliot Foster Date: Fri, 23 Jul 2021 12:54:26 -0500 Subject: [PATCH 1/3] Try to make my vimrc usable for mac and ruby --- .gitmodules | 3 +++ bundle/match-up | 1 + vimrc | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 160000 bundle/match-up diff --git a/.gitmodules b/.gitmodules index 2c3a5b9..1267225 100644 --- a/.gitmodules +++ b/.gitmodules @@ -109,3 +109,6 @@ [submodule "bundle/unimpaired"] path = bundle/unimpaired url = https://github.com/tpope/vim-unimpaired.git +[submodule "bundle/match-up"] + path = bundle/match-up + url = https://github.com/andymass/vim-matchup.git diff --git a/bundle/match-up b/bundle/match-up new file mode 160000 index 0000000..61802ad --- /dev/null +++ b/bundle/match-up @@ -0,0 +1 @@ +Subproject commit 61802ad25f303dc37f575cbed9b902605353db49 diff --git a/vimrc b/vimrc index e92b528..b5da3e9 100644 --- a/vimrc +++ b/vimrc @@ -47,9 +47,7 @@ if has('gui_running') set guifont=Source\ Code\ Pro\ 9 endif -if $COLORTERM == 'gnome-terminal' - set t_Co=256 -endif +set t_Co=256 colorscheme monokai_lumpy @@ -97,7 +95,7 @@ let g:ctrlp_custom_ignore = { \ 'dir': 'node_modules\|dist$', \ } -set diffopt+=vertical +set diffopt=vertical let g:lasttab = 1 nmap f :ALEFix From dec920682daf6e1d7fa5e01206d333c663ac0561 Mon Sep 17 00:00:00 2001 From: Elliot Foster Date: Mon, 26 Jul 2021 08:27:56 -0500 Subject: [PATCH 2/3] Spend less time waiting for ctrlp/Ack Because rg is _much_ faster than ag, at least in a large repo --- vimrc | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/vimrc b/vimrc index b5da3e9..62a5302 100644 --- a/vimrc +++ b/vimrc @@ -125,16 +125,49 @@ let g:gitgutter_max_signs = 2000 set modelines=0 set nomodeline -" The Silver Searcher -if executable('ag') +" quickly zoom splits in/out from https://medium.com/@vinodkri/zooming-vim-window-splits-like-a-pro-d7a9317d40 +noremap z _ \| \| + +if executable('rg') + set grepprg=rg\ --color=never + let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""' + let g:ctrlp_use_caching = 0 +elseif executable('ag') " Use ag over grep set grepprg=ag\ --nogroup\ --nocolor " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' " ag is fast enough that CtrlP doesn't need to cache let g:ctrlp_use_caching = 0 endif -command! -nargs=+ -complete=file -bar Ag silent! grep! |cwindow|redraw! -nmap d :grep! "\b\b":cw" Ack -if executable('ag') + +" adapted from https://www.freecodecamp.org/news/how-to-search-project-wide-vim-ripgrep-ack/ with a fallback to ag for transition +"ack.vim --- {{{ + +" Use ripgrep for searching ⚡️ +" Options include: +" --vimgrep -> Needed to parse the rg response properly for ack.vim +" --type-not sql -> Avoid huge sql file dumps as it slows down the search +" --smart-case -> Search case insensitive if all lowercase pattern, Search case sensitively otherwise +if executable('rg') + let g:ackprg = 'rg --vimgrep --type-not sql --smart-case' +elseif executable('ag') let g:ackprg = 'ag --vimgrep' endif -cabbrev Ack Ack! + +" Auto close the Quickfix list after pressing '' on a list item +"let g:ack_autoclose = 1 +let g:ack_autoclose = 0 + +" Any empty ack search will search for the work the cursor is on +let g:ack_use_cword_for_empty_search = 1 + +" Don't jump to first match +cnoreabbrev Ack Ack! + +" Maps / so we're ready to type the search keyword +"nnoremap / :Ack! +"nmap d :grep! "\b\b":cw" Ack +" }}} + +" Navigate quickfix list with ease +nnoremap [q :cprevious +nnoremap ]q :cnext From 2fe7f9dcaf5a372ed1686d90b2aca2c5856d4a1b Mon Sep 17 00:00:00 2001 From: Elliot Foster Date: Wed, 29 Mar 2023 13:41:58 -0500 Subject: [PATCH 3/3] Commit whatever I have --- .gitmodules | 12 +++++++ bundle/fastfold | 1 + bundle/tlib_vim | 2 +- bundle/vim-lsc | 1 + bundle/vim-ruby | 1 + init/keybindings.vim | 24 ++++++------- init/options.vim | 8 +++-- init/tabline.vim | 81 ++++++++++++++++++++++++++++++++++++++++++-- rust.vim | 1 + vimrc | 79 ++++++++++++++++++++++++++++++++++++++---- 10 files changed, 185 insertions(+), 25 deletions(-) create mode 160000 bundle/fastfold create mode 160000 bundle/vim-lsc create mode 160000 bundle/vim-ruby create mode 160000 rust.vim diff --git a/.gitmodules b/.gitmodules index 1267225..0dcb269 100644 --- a/.gitmodules +++ b/.gitmodules @@ -112,3 +112,15 @@ [submodule "bundle/match-up"] path = bundle/match-up url = https://github.com/andymass/vim-matchup.git +[submodule "bundle/vim-ruby"] + path = bundle/vim-ruby + url = https://github.com/vim-ruby/vim-ruby.git +[submodule "bundle/fastfold"] + path = bundle/fastfold + url = https://github.com/Konfekt/FastFold.git +[submodule "bundle/vim-lsc"] + path = bundle/vim-lsc + url = https://github.com/natebosch/vim-lsc +[submodule "rust.vim"] + path = rust.vim + url = https://github.com/rust-lang/rust.vim.git diff --git a/bundle/fastfold b/bundle/fastfold new file mode 160000 index 0000000..20126c1 --- /dev/null +++ b/bundle/fastfold @@ -0,0 +1 @@ +Subproject commit 20126c1646f96da862af7cbec45ca0fe0a930703 diff --git a/bundle/tlib_vim b/bundle/tlib_vim index ced8f3e..70c4e22 160000 --- a/bundle/tlib_vim +++ b/bundle/tlib_vim @@ -1 +1 @@ -Subproject commit ced8f3ebe85b50da2ec0e6d593e6b2e8e6bd243b +Subproject commit 70c4e222464020edc2809c932b488daaf891eeef diff --git a/bundle/vim-lsc b/bundle/vim-lsc new file mode 160000 index 0000000..4b0fc48 --- /dev/null +++ b/bundle/vim-lsc @@ -0,0 +1 @@ +Subproject commit 4b0fc48037c628f14209f30616a19287d9e54823 diff --git a/bundle/vim-ruby b/bundle/vim-ruby new file mode 160000 index 0000000..5516e30 --- /dev/null +++ b/bundle/vim-ruby @@ -0,0 +1 @@ +Subproject commit 5516e301a5c3cacac008342006a712f5fa80f6a1 diff --git a/init/keybindings.vim b/init/keybindings.vim index 16cbe68..6f7e6dc 100644 --- a/init/keybindings.vim +++ b/init/keybindings.vim @@ -15,17 +15,17 @@ let maplocalleader = ";" "vmap s :s/ " Split screen -map v :vsp +"map v :vsp " Move between screens "map w ^Ww "map = ^W= "map j ^Wj "map k ^Wk -nmap h -nmap j -nmap k -nmap l +nmap h +nmap j +nmap k +nmap l " Open .vimrc file in new tab. Think Command + , [Preferences...] but with Shift. "map :tabedit ~/.vimrc @@ -55,8 +55,8 @@ map \ :NERDTreeToggle map \| :NERDTreeFind " Previous/next quickfix file listings (e.g. search results) -map :cn -map :cp +"map :cn +"map :cp " Previous/next buffers map :bp @@ -76,7 +76,7 @@ vmap :FufFile **/ " refresh the FuzzyFinder cache -map rf :FufRenewCache +"map rf :FufRenewCache " Command-T "map :CommandTFlush:CommandT @@ -84,8 +84,8 @@ map rf :FufRenewCache map f :CtrlP " ctags with rails load path -map rt :!rails runner 'puts $LOAD_PATH.join(" ")' \| xargs /usr/local/bin/ctags -R public/javascripts -map T :!rails runner 'puts $LOAD_PATH.join(" ")' \| xargs rdoc -f tags +"map rt :!rails runner 'puts $LOAD_PATH.join(" ")' \| xargs /usr/local/bin/ctags -R public/javascripts +"map T :!rails runner 'puts $LOAD_PATH.join(" ")' \| xargs rdoc -f tags " Git blame map g :Gblame @@ -96,10 +96,10 @@ map NERDCommenterToggle imap NERDCommenterToggle i " In command-line mode, should go to the front of the line, as in bash. -cmap +"cmap " Copy current file path to system pasteboard -map :let @* = expand("%"):echo "Copied: ".expand("%") +map c :let @* = expand("%"):echo "Copied: ".expand("%") map C :let @* = expand("%").":".line("."):echo "Copied: ".expand("%").":".line(".") " Disable middle mouse button, F1 diff --git a/init/options.vim b/init/options.vim index fdc7ebd..7e7bd75 100644 --- a/init/options.vim +++ b/init/options.vim @@ -3,10 +3,14 @@ set guioptions-=T " Remove GUI toolbar set guioptions-=e " Use text tab bar, not GUI set guioptions-=rL " Remove scrollbars set visualbell " Suppress audio/visual error bell -set notimeout " No command timeout set showcmd " Show typed command prefixes while waiting for operator "set mouse=a " Use mouse support in XTerm/iTerm. +" following line causes odd behavior when exiting insert mode. When is +" pressed to leave insert mode, the `-- INSERT --` marker does not go away +" until another key is pressed +"set notimeout " No command timeout + set expandtab " Use soft tabs set tabstop=2 " Tab settings set autoindent @@ -37,7 +41,7 @@ set scrolloff=3 " Scroll when the cursor is 3 lines from edge set cursorline " Highlight current line " More detailed status line -set statusline=[%n]\ %f\ %m\ %y +set statusline=[tab\ %{tabpagenr()}][buf\ %n]\ %f\ %m\ %y set statusline+=%{fugitive#statusline()} " Show git details" set statusline+=%{exists('g:loaded_rvm')?rvm#statusline():''} " Show RVM details" set statusline+=%w " [Preview] diff --git a/init/tabline.vim b/init/tabline.vim index 824ae23..12bb6c0 100644 --- a/init/tabline.vim +++ b/init/tabline.vim @@ -22,9 +22,11 @@ if exists("+showtabline") let file = bufname(bufnr) let buftype = getbufvar(bufnr, 'buftype') if buftype == 'nofile' - if file =~ '\/.' - let file = substitute(file, '.*\/\ze.', '', '') - endif + if file =~ '\/.' + let file = substitute(file, '.*\/\ze.', '', '') + endif + else + let file = pathshorten(bufname(bufnr)) endif if file == '' let file = '[No Name]' @@ -41,3 +43,76 @@ if exists("+showtabline") set showtabline=1 highlight link TabNum Special endif + +" set showtabline=1 " 1 to show tabline only when more than one tab is present +" set tabline=%!MyTabLine() " custom tab pages line +" function! MyTabLine() " acclamation to avoid conflict +" let s = '' " complete tabline goes here +" " loop through each tab page +" for t in range(tabpagenr('$')) +" " set highlight +" if t + 1 == tabpagenr() +" let s .= '%#TabLineSel#' +" else +" let s .= '%#TabLine#' +" endif +" " set the tab page number (for mouse clicks) +" let s .= '%' . (t + 1) . 'T' +" let s .= ' ' +" " set page number string +" let s .= t + 1 . ' ' +" " get buffer names and statuses +" let n = '' "temp string for buffer names while we loop and check buftype +" let m = 0 " &modified counter +" " let bc = len(tabpagebuflist(t + 1)) "counter to avoid last ' ' +" " loop through each buffer in a tab +" +" " for b in tabpagebuflist(t + 1) +" " " buffer types: quickfix gets a [Q], help gets [H]{base fname} +" " " others get 1dir/2dir/3dir/fname shortened to 1/2/3/fname +" " if getbufvar( b, "&buftype" ) == 'help' +" " let n .= '[H]' . fnamemodify( bufname(b), ':t:s/.txt$//' ) +" " elseif getbufvar( b, "&buftype" ) == 'quickfix' +" " let n .= '[Q]' +" " else +" " let n .= pathshorten(bufname(b)) +" " endif +" " " check and ++ tab's &modified count +" " if getbufvar( b, "&modified" ) +" " let m += 1 +" " endif +" " " no final ' ' added...formatting looks better done later +" " if bc > 1 +" " let n .= ' ' +" " endif +" " let bc -= 1 +" " endfor +" " add modified label [n+] where n pages in tab are modified +" if m > 0 +" let s .= '[' . m . '+]' +" endif +" " select the highlighting for the buffer names +" " my default highlighting only underlines the active tab +" " buffer names. +" if t + 1 == tabpagenr() +" let s .= '%#TabLineSel#' +" else +" let s .= '%#TabLine#' +" endif +" " add buffer names +" if n == '' +" let s.= '[New]' +" else +" let s .= n +" endif +" " switch to no underlining and add final space to buffer list +" let s .= ' ' +" endfor +" " after the last tab fill with TabLineFill and reset tab page nr +" let s .= '%#TabLineFill#%T' +" " right-align the label to close the current tab page +" if tabpagenr('$') > 1 +" let s .= '%=%#TabLineFill#%999Xclose' +" endif +" return s +" endfunction diff --git a/rust.vim b/rust.vim new file mode 160000 index 0000000..4aa69b8 --- /dev/null +++ b/rust.vim @@ -0,0 +1 @@ +Subproject commit 4aa69b84c8a58fcec6b6dad6fe244b916b1cf830 diff --git a/vimrc b/vimrc index 62a5302..6179a7c 100644 --- a/vimrc +++ b/vimrc @@ -31,6 +31,27 @@ filetype plugin indent on runtime! init/**.vim +"runtime! init/ack.vim +"runtime! init/colorscheme.vim +"runtime! init/fugitive.vim +"runtime! init/gundo.vim +"runtime! init/keybindings.vim +"runtime! init/language.vim +" +"runtime! init/nerd_commenter.vim +"runtime! init/nerd_tree.vim +" +"runtime! init/tabline.vim +"runtime! init/terminal.vim +"runtime! init/vim-spec.vim +" +"runtime! init/run_tests.vim +" +"" offending file that causes ESC to not make INSERT mode go away until another +"" key is pressed +"runtime! init/options.vim + + " Machine-local vim settings - keep this at the end " -------------------------- @@ -60,7 +81,8 @@ set cursorline hi CursorLine cterm=NONE ctermbg=238 hi CursorColumn cterm=NONE ctermbg=238 -set foldmethod=syntax +"set foldmethod=syntax +set foldmethod=indent set foldlevelstart=100 set novisualbell @@ -73,10 +95,10 @@ nnoremap :tabnew inoremap :tabpreviousi inoremap :tabnexti inoremap :tabnew -map [1;5C -map [1;5D -map! [1;5C -map! [1;5D +" map [1;5C +" map [1;5D +" map! [1;5C +" map! [1;5D set fileformat=unix @@ -86,6 +108,12 @@ augroup autoformat_settings "autocmd FileType c,cpp,proto,javascript AutoFormatBuffer clang-format augroup END +" augroup ft_rb +" au! +" " fix the SLOOOW syntax highlighting +" au FileType ruby setlocal re=1 +" augroup END + let g:codefmt_clang_format_style = 'Google' set nolist @@ -110,13 +138,13 @@ au TabLeave * let g:lasttab = tabpagenr() highlight ALEError ctermbg=none cterm=underline ctermfg=208 highlight ALEWarning ctermbg=none cterm=underline ctermfg=208 let g:ale_echo_msg_format = '%linter% says %s' +"\ 'typescript': [ 'tslint', 'eslint', 'tsserver' ], let g:ale_linters = { \ 'javascript': [ 'eslint' ], -\ 'typescript': [ 'tslint', 'eslint', 'tsserver' ], \} +"\ 'typescript': [ 'tslint', 'eslint' ], let g:ale_fixers = { \ 'javascript': [ 'eslint' ], -\ 'typescript': [ 'tslint', 'eslint' ], \} let g:gitgutter_max_signs = 2000 @@ -171,3 +199,40 @@ cnoreabbrev Ack Ack! " Navigate quickfix list with ease nnoremap [q :cprevious nnoremap ]q :cnext + +" \ 'javascript': { +" \ 'command': 'typescript-language-server --stdio', +" \ 'log_level': -1, +" \ 'suppress_stderr': v:true, +" \ } +let g:lsc_server_commands = { + \ 'ruby': { + \ 'command': 'solargraph stdio', + \ 'log_level': -1, + \ 'suppress_stderr': v:true, + \ }, + \} +let g:lsc_auto_map = { + \ 'GoToDefinitionSplit': 'gd', + \ 'FindReferences': 'gr', + \ 'Rename': 'gR', + \ 'ShowHover': 'K', + \ 'FindCodeActions': 'ga', + \} +" \ 'GoToDefinition': 'gd', +" \ 'Completion': 'omnifunc', + +"augroup my_lsc +" au! +" au BufNewFile,BufReadPost * +" \ if has_key(g:lsc_servers_by_filetype, &filetype) && lsc#server#filetypeActive(&filetype) +" \| nnoremap ] :tab LSClientGoToDefinitionSplit +" \| nnoremap :tab LSClientGoToDefinitionSplit +" \| endif +"augroup end + +"let g:lsc_enable_autocomplete = v:true +let g:lsc_enable_autocomplete = v:false +let g:lsc_enable_diagnostics = v:false +let g:lsc_reference_highlights = v:false +let g:lsc_trace_level = 'off'