dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit 1804c19fb6c8c2f58f5fd01fcb883c051cd70bdf
parent c73432e02d05d1482a077ed0bddee42bcf532e76
Author: Paco Esteban <paco@onna.be>
Date:   Sat,  8 Dec 2018 19:05:38 +0100

going back to regular vim

Diffstat:
.gitignore | 4++++
vim/.vim/UltiSnips/all.snippets | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/arduino.snippets | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/c.snippets | 145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/go.snippets | 463+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/markdown.snippets | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/perl.snippets | 189+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/python.snippets | 714+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/r.snippets | 190+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/UltiSnips/rmd.snippets | 11+++++++++++
vim/.vim/UltiSnips/sh.snippets | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/after/ftplugin/c.vim | 17+++++++++++++++++
vim/.vim/after/ftplugin/go.vim | 3+++
vim/.vim/after/ftplugin/mail.vim | 12++++++++++++
vim/.vim/after/ftplugin/make.vim | 5+++++
vim/.vim/after/ftplugin/openscad.vim | 3+++
vim/.vim/after/ftplugin/perl.vim | 4++++
vim/.vim/after/ftplugin/python.vim | 7+++++++
vim/.vim/after/ftplugin/text.vim | 7+++++++
vim/.vim/after/ftplugin/yaml.vim | 3+++
vim/.vim/colors/lucius.vim | 799+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/ftdetect/mutt.vim | 1+
vim/.vim/ftplugin/cvs.vim | 5+++++
vim/.vim/ftplugin/tsv.vim | 5+++++
vim/.vim/pack/my_plugins/start/nearby/plugin/nearby.vim | 5+++++
vim/.vim/pack/my_plugins/start/vim-slackcat/plugin/vim-slackcat.vim | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/pythonx/vimsnippets.py | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vim/.vim/spell/en.utf-8.add | 15+++++++++++++++
vim/.vim/spell/en.utf-8.add.spl | 0
vim/.vim/templates/template.R | 4++++
vim/.vim/templates/template.c | 11+++++++++++
vim/.vim/templates/template.go | 8++++++++
vim/.vim/templates/template.pl | 8++++++++
vim/.vim/templates/template.py | 4++++
vim/.vim/templates/template.sh | 3+++
vim/.vim/vimrc | 193+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 files changed, 3387 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,7 @@ __pycache__ nvim/.config/nvim/pack/bundle/* +vim/.vim/pack/bundle/* +vim/.vim/cache/swap/* +vim/.vim/spell/*.utf-8.spl +vim/.vim/spell/*.utf-8.sug .netrwhist diff --git a/vim/.vim/UltiSnips/all.snippets b/vim/.vim/UltiSnips/all.snippets @@ -0,0 +1,128 @@ +# 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 +from vimsnippets import foldmarker, make_box, get_comment_format +endglobal + +snippet box "A nice box with the current comment symbol" b +`!p +box = make_box(len(t[1])) +snip.rv = box[0] +snip += box[1] +`${1:${VISUAL:content}}`!p +box = make_box(len(t[1])) +snip.rv = box[2] +snip += box[3]` +$0 +endsnippet + +snippet bbox "A nice box over the full width" b +`!p +if not snip.c: + width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71 +box = make_box(len(t[1]), width) +snip.rv = box[0] +snip += box[1] +`${1:${VISUAL:content}}`!p +box = make_box(len(t[1]), width) +snip.rv = box[2] +snip += 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 MODELINE GENERATOR # +########################## +# See advice on `:help 'tabstop'` for why these values are set. Uses second +# modeline form ('set') to work in languages with comment terminators +# (/* like C */). +snippet modeline "Vim modeline" +vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'` +endsnippet + +######### +# DATES # +######### +snippet date "YYYY-MM-DD" w +`!v strftime("%F")` +endsnippet + +snippet ddate "Month DD, YYYY" w +`!v strftime("%b %d, %Y")` +endsnippet + +snippet diso "ISO format datetime" w +`!v strftime("%F %H:%M:%S%z")` +endsnippet + +snippet time "hh:mm" w +`!v strftime("%H:%M")` +endsnippet + +snippet datetime "YYYY-MM-DD hh:mm" w +`!v strftime("%Y-%m-%d %H:%M")` +endsnippet + +snippet todo "TODO comment" bw +`!p snip.rv=get_comment_format()[0]` TODO: $1 <`!v strftime('%d-%m-%Y')`, `!v g:snips_author`> `!p snip.rv=get_comment_format()[2]` +$0 +endsnippet + +########################### +# some personal content # +########################### +snippet copy "shot copyright notice" b +`!p snip.rv=get_comment_format()[0]`Copyright © `!v strftime('%Y')` Paco Esteban <paco@onna.be> +`!p snip.rv=get_comment_format()[0]`Distributed under terms of the ISC license. +endsnippet + +snippet license "MIT License" b +Copyright (c) `!v strftime('%Y')` Paco Esteban <paco@onna.be> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +endsnippet + +# vim:ft=snippets: diff --git a/vim/.vim/UltiSnips/arduino.snippets b/vim/.vim/UltiSnips/arduino.snippets @@ -0,0 +1,85 @@ +priority -5 + +extends c + +snippet setup "Setup func" b +void setup() +{ + Serial.begin(${1:9600}); + ${0} +} +endsnippet + +snippet loop "Main loop func" b +void loop() +{ + ${0} +} +endsnippet + +## IO +# pinMode OUTPUT +snippet pinout "pinMode OUTPUT" b +pinMode(${1}, OUTPUT); +$0 +endsnippet +# pinMode INPUT +snippet pinin "pinMode INPUT" b +pinMode(${1}, INPUT); +$0 +endsnippet +# digitalWrite HIGH +snippet dwHigh "digitalWrite(x, HIGH)" +digitalWrite(${1}, HIGH); +$0 +endsnippet +# digitalWrite LOW +snippet dwLow "digitalWrite(x, HIGH)" +digitalWrite(${1}, LOW); +$0 +endsnippet +# digitalRead +snippet dr "digitalRead()" +digitalRead(${1}); +$0 +endsnippet +# analogRead +snippet ar "analogRead()" +analogRead(${1}); +$0 +endsnippet +# analogWrite +snippet aw "AnalogWrite(x)" +analogWrite(${1}); +$0 +endsnippet +# serialRead +snippet sr "Serial.read()" +Serial.read(); +$0 +endsnippet +# serialWrite +snippet sw "Serial.write(x)" +Serial.write(${1}); +$0 +endsnippet +# serial.print +snippet sp "Serial.print(x)" +Serial.print(${1}); +$0 +endsnippet +# serial.println +snippet sl "Serial.println(x)" +Serial.println(${1}); +$0 +endsnippet +# delay +snippet dl "delay()" +delay(${1}); +$0 +endsnippet +# millis +snippet ml "millis()" +millis(); +$0 +endsnippet diff --git a/vim/.vim/UltiSnips/c.snippets b/vim/.vim/UltiSnips/c.snippets @@ -0,0 +1,145 @@ +priority -10 + +snippet def "#define ..." b +#define $1 +endsnippet + +snippet inc "#include <f.h>" b +#include <${1}.h> +endsnippet + +snippet #ifndef "#ifndef ... #define ... #endif" b +#ifndef ${1/([A-Za-z0-9_]+).*/$1/} +#define ${1:SYMBOL} ${2:value} +#endif /* ifndef $1 */ +endsnippet + +snippet #if "#if #endif" b +#if ${1:0} +${VISUAL}$0 +#endif +endsnippet + +snippet mark "#pragma mark (mark)" +#if 0 +${1:#pragma mark - +}#pragma mark $2 +#endif + +$0 +endsnippet + +snippet main "main() (main)" b +int main(int argc, char *argv[]) +{ + ${VISUAL}$0 + return 0; +} +endsnippet + +snippet vmain "main(void)" b +int main(void) +{ + ${VISUAL}$0 + return 0; +} +endsnippet + +snippet for "for int loop (fori)" +for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { + ${VISUAL}$0 +} +endsnippet + +snippet switch "Switch case" b +switch (${1:/* variable */}) { + case ${2:/* variable case */}: + ${3} + ${4:break;} + default: + ${0} +} +endsnippet + +snippet case "case statement" +case ${1:/* variable case */}: + ${2} + ${3:break;} +${0} +endsnippet + +snippet wh "while loop" b +while (${1:/* condition */}) { + ${0} +} +endsnippet + +snippet do "do ... while loop" b +do { + ${0} +} while (${1:/* condition */}); +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 + +${VISUAL}$0 + +#endif /* end of include guard: $1 */ +endsnippet + +snippet fprintf "fprintf ..." +fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +# inline if +snippet ifi "Inline if" b +if (${1:/* condition */}) ${2}; +endsnippet + +snippet if "if () ..." b +if (${1:/* condition */}) { + ${VISUAL}$0 +} +endsnippet +snippet else "else {}" +else { + ${0} +} +endsnippet +snippet elif "else if .. (eli)" +else if (${1:/* condition */}) { + ${VISUAL}$0 +} +endsnippet + +snippet printf "printf .. (printf)" +printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet st "struct" b +struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { + ${0:/* data */} +}; +endsnippet + +snippet func "function" b +${1:void} ${2:function_name}($3) +{ + ${VISUAL}$0 +} +endsnippet + +snippet fund "function declaration" b +${1:void} ${2:function_name}($3); +endsnippet + +# vim:ft=snippets: diff --git a/vim/.vim/UltiSnips/go.snippets b/vim/.vim/UltiSnips/go.snippets @@ -0,0 +1,463 @@ +# Snippets for Go + +priority -10 + +# shorthand variable declaration +snippet : "v := value" +${1} := ${0} +endsnippet + +# anonymous function +snippet anon "fn := func() { ... }" +${1:fn} := func() { + ${2:${VISUAL}} +} +${0} +endsnippet + +# append +snippet ap "append(slice, value)" +append(${1:slice}, ${0:value}) +endsnippet + +# append assignment +snippet ap= "a = append(a, value)" +${1:slice} = append($1, ${0:value}) +endsnippet + +# break +snippet br "break" +break +endsnippet + +# channel +snippet ch "chan Type" +chan ${0:int} +endsnippet + +# case +snippet case "case ...:" +case ${1:value}: + ${0:${VISUAL}} +endsnippet + +# constant +snippet con "const XXX Type = ..." +const ${1:NAME} ${2:Type} = ${0:0} +endsnippet + +# constants +snippet cons "const ( ... )" +const ( + ${1:NAME} ${2:Type} = ${3:value} + ${0} +) +endsnippet + +# constants with iota +snippet iota "const ( ... = iota )" +const ( + ${1:NAME} ${2:Type} = iota + ${0} +) +endsnippet + +# continue +snippet cn "continue" +continue +endsnippet + +# default case +snippet default "default: ..." +default: + ${0:${VISUAL}} +endsnippet + +# defer +snippet df "defer someFunction()" +defer ${1:func}(${2}) +${0} +endsnippet + +snippet def "defer func() { ... }" +defer func() { + ${0:${VISUAL}} +}() +endsnippet + +# defer recover +snippet defr +defer func() { + if err := recover(); err != nil { + ${0:${VISUAL}} + } +}() +endsnippet + +# gpl +snippet gpl +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* Copyright (C) ${1:Author}, `!v strftime("%Y")` +*/ +${0} +endsnippet + +# import +snippet import "import ( ... )" +import ( + "${1:package}" +) +endsnippet + +# full interface snippet +snippet interface "interface I { ... }" +type ${1:Interface} interface { + ${2:/* TODO: add methods */} +} +endsnippet + +# if condition +snippet if "if ... { ... }" +if ${1:condition} { + ${0:${VISUAL}} +} +endsnippet + +# else snippet +snippet else +else { + ${0:${VISUAL}} +} +endsnippet + +# if inline error +snippet ife "If with inline erro" +if err := ${1:condition}; err != nil { + ${0:${VISUAL}} +} +endsnippet + +# error snippet +snippet errn "Error return " !b +if err != nil { + return err +} +${0} +endsnippet + +# error log snippet +snippet errl "Error with log.Fatal(err)" !b +if err != nil { + log.Fatal(err) +} +${0} +endsnippet + +# error multiple return +snippet errn, "Error return with two return values" !b +if err != nil { + return ${1:nil}, ${2:err} +} +${0} +endsnippet + +# error panic +snippet errp "Error panic" !b +if err != nil { + panic(${1}) +} +${0} +endsnippet + +# error test +snippet errt "Error test fatal " !b +if err != nil { + t.Fatal(err) +} +${0} +endsnippet + +# error handle +snippet errh "Error handle and return" !b +if err != nil { + ${1} + return +} +${0} +endsnippet + +# json field tag +snippet json "\`json:key\`" +\`json:"${1:`!v go#util#snippetcase(matchstr(getline("."), '\w\+'))`}"\` +endsnippet + +# yaml field tag +snippet yaml "\`yaml:key\`" +\`yaml:"${1:`!v go#util#snippetcase(matchstr(getline("."), '\w\+'))`}"\` +endsnippet + +# fallthrough +snippet ft "fallthrough" +fallthrough +endsnippet + +# for loop +snippet for "for ... { ... }" +for ${1} { + ${0:${VISUAL}} +} +endsnippet + +# for integer loop +snippet fori "for 0..N-1 { ... }" +for ${1:i} := 0; $1 < ${2:N}; $1++ { + ${0:${VISUAL}} +} +endsnippet + +# for range loop +snippet forr "for k, v := range items { ... }" +for ${2:k}, ${3:v} := range ${1} { + ${0:${VISUAL}} +} +endsnippet + +# function +snippet func "func Function(...) [error] { ... }" +func ${1:name}(${2:params})${3/(.+)/ /}`!p opening_par(snip, 3)`$3`!p closing_par(snip, 3)` { + ${0:${VISUAL}} +} +endsnippet + +# Fmt Printf debug +snippet ff "fmt.Printf(...)" +fmt.Printf("${1:${VISUAL}} = %+v\n", $1) +endsnippet + +# Fmt Println debug +snippet fn "fmt.Println(...)" +fmt.Println("${1:${VISUAL}}") +endsnippet + +# Fmt Errorf debug +snippet fe "fmt.Errorf(...)" +fmt.Errorf("${1:${VISUAL}}") +endsnippet + +# log printf +snippet lf "log.Printf(...)" +log.Printf("${1:${VISUAL}} = %+v\n", $1) +endsnippet + +# log println +snippet ln "log.Println(...)" +log.Println("${1:${VISUAL}}") +endsnippet + +# make +snippet make "make(Type, size)" +make(${1:[]string}, ${2:0})${0} +endsnippet + +# map +snippet map "map[Type]Type" +map[${1:string}]${0:int} +endsnippet + +# main() +snippet main "func main() { ... }" +func main() { + ${0:${VISUAL}} +} +endsnippet + +# method +snippet meth "func (self Type) Method(...) [error] { ... }" +func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}`!p opening_par(snip, 5)`$5`!p closing_par(snip, 5)` { + ${0:${VISUAL}} +} +endsnippet + +# ok +snippet ok "if !ok { ... }" +if !ok { + ${0:${VISUAL}} +} +endsnippet + +# package +snippet package "package ..." +// Package $1 provides ${2:...} +package ${1:main} +${0} +endsnippet + +# panic +snippet pn "panic()" +panic("${0:msg}") +endsnippet + +# return +snippet rt "return" +return ${0:${VISUAL}} +endsnippet + +# select +snippet select "select { case a := <-chan: ... }" +select { +case ${1:v1} := <-${2:chan1} + ${0} +} +endsnippet + +# struct +snippet st "type T struct { ... }" +type ${1:Type} struct { +${0} +} +endsnippet + +# switch +snippet switch "switch x { ... }" +switch ${1:var} { +case ${2:value1}: + ${0} +} +endsnippet + +# sprintf +snippet sp "fmt.Sprintf(...)" +fmt.Sprintf("%${1:s}", ${2:var}) +endsnippet + +# goroutine named function +snippet go "go someFunc(...)" +go ${1:funcName}(${0}) +endsnippet + +# goroutine anonymous function +snippet gof "go func() { ... }()" +go func() { + ${1:${VISUAL}} +}() +${0} +endsnippet + +# test function +snippet test "func TestXYZ(t *testing.T) { ... }" +func Test${1:Function}(t *testing.T) { + ${0:${VISUAL}} +} +endsnippet + +snippet hf "http.HandlerFunc" !b +func ${1:handler}(w http.ResponseWriter, r *http.Request) { + ${0:fmt.Fprintf(w, "hello world")} +} +endsnippet + +snippet hhf "mux.HandleFunc" !b +${1:http}.HandleFunc("${2:/}", func(w http.ResponseWriter, r *http.Request) { + ${0:fmt.Fprintf(w, "hello world")} +}) +endsnippet + +# quick test server +snippet tsrv "httptest.NewServer" +ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, ${1:`response`}) +})) +defer ts.Close() + +${0:someUrl} = ts.URL +endsnippet + +# test error handling +snippet ter "if err != nil { t.Errorf(...) }" +if err != nil { + t.Errorf("${0:message}") +} +endsnippet + +# test fatal error +snippet terf "if err != nil { t.Fatalf(...) }" +if err != nil { + t.Fatalf("${0:message}") +} +endsnippet + +snippet example "func ExampleXYZ() { ... }" +func Example${1:Method}() { + ${0:${VISUAL}} + // Output: +} +endsnippet + +snippet benchmark "func BenchmarkXYZ(b *testing.B) { ... }" +func Benchmark${1:Method}(b *testing.B) { + for i := 0; i < b.N; i++ { + ${0:${VISUAL}} + } +} +endsnippet + +# variable declaration +snippet var "var x Type [= ...]" +var ${1:x} ${2:Type}${3: = ${0:value}} +endsnippet + +# variables declaration +snippet vars "var ( ... )" +var ( + ${1:x} ${2:Type}${3: = ${0:value}} +) +endsnippet + +# equals fails the test if exp is not equal to act. +snippet eq "equals: test two identifiers with DeepEqual" +if !reflect.DeepEqual(${1:expected}, ${2:actual}) { + _, file, line, _ := runtime.Caller(0) + fmt.Printf("%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\n\n", filepath.Base(file), line, $1, $2) + t.FailNow() +} +endsnippet + +global !p + +import re + +# Automatically wrap return types with parentheses + +def return_values(s): + # remove everything wrapped in parentheses + s = re.sub("\(.*?\)|\([^)]*$", "", s) + return len(s.split(",")) + +def opening_par(snip, pos): + if return_values(t[pos]) > 1 and not t[pos].startswith("("): + snip.rv = "(" + else: + snip.rv = "" + +def closing_par(snip, pos): + if return_values(t[pos]) > 1: + snip.rv = ")" + else: + snip.rv = "" + +endglobal + +# vim:ft=snippets: diff --git a/vim/.vim/UltiSnips/markdown.snippets b/vim/.vim/UltiSnips/markdown.snippets @@ -0,0 +1,69 @@ +priority -10 + +########################### +# Sections and Paragraphs # +########################### +snippet sec "Section" b +# ${1:Section Name} +$0 +endsnippet + +snippet ssec "Sub Section" b +## ${1:Section Name} +$0 +endsnippet + +snippet sssec "SubSub Section" b +### ${1:Section Name} +$0 +endsnippet + +snippet par "Paragraph" b +#### ${1:Paragraph Name} +$0 +endsnippet + +snippet spar "Paragraph" b +##### ${1:Paragraph Name} +$0 +endsnippet + +################ +# Common stuff # +################ +snippet link "Link to something" +[${1:${VISUAL:Text}}](${2:https://www.url.com})$0 +endsnippet + +snippet img "Image" +![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0 +endsnippet + +snippet pre "Inline Code" i +\`$1\`$0 +endsnippet + +snippet code "Codeblock" b +\`\`\` +$1 +\`\`\` +$0 +endsnippet + +snippet refl "Reference Link" +[${1:${VISUAL:Text}}][${2:id}]$0 + +[$2]:${3:http://www.url.com} "${4:$3}" +endsnippet + +snippet fnt "Footnote" +[^${1:${VISUAL:Footnote}}]$0 + +[^$1]:${2:Text} +endsnippet + +pre_expand "create_table(snip)" +snippet "tb(\d+x\d+)" "Customizable table" br +endsnippet + +# vim:ft=snippets: diff --git a/vim/.vim/UltiSnips/perl.snippets b/vim/.vim/UltiSnips/perl.snippets @@ -0,0 +1,189 @@ +priority -10 + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet ife "Conditional if..else (ife)" +if ($1) { + ${2:# body...} +} +else { + ${3:# else...} +} + +endsnippet + +snippet ifee "Conditional if..elsif..else (ifee)" +if ($1) { + ${2:# body...} +} +elsif ($3) { + ${4:# elsif...} +} +else { + ${5:# else...} +} + +endsnippet + +snippet xunless "Conditional one-line (unless)" +${1:expression} unless ${2:condition}; + +endsnippet + +snippet xif "Conditional one-line (xif)" +${1:expression} if ${2:condition}; + +endsnippet + +snippet sub "Function (sub)" +sub ${1:function_name} { + ${2:# body...} +} + +endsnippet + +snippet xfore "Loop one-line (xforeach)" +${1:expression} foreach @${2:array}; + +endsnippet + +snippet xwhile "Loop one-line (xwhile)" +${1:expression} while ${2:condition}; + +endsnippet + +snippet test "Test" +#!/usr/bin/env perl -w + +use strict; +use Test::More tests => ${1:1}; +use ${2:ModuleName}; + +ok(${3:assertion}); + +endsnippet + +snippet class "class" +package ${1:ClassName}; + +${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new { + my $class = shift; + $class = ref $class if ref $class; + my $self = bless {}, $class; + $self; +} + +1; + +endsnippet + +snippet eval "eval" +local $@; +eval { + ${1:# do something risky...} +}; +if (my $${2:exception} = $@) { + ${3:# handle failure...} +} + +endsnippet + +snippet for "for" +for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) { + ${3:# body...} +} + +endsnippet + +snippet fore "foreach" +foreach ${1:my $${2:x}} (@${3:array}) { + ${4:# body...} +} + +endsnippet + +snippet if "if" +if ($1) { + ${2:# body...} +} + +endsnippet + +snippet slurp "slurp" +my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> }; + +endsnippet + +snippet unless "unless" +unless ($1) { + ${2:# body...} +} + +endsnippet + +snippet while "while" +while ($1) { + ${2:# body...} +} + +endsnippet + +snippet until "until" +until ($1) { + ${2:# body...} +} + +endsnippet + +snippet openr "Open file for reading" b +open(my $fh, '<:encoding(UTF-8)', $${1:filename}) + or die "Couldnot open file '$$1' $!"; + +while (my $row = <$fh>) { + chomp $row; + ${0} +} + +close $fh; +endsnippet + +snippet openw "Open file for writing" b +open(my $fh, '>:encoding(UTF-8)', $${1:filename}) + or die "Couldnot open file '$$1' $!"; +${0} +close $fh; +endsnippet + +snippet = "" i + => ${0} +endsnippet + +snippet - "" i +-> +endsnippet + +snippet , "" i +->{${0}} +endsnippet + +snippet task "Rex task definition" b +task ${1:task_name} => sub { + ${0} +}; +endsnippet + +snippet subs "Function (sub) with signatures" b +sub ${1:function_name} (${2:params}) { + ${3:# body...} +} + +endsnippet + +snippet sig "Signatures, still experimental ..." b +use feature 'signatures'; +no warnings qw(experimental::signatures); +${0} +endsnippet + +# vim:ft=snippets: diff --git a/vim/.vim/UltiSnips/python.snippets b/vim/.vim/UltiSnips/python.snippets @@ -0,0 +1,714 @@ +priority -10 + +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +#! header +snippet #! "Shebang header for python scripts" b +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +$0 +endsnippet + +snippet ifmain "ifmain" b +if __name__ == `!p snip.rv = get_quoting_style(snip)`__main__`!p snip.rv = get_quoting_style(snip)`: + ${1:${VISUAL:main()}} +endsnippet + +snippet with "with" b +with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}: + ${3:${VISUAL:pass}} +$0 +endsnippet + +snippet for "for loop" b +for ${1:item} in ${2:iterable}: + ${3:${VISUAL:pass}} +endsnippet + +########## +# COMMON # +########## + +# The smart def and smart class snippets use a global option called +# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen +# style comments in docstrings. + +global !p + +NORMAL = 0x1 +DOXYGEN = 0x2 +SPHINX = 0x3 +GOOGLE = 0x4 +NUMPY = 0x5 +JEDI = 0x6 + +SINGLE_QUOTES = "'" +DOUBLE_QUOTES = '"' + + +class Arg(object): + def __init__(self, arg): + self.arg = arg + self.name = arg.split('=')[0].strip() + + def __str__(self): + return self.name + + def __unicode__(self): + return self.name + + def is_kwarg(self): + return '=' in self.arg + + +def get_args(arglist): + args = [Arg(arg) for arg in arglist.split(',') if arg] + args = [arg for arg in args if arg.name != 'self'] + + return args + + +def get_quoting_style(snip): + style = snip.opt("g:ultisnips_python_quoting_style", "double") + if style == 'single': + return SINGLE_QUOTES + return DOUBLE_QUOTES + +def triple_quotes(snip): + style = snip.opt("g:ultisnips_python_triple_quoting_style") + if not style: + return get_quoting_style(snip) * 3 + return (SINGLE_QUOTES if style == 'single' else DOUBLE_QUOTES) * 3 + +def triple_quotes_handle_trailing(snip, quoting_style): + """ + Generate triple quoted strings and handle any trailing quote char, + which might be there from some autoclose/autopair plugin, + i.e. when expanding ``"|"``. + """ + if not snip.c: + # Do this only once, otherwise the following error would happen: + # RuntimeError: The snippets content did not converge: … + _, col = vim.current.window.cursor + line = vim.current.line + + # Handle already existing quote chars after the trigger. + _ret = quoting_style * 3 + while True: + try: + nextc = line[col] + except IndexError: + break + if nextc == quoting_style and len(_ret): + _ret = _ret[1:] + col = col+1 + else: + break + snip.rv = _ret + else: + snip.rv = snip.c + +def get_style(snip): + style = snip.opt("g:ultisnips_python_style", "normal") + + if style == "doxygen": return DOXYGEN + elif style == "sphinx": return SPHINX + elif style == "google": return GOOGLE + elif style == "numpy": return NUMPY + elif style == "jedi": return JEDI + else: return NORMAL + + +def format_arg(arg, style): + if style == DOXYGEN: + return "@param %s TODO" % arg + elif style == SPHINX: + return ":param %s: TODO" % arg + elif style == NORMAL: + return ":%s: TODO" % arg + elif style == GOOGLE: + return "%s (TODO): TODO" % arg + elif style == JEDI: + return ":type %s: TODO" % arg + elif style == NUMPY: + return "%s : TODO" % arg + + +def format_return(style): + if style == DOXYGEN: + return "@return: TODO" + elif style in (NORMAL, SPHINX, JEDI): + return ":returns: TODO" + elif style == GOOGLE: + return "Returns: TODO" + + +def write_docstring_args(args, snip): + if not args: + snip.rv += ' {0}'.format(triple_quotes(snip)) + return + + snip.rv += '\n' + snip.mkline('', indent='') + + style = get_style(snip) + + if style == GOOGLE: + write_google_docstring_args(args, snip) + elif style == NUMPY: + write_numpy_docstring_args(args, snip) + else: + for arg in args: + snip += format_arg(arg, style) + + +def write_google_docstring_args(args, snip): + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + snip += "Args:" + snip.shift() + for arg in args: + snip += format_arg(arg, GOOGLE) + snip.unshift() + snip.rv += '\n' + snip.mkline('', indent='') + + if kwargs: + snip += "Kwargs:" + snip.shift() + for kwarg in kwargs: + snip += format_arg(kwarg, GOOGLE) + snip.unshift() + snip.rv += '\n' + snip.mkline('', indent='') + + +def write_numpy_docstring_args(args, snip): + if args: + snip += "Parameters" + snip += "----------" + + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + for arg in args: + snip += format_arg(arg, NUMPY) + if kwargs: + for kwarg in kwargs: + snip += format_arg(kwarg, NUMPY) + ', optional' + snip.rv += '\n' + snip.mkline('', indent='') + + +def write_init_body(args, parents, snip): + parents = [p.strip() for p in parents.split(",")] + parents = [p for p in parents if p != 'object'] + + for p in parents: + snip += p + ".__init__(self)" + + if parents: + snip.rv += '\n' + snip.mkline('', indent='') + + for arg in args: + snip += "self._%s = %s" % (arg, arg) + + +def write_slots_args(args, snip): + quote = get_quoting_style(snip) + arg_format = quote + '_%s' + quote + args = [arg_format % arg for arg in args] + snip += '__slots__ = (%s,)' % ', '.join(args) + + +def write_function_docstring(t, snip): + """ + Writes a function docstring with the current style. + + :param t: The values of the placeholders + :param snip: UltiSnips.TextObjects.SnippetUtil object instance + """ + snip.rv = "" + snip >> 1 + + args = get_args(t[2]) + if args: + write_docstring_args(args, snip) + + style = get_style(snip) + + if style == NUMPY: + snip += 'Returns' + snip += '-------' + snip += 'TODO' + else: + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) + +def get_dir_and_file_name(snip): + return os.getcwd().split(os.sep)[-1] + '.' + snip.basename + +endglobal + +######################################## +# Class & Special Method Name Snippets # +######################################## + +snippet class "class with docstrings" b +class ${1:MyClass}(${2:object}): + + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` + + def __init__(self$4): + `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined1.}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += '{0}'.format(triple_quotes(snip)) + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet slotclass "class with slots and docstrings" b +class ${1:MyClass}(${2:object}): + + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` +`!p +snip >> 1 +args = get_args(t[4]) +write_slots_args(args, snip) +` + + def __init__(self$4): + `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet contain "methods for emulating a container type" b +def __len__(self): + ${1:pass} + +def __getitem__(self, key): + ${2:pass} + +def __setitem__(self, key, value): + ${3:pass} + +def __delitem__(self, key): + ${4:pass} + +def __iter__(self): + ${5:pass} + +def __reversed__(self): + ${6:pass} + +def __contains__(self, item): + ${7:pass} +endsnippet + + +snippet context "context manager methods" b +def __enter__(self): + ${1:pass} + +def __exit__(self, exc_type, exc_value, traceback): + ${2:pass} +endsnippet + + +snippet attr "methods for customizing attribute access" b +def __getattr__(self, name): + ${1:pass} + +def __setattr__(self, name, value): + ${2:pass} + +def __delattr__(self, name): + ${3:pass} +endsnippet + + +snippet desc "methods implementing descriptors" b +def __get__(self, instance, owner): + ${1:pass} + +def __set__(self, instance, value): + ${2:pass} + +def __delete__(self, instance): + ${3:pass} +endsnippet + + +snippet cmp "methods implementing rich comparison" +def __eq__(self, other): + ${1:pass} + +def __ne__(self, other): + ${2:pass} + +def __lt__(self, other): + ${3:pass} + +def __le__(self, other): + ${4:pass} + +def __gt__(self, other): + ${5:pass} + +def __ge__(self, other): + ${6:pass} + +def __cmp__(self, other): + ${7:pass} +endsnippet + + +snippet repr "methods implementing string representation" +def __repr__(self): + ${1:pass} + +def __str__(self): + ${2:pass} + +def __unicode__(self): + ${3:pass} +endsnippet + + +# note: reflected operands and augmented arithmeitc assignements have been +# intentionally ommited to reduce verbosity. +snippet numeric "methods for emulating a numeric type" b +def __add__(self, other): + ${1:pass} + +def __sub__(self, other): + ${2:pass} + +def __mul__(self, other): + ${3:pass} + +def __div__(self, other): + ${4:pass} + +def __truediv__(self, other): + ${5:pass} + +def __floordiv__(self, other): + ${6:pass} + + +def __mod__(self, other): + ${7:pass} + +def __divmod__(self, other): + ${8:pass} + +def __pow__(self, other): + ${9:pass} + + +def __lshift__(self, other): + ${10:pass} + +def __rshift__(self, other): + ${11:pass} + +def __and__(self, other): + ${12:pass} + +def __xor__(self, other): + ${13:pass} + +def __or__(self, other): + ${14:pass} + + +def __neg__(self): + ${15:pass} + +def __pos__(self): + ${16:pass} + +def __abs__(self): + ${17:pass} + +def __invert__(self): + ${18:pass} + + +def __complex__(self): + ${19:pass} + +def __int__(self): + ${20:pass} + +def __long__(self): + ${21:pass} + +def __float__(self): + ${22:pass} + + +def __oct__(self): + ${22:pass} + +def __hex__(self): + ${23:pass} + + +def __index__(self): + ${24:pass} + +def __coerce__(self, other): + ${25:pass} +endsnippet + +snippet deff +def ${1:fname}(`!p snip.rv = vim.eval('indent(".") ? "self" : ""')`$2): + $0 +endsnippet + +snippet def "function with docstrings" b +def ${1:function}(`!p +if snip.indent: + snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +snippet defc "class method with docstrings" b +@classmethod +def ${1:function}(`!p +if snip.indent: + snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +snippet defs "static method with docstrings" b +@staticmethod +def ${1:function}(${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +# doesn't expand when there is a word in front +snippet /(^|(?<=\W))\./ "self." r +self. +endsnippet + +snippet from "from module import name" b +from ${1:module} import ${2:Stuff} +endsnippet + + +############## +# PROPERTIES # +############## +snippet roprop "Read Only Property" b +@property +def ${1:name}(self): + ${2:return self._$1}$0 +endsnippet + +snippet rwprop "Read write property" b +def ${1:name}(): + `!p snip.rv = triple_quotes(snip) if t[2] else '' +`${2:TODO: Docstring for $1.}`!p +if t[2]: + snip >> 1 + + style = get_style(snip) + snip.rv += '\n' + snip.mkline('', indent='') + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) +else: + snip.rv = ""` + def fget(self): + return self._$1$0 + + def fset(self, value): + self._$1 = value + return locals() + +$1 = property(**$1(), doc=$1.__doc__) +endsnippet + + +#################### +# If / Else / Elif # +#################### +snippet if "If" b +if ${1:condition}: + ${2:${VISUAL:pass}} +endsnippet + +snippet ife "If / Else" b +if ${1:condition}: + ${2:${VISUAL:pass}} +else: + ${3:pass} +endsnippet + +snippet ifee "If / Elif / Else" b +if ${1:condition}: + ${2:${VISUAL:pass}} +elif ${3:condition}: + ${4:pass} +else: + ${5:pass} +endsnippet + + +########################## +# Try / Except / Finally # +########################## +snippet try "Try / Except" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +endsnippet + +snippet trye "Try / Except / Else" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +else: + ${5:pass} +endsnippet + +snippet tryf "Try / Except / Finally" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +finally: + ${5:pass} +endsnippet + +snippet tryef "Try / Except / Else / Finally" b +try: + ${1:${VISUAL:pass}} +except${2: ${3:Exception} as ${4:e}}: + ${5:raise} +else: + ${6:pass} +finally: + ${7:pass} +endsnippet + + +###################### +# Assertions & Tests # +###################### + +snippet ae "Assert equal" b +self.assertEqual(${1:${VISUAL:first}},${2:second}) +endsnippet + +snippet at "Assert True" b +self.assertTrue(${1:${VISUAL:expression}}) +endsnippet + +snippet af "Assert False" b +self.assertFalse(${1:${VISUAL:expression}}) +endsnippet + +snippet aae "Assert almost equal" b +self.assertAlmostEqual(${1:${VISUAL:first}},${2:second}) +endsnippet + +snippet ar "Assert raises" b +self.assertRaises(${1:exception}, ${2:${VISUAL:func}}${3/.+/, /}${3:arguments}) +endsnippet + +snippet an "Assert is None" b +self.assertIsNone(${1:${VISUAL:expression}}) +endsnippet + +snippet ann "Assert is not None" b +self.assertIsNotNone(${1:${VISUAL:expression}}) +endsnippet + +snippet testcase "pyunit testcase" b +class Test${1:Class}(${2:unittest.TestCase}): + + `!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)` + + def setUp(self): + ${4:pass} + + def tearDown(self): + ${5:pass} + + def test_${6:name}(self): + ${7:${VISUAL:pass}} +endsnippet + +snippet " "triple quoted string (double quotes)" b +""" +${1:${VISUAL:doc}} +`!p triple_quotes_handle_trailing(snip, '"')` +endsnippet + +snippet ' "triple quoted string (single quotes)" b +''' +${1:${VISUAL:doc}} +`!p triple_quotes_handle_trailing(snip, "'")` +endsnippet + +snippet doc "doc block (triple quotes)" +`!p snip.rv = triple_quotes(snip)` +${1:${VISUAL:doc}} +`!p snip.rv = triple_quotes(snip)` +endsnippet + +snippet pmdoc "pocoo style module doc string" b +# -*- coding: utf-8 -*- +""" + `!p snip.rv = get_dir_and_file_name(snip)` + `!p snip.rv = '~' * len(get_dir_and_file_name(snip))` + + ${1:DESCRIPTION} + + :copyright: (c) `date +%Y` by ${2:YOUR_NAME}. + :license: ${3:LICENSE_NAME}, see LICENSE for more details. +""" +$0 +endsnippet + +# vim:ft=snippets: diff --git a/vim/.vim/UltiSnips/r.snippets b/vim/.vim/UltiSnips/r.snippets @@ -0,0 +1,190 @@ +priority -20 + +global !p +import os +from vimsnippets import complete + +FIELD_TYPES = [ +'character', +'data.frame', +'integer', +'list', +'logical', +'matrix', +'numeric', +'vector'] +endglobal + +snippet #! "Hashbang for Rscript (#!)" b +#!/usr/bin/env Rscript +endsnippet + +snippet setwd "Set workingdir" b +setwd("${1:`!p snip.rv = os.getcwd()`}") +endsnippet + +snippet as "Apply type on variable" w +as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`($2${VISUAL}) +endsnippet + +snippet is "Test type on variable" w +is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`($2${VISUAL}) +endsnippet + +snippet dl "Download and install a package" b +download.file("${1:${VISUAL:url to package}}", destfile = "${2:${1/.*\/(\S*)$/(?1:$1)/ga}}") +install.packages("$2", type = "source", repos = NULL) +library("${3:${2/^(\w+)_.*$/(?1:$1)/ga}}") +endsnippet + +snippet lib "Import a library" +library('${0:${VISUAL:package}}') +endsnippet + +snippet req "Require a file" +require('${0:${VISUAL:package}}') +endsnippet + +snippet source "Source a file" +source('${0:${VISUAL:file}}') +endsnippet + +snippet if "If statement" +if ($1) { + ${0:${VISUAL}} +} +endsnippet + +snippet eif "Else-If statement" +else if ($1) { + ${0:${VISUAL}} +} +endsnippet + +snippet el "Else statement" +else { + ${0:${VISUAL}} +} +endsnippet + +snippet ife "if .. else" +if ($1) { + ${2:${VISUAL}} +} else { + $0 +} +endsnippet + +snippet wh "while loop" +while($1) { + ${0:${VISUAL}} +} +endsnippet + +snippet for "for loop" +for (${1:item} in ${2:list}) { + ${0:${VISUAL}} +} +endsnippet + +snippet fun "Function definition" +${1:name} <- function ($2) { + ${0:${VISUAL}} +} +endsnippet + +snippet ret "Return call" +return(${0:${VISUAL}}) +endsnippet + +snippet df "Data frame" +${1:name}[${2:rows}, ${0:cols}] +endsnippet + +snippet c "c function" +c(${0:${VISUAL:items}}) +endsnippet + +snippet li "list function" +list(${0:${VISUAL:items}}) +endsnippet + +snippet mat "matrix function" +matrix(${1:${VISUAL:data}}, nrow = ${2:rows}, ncol = ${0:cols}) +endsnippet + +snippet apply "apply function" +apply(${1:${VISUAL:array}}, ${2:margin}, ${0:function}) +endsnippet + +snippet lapply "lapply function" +lapply(${1:${VISUAL:list}}, ${0:function}) +endsnippet + +snippet sapply "sapply function" +sapply(${1:${VISUAL:list}}, ${0:function}) +endsnippet + +snippet vapply "vapply function" +vapply(${1:${VISUAL:list}}, ${2:function}, ${0:type}) +endsnippet + +snippet mapply "mapply function" +mapply(${1:${VISUAL:function}}, ${0:...}) +endsnippet + +snippet tapply "tapply function" +tapply(${1:${VISUAL:vector}}, ${2:index}, ${0:function}) +endsnippet + +snippet rapply "rapply function" +rapply(${1:${VISUAL:list}}, ${0:function}) +endsnippet + +snippet pl "Plot function" +plot(${1:${VISUAL:x}}, ${0:y}) +endsnippet + +snippet ggp "ggplot2 plot" +ggplot(${1:${VISUAL:data}}, aes(${0:aesthetics})) +endsnippet + +snippet fis "Fisher test" +fisher.test(${1:x}, ${0:y}) +endsnippet + +snippet chi "Chi Squared test" +chisq.test(${1:x}, ${0:y}) +endsnippet + +snippet tt "t-test" +t.test(${1:x}, ${0:y}) +endsnippet + +snippet wil "Wilcox test" +wilcox.test(${1:x}, ${0:y}) +endsnippet + +snippet cor "Correlation test" +cor.test(${1:x}, ${0:y}) +endsnippet + +snippet fte "FTE test" +var.test(${1:x}, ${0:y}) +endsnippet + +snippet kvt "KV test" +kv.test(${1:x}, ${0:y}) +endsnippet + +################################# +# easily create string vector # +################################# +# Given individual words separated by spaces +# Select words (e.g. shift-v for whole line (such as the line above) +# then press <Tab> then type "vec", press <Tab> again to get this: +# var <- c("#","Given","individual","words","separated","by","spaces") +# var <- c("#","type","out","individual","words","separated","by","spaces") +snippet vec +${1:var} <- c("${0:${VISUAL:/ /","/g}}") +endsnippet diff --git a/vim/.vim/UltiSnips/rmd.snippets b/vim/.vim/UltiSnips/rmd.snippets @@ -0,0 +1,11 @@ +extends markdown + +## diferent codeblocks I usually use. +snippet "(bash|perl|python|go|c)" "Language code block" br +\`\`\`{r, engine = '${1:`!p +snip.rv = match.group(1) + `}', eval = ${2:FALSE}} +${3:${VISUAL}} +\`\`\` +$0 +endsnippet diff --git a/vim/.vim/UltiSnips/sh.snippets b/vim/.vim/UltiSnips/sh.snippets @@ -0,0 +1,109 @@ +priority -10 + +snippet #! +#!/bin/sh +endsnippet + +snippet bash "safe bash options" +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +`!p snip.rv ='\n\n' ` +endsnippet + +snippet tmpfile "Tempfile" +${1:TMPFILE}="$(mktemp -t ${2:`!p +snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" +`}.XXXXXX)" +${3:trap "rm `!p snip.rv = t[1]`" EXIT} +$0 +endsnippet + +snippet tmpdir "Tempdir" +${1:TMPDIR}="$(mktemp -d -t ${2:`!p +snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" +`}.XXXXXX)" +${3:trap "rm -rf `!p snip.rv = t[1]`" EXIT} +$0 +endsnippet + +snippet case "case .. esac (case)" +case ${1:word} in + ${2:pattern} ) + $0;; +esac +endsnippet + +snippet func "Function ()" +${1:function}() { + ${0:#statements} +} +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 fori "for ... in ... done (fori)" +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 + +snippet bashif "bash if ... then (if)" +if ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +fi +endsnippet + +snippet bashuntil "bash until ... (done)" +until ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +snippet bashwhile "bash while ... (done)" +while ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +snippet cleanup "bash exit trap" +cleanup() { + ${0:#cleanup logic ...} +} +trap cleanup EXIT INT QUIT TERM +endsnippet + +# vim:ft=snippets: diff --git a/vim/.vim/after/ftplugin/c.vim b/vim/.vim/after/ftplugin/c.vim @@ -0,0 +1,17 @@ +" (astyle) +nnoremap <silent> <Leader>t :mark t <bar> execute'%!astyle' <bar> execute 'normal! `t' <bar> delmarks t<CR> +vnoremap <buffer> <Leader>t :!astyle<CR> + +setlocal colorcolumn=80 + +" Include macros in completion +setlocal complete+=d + +" Set include pattern +setlocal include=^\\s*#\\s*include + +" Include headers on UNIX +if has('unix') + setlocal path+=/usr/include + setlocal path+=/usr/local/include +endif diff --git a/vim/.vim/after/ftplugin/go.vim b/vim/.vim/after/ftplugin/go.vim @@ -0,0 +1,3 @@ +setlocal noexpandtab +nnoremap <silent> <Leader>t :mark t <bar> execute'%!gofmt' <bar> execute 'normal! `t' <bar> delmarks t<CR> +vnoremap <silent> <Leader>t :!gofmt<CR> diff --git a/vim/.vim/after/ftplugin/mail.vim b/vim/.vim/after/ftplugin/mail.vim @@ -0,0 +1,12 @@ +setlocal syntax=mail +setlocal tw=72 +setlocal wrap +setlocal lbr +setlocal formatprg=fmt\ -72 +" default spell +setlocal spell +setlocal spelllang=en_gb +" and some optionals +nmap <leader>ca :setlocal spelllang=ca_es<CR> +nmap <leader>es :setlocal spelllang=es_es<CR> +nmap <leader>en :setlocal spelllang=en_gb<CR> diff --git a/vim/.vim/after/ftplugin/make.vim b/vim/.vim/after/ftplugin/make.vim @@ -0,0 +1,5 @@ +setlocal tabstop=8 +setlocal softtabstop=8 +setlocal shiftwidth=8 +setlocal noexpandtab +setlocal colorcolumn=80 diff --git a/vim/.vim/after/ftplugin/openscad.vim b/vim/.vim/after/ftplugin/openscad.vim @@ -0,0 +1,3 @@ +setlocal tabstop=2 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/vim/.vim/after/ftplugin/perl.vim b/vim/.vim/after/ftplugin/perl.vim @@ -0,0 +1,4 @@ +" perltidy +nnoremap <silent> <Leader>t :mark t <bar> execute'%!perltidy' <bar> execute 'normal! `t' <bar> delmarks t<CR> +vnoremap <silent> <Leader>t :!perltidy<CR> +setlocal colorcolumn=80 diff --git a/vim/.vim/after/ftplugin/python.vim b/vim/.vim/after/ftplugin/python.vim @@ -0,0 +1,7 @@ +" and for python +nnoremap <silent> <Leader>i :!isort %<CR><CR> +nnoremap <silent> <Leader>t :mark t <bar> execute'%!yapf' <bar> execute 'normal! `t' <bar> delmarks t<CR> +vnoremap <silent> <Leader>t :!yapf<CR> +setlocal textwidth=79 +setlocal shiftround +setlocal colorcolumn=80 diff --git a/vim/.vim/after/ftplugin/text.vim b/vim/.vim/after/ftplugin/text.vim @@ -0,0 +1,7 @@ +setlocal textwidth=72 +setlocal wrap +setlocal linebreak +setlocal formatprg=fmt\ -72 +setlocal colorcolumn=73 +setlocal spell +setlocal spelllang=en_gb diff --git a/vim/.vim/after/ftplugin/yaml.vim b/vim/.vim/after/ftplugin/yaml.vim @@ -0,0 +1,3 @@ +setlocal tabstop=2 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/vim/.vim/colors/lucius.vim b/vim/.vim/colors/lucius.vim @@ -0,0 +1,799 @@ +" ============================================================================ +" Name: Lucius vim color scheme +" Author: Jonathan Filip <jfilip1024@gmail.com> +" Version: 8.1.7 +" ---------------------------------------------------------------------------- +" +" Light and dark color scheme for GUI and 256 color terminal. +" +" There are several options available to customize the color scheme to your +" own tastes. This is particularly useful when you have to work in different +" environments at different times (home, work, day, night, etc). +" +" The GUI and 256 color terminal versions of this color scheme are identical. +" +" You can set up the color scheme by manually setting the options you want or +" by choosing one of the presets defined. These presets are loaded after you +" first source the color scheme file and are all commands that start with +" 'Lucius'. +" +" I have also started to create color schemes for different applications. I +" have been using them for PuTTY, iTerm2, and Visual Studio, but will keep +" adding more as I go along. You can find the files for these on Github: +" +" https://github.com/jonathanfilip/lucius +" +" You can also clone the following repository if you use Pathogen or something +" similar. It holds the vim color scheme in a 'colors' directory: +" +" https://github.com/jonathanfilip/vim-lucius +" +" +" +" Presets: +" +" There are several presets available that will set all the options for you. +" There are screenshots of each preset below: +" +" * LuciusDark (dark default): http://i.imgur.com/LsZbF.png +" * LuciusDarkHighContrast: http://i.imgur.com/e70i9.png +" * LuciusDarkLowContrast: http://i.imgur.com/Hmw8s.png +" * LuciusBlack: http://i.imgur.com/iD4ri.png +" * LuciusBlackHighContrast: http://i.imgur.com/lHvTJ.png +" * LuciusBlackLowContrast: http://i.imgur.com/oZLkg.png +" +" * LuciusLight (light default): http://i.imgur.com/soYD8.png +" * LuciusLightLowContrast: http://i.imgur.com/95I86.png +" * LuciusWhite: http://i.imgur.com/wDzkz.png +" * LuciusWhiteLowContrast: http://i.imgur.com/jlUf4.png +" +" To use the presets, you just need to set the color scheme first. In your +" vimrc, you can just do this: +" +" colorscheme lucius +" LuciusBlack +" +" You can still just set the background variable and then set the color +" scheme. This will default to LuciusDark for 'dark' and LuciusLight for +" 'light'. +" +" +" Options: +" +" The presets available cover most of the options. You can, however, customize +" things by setting the following variables yourself: +" +" g:lucius_style (default: 'dark') +" +" Set this option to either 'light' or 'dark' for your desired color scheme. +" It has the same effect as setting the background. +" +" g:lucius_contrast (default: 'normal') +" +" This option determines the contrast to use for text/ui elements. It can be +" set to 'low', 'normal', or 'high'. At this time there is no 'high' for the +" light scheme. +" +" g:lucius_contrast_bg (default: 'normal') +" +" Setting this option makes the background a higher contrast. Current settings +" are 'normal' and 'high'. +" +" g:lucius_use_bold (default: 1) +" +" Setting this will cause the color scheme to use bold fonts for some items. +" +" g:lucius_use_underline (default: 1) +" +" Setting this will cause the color scheme to use underlined fonts for some +" items. +" +" g:lucius_no_term_bg (default: 0) +" +" Setting this will cause the color scheme to not set a background color in +" the terminal (useful for transparency or terminals with different background +" colors). +" +" License: +" +" Copyright (c) 2015 Jonathan Filip +" +" Permission is hereby granted, free of charge, to any person obtaining a copy +" of this software and associated documentation files (the "Software"), to deal +" in the Software without restriction, including without limitation the rights +" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +" copies of the Software, and to permit persons to whom the Software is +" furnished to do so, subject to the following conditions: +" +" The above copyright notice and this permission notice shall be included in +" all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +" THE SOFTWARE. +" +" ============================================================================ + + + +" ============================================================================ +" Options: +" ============================================================================ + +unlet! g:colors_name +hi clear +if exists("syntax_on") + syntax reset +endif + +if exists("g:lucius_style") + let s:style = g:lucius_style +else + let s:style = &background +endif + +if exists("g:lucius_contrast") + let s:contrast = g:lucius_contrast +else + let s:contrast = "normal" +endif + +if exists("g:lucius_contrast_bg") + let s:contrast_bg = g:lucius_contrast_bg +else + let s:contrast_bg = "normal" +endif + +if exists("g:lucius_use_bold") + let s:use_bold = g:lucius_use_bold +else + let s:use_bold = 1 +endif + +if exists("g:lucius_use_underline") + let s:use_underline = g:lucius_use_underline +else + let s:use_underline = 1 +endif + +if exists("g:lucius_no_term_bg") + let s:no_term_bg = g:lucius_no_term_bg +else + let s:no_term_bg = 0 +endif + + +" ============================================================================ +" Color Map: +" ============================================================================ + +let s:color_map = { + \ 'bg': 'bg', 'fg': 'fg', 'NONE': 'NONE', + \ '#000000': '16', '#00005f': '17', '#000087': '18', '#0000af': '19', + \ '#0000d7': '20', '#0000ff': '21', '#005f00': '22', '#005f5f': '23', + \ '#005f87': '24', '#005faf': '25', '#005fd7': '26', '#005fff': '27', + \ '#008700': '28', '#00875f': '29', '#008787': '30', '#0087af': '31', + \ '#0087d7': '32', '#0087ff': '33', '#00af00': '34', '#00af5f': '35', + \ '#00af87': '36', '#00afaf': '37', '#00afd7': '38', '#00afff': '39', + \ '#00d700': '40', '#00d75f': '41', '#00d787': '42', '#00d7af': '43', + \ '#00d7d7': '44', '#00d7ff': '45', '#00ff00': '46', '#00ff5f': '47', + \ '#00ff87': '48', '#00ffaf': '49', '#00ffd7': '50', '#00ffff': '51', + \ '#5f0000': '52', '#5f005f': '53', '#5f0087': '54', '#5f00af': '55', + \ '#5f00d7': '56', '#5f00ff': '57', '#5f5f00': '58', '#5f5f5f': '59', + \ '#5f5f87': '60', '#5f5faf': '61', '#5f5fd7': '62', '#5f5fff': '63', + \ '#5f8700': '64', '#5f875f': '65', '#5f8787': '66', '#5f87af': '67', + \ '#5f87d7': '68', '#5f87ff': '69', '#5faf00': '70', '#5faf5f': '71', + \ '#5faf87': '72', '#5fafaf': '73', '#5fafd7': '74', '#5fafff': '75', + \ '#5fd700': '76', '#5fd75f': '77', '#5fd787': '78', '#5fd7af': '79', + \ '#5fd7d7': '80', '#5fd7ff': '81', '#5fff00': '82', '#5fff5f': '83', + \ '#5fff87': '84', '#5fffaf': '85', '#5fffd7': '86', '#5fffff': '87', + \ '#870000': '88', '#87005f': '89', '#870087': '90', '#8700af': '91', + \ '#8700d7': '92', '#8700ff': '93', '#875f00': '94', '#875f5f': '95', + \ '#875f87': '96', '#875faf': '97', '#875fd7': '98', '#875fff': '99', + \ '#878700': '100', '#87875f': '101', '#878787': '102', '#8787af': '103', + \ '#8787d7': '104', '#8787ff': '105', '#87af00': '106', '#87af5f': '107', + \ '#87af87': '108', '#87afaf': '109', '#87afd7': '110', '#87afff': '111', + \ '#87d700': '112', '#87d75f': '113', '#87d787': '114', '#87d7af': '115', + \ '#87d7d7': '116', '#87d7ff': '117', '#87ff00': '118', '#87ff5f': '119', + \ '#87ff87': '120', '#87ffaf': '121', '#87ffd7': '122', '#87ffff': '123', + \ '#af0000': '124', '#af005f': '125', '#af0087': '126', '#af00af': '127', + \ '#af00d7': '128', '#af00ff': '129', '#af5f00': '130', '#af5f5f': '131', + \ '#af5f87': '132', '#af5faf': '133', '#af5fd7': '134', '#af5fff': '135', + \ '#af8700': '136', '#af875f': '137', '#af8787': '138', '#af87af': '139', + \ '#af87d7': '140', '#af87ff': '141', '#afaf00': '142', '#afaf5f': '143', + \ '#afaf87': '144', '#afafaf': '145', '#afafd7': '146', '#afafff': '147', + \ '#afd700': '148', '#afd75f': '149', '#afd787': '150', '#afd7af': '151', + \ '#afd7d7': '152', '#afd7ff': '153', '#afff00': '154', '#afff5f': '155', + \ '#afff87': '156', '#afffaf': '157', '#afffd7': '158', '#afffff': '159', + \ '#d70000': '160', '#d7005f': '161', '#d70087': '162', '#d700af': '163', + \ '#d700d7': '164', '#d700ff': '165', '#d75f00': '166', '#d75f5f': '167', + \ '#d75f87': '168', '#d75faf': '169', '#d75fd7': '170', '#d75fff': '171', + \ '#d78700': '172', '#d7875f': '173', '#d78787': '174', '#d787af': '175', + \ '#d787d7': '176', '#d787ff': '177', '#d7af00': '178', '#d7af5f': '179', + \ '#d7af87': '180', '#d7afaf': '181', '#d7afd7': '182', '#d7afff': '183', + \ '#d7d700': '184', '#d7d75f': '185', '#d7d787': '186', '#d7d7af': '187', + \ '#d7d7d7': '188', '#d7d7ff': '189', '#d7ff00': '190', '#d7ff5f': '191', + \ '#d7ff87': '192', '#d7ffaf': '193', '#d7ffd7': '194', '#d7ffff': '195', + \ '#ff0000': '196', '#ff005f': '197', '#ff0087': '198', '#ff00af': '199', + \ '#ff00d7': '200', '#ff00ff': '201', '#ff5f00': '202', '#ff5f5f': '203', + \ '#ff5f87': '204', '#ff5faf': '205', '#ff5fd7': '206', '#ff5fff': '207', + \ '#ff8700': '208', '#ff875f': '209', '#ff8787': '210', '#ff87af': '211', + \ '#ff87d7': '212', '#ff87ff': '213', '#ffaf00': '214', '#ffaf5f': '215', + \ '#ffaf87': '216', '#ffafaf': '217', '#ffafd7': '218', '#ffafff': '219', + \ '#ffd700': '220', '#ffd75f': '221', '#ffd787': '222', '#ffd7af': '223', + \ '#ffd7d7': '224', '#ffd7ff': '225', '#ffff00': '226', '#ffff5f': '227', + \ '#ffff87': '228', '#ffffaf': '229', '#ffffd7': '230', '#ffffff': '231', + \ '#080808': '232', '#121212': '233', '#1c1c1c': '234', '#262626': '235', + \ '#303030': '236', '#3a3a3a': '237', '#444444': '238', '#4e4e4e': '239', + \ '#585858': '240', '#626262': '241', '#6c6c6c': '242', '#767676': '243', + \ '#808080': '244', '#8a8a8a': '245', '#949494': '246', '#9e9e9e': '247', + \ '#a8a8a8': '248', '#b2b2b2': '249', '#bcbcbc': '250', '#c6c6c6': '251', + \ '#d0d0d0': '252', '#dadada': '253', '#e4e4e4': '254', '#eeeeee': '255', + \ } + + +" ============================================================================ +" Functions: +" ============================================================================ + +function! s:AddCterm(name) + exec "let l:gfg = synIDattr(synIDtrans(hlID('" . a:name . + \ "')), 'fg', 'gui')" + exec "let l:gbg = synIDattr(synIDtrans(hlID('" . a:name . + \ "')), 'bg', 'gui')" + let l:gfg = l:gfg == "" ? "NONE" : l:gfg + let l:gbg = l:gbg == "" ? "NONE" : l:gbg + exec "hi " . a:name . " ctermfg=" . s:color_map[l:gfg] . + \ " ctermbg=" . s:color_map[l:gbg] +endfunction + +function! s:AddSpCterm(name) + exec "let l:gsp = synIDattr(synIDtrans(hlID('" . a:name . + \ "')), 'sp', 'gui')" + let l:gsp = l:gsp == "" ? "NONE" : l:gsp + exec "hi " . a:name . " ctermfg=" . s:color_map[l:gsp] +endfunction + + +" ============================================================================ +" Text Groups: +" ============================================================================ + +let s:normal_items = [ + \ "ColorColumn", "Comment", "Conceal", "Constant", "Cursor", "CursorColumn", + \ "CursorIM", "CursorLine", "CursorLineNr", "DiffAdd", "DiffChange", + \ "DiffDelete", "Directory", "Error", "ErrorMsg", "Identifier", + \ "IncSearch", "LineNr", "MatchParen", "ModeMsg", "MoreMsg", + \ "NonText", "Pmenu", "PmenuSbar", "PmenuSel", + \ "PmenuThumb", "PreProc", "Question", "Search", "SignColumn", + \ "Special", "SpecialKey", "Statement", "StatusLineNC", "TabLine", + \ "TabLineFill", "Todo", "Type", "VertSplit", "Visual", + \ "WarningMsg", "WildMenu", + \ ] + +let s:bold_items = [ + \ "DiffText", "FoldColumn", "Folded", "StatusLine", "TabLineSel", + \ "Title", "CursorLineNr", + \ ] + +let s:underline_items = [ + \ "Underlined", "VisualNOS" + \ ] + +let s:undercurl_items = [ + \ "SpellBad", "SpellCap", "SpellLocal", "SpellRare" + \ ] + + +" ============================================================================ +" Color Definitions: +" ============================================================================ + +" ---------------------------------------------------------------------------- +" 'Normal' Colors: +" ---------------------------------------------------------------------------- + +hi clear Normal +hi Normal gui=none cterm=none term=none + +if s:style == "light" + if s:contrast == "high" + hi Normal guifg=#000000 + elseif s:contrast == "low" + hi Normal guifg=#626262 + else + hi Normal guifg=#444444 + endif +else + if s:contrast == "high" + hi Normal guifg=#eeeeee + elseif s:contrast == "low" + hi Normal guifg=#bcbcbc + else + hi Normal guifg=#d7d7d7 + endif +endif + +if s:style == "light" + if s:contrast_bg == "high" + hi Normal guibg=#ffffff + else + hi Normal guibg=#eeeeee + endif +else + if s:contrast_bg == "high" + hi Normal guibg=#121212 + else + hi Normal guibg=#303030 + endif +endif + +call s:AddCterm("Normal") + + +" ---------------------------------------------------------------------------- +" Extra setup +" ---------------------------------------------------------------------------- + +exec "set background=" . s:style + +" Clear default settings +for s:item in s:normal_items + s:bold_items + s:underline_items + s:undercurl_items + exec "hi " . s:item . " guifg=NONE guibg=NONE gui=none" + \ . " ctermfg=NONE ctermbg=NONE cterm=none term=none" +endfor + +let g:colors_name="lucius" + + +" ---------------------------------------------------------------------------- +" Text Markup: +" ---------------------------------------------------------------------------- + +if s:style == "light" + hi NonText guifg=#afafd7 + hi SpecialKey guifg=#afd7af + if s:contrast == "low" + hi Comment guifg=#9e9e9e + hi Conceal guifg=#9e9e9e + hi Constant guifg=#d78700 + hi Directory guifg=#00af87 + hi Identifier guifg=#00af00 + hi PreProc guifg=#00afaf + hi Special guifg=#af00af + hi Statement guifg=#0087d7 + hi Title guifg=#0087d7 + hi Type guifg=#0087af + else + hi Comment guifg=#808080 + hi Conceal guifg=#808080 + hi Constant guifg=#af5f00 + hi Directory guifg=#00875f + hi Identifier guifg=#008700 + hi PreProc guifg=#008787 + hi Special guifg=#870087 + hi Statement guifg=#005faf + hi Title guifg=#005faf + hi Type guifg=#005f87 + endif +else + hi NonText guifg=#5f5f87 + hi SpecialKey guifg=#5f875f + if s:contrast == "low" + hi Comment guifg=#6c6c6c + hi Conceal guifg=#6c6c6c + hi Constant guifg=#afaf87 + " hi Constant guifg=#afd787 + hi Directory guifg=#87af87 + hi Identifier guifg=#87af5f + hi PreProc guifg=#5faf87 + hi Special guifg=#af87af + hi Statement guifg=#5fafd7 + hi Title guifg=#00afd7 + hi Type guifg=#5fafaf + " hi Number guifg=#8787d7 + " hi String guifg=#5f8700 + elseif s:contrast == "high" + hi Comment guifg=#8a8a8a + hi Conceal guifg=#8a8a8a + hi Constant guifg=#ffffd7 + hi Directory guifg=#d7ffd7 + hi Identifier guifg=#d7ffaf + hi PreProc guifg=#afffd7 + hi Special guifg=#ffd7ff + hi Statement guifg=#afffff + hi Title guifg=#87d7ff + hi Type guifg=#afffff + else + hi Comment guifg=#808080 + hi Conceal guifg=#808080 + hi Constant guifg=#d7d7af + hi Directory guifg=#afd7af + hi Identifier guifg=#afd787 + hi PreProc guifg=#87d7af + hi Special guifg=#d7afd7 + hi Statement guifg=#87d7ff + hi Title guifg=#5fafd7 + hi Type guifg=#87d7d7 + endif +endif + + +" ---------------------------------------------------------------------------- +" Highlighting: +" ---------------------------------------------------------------------------- + +hi Cursor guifg=bg +hi CursorColumn guifg=NONE +hi CursorIM guifg=bg +hi CursorLine guifg=NONE +hi Visual guifg=NONE +hi VisualNOS guifg=fg guibg=NONE +if s:style == "light" + hi CursorColumn guibg=#dadada + hi CursorLine guibg=#dadada + hi IncSearch guifg=fg guibg=#5fd7d7 + hi MatchParen guifg=NONE guibg=#5fd7d7 + hi Search guifg=fg guibg=#ffaf00 + hi Visual guibg=#afd7ff + if s:contrast == "low" + hi Cursor guibg=#87afd7 + hi CursorIM guibg=#87afd7 + hi Error guifg=#d70000 guibg=#ffd7d7 + hi Todo guifg=#af8700 guibg=#ffffaf + else + hi Cursor guibg=#5f87af + hi CursorIM guibg=#5f87af + hi Error guifg=#af0000 guibg=#d7afaf + hi Todo guifg=#875f00 guibg=#ffffaf + endif +else + hi CursorColumn guibg=#444444 + hi CursorLine guibg=#444444 + hi IncSearch guifg=bg + hi MatchParen guifg=fg guibg=#87af00 + hi Search guifg=bg + hi Visual guibg=#005f87 + if s:contrast == "low" + hi Cursor guibg=#5f87af + hi CursorIM guibg=#5f87af + hi Error guifg=#d75f5f guibg=#870000 + hi IncSearch guibg=#00afaf + hi Search guibg=#d78700 + hi Todo guifg=#afaf00 guibg=#5f5f00 + elseif s:contrast == "high" + hi Cursor guibg=#afd7ff + hi CursorIM guibg=#afd7ff + hi Error guifg=#ffafaf guibg=#af0000 + hi IncSearch guibg=#87ffff + hi Search guibg=#ffaf5f + hi Todo guifg=#ffff87 guibg=#87875f + else + hi Cursor guibg=#87afd7 + hi CursorIM guibg=#87afd7 + hi Error guifg=#ff8787 guibg=#870000 + hi IncSearch guibg=#5fd7d7 + hi Search guibg=#d78700 + hi Todo guifg=#d7d75f guibg=#5f5f00 + endif +endif + + +" ---------------------------------------------------------------------------- +" Messages: +" ---------------------------------------------------------------------------- + +hi Question guifg=fg +if s:style == "light" + if s:contrast == "low" + hi ErrorMsg guifg=#d70000 + hi ModeMsg guifg=#0087ff + hi MoreMsg guifg=#0087ff + hi WarningMsg guifg=#d78700 + else + hi ErrorMsg guifg=#af0000 + hi ModeMsg guifg=#005faf + hi MoreMsg guifg=#005faf + hi WarningMsg guifg=#af5f00 + endif +else + if s:contrast == "low" + hi ErrorMsg guifg=#d75f5f + hi ModeMsg guifg=#87afaf + hi MoreMsg guifg=#87afaf + hi WarningMsg guifg=#af875f + elseif s:contrast == "high" + hi ErrorMsg guifg=#ff8787 + hi ModeMsg guifg=#afffff + hi MoreMsg guifg=#afffff + hi WarningMsg guifg=#ffaf87 + else + hi ErrorMsg guifg=#ff5f5f + hi ModeMsg guifg=#afd7d7 + hi MoreMsg guifg=#afd7d7 + hi WarningMsg guifg=#d7875f + endif +endif + + +" ---------------------------------------------------------------------------- +" UI: +" ---------------------------------------------------------------------------- + +hi ColorColumn guifg=NONE +hi Pmenu guifg=bg +hi PmenuSel guifg=fg +hi PmenuThumb guifg=fg +hi StatusLine guifg=bg +hi TabLine guifg=bg +hi TabLineSel guifg=fg +hi WildMenu guifg=fg +if s:style == "light" + hi ColorColumn guibg=#e4e4e4 + hi CursorLineNr guifg=#626262 guibg=#dadada + hi FoldColumn guibg=#bcbcbc + hi Folded guibg=#bcbcbc + hi LineNr guifg=#9e9e9e guibg=#dadada + hi PmenuSel guibg=#afd7ff + hi SignColumn guibg=#d0d0d0 + hi StatusLineNC guifg=#dadada + hi TabLineFill guifg=#dadada + hi VertSplit guifg=#e4e4e4 + hi WildMenu guibg=#afd7ff + if s:contrast == "low" + hi FoldColumn guifg=#808080 + hi Folded guifg=#808080 + hi Pmenu guibg=#9e9e9e + hi PmenuSbar guifg=#9e9e9e guibg=#626262 + hi PmenuThumb guibg=#9e9e9e + hi SignColumn guifg=#808080 + hi StatusLine guibg=#9e9e9e + hi StatusLineNC guibg=#9e9e9e + hi TabLine guibg=#9e9e9e + hi TabLineFill guibg=#9e9e9e + hi TabLineSel guibg=#afd7ff + hi VertSplit guibg=#9e9e9e + else + hi FoldColumn guifg=#626262 + hi Folded guifg=#626262 + hi Pmenu guibg=#808080 + hi PmenuSbar guifg=#808080 guibg=#444444 + hi PmenuThumb guibg=#9e9e9e + hi SignColumn guifg=#626262 + hi StatusLine guibg=#808080 + hi StatusLineNC guibg=#808080 + hi TabLine guibg=#808080 + hi TabLineFill guibg=#808080 + hi TabLineSel guibg=#afd7ff + hi VertSplit guibg=#808080 + endif +else + hi ColorColumn guibg=#3a3a3a + hi CursorLineNr guifg=#9e9e9e guibg=#444444 + hi FoldColumn guibg=#4e4e4e + hi Folded guibg=#4e4e4e + hi LineNr guifg=#626262 guibg=#444444 + hi PmenuSel guibg=#005f87 + hi SignColumn guibg=#4e4e4e + hi StatusLineNC guifg=#4e4e4e + hi TabLineFill guifg=#4e4e4e + hi VertSplit guifg=#626262 + hi WildMenu guibg=#005f87 + if s:contrast == "low" + hi FoldColumn guifg=#a8a8a8 + hi Folded guifg=#a8a8a8 + hi Pmenu guibg=#8a8a8a + hi PmenuSbar guifg=#8a8a8a guibg=#bcbcbc + hi PmenuThumb guibg=#585858 + hi SignColumn guifg=#8a8a8a + hi StatusLine guibg=#8a8a8a + hi StatusLineNC guibg=#8a8a8a + hi TabLine guibg=#8a8a8a + hi TabLineFill guibg=#8a8a8a + hi TabLineSel guibg=#005f87 + hi VertSplit guibg=#8a8a8a + elseif s:contrast == "high" + hi FoldColumn guifg=#c6c6c6 + hi Folded guifg=#c6c6c6 + hi Pmenu guibg=#bcbcbc + hi PmenuSbar guifg=#bcbcbc guibg=#dadada + hi PmenuThumb guibg=#8a8a8a + hi SignColumn guifg=#bcbcbc + hi StatusLine guibg=#bcbcbc + hi StatusLineNC guibg=#bcbcbc + hi TabLine guibg=#bcbcbc + hi TabLineFill guibg=#bcbcbc + hi TabLineSel guibg=#0087af + hi VertSplit guibg=#bcbcbc + else + hi FoldColumn guifg=#bcbcbc + hi Folded guifg=#bcbcbc + hi Pmenu guibg=#b2b2b2 + hi PmenuSbar guifg=#b2b2b2 guibg=#d0d0d0 + hi PmenuThumb guibg=#808080 + hi SignColumn guifg=#b2b2b2 + hi StatusLine guibg=#b2b2b2 + hi StatusLineNC guibg=#b2b2b2 + hi TabLine guibg=#b2b2b2 + hi TabLineFill guibg=#b2b2b2 + hi TabLineSel guibg=#005f87 + hi VertSplit guibg=#b2b2b2 + endif +endif + + +" ---------------------------------------------------------------------------- +" Diff: +" ---------------------------------------------------------------------------- + +hi DiffAdd guifg=fg +hi DiffChange guifg=fg +hi DiffDelete guifg=fg + +if s:style == "light" + hi DiffAdd guibg=#afd7af + hi DiffChange guibg=#d7d7af + hi DiffDelete guibg=#d7afaf + hi DiffText guibg=#d7d7af + if s:contrast == "low" + hi DiffText guifg=#ff8700 + else + hi DiffText guifg=#d75f00 + endif +else + hi DiffAdd guibg=#5f875f + hi DiffChange guibg=#87875f + hi DiffDelete guibg=#875f5f + hi DiffText guibg=#87875f + if s:contrast == "low" + hi DiffText guifg=#d7d75f + else + hi DiffText guifg=#ffff87 + endif +endif + + +" ---------------------------------------------------------------------------- +" Spelling: +" ---------------------------------------------------------------------------- + +if s:style == "light" + hi SpellBad guisp=#d70000 + hi SpellCap guisp=#00afd7 + hi SpellLocal guisp=#d7af00 + hi SpellRare guisp=#5faf00 +else + hi SpellBad guisp=#ff5f5f + hi SpellCap guisp=#5fafd7 + hi SpellLocal guisp=#d7af5f + hi SpellRare guisp=#5faf5f +endif + + +" ---------------------------------------------------------------------------- +" Miscellaneous: +" ---------------------------------------------------------------------------- + +hi Ignore guifg=bg +hi Underlined guifg=fg + + +" ============================================================================ +" Text Emphasis: +" ============================================================================ + +if s:use_bold == 1 + for s:item in s:bold_items + exec "hi " . s:item . " gui=bold cterm=bold term=none" + endfor +endif + +if s:use_underline == 1 + for s:item in s:underline_items + exec "hi " . s:item . " gui=underline cterm=underline term=none" + endfor + for s:item in s:undercurl_items + exec "hi " . s:item . " cterm=underline" + endfor +endif + +for s:item in s:undercurl_items + exec "hi " . s:item . " gui=undercurl term=none" +endfor + + +" ============================================================================ +" Cterm Colors: +" ============================================================================ + +for s:item in s:normal_items + s:bold_items + s:underline_items + call s:AddCterm(s:item) +endfor + +for s:item in s:undercurl_items + call s:AddSpCterm(s:item) +endfor + +if s:no_term_bg == 1 + hi Normal ctermbg=NONE +endif + + +" ============================================================================ +" Alternative Bold Definitions: +" ============================================================================ + +let s:alternative_bold_items = ["Identifier", "PreProc", "Statement", + \ "Special", "Constant", "Type"] + +for s:item in s:alternative_bold_items + exec "let s:temp_gui_fg = synIDattr(synIDtrans(hlID('" . s:item . + \ "')), 'fg', 'gui')" + exec "let s:temp_cterm_fg = synIDattr(synIDtrans(hlID('" . s:item . + \ "')), 'fg', 'cterm')" + exec "hi B" . s:item . " guifg=" . s:temp_gui_fg . " ctermfg=" . + \ s:temp_cterm_fg . " gui=bold cterm=bold term=none" +endfor + + +" ============================================================================ +" Plugin Specific Colors: +" ============================================================================ + +" Tagbar: +hi link TagbarAccessPublic Constant +hi link TagbarAccessProtected Type +hi link TagbarAccessPrivate PreProc + +" Vimwiki: +hi link VimwikiHeader1 BIdentifier +hi link VimwikiHeader2 BPreProc +hi link VimwikiHeader3 BStatement +hi link VimwikiHeader4 BSpecial +hi link VimwikiHeader5 BConstant +hi link VimwikiHeader6 BType + + +" ============================================================================ +" Preset Commands: +" ============================================================================ + +function! SetLucius(style, contrast, contrast_bg) + let g:lucius_style = a:style + let g:lucius_contrast = a:contrast + let g:lucius_contrast_bg = a:contrast_bg +endfunction + +command! LuciusLight call SetLucius("light", "normal", "normal") + \ | colorscheme lucius +command! LuciusLightLowContrast call SetLucius("light", "low", "normal") + \ | colorscheme lucius +command! LuciusLightHighContrast call SetLucius("light", "high", "normal") + \ | colorscheme lucius + +command! LuciusWhite call SetLucius("light", "normal", "high") + \ | colorscheme lucius +command! LuciusWhiteLowContrast call SetLucius("light", "low", "high") + \ | colorscheme lucius +command! LuciusWhiteHighContrast call SetLucius("light", "high", "high") + \ | colorscheme lucius + +command! LuciusDark call SetLucius("dark", "normal", "normal") + \ | colorscheme lucius +command! LuciusDarkLowContrast call SetLucius("dark", "low", "normal") + \ | colorscheme lucius +command! LuciusDarkHighContrast call SetLucius("dark", "high", "normal") + \ | colorscheme lucius + +command! LuciusBlack call SetLucius("dark", "normal", "high") + \ | colorscheme lucius +command! LuciusBlackLowContrast call SetLucius("dark", "low", "high") + \ | colorscheme lucius +command! LuciusBlackHighContrast call SetLucius("dark", "high", "high") + \ | colorscheme lucius + +" vim: tw=78 diff --git a/vim/.vim/ftdetect/mutt.vim b/vim/.vim/ftdetect/mutt.vim @@ -0,0 +1 @@ +autocmd BufReadPost *mutt-* set ft=mail diff --git a/vim/.vim/ftplugin/cvs.vim b/vim/.vim/ftplugin/cvs.vim @@ -0,0 +1,5 @@ +" No autoformatting, literal tabs +setlocal noautoindent +setlocal noexpandtab +setlocal formatoptions= +let b:undo_ftplugin = 'setlocal autoindent< expandtab< formatoptions<' diff --git a/vim/.vim/ftplugin/tsv.vim b/vim/.vim/ftplugin/tsv.vim @@ -0,0 +1,5 @@ +" No autoformatting, literal tabs +setlocal noautoindent +setlocal noexpandtab +setlocal formatoptions= +let b:undo_ftplugin = 'setlocal autoindent< expandtab< formatoptions<' diff --git a/vim/.vim/pack/my_plugins/start/nearby/plugin/nearby.vim b/vim/.vim/pack/my_plugins/start/nearby/plugin/nearby.vim @@ -0,0 +1,5 @@ +cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr> +map <leader>ew :e %% +map <leader>es :sp %% +map <leader>ev :vsp %% +map <leader>et :tabe %% diff --git a/vim/.vim/pack/my_plugins/start/vim-slackcat/plugin/vim-slackcat.vim b/vim/.vim/pack/my_plugins/start/vim-slackcat/plugin/vim-slackcat.vim @@ -0,0 +1,60 @@ +" vim-slackcat.vim +" Ridiculously simple plugin to send a visual selection to an Slack channel +" +" Copyright © 2016 Paco Esteban <paco@onna.be> + +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the 'Software'), +" to deal in the Software without restriction, including without limitation +" the rights to use, copy, modify, merge, publish, distribute, sublicense, +" and/or sell copies of the Software, and to permit persons to whom the +" Software is furnished to do so, subject to the following conditions: + +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. + +" THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +" OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +" OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +" it accepts g:slackcat_default_channel +" slackcat (http://slackcat.chat/) must be configured beforehand. + +if !exists("g:slackcat_default_channel") + let g:slackcat_default_channel = "" +endif + +" send selection to slack +vnoremap <Leader>S :<C-u>call SendToSlack()<CR> + +function! SendToSlack() + call inputsave() + let s_channel = input("Slack Channel? ", g:slackcat_default_channel) + let s_lang = input("lang? ", &filetype) + call inputrestore() + echo "\rSending to Slack ..." + let s_selection = s:escapeTildes(s:getVisualSelection()) + if empty(s_lang) + let s_lang = 'txt' + endif + let return = system("echo '". s_selection ."' |slackcat -c " . s_channel . " --filetype " . s_lang) + echo "\rSent !" +endfunction + +function! s:escapeTildes(text) + return substitute(a:text, "'", "'\"'\"'", 'g') +endfunction + +function! s:getVisualSelection() + " Why is this not a built-in Vim script function?! + let [lnum1, col1] = getpos("'<")[1:2] + let [lnum2, col2] = getpos("'>")[1:2] + let lines = getline(lnum1, lnum2) + let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] + let lines[0] = lines[0][col1 - 1:] + return join(lines, "\n") +endfunction diff --git a/vim/.vim/pythonx/vimsnippets.py b/vim/.vim/pythonx/vimsnippets.py @@ -0,0 +1,98 @@ +"""Helper methods used in UltiSnips snippets.""" + +import string +import vim + + +def complete(tab, opts): + """ + get options that start with tab + + :param tab: query string + :param opts: list that needs to be completed + + :return: a string that start with tab + """ + msg = "({0})" + if tab: + opts = [m[len(tab):] for m in opts if m.startswith(tab)] + if len(opts) == 1: + return opts[0] + + if not len(opts): + msg = "{0}" + return msg.format("|".join(opts)) + + +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(('OTHER', text, text, text, "")) + # parse 3-part comment, but ignore those with O flag + elif 's' in flags and 'O' not in flags: + ctriple = ["TRIPLE"] + 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 'b' in flags: + if len(text) == 1: + rv.insert(0, ("SINGLE_CHAR", text, text, text, "")) + except StopIteration: + return rv + + +def get_comment_format(): + """ Returns a 4-element tuple (first_line, middle_lines, end_line, indent) + representing the comment format for the current file. + + It first looks at the 'commentstring', if that ends with %s, it uses that. + Otherwise it parses '&comments' and prefers single character comment + markers if there are any. + """ + commentstring = vim.eval("&commentstring") + if commentstring.endswith("%s"): + c = commentstring[:-2] + return (c, c, c, "") + comments = _parse_comments(vim.eval("&comments")) + for c in comments: + if c[0] == "SINGLE_CHAR": + return c[1:] + return comments[0][1:] + + +def make_box(twidth, bwidth=None): + b, m, e, i = (s.strip() for s in 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(",") diff --git a/vim/.vim/spell/en.utf-8.add b/vim/.vim/spell/en.utf-8.add @@ -0,0 +1,15 @@ +FreeCAD +STL +ATTiny85 +AVR +EEVBlog +IR +arduino +usb +NPN +BJT +Brymen +paco +onna +gophermap +gophermaps diff --git a/vim/.vim/spell/en.utf-8.add.spl b/vim/.vim/spell/en.utf-8.add.spl Binary files differ. diff --git a/vim/.vim/templates/template.R b/vim/.vim/templates/template.R @@ -0,0 +1,4 @@ +#!/usr/bin/env Rscript +# Description + + diff --git a/vim/.vim/templates/template.c b/vim/.vim/templates/template.c @@ -0,0 +1,11 @@ +/* + * ... + */ + +#include <stdio.h> + +int main(void) +{ + + return 0; +} diff --git a/vim/.vim/templates/template.go b/vim/.vim/templates/template.go @@ -0,0 +1,8 @@ +// ... +package main + +import "fmt" + +func main() { + fmt.Println("foo") +} diff --git a/vim/.vim/templates/template.pl b/vim/.vim/templates/template.pl @@ -0,0 +1,8 @@ +#!/usr/bin/env perl +# +# ... + +use v5.26; +use strict; +use warnings; + diff --git a/vim/.vim/templates/template.py b/vim/.vim/templates/template.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# vim:fenc=utf-8 + diff --git a/vim/.vim/templates/template.sh b/vim/.vim/templates/template.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +set -eu diff --git a/vim/.vim/vimrc b/vim/.vim/vimrc @@ -0,0 +1,193 @@ +" my silly vimrc +" Basic config {{{ +filetype plugin indent on +syntax on +set nocompatible +set autoindent +set backspace=indent,eol,start +set smarttab +set shiftwidth=4 " Number of spaces to use for each step of (auto)indent +set tabstop=4 " Number of spaces that a <Tab> in the file counts for +set softtabstop=4 " Number of spaces that a <Tab> counts for while performing editing +set expandtab " use spaces instead of tabs +set scrolloff=2 " show 2 lines before/after cursor always +set number +set relativenumber +set ignorecase +set smartcase " don't use ignorecase when we search for a cased pattern +set hidden " avoiding annoying messages (no write since last change) +set splitright " split windows on the right ! +set splitbelow " split windows below ! +set list " mark non-printable chars as per above instructions +set listchars=tab:▸\ ,trail:·,precedes:«,extends:»,nbsp:+ +set wildmenu +set wildmode=longest,list:longest " command completion works as I want +set foldmethod=syntax +set foldlevelstart=10 " open most folds by default +set foldnestmax=10 " 10 nested fold max +set updatetime=1000 +set lazyredraw " redraw less, let's see how it goes +set path-=/usr/include " do not assume C by default +set path+=** " search current directory whole tree +set completeopt+=longest +set completeopt+=menuone +set nrformats+=alpha " with C-a can increment dec, hex, bin, and chars too +set nrformats-=octal " and we do not care about octal (0 starting can be bad) +set incsearch +set hlsearch +set display+=lastline +set encoding=utf-8 +set formatoptions+=j " Delete comment character when joining commented lines " +set autoread +set complete-=i " C-N does not search on 'include' +set omnifunc=syntaxcomplete#Complete +set directory^=~/.vim/cache/swap// " try to keep swapfiles in one place +set include= " don't asume C by default +set linebreak " pretier line breaks +set showbreak=... +set showcmd " shows what I'm typing in normal mode +" }}} + +" Color {{{ +color lucius +LuciusBlackLowContrast +" }}} + +" Templates {{{ +augroup templates + autocmd! + autocmd BufNewFile *.sh 0r $HOME/.config/nvim/templates/template.sh + autocmd BufNewFile *.pl 0r $HOME/.config/nvim/templates/template.pl + autocmd BufNewFile *.c 0r $HOME/.config/nvim/templates/template.c + autocmd BufNewFile *.go 0r $HOME/.config/nvim/templates/template.go + autocmd BufNewFile *.py 0r $HOME/.config/nvim/templates/template.py +augroup END +" }}} + +" Mappings {{{ +" space bar un-highlights search +noremap <silent> <Space> :silent noh<Bar>echo<CR> +" better behaviour of > in visual mode +vnoremap > >gv +vnoremap < <gv +" search with true regexp, not vim's ... +nnoremap / /\v +vnoremap / /\v +" next prev tab +let i = 1 +while i < 10 + execute 'nnoremap <leader>'.i.' '.i.'gt' + let i += 1 +endwhile +nmap <leader>[ :tabprevious<CR> +nmap <leader>] :tabnext<CR> +" go fast to home end of line +inoremap <C-e> <C-o>$ +inoremap <C-a> <C-o>0 +" char forward back in insert mode (useful for auto-close) +inoremap <C-f> <C-o>a +inoremap <C-b> <C-o>h +" copy and paste from system easily +if has("mac") + nnoremap cp "*p + vnoremap cy "*y +else + nnoremap cp "+p + vnoremap cy "+y +endif +" \b calls make +nnoremap <leader>b :make<CR> +" }}} + +" Plugins {{{ +" ALE {{{ +nmap <silent> <Leader>k <Plug>(ale_previous_wrap) +nmap <silent> <Leader>j <Plug>(ale_next_wrap) +let g:ale_lint_on_text_changed = 'never' +" }}} +" Nerdcommenter {{{ +let g:NERDSpaceDelims = 1 +let g:NERDDefaultAlign = 'left' +let g:NERDCommentEmptyLines = 1 +let g:NERDTrimTrailingWhitespace = 1 +let g:NERDCompactSexyComs = 1 +" }}} +" vim-go {{{ +let g:go_highlight_functions = 1 +let g:go_highlight_methods = 1 +let g:go_highlight_fields = 1 +let g:go_highlight_types = 1 +let g:go_highlight_operators = 1 +let g:go_highlight_build_constraints = 1 +let g:go_highlight_extra_types = 1 +let g:go_fmt_command = "goimports" +let g:go_template_autocreate = 0 +let g:go_info_mode = 'guru' +" }}} +" UltiSnips {{{ +let g:UltiSnipsEnableSnipMate = 0 +" }}} +" Autopairs {{{ +" fixing how urxvt deals with Meta key +if !has("mac") + imap n <M-n> + imap e <M-e> + imap p <M-p> + imap ] <M-]> + imap } <M-}> +endif +" }}} +" }}} + +" Tabline {{{ +" tabline with numbers +" shamelessly taken form +" https://github.com/mkitt/tabline.vim/blob/master/plugin/tabline.vim +" and modified slightly +function! Tabline() + let s = '' + for i in range(tabpagenr('$')) + let tab = i + 1 + let winnr = tabpagewinnr(tab) + let buflist = tabpagebuflist(tab) + let bufnr = buflist[winnr - 1] + let bufname = bufname(bufnr) + let bufmodified = getbufvar(bufnr, "&mod") + + let s .= '%' . tab . 'T' + let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#') + let s .= ' ' . tab + let n = tabpagewinnr(tab,'$') " get the number of windows in the current tab + if n > 1 + let s .= '(' . n .')' " if there's more than one, add a colon and display the count + endif + let s .= ':' + let s .= (bufname != '' ? '['. pathshorten(fnamemodify(bufname, ':~:.')) . '] ' : '[No Name] ') + + if bufmodified + let s .= '[+] ' + endif + endfor + + let s .= '%#TabLineFill#' + if (exists("g:tablineclosebutton")) + let s .= '%=%999XX' + endif + return s +endfunction +set tabline=%!Tabline() +" }}} + +" Statusline {{{ +set laststatus=2 +set statusline=\[%n] +set statusline+=\ >>\ %f +set statusline+=\ %m%r%h +set statusline+=\ %y +set statusline+=\ \[%{(&fenc!=''?&fenc:&enc)}/%{&ff}] +set statusline+=\ %= +set statusline+=\ L:%4l/%4L\ C:%3c +set statusline+=\ [%3p%%] +" }}} + +" vim:foldmethod=marker:foldlevel=0