enhancing tex feeling in vim

master
tiynger 5 years ago
parent fd43bc1b43
commit bf175d083f

@ -28,7 +28,7 @@ sd() { find ~/ownCloud/* -type f | grep ".pdf" | fzf | xargs -r $READER ;}
# git # git
texhandout() { texhandout() {
[[ -z $1 ]] && echo "missing argument: filename (no ending)" && return 1 [[ -z $1 ]] && echo "missing argument: filename (no ending)" && return 1
cp ~/gitrepos/Tools/LaTeX\ Templates/LaTeX\ Handout/Handout.tex $1.tex && xelatex $1.tex cp ~/gitrepos/Tools/LaTeX\ Templates/LaTeX\ Handout/Handout.tex $1.tex && compile $1.tex
} }
# grep # grep

@ -1,3 +1,5 @@
let mapleader =","
if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
echo "Downloading junegunn/vim-plug to manage plugins..." echo "Downloading junegunn/vim-plug to manage plugins..."
silent !mkdir -p ~/.config/nvim/autoload/ silent !mkdir -p ~/.config/nvim/autoload/
@ -11,21 +13,33 @@ set nohlsearch
set clipboard=unnamedplus set clipboard=unnamedplus
" Some basics: " Some basics:
nnoremap c "_c nnoremap c "_c
set nocompatible set nocompatible
filetype plugin on filetype plugin on
syntax on syntax on
set encoding=utf-8 set encoding=utf-8
set number relativenumber set number relativenumber
" Disables automatic commenting on newline: " Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults. " Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright set splitbelow splitright
" Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed): " Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed):
vnoremap <C-c> "+y vnoremap <C-c> "+y
map <C-p> "+P map <C-p> "+P
" Read files correctly
autocmd BufRead,BufNewFile *.tex set filetype=tex
" Compiler for languages
map <leader>c :w! \| !compiler <c-r>%<CR>
" Clean LaTex build files
autocmd VimLeave *.tex !texclear %
" Delete trailing whitespaces on save
autocmd BufWritePre * %s/\s\+$//e
" Plugin section " Plugin section
call plug#begin('~/.config/nvim/plugged') call plug#begin('~/.config/nvim/plugged')
@ -34,12 +48,7 @@ Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'lervag/vimtex', {'for': 'tex'} Plug 'lervag/vimtex', {'for': 'tex'}
Plug 'artur-shaik/vim-javacomplete2' Plug 'artur-shaik/vim-javacomplete2'
call plug#end() call plug#end()
" neotex
let g:neotex_enabled = 2 let g:neotex_enabled = 2
let g:neotex_pdflatex_alternative = 'xelatex'
" deoplete
let g:deoplete#enable_at_startup = 1 let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 1 let g:deoplete#enable_smart_case = 1
let g:deoplete#sources = {} let g:deoplete#sources = {}
@ -47,7 +56,6 @@ let g:deoplete#sources.java = ['jc', 'javacomplete2', 'file', 'buffer']
call deoplete#custom#var('omni', 'input_patterns', { call deoplete#custom#var('omni', 'input_patterns', {
\ 'tex': g:vimtex#re#deoplete \ 'tex': g:vimtex#re#deoplete
\}) \})
"tab as remapping for deoplete "tab as remapping for deoplete
inoremap <silent><expr> <TAB> inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" : \ pumvisible() ? "\<C-n>" :
@ -57,6 +65,5 @@ function! s:check_back_space() abort "" {{{
let col = col('.') - 1 let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s' return !col || getline('.')[col - 1] =~ '\s'
endfunction "" }}} endfunction "" }}}
" javacomplete2 " javacomplete2
autocmd FileType java setlocal omnifunc=javacomplete#Complete autocmd FileType java setlocal omnifunc=javacomplete#Complete

@ -0,0 +1,38 @@
#!/usr/bin/env sh
# This script will compile or run another finishing operation on a document. I
# have this script run via vim.
#
# Compiles .tex. groff (.mom, .ms), .rmd, .md. Opens .sent files as sent
# presentations. Runs scripts based on extention or shebang
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
cd "$dir" || exit
textype() { \
command="pdflatex"
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
$command --output-directory="$dir" "$base" &&
grep -i addbibresource "$file" >/dev/null &&
biber --input-directory "$dir" "$base" &&
$command --output-directory="$dir" "$base" &&
$command --output-directory="$dir" "$base"
}
case "$file" in
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
*\.tex) textype "$file" ;;
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
*config.h) sudo make install ;;
*\.c) cc "$file" -o "$base" && "$base" ;;
*\.py) python "$file" ;;
*\.go) go run "$file" ;;
*\.sent) setsid sent "$file" 2>/dev/null & ;;
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac

@ -0,0 +1,14 @@
#!/usr/bin/env sh
# Clears the build files of a LaTeX/XeLaTeX build.
# I have vim run this file whenever I exit a .tex file.
case "$1" in
*.tex)
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;;
*) printf "Give .tex file as argument.\\n" ;;
esac

@ -1,25 +0,0 @@
#!/bin/sh
#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
#converted to shell by #nixers @ irc.unix.chat
cat << 'eof'
,_ ,_==▄▂
, ▂▃▄▄▅▅▅▂▅¾. / /
▄▆<´ "»▓▓▓%\ / / / /
,▅7" ´>▓▓▓% / / > / >/%
▐¶▓ ,»▓▓¾´ /> %/%// / /
▓▃▅▅▅▃,,▄▅▅▅Æ\// ///>// />/ /
V║«¼.;→ ║<«.,`=// />//%/% / /
//╠<´ -²,)(▓~"-╝/¾/ %/>/ />
/ / / ▐% -./▄▃▄▅▐, /7//;//% / /
/ ////`▌▐ %zWv xX▓▇▌//&;% / /
/ / / %//%/¾½´▌▃▄▄▄▄▃▃▐¶\/& /
</ /</%//`▓!%▓%╣[38;5;255;╣WY<Y)y&/`\
/ / %/%//</%//\i7; ╠N>)VY>7; \_ UNIX IS VERY SIMPLE IT JUST NEEDS A
/ /</ //<///<_/%\▓ V%W%£)XY _/%‾\_, GENIUS TO UNDERSTAND ITS SIMPLICITY
/ / //%/_,=--^/%/%%\¾%¶%%} /%%%%%%;\,
%/< /_/ %%%%%;X%%\%%;, _/%%%;, \
/ / %%%%%%;, \%%l%%;// _/%;, dmr
/ %%%;, <;\-=-/ /
;, l
eof
Loading…
Cancel
Save