summaryrefslogtreecommitdiffstats
path: root/nvim/pack/mitsuo/start/fun/plugin
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2023-03-20 02:12:27 -0500
committerMitsuo Tokumori <[email protected]>2023-03-20 02:12:27 -0500
commit11aedecab8a8ef7d54f0fa2f1adc67ac78ba42eb (patch)
tree5df140f00fb12508310699af04bebde17a7d4117 /nvim/pack/mitsuo/start/fun/plugin
parent3d4887349318f43dadf1de00ad15e35ba7812a84 (diff)
downloaddotfiles-11aedecab8a8ef7d54f0fa2f1adc67ac78ba42eb.tar.gz
dotfiles-11aedecab8a8ef7d54f0fa2f1adc67ac78ba42eb.tar.bz2
dotfiles-11aedecab8a8ef7d54f0fa2f1adc67ac78ba42eb.zip
Simplify bashrc, modify install.sh, add nvim/
bashrc is now simpler. Hopefully with the same functionality. Remove some of the default stuff that came with Debian years ago. Start with default Archlinux bashrc as base (very minimal). install.sh now recommends only using slinks. nvim and zathura now get linked directory-wise. This is way better because added configuration files will get here seamlessly. Doing diffs between 2 independent copies is painful. Now I'm transitioning to NeoVim. I've copied all relevant config from vimrc (Vim) to init.vim (NeoVim). Very promising. File got smaller and more organized in my opinion. PD: Cheers, this pulse15 laptop is amazing.
Diffstat (limited to 'nvim/pack/mitsuo/start/fun/plugin')
-rw-r--r--nvim/pack/mitsuo/start/fun/plugin/fun.vim109
1 files changed, 109 insertions, 0 deletions
diff --git a/nvim/pack/mitsuo/start/fun/plugin/fun.vim b/nvim/pack/mitsuo/start/fun/plugin/fun.vim
new file mode 100644
index 0000000..42574d3
--- /dev/null
+++ b/nvim/pack/mitsuo/start/fun/plugin/fun.vim
@@ -0,0 +1,109 @@
+" To call functions use `:call foo()`
+
+" Echoes longest line number and lenght.
+function! LongestLineLength ( )
+ let maxlength = 0
+ let linenumber= 1
+ while linenumber <= line("$")
+ exe ":".linenumber
+ let linelength = virtcol("$")
+ if maxlength < linelength
+ let maxlength = linelength
+ let maxlinenumber = linenumber
+ endif
+ let linenumber = linenumber+1
+ endwhile
+
+"exe ':0'
+"exe 'normal O'
+"exe 'normal 0C'.maxlength
+ exe "normal" . maxlinenumber . "G"
+ exe ":echo \"" . maxlinenumber . ": " . maxlength . "\""
+endfunction
+
+command LongestLineLength call LongestLineLength()
+
+
+" Save markdown document and export to pdf using pandoc.
+"
+" It would be nicer if a default document would be used but I coulnd't made it
+" to work even after reading that manual section like 2 times. Also, there are
+" variables that are lists of other variables that I don't know how to make them
+" work (e.g. geometry=[top=1in, bottom=1in, heightrounded])
+function! Md2Pdf ( )
+ exe ":w"
+ "-N for numbered headers
+ exe ":! pandoc -o \"" . expand("%:r") . ".pdf\" -t latex --variable classoption=twosides --variable papersize=a4 --variable margin-left=1in --variable margin-right=1in --variable margin-top=1in --variable margin-bottom=1in --variable links-as-notes --variable colorlinks --variable pagestyle=plain --variable documentclass=article -f markdown-implicit_figures \"" . expand("%") . "\""
+ echo "pdf saved as \"" . expand("%:p:r") . ".pdf\""
+endfunction
+
+function! Md2Pdfms ( )
+ exe ":w"
+ exe ":! pandoc -o " . expand("%:r") . ".pdf" . " -t ms -f markdown-implicit_figures \"" . expand("%") . "\""
+ echo "pdf saved as " . expand("%:p:r") . ".pdf"
+endfunction
+
+command Md2Pdf call Md2Pdf()
+command Md2Pdfms call Md2Pdfms()
+
+
+" Save markdown document and export to html using pandoc
+function! Md2Html ( )
+ exe ":w"
+ "exe ":! pandoc -s --toc -H ~/mahcode/markdown/pandoc/pandoc_style.html --highlight-style tango -o \"" . expand("%:r") . ".html\"" . " \"" . expand("%") . "\""
+ exe ":! pandoc --highlight-style tango -o \"" . expand("%:r") . ".html\"" . " \"" . expand("%") . "\""
+ echo "html saved as " . expand("%:p:r") . ".html"
+endfunction
+
+command Md2Html call Md2Html()
+
+" Save markdown as ODT file (.docx is also possible)
+function! Md2Odt ( )
+ exe ":w"
+ exe ":! pandoc -s --toc -H ~/mahcode/markdown/pandoc/pandoc_style.html --highlight-style tango -o \"" . expand("%:r") . ".odt\"" . " \"" . expand("%") . "\""
+ echo "ODT saved as " . expand("%:p:r") . ".odt"
+endfunction
+
+command Md2Odt call Md2Odt()
+
+
+" Compiles and Runs a C++ project
+" TODO: how to add program's arguments or file redirectioning from command.
+function! CompRunProj ( )
+ exe ":w"
+ exe ":! g++ -o " . expand("%:r") . "-g *.cpp"
+ exe ":! ./" . expand("%:r")
+endfunction
+
+command CompRunProj call CompRunProj()
+
+
+" Function made to give feedback to students code in 1INF01
+" export C code to syntax highlighted pdf
+function! C2Pdf ( )
+ exe ":set ts=4"
+ exe ":w"
+ exe ":ha > %.ps"
+ exe ":!ps2pdf %.ps"
+ exe ":!rm %.ps"
+endfunction
+
+
+" For printing first export to html and then print using web browser
+" Ref.: https://vi.stackexchange.com/questions/12058/printing-unicode-chars
+function! ExportHTML (colorscheme="quiet", bg="light")
+ " Nice colorschemes for printing on paper: quiet, morning, mac_classic
+ let s:prev_color = g:colors_name
+ let s:prev_bg = &background
+ exe "colorscheme" a:colorscheme
+ exe "set bg=" . a:bg
+
+ exe "TOhtml | w | !xdg-open %"
+ echo "html export saved as " . expand('%:p')
+ exe "bd"
+
+ exe "colorscheme" s:prev_color
+ exe "set bg=" . s:prev_bg
+endfunction
+
+command ExportHTML call ExportHTML()