Skip to content

Instantly share code, notes, and snippets.

@jacobobryant
Created January 13, 2024 20:40
Show Gist options
  • Save jacobobryant/d40fece1da5e54681879c6df4e17af35 to your computer and use it in GitHub Desktop.
Save jacobobryant/d40fece1da5e54681879c6df4e17af35 to your computer and use it in GitHub Desktop.
neovim config as of jan 2024
call plug#begin()
function! DoRemote(arg)
UpdateRemotePlugins
endfunction
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'guns/vim-sexp'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
" search file navigation (fuzzy find)
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" session management; i.e. open up to the same files when you start vim
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
"Plug 'rmagatti/auto-session'
" used for goto definition
Plug 'ludovicchabant/vim-gutentags'
" hierarchical file navigation
Plug 'scrooloose/nerdtree'
" shows you what lines in the current file have been added/modified/deleted
Plug 'airblade/vim-gitgutter'
" handy git commands like Gread and Gblame
" example: see version of current file on master with `:Gread master:%`
Plug 'tpope/vim-fugitive'
Plug 'junegunn/gv.vim'
" handy way to see a list of your open files
" nice for when you have a lot of open files
Plug 'jlanzarotta/bufexplorer'
" tweak: makes closing files better
"Plug 'rbgrouleff/bclose.vim'
" make parentheses have matching colors
Plug 'luochen1990/rainbow'
Plug 'Olical/conjure' ", {'tag': 'v4.18.0'}
"Plug 'joukevandermaas/vim-ember-hbs'
"Plug 'github/copilot.vim'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"
"Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
"Plug 'MattesGroeger/vim-bookmarks'
call plug#end()
"======PLUGIN CONFIG=====
" vim-sexp -- even the mapping from vim-sexp-mappings-for-regular-people need some improvement imo
nmap <M-k> <Plug>(sexp_emit_head_element)
nmap <M-j> <Plug>(sexp_capture_prev_element)
nmap H <Plug>(sexp_emit_tail_element)
nmap L <Plug>(sexp_capture_next_element)
let mapleader=","
let maplocalleader="\<space>"
" FZF
"let $FZF_DEFAULT_COMMAND = 'ag -l --nocolor -U -g ""'
function! FzfTagsCurrentWord()
let l:word = expand('<cword>')
let l:list = taglist(l:word)
if len(l:list) == 1
execute ':tag ' . l:word
else
call fzf#vim#tags(l:word)
endif
endfunction
noremap <c-]> :call FzfTagsCurrentWord()<cr>
map <c-p> :Files<cr>
map <c-t> :Tags<cr>
" vim-session
let g:session_autosave = 'yes'
let g:session_default_to_last = 1
"let g:session_autoload = 'yes'
let g:session_autosave_periodic = 1
let g:session_autosave_silent = 1
cnoreabbrev ss SaveSession
cnoreabbrev os OpenSession
set sessionoptions=curdir,folds,help,tabpages,winsize
"set sessionoptions-=options
"set sessionoptions-=blank
"set sessionoptions-=tabpages
"set sessionoptions+=winpos,terminal,folds
"
"
"set sessionoptions=buffers,curdir,tabpages,winsize,options
"
"set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,options
"lua << EOF
"local opts = {
" --log_level = 'info',
" --auto_session_enable_last_session = false,
" --auto_session_root_dir = vim.fn.stdpath('data').."/sessions/",
" --auto_session_enabled = true,
" --auto_save_enabled = nil,
" --auto_restore_enabled = nil,
" --auto_session_suppress_dirs = nil,
" --auto_session_use_git_branch = nil,
" ---- the configs below are lua only
" --bypass_session_save_file_types = nil
"}
"
"require("auto-session").setup(opts)
"EOF
" gutentags
" use <C-]> for go to definition
"let g:gutentags_trace = 1
set tags=./.tags,.tags;
let g:gutentags_enabled = 1
let g:gutentags_ctags_tagfile = '.tags'
let g:gutentags_file_list_command = {
\ 'markers': {
\ '.git': 'git-ls-files',
\ },
\ }
let g:gutentags_generate_on_new = 1
let g:gutentags_define_advanced_commands = 1
" nerdtree
let g:NERDTreeWinSize=55
let g:NERDTreeDirArrows=0
map <leader>f :NERDTreeFind<cr>
map <m-o> :NERDTreeToggle<cr>
" gitgutter
let g:gitgutter_map_keys = 0
set updatetime=250
" bufexplorer
let g:bufExplorerFindActive=0
" bclose
"map <leader>d :Bclose<cr>
"" rainbow parentheses
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['white', 'red', 'green', 'blue', 'yellow'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
" conjure / clojure
map <leader>CB :ConjureConnect 7888<cr><cr>
map <leader>R :ConjureEval ((requiring-resolve 'development/restart))<cr>
map <leader>S :ConjureShadowSelect main<cr>
"======END PLUGIN CONFIG=====
" Clojure
let g:clojure_maxlines = 500
let g:clojure_fuzzy_indent = 1
let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let', '^go', '-join$', 'submit-tx$', 'list-when$', '^do$', '^comment$', 'cond$',
\ '^try$', '^finally$', '^future$',
\ '^div$', '^span$', '^button$', '^table$', '^thead$', '^tbody$', '^tr$',
\ '^th$', '^td$', '^label$', '^h1$', '^h2$', '^h3$', '^h4$', '^h5$', '^h6$',
\ '^svg$', '^path$', '^p$', '^input$', '^form$', '^i$', '^a$', '^em$',
\ '^strong$', '^hr$', '^ul$', '^ol$', '^li$', '^textarea$', '^set-state!$',
\ '^specification$', '^component$']
let g:clojure_align_subforms = 1
let g:clojure_special_indent_words =
\ 'deftype,defrecord,reify,proxy,extend-type,extend-protocol,letfn,defmutation'
let g:clojure_align_multiline_strings = 1
set conceallevel=0
set guicursor=
set list
set laststatus=1
set expandtab
set tabstop=2 " hard tabs
set shiftwidth=2 " soft tabs
set softtabstop=2 " soft tabs when backspacing, etc
set scrolloff=8
set hidden
set number
set nojoinspaces
set ignorecase
set smartcase
set spellcapcheck=false
set nowrap
set nostartofline
set autoindent
set nofixendofline
set exrc
set textwidth=120
nnoremap s :set invspell<cr>
noremap ; :
map <c-l> gt
map <c-h> gT
map j gj
map k gk
imap <c-c> <esc>
map <leader>h :nohlsearch<cr>
" get the highlight name of the text under the cursor
"map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
"\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
"\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
map <C-W>t :tab split<cr>
noremap <f9> :syntax sync fromstart<cr>
map <leader>s :s/\(^\\|$\)/"/g<cr>:nohlsearch<cr>
nnoremap cp :let @" = expand("%")<cr>
" Navigation
" jump to symbol from nav file
"nnoremap <leader>j :tab split<cr>0yE$gfgg/<C-r>"<cr>:nohlsearch<cr>
"" yank current symbol into nav file
"nnoremap <leader>y yiw<c-w>v:e nav.txt<cr>Go<esc>pa <esc><c-w><c-w>:let @" = expand("%")<cr><c-w><c-w>p:w<cr>
"" Open nav file
"nnoremap <leader>n <c-w>v:e nav.txt<cr>
"nnoremap <leader>m yiw:BookmarkToggle<cr>:BookmarkAnnotate <c-r>"<cr>
"nnoremap <leader>M <cr>:BookmarkToggle<cr>Y<cr><cr>
"let g:bookmark_no_default_key_mappings = 1
"let g:bookmark_auto_close = 1
"nmap mm <Plug>BookmarkShowAll
filetype plugin on
"filetype plugin indent on
syntax on
" The Silver Searcher
if executable('ag')
" Use ag over grep
" TODO only search files tracked by git
set grepprg=ag\ --nogroup\ --nocolor
endif
nnoremap <Leader>* :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
color desert
hi default link BufTabLineCurrent WildMenu
hi Search cterm=NONE ctermfg=white ctermbg=darkblue
hi VertSplit cterm=NONE ctermfg=white ctermbg=NONE
hi NormalFloat ctermbg=234 ctermfg=NONE guibg=NONE guifg=NONE
autocmd BufNewFile,BufRead *.bb set ft=clojure
autocmd VimEnter * set indentexpr=<cr>
" `autoread` when files changes on disk
" https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
" https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" Notification after file change
" https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
"autocmd FileChangedShellPost * echohl WarningMsg | echo \"File changed on disk. Buffer reloaded. \" . exapnd(\"%\") | echohl None
autocmd FileType html setlocal indentkeys=
"set clipboard+=unnamedplus
let g:clipboard = {
\ 'name': 'win32yank-wsl',
\ 'copy': {
\ '+': 'win32yank.exe -i --crlf',
\ '*': 'win32yank.exe -i --crlf',
\ },
\ 'paste': {
\ '+': 'win32yank.exe -o --lf',
\ '*': 'win32yank.exe -o --lf',
\ },
\ 'cache_enabled': 0,
\ }
"autocmd VimEnter * Copilot disable
"nnoremap <localleader>pe :Copilot enable<cr>
"nnoremap <localleader>pd :Copilot disable<cr>
"
"let g:LanguageClient_serverCommands = {
" \ 'clojure': ['/usr/local/bin/clojure-lsp'],
" \ }
"nmap <F5> <Plug>(lcn-menu)
"
let g:ftplugin_sql_omni_key = '<C-j>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment