dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit 105c20565c8d7c7a5a0268805cd4c3a058b6e08e
parent 6fd81dd7a81452246a9b276c904512604adb8094
Author: Chris Bracken <chris@bracken.jp>
Date:   Mon, 13 May 2024 21:10:36 -0700

Migrate from vim config to nvim config

After multiple attempts to use nvim, I've finally managed to pull off
using it for several months straight without issue. Now that the former
https://git.bracken.jp/vim.git repo is merged into my main dotfiles repo
https://git.bracken.jp/dotfiles.git, switch over from a vim-style ~/.vim
based config to an nvim-style ~/.config/nvim based config.

Diffstat:
M.config/git/config | 4++--
M.config/lynx/.lynxrc | 2+-
M.config/mutt/muttrc | 2+-
M.config/nvim/init.vim | 159+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
A.config/nvim/plugin/cscope.vim | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
R.vim/plugin/flutter.vim -> .config/nvim/plugin/flutter.vim | 0
R.vim/plugin/snippets.vim -> .config/nvim/plugin/snippets.vim | 0
R.vim/snippets/cc.cc -> .config/nvim/snippets/cc.cc | 0
R.vim/snippets/cc.h -> .config/nvim/snippets/cc.h | 0
R.vim/snippets/class.cc -> .config/nvim/snippets/class.cc | 0
R.vim/snippets/journal.md -> .config/nvim/snippets/journal.md | 0
R.vim/snippets/namespace.cc -> .config/nvim/snippets/namespace.cc | 0
R.vim/snippets/struct.cc -> .config/nvim/snippets/struct.cc | 0
R.vim/spell/en.utf-8.add -> .config/nvim/spell/en.utf-8.add | 0
R.vim/spell/fr.utf-8.add -> .config/nvim/spell/fr.utf-8.add | 0
M.config/zsh/.zshenv | 4++--
M.gitignore | 8++++++++
D.vim/.gitignore | 11-----------
D.vim/Makefile | 3---
D.vim/plugin/cscope.vim | 69---------------------------------------------------------------------
D.vim/vimrc | 155-------------------------------------------------------------------------------
AMakefile | 5+++++
22 files changed, 243 insertions(+), 248 deletions(-)

diff --git a/.config/git/config b/.config/git/config @@ -6,13 +6,13 @@ ui = auto [core] excludesfile = ~/.config/git/gitignore_global - editor = vim + editor = nvim [credential] helper = store [diff] algorithm = histogram mnemonicprefix = true - tool = vimdiff + tool = nvimdiff [filter "lfs"] required = true clean = git-lfs clean -- %f diff --git a/.config/lynx/.lynxrc b/.config/lynx/.lynxrc @@ -145,7 +145,7 @@ emacs_keys=off # or sending mail. If no editor is specified, then file editing is disabled # unless it is activated from the command line, and the built-in line editor # will be used for sending mail. -file_editor=vim +file_editor=nvim # The file_sorting_method specifies which value to sort on when viewing # file lists such as FTP directories. The options are: diff --git a/.config/mutt/muttrc b/.config/mutt/muttrc @@ -132,7 +132,7 @@ set include # include message in replies set forward_quote # include message in forwards # Editor ---------------------------------------------- -set editor='vim + -c "set nocp" -c "set textwidth=72" -c "set wrap" -c "silent /^$" -c "noh" -c "vmap <leader>s c[... snip ...]<ESC>" +set editor='nvim + -c "set nocp" -c "set textwidth=72" -c "set wrap" -c "silent /^$" -c "noh" -c "vmap <leader>s c[... snip ...]<ESC>" # Send Options --------------------------------------- set from = "chris@bracken.jp" diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim @@ -1,4 +1,155 @@ -" Share config with regular vim. -set runtimepath^=~/.vim runtimepath+=~/.vim/after -let &packpath = &runtimepath -source ~/.vim/vimrc +set nocompatible +set encoding=utf-8 + +" Remove any autocmds defined by the system for consistency. +if has("autocmd") + autocmd! +endif + +call plug#begin() +" Formatting. +Plug 'rhysd/vim-clang-format' " clang-format. +Plug 'vim-scripts/spacehi.vim' " Highlight bad whitespace. + +" Language support plugins. +Plug 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } +Plug 'rust-lang/rust.vim' +call plug#end() + +" Bind fancier manpage plugin to Shift-k. +runtime ftplugin/man.vim +set keywordprg=:Man + +let mapleader=',' +let s:cpo_save=&cpo +set cpo&vim + +" Enable middle-mouse paste. +map! <S-Insert> <MiddleMouse> +map <S-Insert> <MiddleMouse> + +" Kill ex mode. +noremap Q <NOP> + +" Disable visual-mode mouse select. +set mouse= + +" Kill arrow keys, for great justice. +noremap <Up> <NOP> +noremap <Down> <NOP> +noremap <Left> <NOP> +noremap <Right> <NOP> + +" Retain selection on <,>. +vmap < <gv +vmap > >gv +let &cpo=s:cpo_save +unlet s:cpo_save + +" Basic options +set incsearch " Turn on incrememental searching. +set hlsearch " Highlight search. +set visualbell " Less noise. +set number " Use line numbering. +set ruler " Show row/col in status. +set laststatus=1 " Only show status line if > 1 window. +set showmatch " Highlight matching bracket. +set history=50 " Keep 50 lines of cmdline history. +set wildmenu " Nicer autocomplete. +set wildmode=longest,full +set wildignore=*.o,*.pyc " Ignore some filetypes during completion. +set spelllang=en_ca " Set the spelling language. + +" Omnicomplete +set completeopt+=longest + +" Indentation/tabulation +set autoindent " Copy indent from current line when starting a new line. +set smartindent " Attempt to autoindent when starting a new line. +set smarttab " Use shiftwidth rather than tabstop at start of line. +set tabstop=2 " Number of spaces per tab. +set shiftwidth=2 " Number of spaces for each step of autoindent. +set softtabstop=2 " Number of spaces per tab when editing. +set expandtab " Insert spaces in place of tabs. + +" Configure whitespace highlighting. +let g:spacehi_spacecolor="ctermbg=red" +let g:spacehi_tabcolor="ctermbg=red" + +" Configure tag file locations. +set tags+=~/.local/tags/system.tags +set tags+=~/.local/tags/cxx.tags + +" Snippets +nmap <leader>sch :0r ~/.config/nvim/snippets/cc.h<CR> +nmap <leader>sci :0r ~/.config/nvim/snippets/cc.cc<CR> +nmap <leader>scn :.-1r ~/.config/nvim/snippets/namespace.cc<CR> +nmap <leader>scs :.-1r ~/.config/nvim/snippets/struct.cc<CR> +nmap <leader>scc :.-1r ~/.config/nvim/snippets/class.cc<CR> +nmap <leader>sjn :.-1r ~/.config/nvim/snippets/journal.md<CR> + +" Configure colour scheme and syntax highlighting. +if &t_Co > 2 + syntax enable + set background=dark + + " No background colour in terminal. + hi Normal ctermbg=none + + " Visual selection colour. + hi Visual ctermbg=237 + + " Spelling mistake hightlight colour. + hi SpellLocal cterm=underline ctermbg=58 + hi SpellBad cterm=underline ctermbg=88 + + " Completion menu colour. + hi Pmenu ctermbg=0 ctermfg=8 + hi PmenuSel ctermbg=8 ctermfg=15 + + " Line number colour. + hi LineNr ctermfg=7 + + " Highlight cursor line, max column. + set cursorline + hi ColorColumn ctermbg=235 + hi CursorLine ctermbg=235 cterm=bold + hi CursorLineNr ctermbg=235 cterm=bold + + if has("autocmd") + " Cursor line highlighting + au WinLeave * setlocal nocursorline + au WinEnter * setlocal cursorline + au BufLeave * setlocal nocursorline + au BufEnter * setlocal cursorline + + " Highlight over-length lines + au BufEnter,InsertLeave * set colorcolumn=80 + au BufEnter,InsertLeave *.txt,*.md,*.wiki set colorcolumn=80 + au BufEnter,InsertLeave *.txt,*.md,*.wiki set textwidth=80 + au BufEnter,InsertLeave *.java,*.m,*.mm set colorcolumn=100 + au BufEnter,InsertLeave *.java,*.m,*.mm set textwidth=100 + + " Highlight trailing space + au BufEnter,InsertLeave *.bzl,*.c,*.cc,*.cpp,*.cs,*.dart,*.h,*.java,*.m,*.mm,*.py,*.s SpaceHi + + " Fix python's indent overrides. + au FileType python setl ts=2 sw=2 sts=2 et + endif +endif + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Functions + +" Toggle absolute/relative numbering. +function! ToggleNumbering() + if (&number == 0) + set number + elseif (&relativenumber == 0) + set relativenumber + else + set norelativenumber + set nonumber + endif +endfunc +nmap <C-n> :call ToggleNumbering()<CR> diff --git a/.config/nvim/plugin/cscope.vim b/.config/nvim/plugin/cscope.vim @@ -0,0 +1,69 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" CSCOPE settings for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" USAGE: +" Stick this file in your vim `plugin` directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" Based off cscope_maps.vim by Jason Duell <jduell@alumni.princeton.edu> +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" This tests to see if vim was configured with the '--enable-cscope' option +" when it was compiled. If it wasn't, time to recompile vim... +if has("cscope") + + """"""""""""" Standard cscope/vim boilerplate + + " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' + set cscopetag + + " check cscope for definition of a symbol before checking ctags: set to 1 + " if you want the reverse search order. + set csto=0 + + " add any cscope database in current directory + if filereadable("cscope.out") + cs add cscope.out + " else add the database pointed to by environment variable + elseif $CSCOPE_DB != "" + cs add $CSCOPE_DB + endif + + " show msg when any other cscope db added + set cscopeverbose + + + """"""""""""" My cscope/vim key mappings + " + " The following maps all invoke one of the following cscope search types: + " + " 's' symbol: find all references to the token under cursor + " 'g' global: find global definition(s) of the token under cursor + " 'c' calls: find all calls to the function name under cursor + " 't' text: find all instances of the text under cursor + " 'e' egrep: egrep search for the word under cursor + " 'f' file: open the filename under cursor + " 'i' includes: find files that include the filename under cursor + " 'd' called: find functions that function under cursor calls + " + " All of the maps involving the <cfile> macro use '^<cfile>$': this is so + " that searches over '#include <time.h>" return only references to + " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all + " files that contain 'time.h' as part of their name). + + " To do the first type of search, hit the leader key, followed by one of + " the cscope search types above (s,g,c,t,e,f,i,d). The result of your + " cscope search will be displayed in the current window. You can use + " CTRL-T to go back to where you were before the search. + + au FileType c,cpp,objc nmap <leader>s :cs find s <C-R>=expand("<cword>")<CR><CR> + au FileType c,cpp,objc nmap <leader>g :cs find g <C-R>=expand("<cword>")<CR><CR> + au FileType c,cpp,objc nmap <leader>c :cs find c <C-R>=expand("<cword>")<CR><CR> + au FileType c,cpp,objc nmap <leader>t :cs find t <C-R>=expand("<cword>")<CR><CR> + au FileType c,cpp,objc nmap <leader>e :cs find e <C-R>=expand("<cword>")<CR><CR> + au FileType c,cpp,objc nmap <leader>f :cs find f <C-R>=expand("<cfile>")<CR><CR> + au FileType c,cpp,objc nmap <leader>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> + au FileType c,cpp,objc nmap <leader>d :cs find d <C-R>=expand("<cword>")<CR><CR> +endif diff --git a/.vim/plugin/flutter.vim b/.config/nvim/plugin/flutter.vim diff --git a/.vim/plugin/snippets.vim b/.config/nvim/plugin/snippets.vim diff --git a/.vim/snippets/cc.cc b/.config/nvim/snippets/cc.cc diff --git a/.vim/snippets/cc.h b/.config/nvim/snippets/cc.h diff --git a/.vim/snippets/class.cc b/.config/nvim/snippets/class.cc diff --git a/.vim/snippets/journal.md b/.config/nvim/snippets/journal.md diff --git a/.vim/snippets/namespace.cc b/.config/nvim/snippets/namespace.cc diff --git a/.vim/snippets/struct.cc b/.config/nvim/snippets/struct.cc diff --git a/.vim/spell/en.utf-8.add b/.config/nvim/spell/en.utf-8.add diff --git a/.vim/spell/fr.utf-8.add b/.config/nvim/spell/fr.utf-8.add diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv @@ -29,7 +29,7 @@ fi export ZDOTDIR="$XDG_CONFIG_HOME/zsh" # Basics -export EDITOR=vim +export EDITOR=nvim export PAGER=less export LESS="-FRX" @@ -57,7 +57,7 @@ export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config" # Google stuff. export P4CONFIG=.p4config -export P4EDITOR=vim +export P4EDITOR=nvim export GEM_HOME="$HOME/.gem" # Platform-specific source directory. diff --git a/.gitignore b/.gitignore @@ -36,6 +36,14 @@ .config/flutter .config/tool_state +# nvim +.config/nvim/autoload/plug.vim +.config/nvim/autoload/plug.vim.old +.config/nvim/plugged +.config/nvim/.netrwhist +.config/nvim/*.spl +.config/nvim/*.sug + # zsh cached data .config/zsh/.zcompdump .config/zsh/.zcompdumps/ diff --git a/.vim/.gitignore b/.vim/.gitignore @@ -1,11 +0,0 @@ -# vim-plug -autoload/plug.vim -autoload/plug.vim.old -plugged - -# vundle -bundle - -.netrwhist -*.spl -*.sug diff --git a/.vim/Makefile b/.vim/Makefile @@ -1,3 +0,0 @@ -install: - curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim diff --git a/.vim/plugin/cscope.vim b/.vim/plugin/cscope.vim @@ -1,69 +0,0 @@ -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" CSCOPE settings for vim -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" -" USAGE: -" Stick this file in your ~/.vim/plugin directory (or in a -" 'plugin' directory in some other directory that is in your -" 'runtimepath'. -" -" Based off cscope_maps.vim by Jason Duell <jduell@alumni.princeton.edu> -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -" This tests to see if vim was configured with the '--enable-cscope' option -" when it was compiled. If it wasn't, time to recompile vim... -if has("cscope") - - """"""""""""" Standard cscope/vim boilerplate - - " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' - set cscopetag - - " check cscope for definition of a symbol before checking ctags: set to 1 - " if you want the reverse search order. - set csto=0 - - " add any cscope database in current directory - if filereadable("cscope.out") - cs add cscope.out - " else add the database pointed to by environment variable - elseif $CSCOPE_DB != "" - cs add $CSCOPE_DB - endif - - " show msg when any other cscope db added - set cscopeverbose - - - """"""""""""" My cscope/vim key mappings - " - " The following maps all invoke one of the following cscope search types: - " - " 's' symbol: find all references to the token under cursor - " 'g' global: find global definition(s) of the token under cursor - " 'c' calls: find all calls to the function name under cursor - " 't' text: find all instances of the text under cursor - " 'e' egrep: egrep search for the word under cursor - " 'f' file: open the filename under cursor - " 'i' includes: find files that include the filename under cursor - " 'd' called: find functions that function under cursor calls - " - " All of the maps involving the <cfile> macro use '^<cfile>$': this is so - " that searches over '#include <time.h>" return only references to - " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all - " files that contain 'time.h' as part of their name). - - " To do the first type of search, hit the leader key, followed by one of - " the cscope search types above (s,g,c,t,e,f,i,d). The result of your - " cscope search will be displayed in the current window. You can use - " CTRL-T to go back to where you were before the search. - - au FileType c,cpp,objc nmap <leader>s :cs find s <C-R>=expand("<cword>")<CR><CR> - au FileType c,cpp,objc nmap <leader>g :cs find g <C-R>=expand("<cword>")<CR><CR> - au FileType c,cpp,objc nmap <leader>c :cs find c <C-R>=expand("<cword>")<CR><CR> - au FileType c,cpp,objc nmap <leader>t :cs find t <C-R>=expand("<cword>")<CR><CR> - au FileType c,cpp,objc nmap <leader>e :cs find e <C-R>=expand("<cword>")<CR><CR> - au FileType c,cpp,objc nmap <leader>f :cs find f <C-R>=expand("<cfile>")<CR><CR> - au FileType c,cpp,objc nmap <leader>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> - au FileType c,cpp,objc nmap <leader>d :cs find d <C-R>=expand("<cword>")<CR><CR> -endif diff --git a/.vim/vimrc b/.vim/vimrc @@ -1,155 +0,0 @@ -set nocompatible -set encoding=utf-8 - -" Remove any autocmds defined by the system for consistency. -if has("autocmd") - autocmd! -endif - -call plug#begin('~/.vim/plugged') -" Formatting. -Plug 'rhysd/vim-clang-format' " clang-format. -Plug 'vim-scripts/spacehi.vim' " Highlight bad whitespace. - -" Language support plugins. -Plug 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } -Plug 'rust-lang/rust.vim' -call plug#end() - -" Bind fancier manpage plugin to Shift-k. -runtime ftplugin/man.vim -set keywordprg=:Man - -let mapleader=',' -let s:cpo_save=&cpo -set cpo&vim - -" Enable middle-mouse paste. -map! <S-Insert> <MiddleMouse> -map <S-Insert> <MiddleMouse> - -" Kill ex mode. -noremap Q <NOP> - -" Disable visual-mode mouse select. -set mouse= - -" Kill arrow keys, for great justice. -noremap <Up> <NOP> -noremap <Down> <NOP> -noremap <Left> <NOP> -noremap <Right> <NOP> - -" Retain selection on <,>. -vmap < <gv -vmap > >gv -let &cpo=s:cpo_save -unlet s:cpo_save - -" Basic options -set incsearch " Turn on incrememental searching. -set hlsearch " Highlight search. -set visualbell " Less noise. -set number " Use line numbering. -set ruler " Show row/col in status. -set laststatus=1 " Only show status line if > 1 window. -set showmatch " Highlight matching bracket. -set history=50 " Keep 50 lines of cmdline history. -set wildmenu " Nicer autocomplete. -set wildmode=longest,full -set wildignore=*.o,*.pyc " Ignore some filetypes during completion. -set spelllang=en_ca " Set the spelling language. - -" Omnicomplete -set completeopt+=longest - -" Indentation/tabulation -set autoindent " Copy indent from current line when starting a new line. -set smartindent " Attempt to autoindent when starting a new line. -set smarttab " Use shiftwidth rather than tabstop at start of line. -set tabstop=2 " Number of spaces per tab. -set shiftwidth=2 " Number of spaces for each step of autoindent. -set softtabstop=2 " Number of spaces per tab when editing. -set expandtab " Insert spaces in place of tabs. - -" Configure whitespace highlighting. -let g:spacehi_spacecolor="ctermbg=red" -let g:spacehi_tabcolor="ctermbg=red" - -" Configure tag file locations. -set tags+=~/.local/tags/system.tags -set tags+=~/.local/tags/cxx.tags - -" Snippets -nmap <leader>sch :0r ~/.vim/snippets/cc.h<CR> -nmap <leader>sci :0r ~/.vim/snippets/cc.cc<CR> -nmap <leader>scn :.-1r ~/.vim/snippets/namespace.cc<CR> -nmap <leader>scs :.-1r ~/.vim/snippets/struct.cc<CR> -nmap <leader>scc :.-1r ~/.vim/snippets/class.cc<CR> -nmap <leader>sjn :.-1r ~/.vim/snippets/journal.md<CR> - -" Configure colour scheme and syntax highlighting. -if &t_Co > 2 - syntax enable - set background=dark - - " No background colour in terminal. - hi Normal ctermbg=none - - " Visual selection colour. - hi Visual ctermbg=237 - - " Spelling mistake hightlight colour. - hi SpellLocal cterm=underline ctermbg=58 - hi SpellBad cterm=underline ctermbg=88 - - " Completion menu colour. - hi Pmenu ctermbg=0 ctermfg=8 - hi PmenuSel ctermbg=8 ctermfg=15 - - " Line number colour. - hi LineNr ctermfg=7 - - " Highlight cursor line, max column. - set cursorline - hi ColorColumn ctermbg=235 - hi CursorLine ctermbg=235 cterm=bold - hi CursorLineNr ctermbg=235 cterm=bold - - if has("autocmd") - " Cursor line highlighting - au WinLeave * setlocal nocursorline - au WinEnter * setlocal cursorline - au BufLeave * setlocal nocursorline - au BufEnter * setlocal cursorline - - " Highlight over-length lines - au BufEnter,InsertLeave * set colorcolumn=80 - au BufEnter,InsertLeave *.txt,*.md,*.wiki set colorcolumn=80 - au BufEnter,InsertLeave *.txt,*.md,*.wiki set textwidth=80 - au BufEnter,InsertLeave *.java,*.m,*.mm set colorcolumn=100 - au BufEnter,InsertLeave *.java,*.m,*.mm set textwidth=100 - - " Highlight trailing space - au BufEnter,InsertLeave *.bzl,*.c,*.cc,*.cpp,*.cs,*.dart,*.h,*.java,*.m,*.mm,*.py,*.s SpaceHi - - " Fix python's indent overrides. - au FileType python setl ts=2 sw=2 sts=2 et - endif -endif - -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Functions - -" Toggle absolute/relative numbering. -function! ToggleNumbering() - if (&number == 0) - set number - elseif (&relativenumber == 0) - set relativenumber - else - set norelativenumber - set nonumber - endif -endfunc -nmap <C-n> :call ToggleNumbering()<CR> diff --git a/Makefile b/Makefile @@ -0,0 +1,5 @@ +CONFIG_DIR=~/.config/nvim + +vim-plug: + curl -fLo ${CONFIG_DIR}/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim