commit 5d3118761c72eb8ee05bcddfbb95f761ae85bb72
parent a7d7faab5d47c429745df6c180f80c0aa38b8dd8
Author: Bharatvaj <bharatvaj@yahoo.com>
Date: Wed, 6 Sep 2023 13:47:45 +0530
Move functions to $XDG_DATA_HOME/vim/plugin.vim
...from .vimrc for reusing them with nvim and vim
Diffstat:
A | .local/share/vim/plugin.vim | | | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
M | .vimrc | | | 82 | ++----------------------------------------------------------------------------- |
2 files changed, 80 insertions(+), 80 deletions(-)
diff --git a/.local/share/vim/plugin.vim b/.local/share/vim/plugin.vim
@@ -0,0 +1,78 @@
+" Strip the newline from the end of a string
+function! Chomp(str)
+ return substitute(a:str, '\n$', '', '')
+endfunction
+
+" Find a file and pass it to cmd
+function! DmenuOpen(cmd)
+ let fname = Chomp(system("git ls-files | dmenu-mac -i -l 20 -p " . a:cmd))
+ if empty(fname)
+ return
+ endif
+ execute a:cmd . " " . fname
+endfunction
+
+" find file in git repo
+function! ChooseFile()
+ let dir = expand("%:h")
+ if empty(dir) | let dir = getcwd() | endif
+
+ let root = system("cd " . dir . " && git rev-parse --show-toplevel")
+ if v:shell_error != 0 | echo "Not in a git repo" | return | endif
+ let root = root[0:-2]
+
+ let selection = system("cd " . root . " && git ls-files -co --exclude-standard | choose")
+ if empty(selection) | echo "Canceled" | return | end
+
+ echo "Finding file..."
+ exec ":e " . root . "/" . selection
+endfunction
+
+function! DiffWithSaved()
+ let filetype=&ft
+ diffthis
+ vnew | r # | normal! 1Gdd
+ diffthis
+ exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
+endfunction
+
+" Move to a file common to nvim and vim
+function! ToggleList()
+ if &list == "nolist"
+ set list
+ else
+ set nolist
+ endif
+endfunction
+
+function! ToggleBackground()
+ if &background == "light"
+ set background=dark
+ else
+ set background=light
+ endif
+endfunction
+
+function! FileMvHelper()
+ :normal! 0i"A"0y$A p0imv j0
+endfunction
+" Run Make
+
+function SaveAndBuild()
+ wall
+ Make
+endfunction
+
+function QuickUnderline(n)
+ if a:n == 1
+ normal! yypv$r=
+ else
+ normal! yypv$r-
+ endif
+endfunction
+
+function ReverseDate()
+ normal! dt/wwpldeBP
+endfunction
+
+
diff --git a/.vimrc b/.vimrc
@@ -75,7 +75,7 @@ set packpath^=$XDG_DATA_HOME/vim
function! FZYFiles() abort
let l:tempname = tempname()
" fzf | awk '{ print $1":1:0" }' > file
- execute 'silent !git ls-files --recurse-submodules | fzy > ' . fnameescape(l:tempname)
+ execute 'silent !git ls-files --recurse-submodules | fzf > ' . fnameescape(l:tempname)
let l:tcontents = join(readfile(l:tempname))
try
" TODO Add option to add multiple files to argslist
@@ -159,86 +159,8 @@ else
set shell=sh
endif
-" Move to a file common to nvim and vim
-function! ToggleList()
- if &list == "nolist"
- set list
- else
- set nolist
- endif
-endfunction
-
-function! ToggleBackground()
- if &background == "light"
- set background=dark
- else
- set background=light
- endif
-endfunction
-
-function! FileMvHelper()
- :normal! 0i"A"0y$A p0imv j0
-endfunction
-" Run Make
-
-function SaveAndBuild()
- wall
- Make
-endfunction
-
-function QuickUnderline(n)
- if a:n == 1
- normal! yypv$r=
- else
- normal! yypv$r-
- endif
-endfunction
-
-function ReverseDate()
- normal! dt/wwpldeBP
-endfunction
-
-
" TODO load this automatically
source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim
+source $XDG_DATA_HOME/vim/plugin.vim
let g:birck_default_chan="irc.libera.chat"
-
-" Strip the newline from the end of a string
-function! Chomp(str)
- return substitute(a:str, '\n$', '', '')
-endfunction
-
-" Find a file and pass it to cmd
-function! DmenuOpen(cmd)
- let fname = Chomp(system("git ls-files | dmenu-mac -i -l 20 -p " . a:cmd))
- if empty(fname)
- return
- endif
- execute a:cmd . " " . fname
-endfunction
-
-" find file in git repo
-function! ChooseFile()
- let dir = expand("%:h")
- if empty(dir) | let dir = getcwd() | endif
-
- let root = system("cd " . dir . " && git rev-parse --show-toplevel")
- if v:shell_error != 0 | echo "Not in a git repo" | return | endif
- let root = root[0:-2]
-
- let selection = system("cd " . root . " && git ls-files -co --exclude-standard | choose")
- if empty(selection) | echo "Canceled" | return | end
-
- echo "Finding file..."
- exec ":e " . root . "/" . selection
-endfunction
-
-function! DiffWithSaved()
- let filetype=&ft
- diffthis
- vnew | r # | normal! 1Gdd
- diffthis
- exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
-endfunction
-