dotfiles

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

commit da9afa333c1a0b501b8e43df83f1460654dfef2f
parent 0cb5bd9e7dc80e4ac678ae1fad0dc29241a66905
Author: Chris Bracken <chris@bracken.jp>
Date:   Sat, 24 Aug 2024 18:11:57 -0700

vim: migrate personal vimscript plugins to Lua

Deletes cscope, and most of the snippets, which in practice, I don't use
at all.

Diffstat:
M.config/nvim/init.lua | 1+
A.config/nvim/lua/config/snippets.lua | 18++++++++++++++++++
D.config/nvim/plugin/cscope.vim | 69---------------------------------------------------------------------
D.config/nvim/plugin/flutter.vim | 6------
D.config/nvim/plugin/snippets.vim | 22----------------------
D.config/nvim/snippets/cc.cc | 9---------
D.config/nvim/snippets/cc.h | 17-----------------
D.config/nvim/snippets/class.cc | 8--------
D.config/nvim/snippets/journal.md | 13-------------
D.config/nvim/snippets/namespace.cc | 2--
D.config/nvim/snippets/struct.cc | 2--
11 files changed, 19 insertions(+), 148 deletions(-)

diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua @@ -2,6 +2,7 @@ require('config.colorscheme') require('config.keymappings') require('config.options') +require('config.snippets') -- Package manager. require('config.lazy') diff --git a/.config/nvim/lua/config/snippets.lua b/.config/nvim/lua/config/snippets.lua @@ -0,0 +1,18 @@ +-- Function to get the current date in 'YYYY-mm-dd (Day)' format +local function get_current_date() + local fname = vim.fn.expand('%:t:r') + local date_pattern = '^%d%d%d%d%-%d%d%-%d%d$' + + if fname:match(date_pattern) then + local fdate = vim.fn.strptime('%Y-%m-%d', fname) + return vim.fn.strftime('%Y-%m-%d (%a)', fdate) + else + return vim.fn.strftime('%Y-%m-%d (%a)') + end +end + +-- Key mapping to insert the current date in 'YYYY-mm-dd (Day)' format +vim.keymap.set('n', '<Leader>cd', function() + local date_str = get_current_date() + vim.api.nvim_put({date_str}, 'c', true, true) +end) diff --git a/.config/nvim/plugin/cscope.vim b/.config/nvim/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/.config/nvim/plugin/flutter.vim b/.config/nvim/plugin/flutter.vim @@ -1,6 +0,0 @@ -" Project-specific settings when working in the Flutter engine codebase. -if expand('%:p:h') ==# expand('~/Developer/flutter/engine/src/flutter') - set path+=shell/platform/darwin/ios/** - set path+=shell/platform/darwin/common/** - set path+=shell/platform/darwin/graphics/** -endif diff --git a/.config/nvim/plugin/snippets.vim b/.config/nvim/plugin/snippets.vim @@ -1,22 +0,0 @@ -" Code snippets - -" Insert the current date in '2020-04-22 (Thu)' format. -nnoremap <Leader>cd i<C-R>=CurrentDate()<CR><Esc> - -" Returns the current date in YYYY-mm-dd form. -" When in a file whose name is of the form YYYY-mm-dd, use that date instead. -" This is useful for headings in VimWiki entries. -function! CurrentDate() - " Get the filename without path or extension. - let fname = expand('%:t:r') - if fname =~ '\d\d\d\d-\d\d-\d\d' - let fdate = strptime('%Y-%m-%d', fname) - return strftime('%Y-%m-%d (%a)', fdate) - else - return strftime('%Y-%m-%d (%a)') - endif -endfunc - - -" Inject a boilerplate C/C++/Obj-C main() function. -au FileType c,cpp,objc nmap <leader>cm iint main(int argc, char** argv) {<CR>return 0;<CR>}<ESC>%0 diff --git a/.config/nvim/snippets/cc.cc b/.config/nvim/snippets/cc.cc @@ -1,9 +0,0 @@ -#include "cc.h" - -namespace foo { - -Bar::Bar() {} - -Bar::~Bar() {} - -} // namespace foo diff --git a/.config/nvim/snippets/cc.h b/.config/nvim/snippets/cc.h @@ -1,17 +0,0 @@ -#ifndef _H_ -#define _H_ - -namespace foo { - -class Bar { - public: - Bar(); - ~Bar(); - - private: - int baz_; -}; - -} // namespace foo - -#endif // _H_ diff --git a/.config/nvim/snippets/class.cc b/.config/nvim/snippets/class.cc @@ -1,8 +0,0 @@ -class Bar { - public: - Bar(); - ~Bar(); - - private: - int baz_; -}; diff --git a/.config/nvim/snippets/journal.md b/.config/nvim/snippets/journal.md @@ -1,13 +0,0 @@ -## Code - -## Review - -## Issues - -## Readability - -## Meetings - -## Process - -## Notes diff --git a/.config/nvim/snippets/namespace.cc b/.config/nvim/snippets/namespace.cc @@ -1,2 +0,0 @@ -namespace foo { -} // namespace foo diff --git a/.config/nvim/snippets/struct.cc b/.config/nvim/snippets/struct.cc @@ -1,2 +0,0 @@ -struct Bar { -};