summaryrefslogtreecommitdiffstats
path: root/public/.vim
diff options
context:
space:
mode:
Diffstat (limited to 'public/.vim')
-rw-r--r--public/.vim/fun.vim89
-rw-r--r--public/.vim/pack/mitsuo/README.md12
m---------public/.vim/pack/mitsuo/nerdtree0
m---------public/.vim/pack/mitsuo/vim-fugitive0
-rw-r--r--public/.vim/viminfo31
-rw-r--r--public/.vim/vimrc332
-rw-r--r--public/.vim/vimrc_windows10
7 files changed, 474 insertions, 0 deletions
diff --git a/public/.vim/fun.vim b/public/.vim/fun.vim
new file mode 100644
index 0000000..bd911f9
--- /dev/null
+++ b/public/.vim/fun.vim
@@ -0,0 +1,89 @@
+" 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
+
+command C2Pdf call C2Pdf()
diff --git a/public/.vim/pack/mitsuo/README.md b/public/.vim/pack/mitsuo/README.md
new file mode 100644
index 0000000..172c269
--- /dev/null
+++ b/public/.vim/pack/mitsuo/README.md
@@ -0,0 +1,12 @@
+Plugins I usually use and work fine together.
+
+- [NERDTree](https://github.com/preservim/nerdtree)
+
+ <C-t>
+
+- [vim-fugitive](https://github.com/tpope/vim-fugitive)
+
+ :G
+ :G blame
+
+Vim packages (version >= 8.2). See `:h packages`
diff --git a/public/.vim/pack/mitsuo/nerdtree b/public/.vim/pack/mitsuo/nerdtree
new file mode 160000
+Subproject eed488b1cd1867bd25f19f90e10440c5cc7d642
diff --git a/public/.vim/pack/mitsuo/vim-fugitive b/public/.vim/pack/mitsuo/vim-fugitive
new file mode 160000
+Subproject b7287bd5421da62986d9abf9131509b2c9f918e
diff --git a/public/.vim/viminfo b/public/.vim/viminfo
new file mode 100644
index 0000000..7651f85
--- /dev/null
+++ b/public/.vim/viminfo
@@ -0,0 +1,31 @@
+# This viminfo file was generated by Vim 8.2.
+# You may edit it if you're careful!
+
+# Viminfo version
+|1,4
+
+# Value of 'encoding' when this file was written
+*encoding=utf-8
+
+
+# hlsearch on (H) or off (h):
+~h
+# Command Line History (newest to oldest):
+:q
+|2,0,1649356827,,"q"
+
+# Search String History (newest to oldest):
+
+# Expression History (newest to oldest):
+
+# Input Line History (newest to oldest):
+
+# Debug Line History (newest to oldest):
+
+# Registers:
+
+# File marks:
+
+# Jumplist (newest first):
+
+# History of marks within files (newest to oldest):
diff --git a/public/.vim/vimrc b/public/.vim/vimrc
new file mode 100644
index 0000000..f97a654
--- /dev/null
+++ b/public/.vim/vimrc
@@ -0,0 +1,332 @@
+" mitsuo's vimrc
+" Created c. 2019-11-11
+" Last update (after destroying it accidentally): 2020-09-02
+"
+" ┌─┬─┬─┬─┬─┬─┐
+" │m│i│t│s│u│o│✓x け が
+" ├─┼─┼─┼─┼─┼─┤ ん
+" │v│i│m│r│c│←│█▓▒░ り ば
+" └─┴─┴─┴─┴─┴─┘ こ れ
+
+" XDG compliant REMOVED :D (what a pain)
+" - For new installs just copy (or link) this file into ~/.vimrc and create
+" the ~/.vim directory
+" TODO: - sort sections
+
+
+" Variables
+" ----------------------------------------------------------------------
+" Get the first directory from the list in $VIMRUNTIMEPATH
+let $VIMFILES=split(&rtp,",")[0]
+set undodir=$VIMFILES/undo
+set viewdir=$VIMFILES/view
+set directory=$VIMFILES/swap
+set viminfofile=$VIMFILES/viminfo
+
+
+" Useful
+" ----------------------------------------------------------------------
+set nocompatible
+" Auto-recognize files and apply pluggins
+filetype plugin indent on " See :h vimrc-filetype
+syntax on
+
+" Search files
+set wildmenu " command-line <Tab> completion <-- soo good
+set wildignore+=*.o,*.obj,.git,*.rbc,*.class
+set path+=./**30 " For gf and :find, add all subdirectories relative to
+ " current file (30 max) to the "search space"
+
+set scrolloff=5 " show a few lines of context
+
+set backspace=indent,eol,start " Allow <BS> and <Del> in insert mode
+
+" number gutter
+set nonumber
+set norelativenumber
+
+" Store session information
+set viminfo+='1000
+
+" Tag Jumping <-- so cool
+" Instructions: create tag index (e.g. $ ctags -R .)
+" place cursor on tag
+" ^] to jump to definition
+" g^] if more than 1 definition
+" ^T to return (or ^O)
+" TODO: create tags automatically (:!ctags -R . after :w if ft=c)
+
+
+" Status line
+" ----------------------------------------------------------------------
+set showcmd " show partial command on last line (below status bar)
+" just add buffer number to the default
+set statusline=%<%f\ %h%m%r%=b%02n\ \ %-14.(%l,%c%V%)\ %P
+
+
+" Search
+" ----------------------------------------------------------------------
+set hlsearch " highlight search (this can be annoying if no shortcut to then
+ " clear the highlight
+set incsearch " Incrementally move cursor while typing search-string
+" stop highlight only for current search.
+" (Still preserve <C-L> updating directory in netrw)
+nnoremap <C-L> :nohl<CR><C-L>
+" Ignore case only when pattern is lowercase (both needed)
+set ignorecase
+set smartcase
+
+
+" Indentation
+" ----------------------------------------------------------------------
+" 4 column softtabs (uses ' ', not '\t').
+" TODO: move this 'guide' to somewhere apropiate
+" tab->softtab :set tabstop=n :set expandtab :retab
+" softtab->tab :set noexpandtab :set tabstop={softtabstop} :retab!
+" Caution:
+" - This will insert a tab wherever it can, even between words
+" separated by as few as 2 spaces if ts=2!
+" - Not recommended at all. Use some other program to only translate
+" leading indenting from space to tabs. Also using tabs is not very
+" good. My opinion is that they are good as a special character to
+" separate data (like comma for CSV).
+set tabstop=8 " '\t' or HT = 8 virtual columns
+set shiftwidth=4 " Indentation with >> and C-T and C-D (insert mode)
+set softtabstop=4 " For "inserted tabs" (inserts <Space> and <Tab>
+ " minimizing <Space>)
+set expandtab " Expand with <Space> the inserted <Tab>s
+"set smarttab " Use shiftwidth for inserted <Tabs> in the front of
+ " a line (Maybe useful for YAML)
+" autoindent -> smartindent -> cindent -> indentexpr
+" (from simple/less general to complex/more general)
+set smartindent " This is a really nice and simple one
+"set cindent
+"set cinoptions=:0,g0 " See C-indenting
+
+
+" Automatic formatting
+" ----------------------------------------------------------------------
+" see fo-table
+set formatoptions=l " Don't break long lines that are already typed
+set formatoptions+=q " Allow formatting of comments with "gq"
+set formatoptions+=r " Insert current leader after <Enter> in Insert mode
+set formatoptions-=o " Automatically insert the current comment leader
+ " after hitting 'o'.
+set formatoptions+=t " auto-wrap text (when inserting)
+set formatoptions+=c " auto-wrap comments (when inserting)
+set formatoptions+=p " Don't break honorifics like Prof. Smith
+set formatoptions+=n " Allow lists
+set formatoptions+=j " Removes comment leader when joining lines
+
+
+" Word wrap
+" ----------------------------------------------------------------------
+set wrap " Visual wrapping of lines wider than window
+set linebreak " Works with previous option to not break words
+" To 'justify' comments or block of text (paragraph) use "gq{motion}" or
+" "gp{motion}", where {motion} can be "[/", "]/", "ip", "i{", "a{".
+set textwidth=80 " auto break inserted text longer than 80 colums
+
+
+" Other settings
+" ----------------------------------------------------------------------
+set mouse=a " Enable for all modes
+" set cmdheight=1
+" Always display the status line, even if only one window is displayed
+set laststatus=2
+set ruler
+set encoding=utf-8
+set more " Enable more-prompt for listings that don't fit in
+ " screen
+"hint: g< command can be used to see the last page of previous command.
+
+
+" Mappings
+" ----------------------------------------------------------------------
+" F1 is help, F11 is full screen (terminal emulator)
+map <F5> :source $VIMFILES/vimrc<CR>
+map <S-F5> :e $VIMFILES/vimrc<CR>
+
+map <F7> :tabp<CR>
+map <F8> :tabn<CR>
+
+" C/C++ Programming:
+
+map <F6> :w<CR>:!clear && make<CR>
+"map <F10> :!./%:r<CR>
+"map <F10> :!./a.out<CR>
+
+map <F11> :cnext<CR>
+map <S-F11> :cprev<CR>
+
+" <Leader> = '\' when 'mapleader' is empty
+" "Run cTags"
+map <Leader>rt :!ctags -R .<CR>
+map <C-\> :tnext<CR>
+
+" Motion to go to beggining of function while cursor is inside
+nmap [f [m[{k0
+
+" Other programs:
+
+" pandoc (& website)
+nnoremap mm :w<CR>:Md2Html<CR><CR><CR>
+nmap mM mm:!updatewebsite_zaz<CR><CR>
+" asciidoc
+nnoremap ma :w<CR>:!asciidoctor %<CR><CR>
+nmap mA ma:!updatewebsite_zaz<CR><CR>
+
+" Funcionallity of the following depends on terminal. Needs 8bit input enabled
+" for <Meta> = Alt key combos
+" From: https://vim.fandom.com/wiki/Get_Alt_key_to_work_in_terminal
+
+nmap <M-H> <C-W>h
+nmap <M-J> <C-W>j
+nmap <M-K> <C-W>k
+nmap <M-L> <C-W>l
+
+" Misc.:
+
+" Go Title Case (and clear highlighted matches)
+" Ref.: vim.fandom.com
+vmap gt :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<CR><C-L>
+
+" Autoformat JSON jumbled data. (Selects the whole file as range to pass as
+" standard input to `jq .` which pretty prints JSON. Then replace range with
+" output.)
+" Ref.: https://stackoverflow.com/questions/26214156/how-to-auto-format-json-on-save-in-vim
+nnoremap gJ :%!python3 -m json.tool<CR>
+" :%!jq .
+
+" NERDTree plugin
+nnoremap <C-t> :NERDTreeToggle<CR>
+
+" Comment/UnComment lines
+" Ref.:
+" - https://vim.fandom.com/wiki/Comment/UnComment_visually_selected_text
+" - https://stackoverflow.com/a/1676672/7498073
+" - https://stackoverflow.com/a/9051932/7498073
+au FileType haskell,vhdl,ada let b:comment_leader = '-- '
+au FileType vim let b:comment_leader = '" '
+au FileType c,cpp,java,asciidoc let b:comment_leader = '// '
+au FileType sh,make let b:comment_leader = '# '
+au FileType tex let b:comment_leader = '% '
+" That c_CTRL-R_= thingy enters the "expression register". And that \V
+" tells :s to go into "Very NonMagic" mode.
+noremap ,c :s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:noh<CR>
+noremap ,u :s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:noh<CR>
+
+
+" Yanking and pasting
+" ----------------------------------------------------------------------
+" TODO: map something to "+y (cut buffer) and "*y (selection buffer) while in
+" visual mode.
+"vmap <++> "+y " The yank to the cut buffer (clipboard)
+"vmap <++> "*y " The yank to the selection buffer
+
+
+" Buffers
+" ----------------------------------------------------------------------
+set hidden
+map <S-F7> :bNext<LF>
+map <S-F8> :bnext<LF>
+
+
+" Printing
+" ----------------------------------------------------------------------
+set printoptions=paper:A4,duplex:long
+" set printoptions+=number:y
+" TODO: Figure out how to print multibyte encodings. Enabling this settings
+" produces errors.
+set encoding=utf-8
+set fileencoding=utf-8
+" set printmbcharset=JIS_X_1990 " This allows Japanese characters to be printed
+" set printmbfont=r:Noto-Sans-CJK-JP
+
+
+" Functions
+" ----------------------------------------------------------------------
+" TODO: maybe replace with $runtimepath
+source $VIMFILES/fun.vim
+
+
+" Views and Sessions (Window layout and Line folding)
+" ----------------------------------------------------------------------
+" It is possible to create folds automatically but idk how to do it.
+" :mkview so save them :loadview to load them (zo open one, zc close one,
+" zR to open all, zM to close all, zx to restore))
+
+" Views saves folds. Sessions saves all windows configuration and layout
+" Load Sessions with $ vim -S Session.vim
+
+" To automatically save and restore views for *.c *.cpp files:
+au BufWinLeave *.c mkview
+au BufWinEnter *.c silent loadview
+au BufWinLeave *.cpp mkview
+au BufWinEnter *.cpp silent loadview
+
+
+" Snippets
+" ----------------------------------------------------------------------
+" I deleted the file accidently
+"nnoremap ,ch :-1r $VIMFILES/snippets/cheader.c<CR>
+
+
+" File Browsing
+" ----------------------------------------------------------------------
+" Use netrw out of the box file browser plugin.
+" :e . open file browser on current directory
+" V or t open file on vsplit or new tab.
+" :bd or :Rex to return
+" More mappings on |netrw-browse-maps|
+"let g:netrw_banner=0 " disable banner
+"let g:netrw_browse_split=4 " open in prior window
+let g:netrw_altv=1 " open splits to the right
+"let g:netrw_list_hide=netrw_gitignore#Hide()
+"let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' " wtf? (?)
+" Learned from Max Cantor talk https://youtu.be/XA2WjJbmmoM
+
+
+" Additions
+" ----------------------------------------------------------------------
+" Replaces previous WORD arithmetic expression with result (from Vim
+" fandom-wiki)
+inoremap <C-A> <Esc>diWi<C-R>=<C-R>"<CR>
+
+
+" Plugins
+" ----------------------------------------------------------------------
+" I disabled it bc I think it interferes with formatoptions
+"" Automatic vim-plug install
+"if empty(glob('~/.vim/autoload/plug.vim'))
+" silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
+" \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
+" autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
+"endif
+"
+"call plug#begin()
+"Plug 'ARM9/arm-syntax-vim'
+"autocmd BufNewFile,BufRead *.s,*.S set filetype=arm " arm = armv6/7
+"
+"call plug#end()
+
+" Other plugins
+" I used to use IndexedSearch plugin. Functionality was incorporated into Vim
+" since Vim 8.1.1270.
+set shortmess-=S
+
+
+" Colors
+" ----------------------------------------------------------------------
+" I like desert, murphy, pablo, industry
+" (default is OK for most cases but when using vimdiff, highlighted numbers are
+" unreadable)
+:colorscheme industry
+
+
+" Ducktape (place this in ~/.vim/after (after directory))
+" ----------------------------------------------------------------------
+" Not even the ducktape worked for this one on C files TODO
+set formatoptions-=o " Automatically insert the current comment leader
+" TODO: fix this shit getting reset in a markdown text
+set formatoptions+=r " auto insert comment leader after <Enter>
diff --git a/public/.vim/vimrc_windows b/public/.vim/vimrc_windows
new file mode 100644
index 0000000..8ce69cd
--- /dev/null
+++ b/public/.vim/vimrc_windows
@@ -0,0 +1,10 @@
+" Git for Windows Vim user initialization file
+" GFW uses ~/.vimrc and ~/.vim/vimrc instead of ~/_vimrc and ~/vimfiles/vimrc
+" See https://github.com/git-for-windows/git/issues/658#issuecomment-184269470
+" This file configures GFW Vim to behave like Windows Vim
+" From: https://kevinlocke.name/bits/2020/07/30/sharing-vimrc-in-git-for-windows/
+let &runtimepath = '~/vimfiles,'
+\ . join(filter(split(&runtimepath, ','), 'v:val !~? "/\\.vim"'), ',')
+\ . ',~/vimfiles/after'
+let &packpath = &runtimepath
+source ~/vimfiles/vimrc