From 9423e274cacba16dc9d1e78109567879a33505f4 Mon Sep 17 00:00:00 2001 From: Bruno Freitas Tissei <bft15@inf.ufpr.br> Date: Mon, 13 May 2019 22:00:34 -0300 Subject: [PATCH] Add support for vim files to notebook Signed-off-by: Bruno Freitas Tissei <bft15@inf.ufpr.br> --- misc/environment/config.vim | 23 +++++++++++++++++++++++ misc/{ => environment}/template.cpp | 0 notebook/gen_latex.py | 10 ++++++---- notebook/header.tex | 7 +++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 misc/environment/config.vim rename misc/{ => environment}/template.cpp (100%) diff --git a/misc/environment/config.vim b/misc/environment/config.vim new file mode 100644 index 0000000..bbdad1a --- /dev/null +++ b/misc/environment/config.vim @@ -0,0 +1,23 @@ +""" Vim Config + +" Tabs +set expandtab +set smarttab + +" Indents +set shiftwidth=2 +set tabstop=2 +set autoindent +set smartindent +set cindent + +" Turn backup off +set nobackup +set nowb +set noswapfile + +" Highlight matching brackets +set showmatch + +" Display line numbers +set number diff --git a/misc/template.cpp b/misc/environment/template.cpp similarity index 100% rename from misc/template.cpp rename to misc/environment/template.cpp diff --git a/notebook/gen_latex.py b/notebook/gen_latex.py index 9b49dbe..c42922a 100644 --- a/notebook/gen_latex.py +++ b/notebook/gen_latex.py @@ -11,7 +11,9 @@ class Tree: # and directories. def build(self): for di in self.dirs: - path_list = sorted(list(Path(di).glob('**/*.cpp'))) + path_list = list(Path(di).glob('**/*.cpp')) + path_list += list(Path(di).glob('**/*.vim')) + path_list = sorted(path_list) for path in path_list: branch = str(path).split('/') @@ -46,7 +48,7 @@ class LatexGenerator: self._add_header() self.gen_latex(tree) - self.output.write('\end{document}') + self.output.write('\\end{document}') # Adds Latex header to the output. def _add_header(self): @@ -63,7 +65,8 @@ class LatexGenerator: # Prints code in Latex format. def gen_code_latex(self, path): # TODO: Add code parsing funcion to extract text - self.output.write('\\begin{lstlisting}[style=customcpp]\n') + suffix = path.split('.')[-1] + self.output.write('\\begin{lstlisting}[style=custom%s]\n' % suffix) with open(path) as f: lines = f.readlines() @@ -84,7 +87,6 @@ class LatexGenerator: self.gen_title_latex(self._parse_dir_name(i), depth) self.gen_latex(sub[i], path + i + '/', depth + 1) - #self.output.write('\\newpage\n') self.output.write('\n') # Parses name of the section (capitalize) diff --git a/notebook/header.tex b/notebook/header.tex index 6310e59..163ead9 100644 --- a/notebook/header.tex +++ b/notebook/header.tex @@ -18,5 +18,12 @@ breaklines=true, morekeywords={int32\_t, ll} } +\lstdefinestyle{customvim}{ + frame=single, + basicstyle=\small, + tabsize=2, + breaklines=true, + morekeywords={set} +} \begin{document} \tableofcontents -- GitLab