Add neovim config; Remove things
This commit is contained in:
1
nvim/.gitignore
vendored
1
nvim/.gitignore
vendored
@ -1 +0,0 @@
|
||||
.cache/
|
||||
@ -1,123 +0,0 @@
|
||||
# This file contains snippets that are always defined. I personally
|
||||
# have snippets for signatures and often needed texts
|
||||
|
||||
# sligthly lower priority than everything else since specialized versions
|
||||
# should overwrite. The user needs to adjust her priority in her snippets to
|
||||
# ~-55 so that other filetypes will still overwrite.
|
||||
priority -60
|
||||
|
||||
##############
|
||||
# NICE BOXES #
|
||||
##############
|
||||
global !p
|
||||
import string, vim
|
||||
|
||||
""" Maps a filetype to comment format used for boxes.
|
||||
Automatically filled during usage"""
|
||||
_commentDict = { }
|
||||
|
||||
def _parse_comments(s):
|
||||
""" Parses vim's comments option to extract comment format """
|
||||
i = iter(s.split(","))
|
||||
|
||||
rv = []
|
||||
try:
|
||||
while True:
|
||||
# get the flags and text of a comment part
|
||||
flags, text = next(i).split(':', 1)
|
||||
|
||||
if len(flags) == 0:
|
||||
rv.append((text, text, text, ""))
|
||||
# parse 3-part comment, but ignore those with O flag
|
||||
elif flags[0] == 's' and 'O' not in flags:
|
||||
ctriple = []
|
||||
indent = ""
|
||||
|
||||
if flags[-1] in string.digits:
|
||||
indent = " " * int(flags[-1])
|
||||
ctriple.append(text)
|
||||
|
||||
flags,text = next(i).split(':', 1)
|
||||
assert(flags[0] == 'm')
|
||||
ctriple.append(text)
|
||||
|
||||
flags,text = next(i).split(':', 1)
|
||||
assert(flags[0] == 'e')
|
||||
ctriple.append(text)
|
||||
ctriple.append(indent)
|
||||
|
||||
rv.append(ctriple)
|
||||
elif flags[0] == 'b':
|
||||
if len(text) == 1:
|
||||
rv.insert(0, (text,text,text, ""))
|
||||
except StopIteration:
|
||||
return rv
|
||||
|
||||
def _get_comment_format():
|
||||
""" Returns a 4-element tuple representing the comment format for
|
||||
the current file. """
|
||||
return _parse_comments(vim.eval("&comments"))[0]
|
||||
|
||||
|
||||
def make_box(twidth, bwidth=None):
|
||||
b, m, e, i = _get_comment_format()
|
||||
bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2
|
||||
sline = b + m + bwidth_inner * m[0] + 2 * m[0]
|
||||
nspaces = (bwidth_inner - twidth) // 2
|
||||
mlines = i + m + " " + " " * nspaces
|
||||
mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m
|
||||
eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e
|
||||
return sline, mlines, mlinee, eline
|
||||
|
||||
def foldmarker():
|
||||
"Return a tuple of (open fold marker, close fold marker)"
|
||||
return vim.eval("&foldmarker").split(",")
|
||||
|
||||
endglobal
|
||||
|
||||
snippet box "A nice box with the current comment symbol" b
|
||||
`!p
|
||||
box = make_box(len(t[1]))
|
||||
snip.rv = box[0] + '\n' + box[1]
|
||||
`${1:content}`!p
|
||||
box = make_box(len(t[1]))
|
||||
snip.rv = box[2] + '\n' + box[3]`
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet bbox "A nice box over the full width" b
|
||||
`!p
|
||||
width = int(vim.eval("&textwidth")) or 71
|
||||
box = make_box(len(t[1]), width)
|
||||
snip.rv = box[0] + '\n' + box[1]
|
||||
`${1:content}`!p
|
||||
box = make_box(len(t[1]), width)
|
||||
snip.rv = box[2] + '\n' + box[3]`
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet fold "Insert a vim fold marker" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
snippet foldc "Insert a vim fold close marker" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
snippet foldp "Insert a vim fold marker pair" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]`
|
||||
${2:${VISUAL:Content}}
|
||||
`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
##########################
|
||||
# LOREM IPSUM GENERATORS #
|
||||
##########################
|
||||
snippet lorem "Lorem Ipsum - 50 Words" b
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
|
||||
no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
@ -1,154 +0,0 @@
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
snippet def "#define ..."
|
||||
#define ${1}
|
||||
endsnippet
|
||||
|
||||
snippet ifndef "#ifndef ... #define ... #endif"
|
||||
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
|
||||
#define ${1:SYMBOL} ${2:value}
|
||||
#endif
|
||||
endsnippet
|
||||
|
||||
snippet #if "#if #endif" b
|
||||
#if ${1:0}
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
|
||||
#endif
|
||||
endsnippet
|
||||
|
||||
snippet inc "#include local header (inc)"
|
||||
#include "${1:`!p snip.rv = snip.basename + '.h'`}"
|
||||
endsnippet
|
||||
|
||||
snippet Inc "#include <> (Inc)"
|
||||
#include <${1:.h}>
|
||||
endsnippet
|
||||
|
||||
snippet mark "#pragma mark (mark)"
|
||||
#if 0
|
||||
${1:#pragma mark -
|
||||
}#pragma mark $2
|
||||
#endif
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet main "main() (main)"
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
return 0;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
# snippet for "for loop (for)"
|
||||
# for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
||||
# {
|
||||
# ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
# }
|
||||
# endsnippet
|
||||
|
||||
snippet for "for int loop (for)"
|
||||
for ( ${4:int} ${2:i}=0; $2<${1:count}; ${3:$2++} ) {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet enum "Enumeration"
|
||||
enum ${1:name} { $0 };
|
||||
endsnippet
|
||||
|
||||
snippet once "Include header once only guard"
|
||||
#ifndef ${1:`!p
|
||||
if not snip.c:
|
||||
import random, string
|
||||
name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()
|
||||
rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
|
||||
snip.rv = ('%s_%s' % (name,rand)).upper()
|
||||
else:
|
||||
snip.rv = snip.c`}
|
||||
#define $1
|
||||
|
||||
${0}
|
||||
|
||||
#endif /* end of include guard: $1 */
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet td "Typedef"
|
||||
typedef ${1:int} ${2:MyCustomType};
|
||||
endsnippet
|
||||
|
||||
snippet wh "while loop"
|
||||
while(${1:/* condition */}) {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet do "do...while loop (do)"
|
||||
do {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
} while(${1:/* condition */});
|
||||
endsnippet
|
||||
|
||||
snippet fprintf "fprintf ..."
|
||||
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
||||
endsnippet
|
||||
|
||||
snippet if "if .. (if)"
|
||||
if (${1:/* condition */})
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet el "else .. (else)"
|
||||
else {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet eli "else if .. (eli)"
|
||||
else if (${1:/* condition */}) {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ife "if .. else (ife)"
|
||||
if (${1:/* condition */})
|
||||
{
|
||||
${2:/* code */}
|
||||
}
|
||||
else
|
||||
{
|
||||
${3:/* else */}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet printf "printf .. (printf)"
|
||||
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
|
||||
endsnippet
|
||||
|
||||
snippet st "struct"
|
||||
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`}
|
||||
{
|
||||
${0:/* data */}
|
||||
};
|
||||
endsnippet
|
||||
|
||||
snippet fun "function" b
|
||||
${1:void} ${2:function_name}(${3})
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fund "function declaration" b
|
||||
${1:void} ${2:function_name}(${3});
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
@ -1,89 +0,0 @@
|
||||
priority -50
|
||||
|
||||
extends c
|
||||
|
||||
# We want to overwrite everything in parent ft.
|
||||
priority -49
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
snippet beginend "$1.begin(), $1.end() (beginend)"
|
||||
${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end()
|
||||
endsnippet
|
||||
|
||||
snippet cl "class .. (class)"
|
||||
class ${1:`!p snip.rv = snip.basename or "name"`}
|
||||
{
|
||||
public:
|
||||
${1/(\w+).*/$1/} (${2:arguments});
|
||||
virtual ~${1/(\w+).*/$1/} ();
|
||||
|
||||
private:
|
||||
${0:/* data */}
|
||||
};
|
||||
endsnippet
|
||||
|
||||
snippet ns "namespace .. (namespace)"
|
||||
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
|
||||
endsnippet
|
||||
|
||||
snippet readfile "read file (readF)"
|
||||
std::vector<char> v;
|
||||
if (FILE *fp = fopen(${1:"filename"}, "r"))
|
||||
{
|
||||
char buf[1024];
|
||||
while(size_t len = fread(buf, 1, sizeof(buf), fp))
|
||||
v.insert(v.end(), buf, buf + len);
|
||||
fclose(fp);
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet map "std::map (map)"
|
||||
std::map<${1:key}, ${2:value}> map$0;
|
||||
endsnippet
|
||||
|
||||
snippet vector "std::vector (v)"
|
||||
std::vector<${1:char}> v$0;
|
||||
endsnippet
|
||||
|
||||
snippet tp "template <typename ..> (template)"
|
||||
template <typename ${1:_InputIter}>
|
||||
endsnippet
|
||||
|
||||
## my own snippets
|
||||
|
||||
snippet dv "debug with var"
|
||||
std::cout << "$1\n" << ${1:var} << "\n" << std::endl;
|
||||
endsnippet
|
||||
|
||||
snippet dvif "debug with var (if)"
|
||||
if ( output_ ) std::cout << "$1\n" << ${1:var} << "\n" << std::endl;
|
||||
endsnippet
|
||||
|
||||
snippet pm "debug with message"
|
||||
std::cout << "${1:message}" << std::endl;
|
||||
endsnippet
|
||||
|
||||
snippet pmif "debug with message (if)"
|
||||
if ( output_ ) std::cout << "${1:message}" << std::endl;
|
||||
endsnippet
|
||||
|
||||
snippet cb "function comment block" s
|
||||
// =============================================================================
|
||||
// ${1:comment}
|
||||
// =============================================================================
|
||||
endsnippet
|
||||
|
||||
snippet cf "function comment block" s
|
||||
// == Function =================================================================
|
||||
// Name : ${1:Name}
|
||||
// Description: ${2:Description}
|
||||
// =============================================================================
|
||||
endsnippet
|
||||
|
||||
|
||||
# vim:ft=snippets:
|
||||
@ -1,6 +0,0 @@
|
||||
priority -50
|
||||
|
||||
snippet disp "Display variable" i
|
||||
disp('${1:${VISUAL:variableName}}')
|
||||
disp(${2:${VISUAL:variable}})
|
||||
endsnippet
|
||||
@ -1,92 +0,0 @@
|
||||
priority -50
|
||||
|
||||
global !p
|
||||
import vim
|
||||
|
||||
# Tests for the existence of a variable declared by Vim's filetype detection
|
||||
# suggesting the type of shell script of the current file
|
||||
def testShell(scope, shell):
|
||||
return vim.eval("exists('" + scope + ":is_" + shell + "')")
|
||||
|
||||
# Loops over the possible variables, checking for global variables
|
||||
# first since they indicate an override by the user.
|
||||
def getShell():
|
||||
for scope in ["g", "b"]:
|
||||
for shell in ["bash", "posix", "sh", "kornshell"]:
|
||||
if testShell(scope, shell) == "1":
|
||||
if shell == "kornshell":
|
||||
return "ksh"
|
||||
if shell == "posix":
|
||||
return "sh"
|
||||
return shell
|
||||
return "sh"
|
||||
endglobal
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
snippet #!
|
||||
`!p snip.rv = '#!/bin/' + getShell() + "\n\n" `
|
||||
endsnippet
|
||||
|
||||
snippet !env "#!/usr/bin/env (!env)"
|
||||
`!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" `
|
||||
endsnippet
|
||||
|
||||
snippet temp "Tempfile"
|
||||
${1:TMPFILE}="$(mktemp -t ${2:`!p
|
||||
snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled"
|
||||
`})"
|
||||
${3:${4/(.+)/trap "/}${4:rm -f '$${1/.*\s//}'}${4/(.+)/" 0 # EXIT\n/}${5/(.+)/trap "/}${5:rm -f '$${1/.*\s//}'; exit 1}${5/(.+)/" 2 # INT\n/}${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'; exit 1}${6/(.+)/" 1 15 # HUP TERM\n/}}
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet case "case .. esac (case)"
|
||||
case ${1:word} in
|
||||
${2:pattern} )
|
||||
$0;;
|
||||
esac
|
||||
endsnippet
|
||||
|
||||
snippet elif "elif .. (elif)"
|
||||
elif ${2:[[ ${1:condition} ]]}; then
|
||||
${0:#statements}
|
||||
endsnippet
|
||||
|
||||
snippet for "for ... done (for)"
|
||||
for (( i = 0; i < ${1:10}; i++ )); do
|
||||
${0:#statements}
|
||||
done
|
||||
endsnippet
|
||||
|
||||
snippet forin "for ... in ... done (forin)"
|
||||
for ${1:i}${2/.+/ in /}${2:words}; do
|
||||
${0:#statements}
|
||||
done
|
||||
endsnippet
|
||||
|
||||
snippet here "here document (here)"
|
||||
<<-${2:'${1:TOKEN}'}
|
||||
$0
|
||||
${1/['"`](.+)['"`]/$1/}
|
||||
endsnippet
|
||||
|
||||
snippet if "if ... then (if)"
|
||||
if ${2:[[ ${1:condition} ]]}; then
|
||||
${0:#statements}
|
||||
fi
|
||||
endsnippet
|
||||
|
||||
snippet until "until ... (done)"
|
||||
until ${2:[[ ${1:condition} ]]}; do
|
||||
${0:#statements}
|
||||
done
|
||||
endsnippet
|
||||
|
||||
snippet while "while ... (done)"
|
||||
while ${2:[[ ${1:condition} ]]}; do
|
||||
${0:#statements}
|
||||
done
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
@ -1,158 +0,0 @@
|
||||
priority -50
|
||||
|
||||
extends texmath
|
||||
|
||||
snippet document "document setup"
|
||||
\documentclass[a4paper]{article}
|
||||
\usepackage{defaultTex}
|
||||
% \usepackage[style=alphabetic]{biblatex}
|
||||
% \addbibresource{lib.bib}
|
||||
|
||||
\begin{document}
|
||||
${1:text}
|
||||
\end{document}
|
||||
endsnippet
|
||||
|
||||
snippet "b(egin)?" "begin{} / end{}" br
|
||||
\begin{${1:something}}
|
||||
${0:${VISUAL}}
|
||||
\label{${2}}
|
||||
\end{$1}
|
||||
endsnippet
|
||||
|
||||
snippet bo "bold"
|
||||
\textbf{${1:${VISUAL}}}$0
|
||||
endsnippet
|
||||
|
||||
snippet tab
|
||||
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
|
||||
$0${2/((?<=.)c|l|r)|./(?1: & )/g}
|
||||
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
|
||||
endsnippet
|
||||
|
||||
snippet fig "Figure environment" b
|
||||
\begin{figure}${2:[htpb]}
|
||||
\centering
|
||||
\includegraphics[width=${3:0.8}\linewidth]{${4:name.ext}}
|
||||
\caption{${4/(\w+)\.\w+/\u$1/}$0}
|
||||
\label{fig:${4/(\w+)\.\w+/$1/}}
|
||||
\end{figure}
|
||||
endsnippet
|
||||
|
||||
snippet enum "Enumerate" b
|
||||
\begin{enumerate}
|
||||
\item $1
|
||||
\end{enumerate}
|
||||
endsnippet
|
||||
|
||||
snippet item "Itemize" b
|
||||
\begin{itemize}
|
||||
\item $1
|
||||
\end{itemize}
|
||||
endsnippet
|
||||
|
||||
snippet desc "Description" b
|
||||
\begin{description}
|
||||
\item[$1] $0
|
||||
\end{description}
|
||||
endsnippet
|
||||
|
||||
snippet eq "equation"
|
||||
\begin{equation}
|
||||
${2:${VISUAL}}
|
||||
\end{equation}
|
||||
endsnippet
|
||||
|
||||
snippet eql "equation with label"
|
||||
\begin{equation}
|
||||
${2:${VISUAL}}
|
||||
\label{$1}
|
||||
\end{equation}
|
||||
endsnippet
|
||||
|
||||
snippet eqs "aligned equations"
|
||||
\begin{equation}
|
||||
\begin{aligned}
|
||||
${2:${VISUAL}}
|
||||
\end{aligned}
|
||||
\end{equation}
|
||||
endsnippet
|
||||
|
||||
snippet eqsl "aligned equations with label"
|
||||
\begin{equation}
|
||||
\begin{aligned}
|
||||
${2:${VISUAL}}
|
||||
\end{aligned}
|
||||
\label{$1}
|
||||
\end{equation}
|
||||
endsnippet
|
||||
|
||||
snippet align "align"
|
||||
\begin{align}
|
||||
${2:${VISUAL}}
|
||||
\label{$1}
|
||||
\end{align}
|
||||
endsnippet
|
||||
|
||||
snippet it "Individual item" b
|
||||
\item $1
|
||||
endsnippet
|
||||
|
||||
snippet part "Part" b
|
||||
\part{${1:part name}}
|
||||
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet cha "Chapter" b
|
||||
\chapter{${1:chapter name}}
|
||||
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet sec "Section" b
|
||||
\section{${1:section name}}
|
||||
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet sub "Subsection" b
|
||||
\subsection{${1:subsection name}}
|
||||
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet ssub "Subsubsection" b
|
||||
\subsubsection{${1:subsubsection name}}
|
||||
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet par "Paragraph" b
|
||||
\paragraph{${1:paragraph name}}
|
||||
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet subp "Subparagraph" b
|
||||
\subparagraph{${1:subparagraph name}}
|
||||
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet ni "Non-indented paragraph" b
|
||||
\noindent
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
snippet pac "Package" b
|
||||
\usepackage[${1:options}]{${2:package}}$0
|
||||
endsnippet
|
||||
# vim:ft=snippets:
|
||||
@ -1,85 +0,0 @@
|
||||
priority -50
|
||||
|
||||
##############
|
||||
# MATH STUFF #
|
||||
##############
|
||||
# snippet eq "Equation" b
|
||||
# \begin{equation}
|
||||
# $0
|
||||
# \end{equation}
|
||||
# endsnippet
|
||||
|
||||
# snippet eqnn "Equation without number" b
|
||||
# \begin{equation*}
|
||||
# $0
|
||||
# \end{equation*}
|
||||
# endsnippet
|
||||
|
||||
# snippet eqa "Equation array" b
|
||||
# \begin{eqnarray}
|
||||
# $1 & $2 & $0
|
||||
# \end{eqnarray}
|
||||
# endsnippet
|
||||
|
||||
# snippet eqann "Equation array without numbers" b
|
||||
# \begin{eqnarray*}
|
||||
# $1 & $2 & $0
|
||||
# \end{eqnarray*}
|
||||
|
||||
# endsnippet
|
||||
snippet frac "Fraction" w
|
||||
\frac{${1:${VISUAL:nom}}}{${2:denom}}
|
||||
endsnippet
|
||||
|
||||
snippet mat "Smart Matrix"
|
||||
\begin{${1:p/b/v/V/B/small}matrix}
|
||||
$0
|
||||
\end{$1matrix}
|
||||
endsnippet
|
||||
|
||||
snippet lrb "left( right)" w
|
||||
\left( ${1:${VISUAL}} \right)
|
||||
endsnippet
|
||||
|
||||
snippet lrv "left| right|" w
|
||||
\left| ${1:${VISUAL}} \right|
|
||||
endsnippet
|
||||
|
||||
snippet lrB "left\{ right\}" w
|
||||
\left\\{ ${1:${VISUAL}} \right\\}
|
||||
endsnippet
|
||||
|
||||
snippet lre "left[ right]" w
|
||||
\left[ ${1:${VISUAL}} \right]
|
||||
endsnippet
|
||||
|
||||
# my snippets
|
||||
snippet func "Function" w
|
||||
\func{${1:${VISUAL}}}{${2}}
|
||||
endsnippet
|
||||
|
||||
snippet funcb "Function with brackets" w
|
||||
\funcb{${1:${VISUAL}}}{${2}}
|
||||
endsnippet
|
||||
|
||||
snippet int "integral"
|
||||
\int_{${1}}^{${2}}
|
||||
endsnippet
|
||||
|
||||
snippet sum "sum"
|
||||
\sum_{${1}}^{${2}}
|
||||
endsnippet
|
||||
|
||||
snippet eqr "eqref"
|
||||
\eqref{${1}}
|
||||
endsnippet
|
||||
|
||||
snippet v "Vector" w
|
||||
\vec
|
||||
endsnippet
|
||||
|
||||
snippet bis "bis" w
|
||||
\bis{${1}}{${2}}
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,6 @@
|
||||
-------------------------
|
||||
-------- OPTIONS --------
|
||||
-------------------------
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.history = 1000
|
||||
vim.opt.ruler = true
|
||||
@ -39,9 +42,46 @@ vim.opt.showbreak = '..'
|
||||
-- vim.opt.clipboard = vim.opt.clipboard + 'unnamedplus'
|
||||
-- vim.opt.clipboard = 'unnamedplus'
|
||||
vim.opt.errorbells = false
|
||||
vim.opt.visualbell = true
|
||||
vim.opt.visualbell = false
|
||||
vim.opt.title = true
|
||||
vim.opt.autoread = true
|
||||
vim.opt.syntax = 'on'
|
||||
vim.opt.encoding = 'utf-8'
|
||||
vim.opt.completeopt = 'menu,menuone,noselect'
|
||||
|
||||
----------------------------
|
||||
-------- COMMANDS --------
|
||||
----------------------------
|
||||
--
|
||||
vim.cmd('filetype plugin indent on')
|
||||
|
||||
-- vim.cmd('colorscheme lucius')
|
||||
-- vim.cmd('LuciusWhite')
|
||||
|
||||
|
||||
----------------------------
|
||||
-------- AUTOGROUPs --------
|
||||
----------------------------
|
||||
|
||||
vim.api.nvim_create_augroup('VimIntern', { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({'FocusGained', 'BufEnter', 'CursorMoved', 'CursorMovedI', 'CursorHold', 'CursorHoldI'}, {
|
||||
group = 'VimIntern',
|
||||
pattern = '*',
|
||||
command = 'silent! checktime'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
group = 'VimIntern',
|
||||
pattern = '*',
|
||||
command = 'silent! lcd %:p:h'
|
||||
})
|
||||
|
||||
|
||||
---------------------------
|
||||
-------- FUNCTIONS --------
|
||||
---------------------------
|
||||
|
||||
vim.api.nvim_create_user_command('TrimWhiteSpace', function()
|
||||
vim.cmd('%s/\\s\\+$//e')
|
||||
end, {})
|
||||
438
nvim/init.vim
438
nvim/init.vim
@ -1,438 +0,0 @@
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" vim
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
lua require('basic_vim')
|
||||
lua require('plugins_vim')
|
||||
lua require('mappings_vim')
|
||||
" set nocompatible
|
||||
" set mouse=a
|
||||
" set history=1000
|
||||
" set ruler
|
||||
" set number
|
||||
" set showcmd
|
||||
" set ttimeoutlen=100
|
||||
" set backspace=indent,eol,start
|
||||
" set tabstop=4
|
||||
" set expandtab
|
||||
" set shiftwidth=4
|
||||
" set softtabstop=4
|
||||
" set autoindent
|
||||
" set showmatch
|
||||
" set incsearch
|
||||
" set hlsearch
|
||||
" set wrapscan
|
||||
" set ignorecase
|
||||
" set smartcase
|
||||
" set hidden
|
||||
" set splitright
|
||||
" set splitbelow
|
||||
" set backupdir=~/.config/nvim/backup,/tmp
|
||||
" set backup
|
||||
" set noswapfile
|
||||
" set wildmode=longest,list
|
||||
" set nospell
|
||||
" set foldmethod=syntax
|
||||
" set foldopen-=block
|
||||
" set foldlevel=99
|
||||
" set lazyredraw
|
||||
" set listchars=eol:¬,tab:\ \ ,trail:·
|
||||
" set fillchars=vert:\|,fold:\
|
||||
" set list
|
||||
" set laststatus=2
|
||||
" set scrolloff=8
|
||||
" set background=light
|
||||
" " set colorcolumn=100
|
||||
" set wrap
|
||||
" set showbreak=..
|
||||
" set clipboard+=unnamedplus
|
||||
" " set formatoptions+=l
|
||||
" set noerrorbells
|
||||
" set visualbell
|
||||
set t_vb=
|
||||
" set title
|
||||
" set autoread
|
||||
" syntax on
|
||||
" let g:tex_flavor="latex"
|
||||
" set listchars=eol:¬,tab:▸\ ,trail:·
|
||||
" set listchars=eol:¬,tab:>\ ,trail:·
|
||||
|
||||
" if !has('nvim') | set encoding=utf-8 | endif
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" plugins
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" call plug#begin('~/.local/share/nvim/site/plugins')
|
||||
|
||||
" Plug 'kien/ctrlp.vim' | Plug 'sgur/ctrlp-extensions.vim'
|
||||
" Plug 'scrooloose/nerdtree'
|
||||
" Plug 'scrooloose/syntastic'
|
||||
" Plug 'vim-scripts/bufexplorer.zip'
|
||||
" Plug 'majutsushi/tagbar'
|
||||
|
||||
" Plug 'Shougo/deoplete.nvim'
|
||||
" Plug 'SirVer/ultisnips'
|
||||
|
||||
" Plug 'Raimondi/delimitMate'
|
||||
" Plug 'tpope/vim-surround'
|
||||
" Plug 'tpope/vim-commentary'
|
||||
" Plug 'junegunn/vim-easy-align'
|
||||
|
||||
" Plug 'maxbrunsfeld/vim-yankstack'
|
||||
|
||||
" Plug 'tpope/vim-repeat'
|
||||
" Plug 'wellle/targets.vim'
|
||||
|
||||
" Plug 'benekastah/neomake'
|
||||
|
||||
" Plug 'tpope/vim-fugitive'
|
||||
" Plug 'tpope/vim-dispatch'
|
||||
|
||||
" Plug 'lervag/vimtex'
|
||||
" Plug 'vim-scripts/LanguageTool'
|
||||
|
||||
" Plug 'mhinz/neovim-remote'
|
||||
|
||||
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | Plug 'junegunn/fzf.vim'
|
||||
" Plug 'rking/ag.vim'
|
||||
"
|
||||
" Plug 'tpope/vim-obsession'
|
||||
" Plug 'mhinz/vim-startify'
|
||||
" Plug 'wesQ3/vim-windowswap'
|
||||
"
|
||||
" Plug 'bling/vim-airline' | Plug 'vim-airline/vim-airline-themes' |Plug 'jonathanfilip/vim-lucius'
|
||||
" Plug 'altercation/vim-colors-solarized'
|
||||
|
||||
" call plug#end()
|
||||
|
||||
filetype plugin indent on
|
||||
|
||||
set omnifunc=syntaxcomplete#Complete
|
||||
" set completeopt=menu
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" plugin specific
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
" NerdTree
|
||||
"let NERDTreeQuitOnOpen=1
|
||||
"let NERDTreeHijackNetrw=1
|
||||
|
||||
" syntastic
|
||||
" set statusline+=%#warningmsg#
|
||||
" set statusline+=%{SyntasticStatuslineFlag()}
|
||||
" set statusline+=%*
|
||||
" let g:syntastic_always_populate_loc_list = 1
|
||||
" let g:syntastic_auto_loc_list = 1
|
||||
" let g:syntastic_check_on_open = 1
|
||||
" let g:syntastic_check_on_wq = 0
|
||||
|
||||
" CtrlP
|
||||
" set wildignore+=main,*.o,*.d,*.aux,*.bbl,*.lof,*.loa,*.blg,*.fdb_latexmk,*.fls,*.tdo,*.pdf,*.pyc
|
||||
" let g:ctrlp_switch_buffer = 'e'
|
||||
" let g:ctrlp_working_path_mode = 'ra'
|
||||
" let g:ctrlp_extensions = [ 'tag', 'buffertag', 'mixed' ]
|
||||
" let g:ctrlp_map = ''
|
||||
" let g:ctrlp_prompt_mappings = {
|
||||
" \ 'PrtSelectMove("j")': ['<c-n>', '<down>'],
|
||||
" \ 'PrtSelectMove("k")': ['<c-p>', '<up>'],
|
||||
" \}
|
||||
|
||||
" tagbar
|
||||
let g:tagbar_left=1
|
||||
let g:tagbar_autoclose=1
|
||||
let g:tagbar_autofocus=1
|
||||
|
||||
" DelimitMate
|
||||
let delimitMate_expand_space=1
|
||||
let delimitMate_expand_cr=1
|
||||
|
||||
" UltiSnips
|
||||
" let g:UltiSnipsSnippetsDir='~/.config/nvim/UltiSnips'
|
||||
" let g:UltiSnipsSnippetsDirectories=["UltiSnips"]
|
||||
" let g:UltiSnipsExpandTrigger="<C-j>"
|
||||
" let g:UltiSnipsJumpForwardTrigger="<C-j>"
|
||||
" let g:UltiSnipsJumpBackwardTrigger="<C-k>"
|
||||
|
||||
" YankStack
|
||||
"let g:yankstack_map_keys=0
|
||||
"call yankstack#setup()
|
||||
|
||||
" vimtex
|
||||
" let g:vimtex_fold_enabled = 1
|
||||
" let g:vimtex_view_method = 'zathura'
|
||||
" let g:vimtex_quickfix_mode = 2
|
||||
" let g:deoplete#omni#input_patterns.tex =
|
||||
" \ '\v\\%('
|
||||
" \ . '\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
||||
" \ . '|\a*ref%(\s*\{[^}]*|range\s*\{[^,}]*%(}\{)?)'
|
||||
" \ . '|hyperref\s*\[[^]]*'
|
||||
" \ . '|includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
||||
" \ . '|%(include%(only)?|input)\s*\{[^}]*'
|
||||
" \ . '|\a*(gls|Gls|GLS)(pl)?\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
||||
" \ . '|includepdf%(\s*\[[^]]*\])?\s*\{[^}]*'
|
||||
" \ . '|includestandalone%(\s*\[[^]]*\])?\s*\{[^}]*'
|
||||
" \ . ')'
|
||||
|
||||
" Startify
|
||||
let g:startify_session_dir = '~/.config/nvim/obsessions'
|
||||
let g:startify_list_order = [[' Sessions'],'sessions',
|
||||
\ [' Bookmarks'],'bookmarks',
|
||||
\ [' Recent dirs'],'dir',]
|
||||
let g:startify_bookmarks = [ {'v': '~/.config/nvim/init.vim'} ]
|
||||
" \ [' Recent files'],'files',
|
||||
let g:startify_custom_header = []
|
||||
|
||||
" windowswap
|
||||
let g:windowswap_map_keys=0
|
||||
|
||||
" airline
|
||||
let g:airline_theme='lucius'
|
||||
if !exists('g:airline_symbols')
|
||||
let g:airline_symbols={}
|
||||
endif
|
||||
let g:airline_left_sep=''
|
||||
let g:airline_right_sep=''
|
||||
let g:airline_symbols.linenr = '␊'
|
||||
let g:airline_symbols.linenr = ''
|
||||
let g:airline_symbols.linenr = '¶'
|
||||
let g:airline_symbols.branch = '⎇'
|
||||
let g:airline_symbols.paste = 'ρ'
|
||||
let g:airline_symbols.paste = 'Þ'
|
||||
let g:airline_symbols.paste = '∥'
|
||||
let g:airline_symbols.whitespace = 'Ξ'
|
||||
let g:airline_section_y=''
|
||||
let g:airline#extensions#tabline#enabled=1
|
||||
let g:airline#extensions#tabline#tab_nr_type = 1
|
||||
let g:airline#extensions#tabline#show_buffers=0
|
||||
let g:airline#extensions#tabline#show_tab_nr=1
|
||||
let g:airline#extensions#tabline#show_tab_type=0
|
||||
let g:airline#extensions#tabline#fnamemod = ':~:.'
|
||||
|
||||
" Lucius
|
||||
colorscheme lucius
|
||||
LuciusWhite
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" misc
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
let mapleader = "\<Space>"
|
||||
|
||||
nnoremap <leader>w :w<CR>
|
||||
|
||||
nnoremap <silent> <leader>q :call ToggleList("Quickfix List", 'c')<CR>
|
||||
|
||||
nnoremap <silent> <leader>ev :tabnew ~/.config/nvim/init.vim<CR>
|
||||
|
||||
nnoremap Y y$
|
||||
|
||||
nnoremap j gj
|
||||
nnoremap k gk
|
||||
vnoremap j gj
|
||||
vnoremap k gk
|
||||
|
||||
" file navigation
|
||||
nnoremap <silent> <leader>ff <cmd>Telescope find_files<CR>
|
||||
nnoremap <silent> <leader>fg <cmd>Telescope live_grep<CR>
|
||||
nnoremap <silent> <leader>o <cmd>Telescope buffers<CR>
|
||||
nnoremap <silent> <leader>fh <cmd>Telescope help_tags<CR>
|
||||
nnoremap <silent> <leader>F :e.<CR>
|
||||
nnoremap <silent> <leader>O :BufExplorer<CR>
|
||||
nnoremap <silent> <leader>t :CtrlPBufTagAll<CR>
|
||||
nnoremap <silent> <leader>T :TagbarToggle<CR>
|
||||
|
||||
|
||||
nnoremap <leader>p :CtrlPYankring<CR>
|
||||
nnoremap <C-p> <Plug>yankstack_substitute_newer_paste
|
||||
nnoremap <C-n> <Plug>yankstack_substitute_older_paste
|
||||
|
||||
" command line mappings
|
||||
cnoremap <C-p> <Up>
|
||||
cnoremap <C-n> <Down>
|
||||
cnoremap w!! w !sudo tee > /dev/null %
|
||||
|
||||
" quickfix mappings
|
||||
" nnoremap <silent> <leader>q :call ToggleList("Quickfix List", 'c')<CR>
|
||||
" nnoremap <silent> [q :cprevious<CR>
|
||||
" nnoremap <silent> ]q :cnext<CR>
|
||||
|
||||
" split movement
|
||||
nnoremap <C-h> <C-w>h
|
||||
nnoremap <BS> <C-w>h
|
||||
nnoremap <C-j> <C-w>j
|
||||
nnoremap <C-k> <C-w>k
|
||||
nnoremap <C-l> <C-w>l
|
||||
nnoremap <leader>s :call WindowSwap#EasyWindowSwap()<CR>
|
||||
|
||||
" terminal mappings
|
||||
tnoremap <Esc> <C-\><C-n>
|
||||
tnoremap <C-h> <C-\><C-n><C-w>h
|
||||
tnoremap <C-j> <C-\><C-n><C-w>j
|
||||
tnoremap <C-k> <C-\><C-n><C-w>k
|
||||
tnoremap <C-l> <C-\><C-n><C-w>l
|
||||
|
||||
" alignment mappings
|
||||
nnoremap <silent> <leader>= :normal vip<CR> :'<,'>EasyAlign =<CR>
|
||||
vnoremap <silent> <leader>= :'<,'>EasyAlign =<CR>
|
||||
vmap <Enter> <Plug>(EasyAlign)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
|
||||
augroup Terminal
|
||||
autocmd!
|
||||
au BufWinEnter,WinEnter term://* startinsert
|
||||
" au TermOpen * call SetMatlabMaps()
|
||||
augroup END
|
||||
|
||||
" no folding on open bracket
|
||||
augroup Folding
|
||||
autocmd!
|
||||
au InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
|
||||
au InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif
|
||||
augroup END
|
||||
|
||||
augroup VimIntern
|
||||
autocmd!
|
||||
" Source init.vim on write
|
||||
au BufWritePost $MYVIMRC source %
|
||||
" check for file change
|
||||
au FocusGained,BufEnter,CursorMoved,CursorMovedI,CursorHold,CursorHoldI * :silent! checktime
|
||||
" change working directory to current files directory
|
||||
au BufEnter * silent! lcd %:p:h
|
||||
augroup END
|
||||
|
||||
" tmux window title
|
||||
" augroup TmuxTitle
|
||||
" autocmd!
|
||||
" au VimEnter * call SaveTmuxWindowName()
|
||||
" au SessionLoadPost * call ChangeTmuxToSessionName()
|
||||
" au VimLeave * call system("tmux rename-window '" . g:tmuxWindowName . "'")
|
||||
" augroup END
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" filetype specific
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" matlab
|
||||
augroup Matlab
|
||||
autocmd!
|
||||
au FileType matlab let b:commentary_format='% %s'
|
||||
au FileType matlab setlocal listchars=eol:¬,tab:\|\ ,trail:·
|
||||
au FileType matlab nnoremap <leader>ml :call OpenMatlabInTerminal()<CR>
|
||||
" au FileType matlab inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
|
||||
augroup END
|
||||
|
||||
" c/c++
|
||||
augroup Cpp
|
||||
autocmd!
|
||||
au FileType c,cpp setlocal listchars=eol:¬,tab:\|\ ,trail:·
|
||||
au FileType c,cpp nnoremap <leader>ml :call OpenMatlabInTerminal()<CR>
|
||||
" au FileType c,cpp inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
|
||||
augroup END
|
||||
|
||||
" " tex
|
||||
" augroup Tex
|
||||
" autocmd!
|
||||
" au Filetype tex,latex setlocal foldmethod=expr
|
||||
" au Filetype tex,latex setlocal foldlevel=0
|
||||
" au Filetype tex,latex setlocal spell
|
||||
" " au Filetype tex,latex setlocal textwidth=80
|
||||
" au Filetype tex,latex inoremap $ $$<Left>
|
||||
" au BufWritePost *.tex Neomake
|
||||
" augroup END
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" custom functions
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" open terminal with matlab in bottom right split
|
||||
function! OpenMatlabInTerminal()
|
||||
execute "normal \<C-w>l"
|
||||
split
|
||||
terminal mlnd
|
||||
call SetMatlabMaps()
|
||||
endfunction
|
||||
|
||||
" function! SetMatlabMaps()
|
||||
" if bufname('') =~? "mlnd"
|
||||
" tnoremap <buffer> <leader><leader>mc close all<CR>
|
||||
" tnoremap <buffer> <leader><leader>mw clear<CR>
|
||||
" tnoremap <buffer> <leader><leader>mf clear functions<CR>
|
||||
" nnoremap <buffer> <C-c> i<C-c>
|
||||
" endif
|
||||
" endfunction
|
||||
|
||||
" change tmux window name to session
|
||||
" function! ChangeTmuxToSessionName()
|
||||
" let sessionName = v:this_session
|
||||
" if strlen(sessionName)
|
||||
" let session = substitute(sessionName, ".*/", "", "g")
|
||||
" call system("tmux rename-window '" . session . "'")
|
||||
" else
|
||||
" call system("tmux rename-window 'nvim'")
|
||||
" endif
|
||||
" endfunction
|
||||
|
||||
" function! SaveTmuxWindowName()
|
||||
" let g:tmuxWindowName = system("tmux display-message -p '#W'")
|
||||
" let g:tmuxWindowName = substitute(g:tmuxWindowName, '\n\+$', '', '')
|
||||
" call system("tmux rename-window 'nvim'")
|
||||
" endfunction
|
||||
|
||||
" remove whitespaces
|
||||
function! TrimWhiteSpace()
|
||||
%s/\s\+$//e
|
||||
endfunction
|
||||
|
||||
" function! s:ealign()
|
||||
" let p = '^.*=\s.*$'
|
||||
" if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
|
||||
" let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
|
||||
" let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
|
||||
" Tabularize/=/l1
|
||||
" normal! 0
|
||||
" call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
|
||||
" endif
|
||||
" endfunction
|
||||
|
||||
" toggle the quickfix or location list window.
|
||||
function! GetBufferList()
|
||||
redir =>buflist
|
||||
silent! ls
|
||||
redir END
|
||||
return buflist
|
||||
endfunction
|
||||
|
||||
function! ToggleList(bufname, pfx)
|
||||
let buflist = GetBufferList()
|
||||
for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))')
|
||||
if bufwinnr(bufnum) != -1
|
||||
exec(a:pfx.'close')
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
if a:pfx == 'l' && len(getloclist(0)) == 0
|
||||
echohl ErrorMsg
|
||||
echo "Location List is Empty."
|
||||
return
|
||||
endif
|
||||
let winnr = winnr()
|
||||
exec(a:pfx.'open')
|
||||
if winnr() != winnr
|
||||
wincmd p
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" let neomake_matlab_mlint_maker = {
|
||||
" \ 'exe': 'mlint',
|
||||
" \ 'errorformat':
|
||||
" \ '%+PFile:\ %f,' .
|
||||
" \ 'L\ %l\ (C\ %c):\ %m,' .
|
||||
" \ 'L\ %l\ (C\ %c-%.):\ %m,',
|
||||
" \ }
|
||||
|
||||
" neomake matlab maker
|
||||
let neomake_matlab_mlint_maker = {
|
||||
\ 'exe': 'mlint',
|
||||
\ 'errorformat':
|
||||
\ '%+PFile:\ %f,' .
|
||||
\ 'L\ %l\ (C\ %c):\ %*[a-zA-Z0-9]:\ %m,'.
|
||||
\ 'L\ %l\ (C\ %c-%*[0-9]):\ %*[a-zA-Z0-9]:\ %m'
|
||||
\ }
|
||||
42
nvim/keymaps.lua
Normal file
42
nvim/keymaps.lua
Normal file
@ -0,0 +1,42 @@
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- Navigation
|
||||
vim.keymap.set('n', 'j', 'gj', {})
|
||||
vim.keymap.set('n', 'k', 'gk', {})
|
||||
vim.keymap.set('v', 'j', 'gj', {})
|
||||
vim.keymap.set('v', 'k', 'gk', {})
|
||||
|
||||
vim.keymap.set('n', '<C-h>', '<C-w>h', {})
|
||||
vim.keymap.set('n', '<C-j>', '<C-w>j', {})
|
||||
vim.keymap.set('n', '<C-k>', '<C-w>k', {})
|
||||
vim.keymap.set('n', '<C-l>', '<C-w>l', {})
|
||||
|
||||
vim.keymap.set('n', '<leader>s', ':call WindowSwap#EasyWindowSwap()<CR>', {})
|
||||
|
||||
-- Convenience
|
||||
vim.keymap.set('n', '<leader>w', ':w<CR>', { silent = true })
|
||||
vim.keymap.set('n', '<leader>F', ':e.<CR>', {})
|
||||
vim.keymap.set('n', 'Y', 'y$', {})
|
||||
|
||||
-- Telescope
|
||||
local telebuiltin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>ff', telebuiltin.find_files, { silent = true })
|
||||
vim.keymap.set('n', '<leader>fg', telebuiltin.live_grep, { silent = true })
|
||||
vim.keymap.set('n', '<leader>fs', telebuiltin.grep_string, { silent = true })
|
||||
vim.keymap.set('n', '<leader>o', telebuiltin.buffers, { silent = true })
|
||||
vim.keymap.set('n', '<leader>fh', telebuiltin.help_tags, { silent = true })
|
||||
|
||||
-- Yanky
|
||||
vim.keymap.set({"n","x"}, "p", "<Plug>(YankyPutAfter)")
|
||||
vim.keymap.set({"n","x"}, "P", "<Plug>(YankyPutBefore)")
|
||||
vim.keymap.set({"n","x"}, "gp", "<Plug>(YankyGPutAfter)")
|
||||
vim.keymap.set({"n","x"}, "gP", "<Plug>(YankyGPutBefore)")
|
||||
vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)")
|
||||
vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)")
|
||||
vim.keymap.set({"n","x"}, "y", "<Plug>(YankyYank)")
|
||||
|
||||
-- Undotree
|
||||
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
|
||||
|
||||
-- nnoremap <silent> <leader>t :CtrlPBufTagAll<CR>
|
||||
-- nnoremap <silent> <leader>T :TagbarToggle<CR>
|
||||
@ -1,7 +0,0 @@
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.history = 1000
|
||||
vim.opt.ruler = true
|
||||
vim.opt.ruler = true
|
||||
vim.opt.number = true
|
||||
vim.opt.showcmd = true
|
||||
vim.opt.ttimeoutlen = 100
|
||||
@ -1,17 +0,0 @@
|
||||
-- Yanky mappings
|
||||
vim.keymap.set({"n","x"}, "p", "<Plug>(YankyPutAfter)")
|
||||
vim.keymap.set({"n","x"}, "P", "<Plug>(YankyPutBefore)")
|
||||
vim.keymap.set({"n","x"}, "gp", "<Plug>(YankyGPutAfter)")
|
||||
vim.keymap.set({"n","x"}, "gP", "<Plug>(YankyGPutBefore)")
|
||||
-- vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)")
|
||||
-- vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)")
|
||||
vim.keymap.set({"n","x"}, "y", "<Plug>(YankyYank)")
|
||||
vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<CR>")
|
||||
-- nnoremap <silent> <leader>f <cmd>Telescope find_files<CR>
|
||||
-- nnoremap <silent> <leader>fg <cmd>Telescope live_grep<CR>
|
||||
-- nnoremap <silent> <leader>o <cmd>Telescope buffers<CR>
|
||||
-- nnoremap <silent> <leader>fh <cmd>Telescope help_tags<CR>
|
||||
-- nnoremap <silent> <leader>F :e.<CR>
|
||||
-- nnoremap <silent> <leader>O :BufExplorer<CR>
|
||||
-- nnoremap <silent> <leader>t :CtrlPBufTagAll<CR>
|
||||
-- nnoremap <silent> <leader>T :TagbarToggle<CR>
|
||||
@ -1,191 +0,0 @@
|
||||
local Plug = vim.fn['plug#']
|
||||
|
||||
vim.call('plug#begin', '~/.local/share/nvim/site/plugins')
|
||||
|
||||
-- enhanced commenting
|
||||
Plug 'tpope/vim-commentary'
|
||||
-- enhanced single-repeat '.'
|
||||
Plug 'tpope/vim-repeat'
|
||||
-- enhanced surrounding
|
||||
Plug 'tpope/vim-surround'
|
||||
-- session management
|
||||
Plug 'tpope/vim-obsession'
|
||||
-- enhanced text objects
|
||||
Plug 'wellle/targets.vim'
|
||||
-- enhanced yank
|
||||
Plug 'gbprod/yanky.nvim'
|
||||
-- auto close brackets
|
||||
Plug 'Raimondi/delimitMate'
|
||||
-- start page
|
||||
Plug 'mhinz/vim-startify'
|
||||
-- alignment
|
||||
Plug 'junegunn/vim-easy-align'
|
||||
-- swap windows
|
||||
Plug 'wesQ3/vim-windowswap'
|
||||
|
||||
-- LSP
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'})
|
||||
|
||||
-- command completion
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/cmp-path'
|
||||
Plug 'hrsh7th/cmp-cmdline'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
-- prettify command completion
|
||||
Plug 'onsails/lspkind.nvim'
|
||||
|
||||
-- snippets
|
||||
Plug 'hrsh7th/cmp-vsnip'
|
||||
Plug 'hrsh7th/vim-vsnip'
|
||||
|
||||
-- fuzzy finder
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug('nvim-telescope/telescope.nvim', {branch = '0.1.x'})
|
||||
|
||||
-- status line and theme
|
||||
Plug 'bling/vim-airline'
|
||||
Plug 'vim-airline/vim-airline-themes'
|
||||
Plug 'jonathanfilip/vim-lucius'
|
||||
Plug 'altercation/vim-colors-solarized'
|
||||
|
||||
-- filetype
|
||||
Plug 'towolf/vim-helm'
|
||||
|
||||
vim.call('plug#end')
|
||||
|
||||
|
||||
-- " Plug 'mhinz/neovim-remote'
|
||||
|
||||
-- Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | Plug 'junegunn/fzf.vim'
|
||||
-- Plug 'rking/ag.vim'
|
||||
|
||||
|
||||
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
cmp.setup {
|
||||
-- As currently, i am not using any snippet manager, thus disabled it.
|
||||
-- snippet = {
|
||||
-- expand = function(args)
|
||||
-- require("luasnip").lsp_expand(args.body)
|
||||
-- end,
|
||||
-- },
|
||||
|
||||
-- mapping = {
|
||||
-- ["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
-- ["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
-- ["<C-e>"] = cmp.mapping.close(),
|
||||
-- ["<c-y>"] = cmp.mapping.confirm {
|
||||
-- behavior = cmp.ConfirmBehavior.Insert,
|
||||
-- select = true,
|
||||
-- },
|
||||
-- }
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format {
|
||||
mode = 'symbol_text',
|
||||
menu = {
|
||||
buffer = "[buf]",
|
||||
nvim_lsp = "[LSP]",
|
||||
path = "[path]",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
sources = {
|
||||
{ name = "nvim_lsp"},
|
||||
{ name = "path" },
|
||||
{ name = "buffer" , keyword_length = 2},
|
||||
},
|
||||
|
||||
experimental = {
|
||||
ghost_text = true
|
||||
}
|
||||
}
|
||||
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the four listed parsers should always be installed)
|
||||
ensure_installed = { "lua", "vim", "help" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = false,
|
||||
|
||||
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
highlight = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
|
||||
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
||||
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
||||
-- the name of the parser)
|
||||
-- list of language that will be disabled
|
||||
-- disable = { "c", "rust" },
|
||||
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
|
||||
require("yanky").setup({
|
||||
ring = {
|
||||
history_length = 100,
|
||||
storage = "shada",
|
||||
sync_with_numbered_registers = true,
|
||||
cancel_event = "update",
|
||||
},
|
||||
system_clipboard = {
|
||||
sync_with_ring = true,
|
||||
},
|
||||
preserve_cursor_position = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
|
||||
--
|
||||
require("telescope").load_extension("yank_history")
|
||||
2
nvim/obsessions/.gitignore
vendored
2
nvim/obsessions/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
178
nvim/plugins.lua
Normal file
178
nvim/plugins.lua
Normal file
@ -0,0 +1,178 @@
|
||||
vim.g.delimitMate_expand_space=1
|
||||
vim.g.delimitMate_expand_cr = 1
|
||||
|
||||
vim.g.tagbar_left=1
|
||||
vim.g.tagbar_autoclose=1
|
||||
vim.g.tagbar_autofocus=1
|
||||
|
||||
vim.g.windowswap_map_keys=0
|
||||
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
end,
|
||||
},
|
||||
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'cmp_yanky' },
|
||||
{ name = 'git' },
|
||||
-- }, {
|
||||
{ name = 'buffer', keyword_length = 2 },
|
||||
}),
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = "symbol_text",
|
||||
menu = ({
|
||||
buffer = "[buf]",
|
||||
nvim_lsp = "[lsp]",
|
||||
vsnip = "[snip]",
|
||||
nvim_lua = "[lua]",
|
||||
latex_symbols = "[tex]",
|
||||
path = "[path]",
|
||||
cmp_yanky = "[yank]",
|
||||
})
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
-- -- Set configuration for specific filetype.
|
||||
-- cmp.setup.filetype('gitcommit', {
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
-- }, {
|
||||
-- { name = 'buffer' },
|
||||
-- })
|
||||
-- })
|
||||
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false }
|
||||
})
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local lspconfig = require("lspconfig")
|
||||
lspconfig.gopls.setup({ capabilities = capabilities })
|
||||
lspconfig.svelte.setup({ capabilities = capabilities })
|
||||
lspconfig.pyright.setup({ capabilities = capabilities })
|
||||
lspconfig.omnisharp.setup({ capabilities = capabilities })
|
||||
lspconfig.clangd.setup({ capabilities = capabilities })
|
||||
lspconfig.dockerls.setup({ capabilities = capabilities })
|
||||
lspconfig.docker_compose_language_service.setup({ capabilities = capabilities })
|
||||
lspconfig.flow.setup({ capabilities = capabilities })
|
||||
lspconfig.marksman.setup({ capabilities = capabilities })
|
||||
lspconfig.als.setup({ capabilities = capabilities })
|
||||
lspconfig.sqls.setup({ capabilities = capabilities })
|
||||
lspconfig.yamlls.setup({ capabilities = capabilities })
|
||||
lspconfig.nil_ls.setup({ capabilities = capabilities })
|
||||
|
||||
require("yanky").setup({
|
||||
ring = {
|
||||
history_length = 100,
|
||||
storage = "shada",
|
||||
sync_with_numbered_registers = true,
|
||||
cancel_event = "update",
|
||||
},
|
||||
system_clipboard = {
|
||||
sync_with_ring = true,
|
||||
},
|
||||
preserve_cursor_position = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
|
||||
require("telescope").load_extension("yank_history")
|
||||
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- ensure_installed = { "lua", "vim", "help" },
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'Tomorrow',
|
||||
component_separators = { left = '', right = ''},
|
||||
section_separators = { left = '', right = ''},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
})
|
||||
2
nvim/plugins/.gitignore
vendored
2
nvim/plugins/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
nvim/pluginstuff/yankring/.gitignore
vendored
2
nvim/pluginstuff/yankring/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
1
nvim/pluginstuff/ycm/.gitignore
vendored
1
nvim/pluginstuff/ycm/.gitignore
vendored
@ -1 +0,0 @@
|
||||
*.pyc
|
||||
@ -1,117 +0,0 @@
|
||||
import os
|
||||
import ycm_core
|
||||
from clang_helpers import PrepareClangFlags
|
||||
|
||||
# These are the compilation flags that will be used in case there's no
|
||||
# compilation database set (by default, one is not set).
|
||||
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
|
||||
flags = [
|
||||
'-Wall',
|
||||
'-pendantic',
|
||||
'-std=c++11',
|
||||
'-x',
|
||||
'c++',
|
||||
'-I',
|
||||
'.',
|
||||
'-isystem',
|
||||
'/usr/include/',
|
||||
'-isystem',
|
||||
'/usr/local/include/',
|
||||
'-isystem',
|
||||
'/Library/Developer/CommandLineTools/usr/include',
|
||||
'-isystem',
|
||||
'/Library/Developer/CommandLineTools/usr/lib/c++/v1'
|
||||
]
|
||||
|
||||
compilation_database_folder = ''
|
||||
|
||||
if os.path.exists( compilation_database_folder ):
|
||||
database = ycm_core.CompilationDatabase( compilation_database_folder )
|
||||
else:
|
||||
database = None
|
||||
|
||||
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
|
||||
|
||||
def DirectoryOfThisScript():
|
||||
return os.path.dirname( os.path.abspath( __file__ ) )
|
||||
|
||||
|
||||
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
|
||||
if not working_directory:
|
||||
return list( flags )
|
||||
new_flags = []
|
||||
make_next_absolute = False
|
||||
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
|
||||
for flag in flags:
|
||||
new_flag = flag
|
||||
|
||||
if make_next_absolute:
|
||||
make_next_absolute = False
|
||||
if not flag.startswith( '/' ):
|
||||
new_flag = os.path.join( working_directory, flag )
|
||||
|
||||
for path_flag in path_flags:
|
||||
if flag == path_flag:
|
||||
make_next_absolute = True
|
||||
break
|
||||
|
||||
if flag.startswith( path_flag ):
|
||||
path = flag[ len( path_flag ): ]
|
||||
new_flag = path_flag + os.path.join( working_directory, path )
|
||||
break
|
||||
|
||||
if new_flag:
|
||||
new_flags.append( new_flag )
|
||||
return new_flags
|
||||
|
||||
|
||||
def IsHeaderFile( filename ):
|
||||
extension = os.path.splitext( filename )[ 1 ]
|
||||
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
|
||||
|
||||
|
||||
def GetCompilationInfoForFile( filename ):
|
||||
# The compilation_commands.json file generated by CMake does not have entries
|
||||
# for header files. So we do our best by asking the db for flags for a
|
||||
# corresponding source file, if any. If one exists, the flags for that file
|
||||
# should be good enough.
|
||||
if IsHeaderFile( filename ):
|
||||
basename = os.path.splitext( filename )[ 0 ]
|
||||
for extension in SOURCE_EXTENSIONS:
|
||||
replacement_file = basename + extension
|
||||
if os.path.exists( replacement_file ):
|
||||
compilation_info = database.GetCompilationInfoForFile(
|
||||
replacement_file )
|
||||
if compilation_info.compiler_flags_:
|
||||
return compilation_info
|
||||
return None
|
||||
return database.GetCompilationInfoForFile( filename )
|
||||
|
||||
|
||||
def FlagsForFile( filename, **kwargs ):
|
||||
if database:
|
||||
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
|
||||
# python list, but a "list-like" StringVec object
|
||||
compilation_info = GetCompilationInfoForFile( filename )
|
||||
if not compilation_info:
|
||||
return None
|
||||
|
||||
final_flags = MakeRelativePathsInFlagsAbsolute(
|
||||
compilation_info.compiler_flags_,
|
||||
compilation_info.compiler_working_dir_ )
|
||||
|
||||
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
|
||||
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
|
||||
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
|
||||
try:
|
||||
final_flags.remove( '-stdlib=libc++' )
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
relative_to = DirectoryOfThisScript()
|
||||
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
|
||||
|
||||
return {
|
||||
'flags': final_flags,
|
||||
'do_cache': True
|
||||
}
|
||||
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
resampling
|
||||
reweighted
|
||||
reweighting
|
||||
Kalman
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user