feat(vim): start moving back

This commit is contained in:
Ade Attwood 2022-06-12 20:25:17 +01:00
parent a533f76a3c
commit c281311657
70 changed files with 462 additions and 2610 deletions

View file

@ -10,8 +10,7 @@
# Edit commands with file previews using `fd` to search files to exclude files
# to improve performance
#
alias fe="e \"\$(FZF_DEFAULT_COMMAND=\"fd -t f\" fzf --layout=reverse --preview 'bat --style=numbers ---color=always {}')\""
alias fte="te \"\$(FZF_DEFAULT_COMMAND=\"fd -t f\" fzf --layout=reverse --preview 'bat --style=numbers ---color=always {}')\""
alias fe="vim \"\$(FZF_DEFAULT_COMMAND=\"fd -t f\" fzf --layout=reverse --preview 'bat --style=numbers ---color=always {}')\""
#
# cd in to a porject directory

View file

@ -1,24 +0,0 @@
snippet date "YYYY-MM-DD" w
`!v strftime("%Y-%m-%d")`
endsnippet
snippet ddate "Month DD, YYYY" w
`!v strftime("%b %d, %Y")`
endsnippet
snippet diso "ISO format datetime" w
`!v strftime("%Y-%m-%d %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 uuid "Random UUID" w
`!p if not snip.c: import uuid; snip.rv = uuid.uuid4()`
endsnippet

View file

@ -1,45 +0,0 @@
snippet fix "Bug fix commit message" b
fix(${1:category}): ${2:title}
${3:description}
fixes issue ${4:issue number}
endsnippet
snippet feat "Feature commit message" b
feat(${1:category}): ${2:title}
endsnippet
snippet chore "Chore commit message" b
chore(${1:category}): ${2:title}
endsnippet
snippet ci "Continuous intergration commit message" b
ci(${1:category}): ${2:title}
endsnippet
snippet docs "Documentation commit message" b
docs(${1:category}): ${2:title}
endsnippet
snippet test "Test commit message" b
test(${1:category}): ${2:title}
endsnippet
snippet style "Code styling commit message" b
style(${1:category}): ${2:title}
endsnippet
snippet perf "Performance commit message" b
perf(${1:category}): ${2:title}
endsnippet
snippet refactor "Refactor commit message" b
refactor(${1:category}): ${2:title}
endsnippet
snippet bc "Breaking change" b
BREAKING CHANGE: ${0:Description}
endsnippet

View file

@ -1,77 +0,0 @@
snippet /^import/ "Import declaration" r
import (
"${1:package}"
)
endsnippet
snippet struct "Struct declaration" b
type ${1:Struct} struct {
${0:${VISUAL}}
}
endsnippet
snippet interface "Interface declaration" b
type ${1:Interface} interface {
${0:${VISUAL}}
}
endsnippet
snippet if "If statement" b
if ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet switch "Switch statement" b
switch ${1:expression}${1/(.+)/ /}{
case$0
}
endsnippet
snippet /^main/ "Main function" r
func main() {
${0:${VISUAL}}
}
endsnippet
snippet /^meth/ "Method" r
func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} {
${0:${VISUAL}}
}
endsnippet
snippet func "Function" b
func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
${0:${VISUAL}}
}
endsnippet
snippet map "Map type" b
map[${1:keytype}]${2:valtype}
endsnippet
snippet : "Variable declaration :=" b
${1:name} := ${0:value}
endsnippet
snippet var "Variable declaration" b
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
endsnippet
snippet vars "Variables declaration" b
var (
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
)
endsnippet
snippet json "JSON field"
\`json:"${1:displayName}"\`
endsnippet
snippet err "Basic error handling" b
if err != nil {
log.${1:Fatal}(err)
}
endsnippet

View file

@ -1,172 +0,0 @@
snippet input "Input with Label" w
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`>
endsnippet
snippet input "XHTML <input>" w
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`>
endsnippet
snippet opt "Option" w
<option${1: value="${2:option}"}>${3:$2}</option>
endsnippet
snippet select "Select Box" w
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
${0:${VISUAL}}
</select>
endsnippet
snippet textarea "XHTML <textarea>" w
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
endsnippet
snippet mailto "XHTML <a mailto: >" w
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
endsnippet
snippet base "XHTML <base>" w
<base href="$1"${2: target="$3"}`!p x(snip)`>
endsnippet
snippet body "<body>"
<body>
${0:${VISUAL}}
</body>
endsnippet
snippet div "<div>" w
<div>
${0:${VISUAL}}
</div>
endsnippet
snippet div. "<div> with class" w
<div`!p snip.rv=' class="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`>
${0:${VISUAL}}
</div>
endsnippet
snippet div# "<div> with ID & class" w
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`>
${0:${VISUAL}}
</div>
endsnippet
snippet form "XHTML <form>" w
<form action="${1:`!p
snip.rv = (snip.basename or 'unnamed') + '_submit'
`}" method="${2:get}" accept-charset="utf-8">
${0:${VISUAL}}
</form>
endsnippet
snippet h1 "XHTML <h1>" w
<h1>${0:${VISUAL}}</h1>
endsnippet
snippet h2 "XHTML <h2>" w
<h2>${0:${VISUAL}}</h2>
endsnippet
snippet h3 "XHTML <h3>" w
<h3>${0:${VISUAL}}</h3>
endsnippet
snippet h4 "XHTML <h4>" w
<h4>${0:${VISUAL}}</h4>
endsnippet
snippet h5 "XHTML <h5>" w
<h5>${0:${VISUAL}}</h5>
endsnippet
snippet h6 "XHTML <h6>" w
<h6>${0:${VISUAL}}</h6>
endsnippet
snippet link "XHTML <link>" w
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`!p x(snip)`>
endsnippet
snippet meta "XHTML <meta>" w
<meta name="${1:name}" content="${2:content}"`!p x(snip)`>
endsnippet
snippet scriptsrc "XHTML <script src...>" w
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>
endsnippet
snippet script "XHTML <script>" w
<script type="text/javascript" charset="utf-8">
${0:${VISUAL}}
</script>
endsnippet
snippet span "<span>" w
<span> ${0:${VISUAL}} </span>
endsnippet
snippet span. "<span> with class" w
<span`!p snip.rv=' class="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`> ${0:${VISUAL}} </span>
endsnippet
snippet span# "<span> with ID & class" w
<span`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`> ${0:${VISUAL}} </span>
endsnippet
snippet style "XHTML <style>" w
<style type="text/css" media="screen">
${0:${VISUAL}}
</style>
endsnippet
snippet table "XHTML <table>" w
<table>
${0:${VISUAL}}
</table>
endsnippet
snippet a "Link" w
<a href="${1:http://www.${2:url.com}}"${3: target="_blank"}>${4:Anchor Text}</a>
endsnippet
snippet p "paragraph" w
<p>${0:${VISUAL}}</p>
endsnippet
snippet li "list item" w
<li>${0:${VISUAL}}</li>
endsnippet
snippet ul "unordered list" w
<ul>
${0:${VISUAL}}
</ul>
endsnippet
snippet td "table cell" w
<td>${0:${VISUAL}}</td>
endsnippet
snippet th "table header" w
<th>${0:${VISUAL}}</th>
endsnippet
snippet tr "table row" w
<tr>${0:${VISUAL}}</tr>
endsnippet
snippet title "XHTML <title>" w
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
endsnippet
snippet fieldset "Fieldset" w
<fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}>
<legend>$1</legend>
${0:${VISUAL}}
</fieldset>
endsnippet

View file

@ -1,47 +0,0 @@
snippet php "php tag" i
<?php $0 ?>
endsnippet
snippet phpe "php echo tag" i
<?= $0 ?>
endsnippet
snippet phpif "php if statment" b
<?php if($1): ?>
$0
<?php endif; ?>
endsnippet
snippet phpife "php if else statment" b
<? if ($1): ?>
$2
<? else: ?>
$0
<? endif; ?>
endsnippet
snippet phpifeif "php if else if statment" b
<? if ($1): ?>
$2
<? elseif ($3): ?>
$4
<? else: ?>
$0
<? endif; ?>
endsnippet
snippet phpfe "php foreach" b
<?php foreach(${1:$array} as ${2:$key}=>${3:$value}): ?>
$0
<?php endforeach; ?>
endsnippet
snippet phpf "php for loop" b
<?php for ($i = ${1:1}; $i <= ${2:count}; $i++): ?>
$0
<?php endfor; ?>
endsnippet
snippet prdd "vardump in php tags" b
<?php \revo\Revo::dieVar( ${0:var} ); ?>
endsnippet

View file

@ -1,93 +0,0 @@
snippet #! "shebang"
#!/usr/bin/env node
endsnippet
snippet vreq "assign a CommonJS-style module to a var"
const ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('$1');
endsnippet
snippet import "ES6 import" b
import {$0} from '$1';
endsnippet
snippet ex "module.exports"
module.exports = $0;
endsnippet
snippet default "export default" b
export default $0
endsnippet
snippet cl "Console LOG" b
console.log($0);
endsnippet
snippet cw "Console Warn" b
console.warn($0);
endsnippet
snippet ce "Console Error" b
console.error($0);
endsnippet
snippet rfc "React functional component" b
export const ${1:Name} = (${2:props})=> {
return (
${0:<div>Component</div>}
);
};
$1.propTypes = {};
endsnippet
snippet rc "React component" b
export class ${1:Name} extends React.Component {
static propTypes = {};
state = {};
render() {
return (
${0:<div>Component</div>}
);
}
}
endsnippet
snippet raect "Adds react import statements" b
import React from 'react';
import PropTypes from 'prop-types';
endsnippet
snippet useState "React.useState" w
const [$1, set${1/\w+\s*/\u$0/g}] = React.useState(${3:''});${0}
endsnippet
snippet useEffect "useEffect" w
React.useEffect(() => {
$0
});
endsnippet
snippet useContext "useContext" w
const $1 = React.useContext($2);${0}
endsnippet
snippet useCallback "useCallback" w
React.useCallback(
() => {
$0
},
[$1],
);
endsnippet
snippet useMemo "useMemo" w
const $1 = React.useMemo(() => {
${0}
}, [$2]);
endsnippet
snippet useRef "useRef" w
const $1 = React.useRef($2);${0}
endsnippet

View file

@ -1,42 +0,0 @@
snippet link "Link to something"
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
endsnippet
snippet img "Image"
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
endsnippet
snippet icode "Inline Code" i
\`$1\`$0
endsnippet
snippet code "Codeblock" b
\`\`\`${1:lang}
$2
\`\`\`
$0
endsnippet
snippet table "A base table layout" b
|${0} | | | | |
|---|---|---|---|---|
| | | | | |
endsnippet
snippet frontmatter "A basic frontmatter block" b
---
title: ${1:Title}
comments: false
date: ${2:date}
tags:
- ${3:tags}
categories:
- ${4:categories}
---
${0}
endsnippet
snippet more "A more comment tag for blogs" b
<!-- more -->
endsnippet

View file

@ -1,5 +0,0 @@
/**
* ${1:{{name}}}
*
* @var ${2:{{type}}{{^type}}mixed{{/type}}}
*/

View file

@ -1,11 +0,0 @@
/**
* ${1:{{name}}}
*
* @category Project
* @package \{\{package\}\}
* @author Ade Attwood <ade@practically.io>
* @copyright `!v strftime('%Y')` Practically.io{{#interfaces}}
* @see {{name}}{{/interfaces}}{{#parent}}
* @see {{name}}{{/parent}}{{#abstract}}
* @abstract {{/abstract}}
*/

View file

@ -1,3 +0,0 @@
/**
* ${1:{{name}}}
*/

View file

@ -1,5 +0,0 @@
/**
* ${1:{{name}}}{{?func: vmustache#InitCounter("params", 1)}}
*{{#parameters}}
* @param ${{{?func: vmustache#IncrementCounter("params")}}:{{type}}{{^type}}mixed{{/type}}} ${{name}}${{{?func: vmustache#IncrementCounter("params")}}}{{/parameters}}
*/

View file

@ -1,5 +0,0 @@
/**
* Interface: ${1:{{name}}}
*{{#parents}}
* @see {{name}}{{/parents}}
*/

View file

@ -1,3 +0,0 @@
/**
* Trait: ${1:{{name}}}
*/

View file

@ -1,200 +0,0 @@
snippet - "" i
->$0
endsnippet
snippet = "" i
=>$0
endsnippet
snippet this "Description" i
$this->$0
endsnippet
snippet dd "Dumb debug helper in HTML"
echo '<pre>' . var_dump($1, 1) . '</pre>';$0
endsnippet
snippet dump "Symfony Dump" i
dump(${1:var});
endsnippet
snippet dumpd "Symfony Dump Die" i
dump(${1:var});
die;
endsnippet
snippet rdd "Revo die var" i
\revo\Revo::dieVar(${1:var});
endsnippet
snippet ai "Array item" i
'${1:key}' => ${0:value}
endsnippet
snippet try "Try and catch block" b
try {
$0
} catch (\Exception $e) {}
endsnippet
snippet pub "Public function" b
/**
* ${3:undocumented function}
*
* @return $4
*/
public function ${1:name}(${2:$param})${3:: ${4:void}}
{
${VISUAL}$0
}
endsnippet
snippet pro "Protected function" b
/**
* ${3:undocumented function}
*
* @return $4
*/
protected function ${1:name}(${2:$param})${3:: ${4:void}}
{
${VISUAL}$0
}
endsnippet
snippet pri "Private function" b
/**
* ${3:undocumented function}
*
* @return $4
*/
private function ${1:name}(${2:$param})${3:: ${4:void}}
{
${VISUAL}$0
}
endsnippet
snippet pubs "Public static function" b
/**
* ${3:undocumented function}
*
* @return $4
*/
public static function ${1:name}(${2:$param})${3:: ${4:void}}
{
${VISUAL}$0
}
endsnippet
snippet pros "Protected static function" b
/**
* ${3:undocumented function}
*
* @return $4
*/
protected static function ${1:name}(${2:$param})${3:: ${4:void}}
{
${VISUAL}$0
}
endsnippet
snippet pris "Private static function" b
/**
* ${3:undocumented function}
*
* @return $4
*/
private static function ${1:name}(${2:$param})${3:: ${4:void}}
{
${VISUAL}$0
}
endsnippet
snippet new "New class instance" b
$${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3);
$0
endsnippet
snippet ns "namespace declaration" b
namespace ${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
endsnippet
snippet class "Class declaration template" b
<?php
declare(strict_types = 1);
namespace ${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
/**
* @author ${2:`!v g:snips_author`}
*/
class ${3:`!p snip.rv=snip.basename`}${4: extends ${5}}
{
${0}
}
endsnippet
snippet interface "Interface declaration template" b
<?php
namespace ${1:`!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
/**
* Interface ${1:`!p snip.rv=snip.basename`}
* @author ${2:`!v g:snips_author`}
*/
interface $1
{
public function ${3:someFunction}();$4
}
endsnippet
snippet construct "__construct()" b
/**
* @param $2mixed ${1/, /\n * \@param mixed /g}
*/
public function __construct(${1:$dependencies})
{${1/\$(\w+)(, )*/\n $this->$1 = $$1;/g}
}
$0
endsnippet
# PHPUnit snippets
snippet testcase "class XYZTest extends \PHPUnit_Framework_TestCase { ... }"
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
/**
* @author `!v g:snips_author`
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends \PHPUnit_Framework_TestCase
{
public function test${1}()
{
${0:${VISUAL}}
}
}
endsnippet

View file

@ -1,35 +0,0 @@
snippet ftest "Functional test" b
public function ${1:name}(FunctionalTester $I): void
{
$I->wantToTest('${2:dis}');
${3://test}
}
endsnippet
snippet utest "Unit test" b
public function ${1:name}(UnitTester $I): void
{
$I->wantToTest('${2:dis}');
${3://test}
}
endsnippet
snippet atest "Acceptance test" b
public function ${1:name}(AcceptanceTester $I): void
{
$I->wantToTest('${2:dis}');
${3://test}
}
endsnippet
snippet _b+a "Before and After class" b
public function _before(${1:inject})
{
}
public function _after($1)
{
}
endsnippet

View file

@ -1,65 +0,0 @@
snippet php "php tag" i
<?php $0 ?>
endsnippet
snippet phpe "php echo tag" i
<?= $0 ?>
endsnippet
snippet phpif "php if statment" b
<?php if($1): ?>
$0
<?php endif; ?>
endsnippet
snippet phpife "php if else statment" b
<? if ($1): ?>
$2
<? else: ?>
$0
<? endif; ?>
endsnippet
snippet phpifeif "php if else if statment" b
<? if ($1): ?>
$2
<? elseif ($3): ?>
$4
<? else: ?>
$0
<? endif; ?>
endsnippet
snippet phpfe "php foreach" b
<?php foreach(${1:$array} as ${2:$key}=>${3:$value}): ?>
$0
<?php endforeach; ?>
endsnippet
snippet phpf "php for loop" b
<?php for ($i = ${1:1}; $i <= ${2:count}; $i++): ?>
$0
<?php endfor; ?>
endsnippet
snippet var-doc "Code for createing a vardoc" b
echo '<pre>';
echo '/**'.PHP_EOL;
echo ' *'.PHP_EOL;
$_type = gettype($this) == 'object' ? get_class($this) : gettype($this);
echo " * @var $_type \\$this\n";
foreach(get_defined_vars() as $name => $var) {
if (substr($name, 0, strlen('_')) !== '_' && $name !== 'this') {
if (is_array($var) && isset($var[0]) && gettype($var[0]) == 'object') {
$type = get_class($var[0]);
echo " * @var {$type}[] \$$name\n";
continue;
}
$type = gettype($var) == 'object' ? get_class($var) : gettype($var);
echo " * @var $type \$$name\n";
}
}
echo ' */'.PHP_EOL;
echo "</pre>";
die;
endsnippet

View file

@ -1,18 +0,0 @@
snippet yiifk "migration foreign key" b
/*
* FOREIGN KEY : ${1:Table}.${2:Field}
* REFERENCES : ${3:Reference Table}.${4:Reference Field}
*/
$this->addForeignKey(
'fk-$1-$2',
'$1',
'$2',
'$3',
'$4',
'CASCADE'
);
endsnippet
snippet yapp "Yii App" i
Yii::$app->${1:Command}
endsnippet

View file

@ -1,66 +0,0 @@
#
# Python helper code for generating namespaces
#
# See: https://github.com/honza/vim-snippets/blob/master/UltiSnips/puppet.snippets
#
global !p
import vim
import os.path
def get_module_namespace_and_basename():
"""This function will try to guess the current class or define name you are
trying to create. Note that for this to work you should be using the module
structure as per the style guide. Examples inputs and it's output
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
"""
first_time = True
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
if not current_file_path_without_ext:
return "name"
parts = os.path.split(current_file_path_without_ext)
namespace = ''
while parts[0] and parts[0] != '/':
if parts[1] == 'init' and first_time and not namespace:
first_time = False
parts = os.path.split(parts[0])
continue
if parts[1] == 'manifests':
return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':')
else:
namespace = parts[1] + '::' + namespace
parts = os.path.split(parts[0])
return "name"
endglobal
#
# Snippets
#
snippet class "Class declaration" b
class ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
${0:# Puppet code}
}
endsnippet
snippet define "Definition" b
define ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
${0:# Puppet Code}
}
endsnippet
snippet = "" i
=>$0
endsnippet
snippet ai "Array item" i
'${1:key}' => ${0:value}
endsnippet
snippet alert "Alert Function" b
alert("${1:message}")$0
endsnippet
snippet info "Info Function" b
info("${1:message}")$0
endsnippet

View file

@ -1,35 +0,0 @@
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
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 if "If Condition" b
if [ $1 ]; then
$0
fi
endsnippet

View file

@ -1,18 +0,0 @@
# We use a little hack so that the snippet is expanded
# and parsed correctly
snippet snip "Snippet definition" b
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
$0
`!p snip.rv = "endsnippet"`
endsnippet
snippet global "Global snippet" b
`!p snip.rv = "global"` !p
$0
`!p snip.rv = "endglobal"`
endsnippet
snippet vis "${VISUAL}" i
\$\{VISUAL${1:${2:default}${3:/transform/}}\}
endsnippet

View file

@ -1,31 +0,0 @@
extends javascript
priority 1
snippet rfc "React functional component" b
export interface $1Props {};
export const ${1:Name}:React.FC<$1Props> = (${2:props}) => {
return (
${0:<div>Component</div>}
);
};
endsnippet
snippet rc "React component" b
export interface $1State {};
export interface $1Props {};
export class ${1:Name} extends React.Component<$1Props, $1State> {
public state: $1State = {}
public render(): JSX.Element {
return (
${0:<div>Component</div>}
);
}
}
endsnippet
snippet react "Adds react import statements" b
import * as React from 'react';
endsnippet

View file

@ -0,0 +1 @@
set conceallevel=0

View file

@ -1,4 +0,0 @@
"
" Sort vim-jsx settting js files to javascript.jsx
"
let g:jsx_ext_required=1

View file

@ -1,58 +0,0 @@
"
" Orignaly from google maktaba
" https://github.com/google/vim-maktaba/blob/master/autoload/maktaba/buffer.vim#L15
"
" Gets the text of the current or last visual selection.
" Useful for visual mode mappings.
function! aa#buffer#GetVisualSelection() abort
let [l:lnum1, l:col1] = getpos("'<")[1:2]
let [l:lnum2, l:col2] = getpos("'>")[1:2]
" 'selection' is a rarely-used option for overriding whether the last
" character is included in the selection. Bizarrely, it always affects the
" last character even when selecting from the end backwards.
if &selection !=# 'inclusive'
let l:col2 -= 1
endif
let l:lines = getline(l:lnum1, l:lnum2)
if !empty(l:lines)
" If there is only 1 line, the part after the selection must be removed
" first because `col2` is relative to the start of the line.
let l:lines[-1] = l:lines[-1][: l:col2 - 1]
let l:lines[0] = l:lines[0][l:col1 - 1 : ]
endif
return join(l:lines, "\n")
endfunction
"
" Mainly taken form maktab. This just uses the pure vim implemetaion to
" replace lines
"
function! aa#buffer#Overwrite(startline, endline, lines) abort
" If lines already match, don't modify buffer.
if getline(a:startline, a:endline) == a:lines
return
endif
" Lines being replaced minus lines being inserted.
let l:line_delta = len(a:lines) - (a:endline + 1 - a:startline)
" If there's a surplus (more to replace than insert), delete the last n lines.
if l:line_delta < 0
let l:winview = winsaveview()
let l:keep_end = a:endline - (-l:line_delta)
execute string(l:keep_end + 1) . ',' . string(a:endline) . 'delete'
" Special case: Move the cursor up to track buffer changes if necessary.
" If we delete lines above the cursor, the cursor should NOT remain on the
" same line number.
if l:winview.lnum > a:endline
let l:winview.lnum += l:line_delta
endif
call winrestview(l:winview)
endif
" If there's a deficit (more to insert than replace), append the last n lines.
let l:lines = a:lines
if l:line_delta > 0
call append(a:endline, a:lines[-l:line_delta : ])
let l:lines = l:lines[ : -l:line_delta - 1]
endif
call setline(a:startline, l:lines)
endfunction

View file

@ -1,21 +0,0 @@
function aa#emmet#init()
"
" Don't install emmet globally we want to only use it on selected languages
"
let g:user_emmet_install_global = 0
"
" Set Ctrl-E emmet trigger
"
"let g:user_emmet_leader_key='<C-E>'
"
" Add the emmet package
"
packadd emmet-vim
"
" Install the package
"
EmmetInstall
endfunction

View file

@ -1,94 +0,0 @@
"
" Sets all the settings for different fold types
"
" a:type
" The type of fold you want to set.
" Valid options are 'marker', 'indent', 'diff', hunk and 'off'
"
function! aa#fold#set_fold(type)
if a:type == "marker"
setlocal foldenable
setlocal foldmethod=marker
setlocal foldlevel=0
setlocal foldnestmax=99
elseif a:type == "indent"
setlocal foldenable
setlocal foldmethod=indent
setlocal foldlevel=1
setlocal foldnestmax=2
elseif a:type == "diff"
setlocal foldenable
setlocal nomodeline formatoptions-=croq formatoptions+=tl
setlocal foldmethod=expr
setlocal foldexpr=aa#fold#diff_fold()
setlocal foldcolumn=3
elseif a:type == "hunk"
setlocal foldenable
setlocal nomodeline formatoptions-=croq formatoptions+=tl
setlocal foldmethod=expr
setlocal foldexpr=aa#fold#diff_hunk_fold()
setlocal foldcolumn=3
elseif a:type == 'off'
set nofoldenable
else
echoerr a:type . " is not a valid fold use 'off', 'marker' or 'indent'"
endif
endfunction
"
" Get the competition list for `set_fold()`
"
function! aa#fold#command_complete(a, cm, cu)
return ['off', 'marker', 'indent', 'diff', 'hunk']
endfunction
"
" Get the fold text for displaying neat folds
" See: https://dhruvasagar.com/2013/03/28/vim-better-foldtext
"
function! aa#fold#fold_text()
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '| ' . printf("%10s", lines_count . ' linesss') . ' |'
let foldchar = '-'
let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
let foldtextend = lines_count_text . repeat(foldchar, 8)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction
"
" function for the `foldexpr` to fold git diffs
"
" Inspired from https://github.com/sgeb/vim-diff-fold
"
function! aa#fold#diff_fold()
let l:line=getline(v:lnum)
if l:line =~# '^\(diff\|Index\)'
return '>1'
else
return '='
endif
endfunction
"
" function for the `foldexpr` to fold git diffs and hunks
"
" Inspired from https://github.com/sgeb/vim-diff-fold
"
function! aa#fold#diff_hunk_fold()
let l:line=getline(v:lnum)
if l:line =~# '^\(diff\|Index\)'
return '>1'
elseif l:line =~# '^\(@@\|\d\)'
return '>2'
elseif l:line =~# '^\*\*\* \d\+,\d\+ \*\*\*\*$'
return '>2'
elseif l:line =~# '^--- \d\+,\d\+ ----$'
return '>2'
else
return '='
endif
endfunction

View file

@ -1,75 +0,0 @@
"
" Turn line numbers on
"
" This set all settings for relative number and enables git gutter
"
function! aa#functions#number_on(local)
if a:local == 1
setlocal relativenumber
setlocal number
setlocal signcolumn=yes
else
set relativenumber
set number
set signcolumn=yes
endif
if exists(':GitGutterEnable')
GitGutterEnable
endif
let g:linenumber=1
endfunction
"
" Turn line numbers off
"
" Disables line numbers and git gutter
"
function! aa#functions#number_off(local)
if a:local == 1
setlocal norelativenumber
setlocal nonumber
setlocal signcolumn=no
else
set norelativenumber
set nonumber
set signcolumn=no
endif
if exists(':GitGutterDisable')
GitGutterDisable
endif
let g:linenumber=0
endfunction
"
" Toggles line numbers and all of the relevant settings
"
function! aa#functions#toggle_numbers()
if g:linenumber
call aa#functions#number_off(0)
else
call aa#functions#number_on(0)
end
endfunction
"
" Display ruler if text is over a specified char length
"
" a:lengthLimit
" The char length when to show the column ruler
"
function! aa#functions#show_column_if_line_too_long(lengthLimit)
" See https://stackoverflow.com/questions/2075276/longest-line-in-vim#2982789
let maxLineLength = max(map(getline(1,'$'), 'len(v:val)'))
if maxLineLength > a:lengthLimit
highlight ColorColumn ctermbg=18 guibg=18
execute "set colorcolumn=" . join(range((a:lengthLimit + 1),999), ",")
else
set colorcolumn=""
endif
endfunction

View file

@ -1,6 +0,0 @@
function! aa#languagetool#init()
let g:languagetool_jar = "~/.local/share/LanguageTool-4.6/languagetool-commandline.jar"
let g:languagetool_lang = 'en-GB'
packadd vim-LanguageTool
endfunction

View file

@ -1,36 +0,0 @@
function aa#supertab#expand()
if exists('g:UltiSnipsEnableSnipMate')
"
" Try to expand snippet or go to the next tab stop
"
call UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res != 0
let g:ulti_expand_or_jump_res = 0
return ""
endif
endif
"
" If popup is open cycle through the items this will most likely be
" deoplete completion
"
if pumvisible()
return "\<c-n>"
endif
if exists('g:loaded_emmet_vim')
"
" If there is an emmet expression expand it
"
if emmet#isExpandable()
call emmet#expandAbbr(0,"")
return "\<Right>"
endif
endif
"
" If all else fails just tab along
"
return "\<tab>"
endfunction

View file

@ -1,353 +0,0 @@
" pathogen.vim - path option manipulation
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 2.4
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
"
" For management of individually installed plugins in ~/.vim/bundle (or
" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
" .vimrc is the only other setup necessary.
"
" The API is documented inline below.
if exists("g:loaded_pathogen") || &cp
finish
endif
let g:loaded_pathogen = 1
" Point of entry for basic default usage. Give a relative path to invoke
" pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke
" pathogen#surround(). Curly braces are expanded with pathogen#expand():
" "bundle/{}" finds all subdirectories inside "bundle" inside all directories
" in the runtime path.
function! pathogen#infect(...) abort
for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}']
if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]'
call pathogen#surround(path)
elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)'
call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
call pathogen#surround(path . '/{}')
elseif path =~# '[{}*]'
call pathogen#interpose(path)
else
call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
call pathogen#interpose(path . '/{}')
endif
endfor
call pathogen#cycle_filetype()
if pathogen#is_disabled($MYVIMRC)
return 'finish'
endif
return ''
endfunction
" Split a path into a list.
function! pathogen#split(path) abort
if type(a:path) == type([]) | return a:path | endif
if empty(a:path) | return [] | endif
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
endfunction
" Convert a list to a path.
function! pathogen#join(...) abort
if type(a:1) == type(1) && a:1
let i = 1
let space = ' '
else
let i = 0
let space = ''
endif
let path = ""
while i < a:0
if type(a:000[i]) == type([])
let list = a:000[i]
let j = 0
while j < len(list)
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
let path .= ',' . escaped
let j += 1
endwhile
else
let path .= "," . a:000[i]
endif
let i += 1
endwhile
return substitute(path,'^,','','')
endfunction
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
function! pathogen#legacyjoin(...) abort
return call('pathogen#join',[1] + a:000)
endfunction
" Turn filetype detection off and back on again if it was already enabled.
function! pathogen#cycle_filetype() abort
if exists('g:did_load_filetypes')
filetype off
filetype on
endif
endfunction
" Check if a bundle is disabled. A bundle is considered disabled if its
" basename or full name is included in the list g:pathogen_blacklist or the
" comma delimited environment variable $VIMBLACKLIST.
function! pathogen#is_disabled(path) abort
if a:path =~# '\~$'
return 1
endif
let sep = pathogen#slash()
let blacklist =
\ get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) +
\ pathogen#split($VIMBLACKLIST)
if !empty(blacklist)
call map(blacklist, 'substitute(v:val, "[\\/]$", "", "")')
endif
return index(blacklist, fnamemodify(a:path, ':t')) != -1 || index(blacklist, a:path) != -1
endfunction
" Prepend the given directory to the runtime path and append its corresponding
" after directory. Curly braces are expanded with pathogen#expand().
function! pathogen#surround(path) abort
let sep = pathogen#slash()
let rtp = pathogen#split(&rtp)
let path = fnamemodify(a:path, ':s?[\\/]\=$??')
let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
let after = filter(reverse(pathogen#expand(path, sep.'after')), '!pathogen#is_disabled(v:val[0:-7])')
call filter(rtp, 'index(before + after, v:val) == -1')
let &rtp = pathogen#join(before, rtp, after)
return &rtp
endfunction
" For each directory in the runtime path, add a second entry with the given
" argument appended. Curly braces are expanded with pathogen#expand().
function! pathogen#interpose(name) abort
let sep = pathogen#slash()
let name = a:name
if has_key(s:done_bundles, name)
return ""
endif
let s:done_bundles[name] = 1
let list = []
for dir in pathogen#split(&rtp)
if dir =~# '\<after$'
let list += reverse(filter(pathogen#expand(dir[0:-6].name, sep.'after'), '!pathogen#is_disabled(v:val[0:-7])')) + [dir]
else
let list += [dir] + filter(pathogen#expand(dir.sep.name), '!pathogen#is_disabled(v:val)')
endif
endfor
let &rtp = pathogen#join(pathogen#uniq(list))
return 1
endfunction
let s:done_bundles = {}
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
function! pathogen#helptags() abort
let sep = pathogen#slash()
for glob in pathogen#split(&rtp)
for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
if (dir)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir) == 2 && !empty(split(glob(dir.'*.txt'))) && (!filereadable(dir.'tags') || filewritable(dir.'tags'))
silent! execute 'helptags' pathogen#fnameescape(dir)
endif
endfor
endfor
endfunction
command! -bar Helptags :call pathogen#helptags()
" Execute the given command. This is basically a backdoor for --remote-expr.
function! pathogen#execute(...) abort
for command in a:000
execute command
endfor
return ''
endfunction
" Section: Unofficial
function! pathogen#is_absolute(path) abort
return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
endfunction
" Given a string, returns all possible permutations of comma delimited braced
" alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
" ['/a/c', '/a/d', '/b/c', '/b/d']. Empty braces are treated as a wildcard
" and globbed. Actual globs are preserved.
function! pathogen#expand(pattern, ...) abort
let after = a:0 ? a:1 : ''
if a:pattern =~# '{[^{}]\+}'
let [pre, pat, post] = split(substitute(a:pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
let found = map(split(pat, ',', 1), 'pre.v:val.post')
let results = []
for pattern in found
call extend(results, pathogen#expand(pattern))
endfor
elseif a:pattern =~# '{}'
let pat = matchstr(a:pattern, '^.*{}[^*]*\%($\|[\\/]\)')
let post = a:pattern[strlen(pat) : -1]
let results = map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
else
let results = [a:pattern]
endif
let vf = pathogen#slash() . 'vimfiles'
call map(results, 'v:val =~# "\\*" ? v:val.after : isdirectory(v:val.vf.after) ? v:val.vf.after : isdirectory(v:val.after) ? v:val.after : ""')
return filter(results, '!empty(v:val)')
endfunction
" \ on Windows unless shellslash is set, / everywhere else.
function! pathogen#slash() abort
return !exists("+shellslash") || &shellslash ? '/' : '\'
endfunction
function! pathogen#separator() abort
return pathogen#slash()
endfunction
" Convenience wrapper around glob() which returns a list.
function! pathogen#glob(pattern) abort
let files = split(glob(a:pattern),"\n")
return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
endfunction
" Like pathogen#glob(), only limit the results to directories.
function! pathogen#glob_directories(pattern) abort
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
endfunction
" Remove duplicates from a list.
function! pathogen#uniq(list) abort
let i = 0
let seen = {}
while i < len(a:list)
if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
call remove(a:list,i)
elseif a:list[i] ==# ''
let i += 1
let empty = 1
else
let seen[a:list[i]] = 1
let i += 1
endif
endwhile
return a:list
endfunction
" Backport of fnameescape().
function! pathogen#fnameescape(string) abort
if exists('*fnameescape')
return fnameescape(a:string)
elseif a:string ==# '-'
return '\-'
else
return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
endif
endfunction
" Like findfile(), but hardcoded to use the runtimepath.
function! pathogen#runtime_findfile(file,count) abort
let rtp = pathogen#join(1,pathogen#split(&rtp))
let file = findfile(a:file,rtp,a:count)
if file ==# ''
return ''
else
return fnamemodify(file,':p')
endif
endfunction
" Section: Deprecated
function! s:warn(msg) abort
echohl WarningMsg
echomsg a:msg
echohl NONE
endfunction
" Prepend all subdirectories of path to the rtp, and append all 'after'
" directories in those subdirectories. Deprecated.
function! pathogen#runtime_prepend_subdirectories(path) abort
call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')')
return pathogen#surround(a:path . pathogen#slash() . '{}')
endfunction
function! pathogen#incubate(...) abort
let name = a:0 ? a:1 : 'bundle/{}'
call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')')
return pathogen#interpose(name)
endfunction
" Deprecated alias for pathogen#interpose().
function! pathogen#runtime_append_all_bundles(...) abort
if a:0
call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')')
else
call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()')
endif
return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}')
endfunction
if exists(':Vedit')
finish
endif
let s:vopen_warning = 0
function! s:find(count,cmd,file,lcd)
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
let file = pathogen#runtime_findfile(a:file,a:count)
if file ==# ''
return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
endif
if !s:vopen_warning
let s:vopen_warning = 1
let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
else
let warning = ''
endif
if a:lcd
let path = file[0:-strlen(a:file)-2]
execute 'lcd `=path`'
return a:cmd.' '.pathogen#fnameescape(a:file) . warning
else
return a:cmd.' '.pathogen#fnameescape(file) . warning
endif
endfunction
function! s:Findcomplete(A,L,P)
let sep = pathogen#slash()
let cheats = {
\'a': 'autoload',
\'d': 'doc',
\'f': 'ftplugin',
\'i': 'indent',
\'p': 'plugin',
\'s': 'syntax'}
if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
let request = cheats[a:A[0]].a:A[1:-1]
else
let request = a:A
endif
let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
let found = {}
for path in pathogen#split(&runtimepath)
let path = expand(path, ':p')
let matches = split(glob(path.sep.pattern),"\n")
call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
for match in matches
let found[match] = 1
endfor
endfor
return sort(keys(found))
endfunction
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':

View file

@ -1,63 +0,0 @@
{
"diagnostic.virtualText": true,
"diagnostic.enableHighlightLineNumber": false,
"diagnostic.errorSign": "❌",
"diagnostic.warningSign": "⚠",
"diagnostic.infoSign": "",
"diagnostic.hintSign": "",
"coc.preferences.hoverTarget": "preview",
"suggest.floatEnable": false,
"diagnostic.messageTarget": "echo",
"json.schemas": [
{
"url": "https://git.baln.co.uk/general/conventional-tools/blob/master/src/config.schema.json"
}
],
"yaml.schemas": {
"https://git.baln.co.uk/general/conventional-tools/raw/master/src/config.schema.json": "/.ctrc.yml"
},
"cSpell.language": "en-GB",
"cSpell.dictionaryDefinitions": [
{"name": "ade", "path": "/home/ade/.vim/spell/en.utf-8.add"}
],
"cSpell.dictionaries": ["ade"],
"cSpell.enabledLanguageIds": [
"asciidoc",
"c",
"cpp",
"csharp",
"css",
"git-commit",
"gitcommit",
"go",
"handlebars",
"haskell",
"html",
"jade",
"java",
"javascript",
"javascript.jsx",
"javascriptreact",
"json",
"jsonc",
"latex",
"less",
"markdown",
"php",
"plaintext",
"pug",
"python",
"restructuredtext",
"rust",
"scala",
"scss",
"text",
"typescript",
"typescript.jsx",
"typescriptreact",
"vim",
"yaml",
"yml"
],
"cSpell.userWords": ["enviopemt", "loded"]
}

View file

@ -1,28 +0,0 @@
" Maintainer: Ade Attwood <code@adeattwood.co.uk>
" Last Change: 2018-07-15
" This is a copy of the default colour theme with some edits to
" to the diff view and spelling
" Set 'background' back to the default.
hi clear Normal
set bg&
" Remove all existing highlighting and set the defaults.
hi clear
" Load the syntax highlighting defaults, if it's enabled.
if exists("syntax_on")
syntax reset
endif
" Add in colours for vim diff
highlight DiffAdd cterm=bold ctermfg=7 ctermbg=28 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=7 ctermbg=9 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=7 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=7 ctermbg=20 gui=none guifg=bg guibg=Red
" Change background colour of highlighted spell words
highlight SpellBad cterm=bold ctermfg=15 ctermbg=9 gui=none guifg=bg guibg=Red
let colors_name = "my_default"

View file

@ -1,29 +0,0 @@
"
" Change filetype to javascript.jsx if a js file imports `React`
"
function! s:ScanFile()
let n = 1
let nmax = line('$')
if line('$') > 500
let nmax = 500
endif
while n < nmax
if getline(n) =~# "\\v<React>"
return 1
break
endif
let n = n + 1
endwhile
return 0
endfunction
function! s:DetectJSX()
if match(&filetype, '\v<jsx>') != -1
return
endif
if s:ScanFile()
set filetype=javascript.jsx
endif
endfunction
autocmd BufNewFile,BufRead *.js call s:DetectJSX()

View file

@ -1,28 +0,0 @@
function! s:ScanFile()
let n = 1
let nmax = line('$')
if line('$') > 500
let nmax = 500
endif
while n < nmax
if getline(n) =~ "^class [A-Z]"
return 1
break
endif
let n = n + 1
endwhile
return 0
endfunction
function! s:DetectPhpClass()
if match(&filetype, '\v<php.class>') != -1
return
endif
if s:ScanFile()
set ft=php.class
return
endif
endfunction
"autocmd BufNewFile,BufRead *.php call s:DetectPhpClass()

View file

@ -1,6 +0,0 @@
"
" Set tsx files to have the typescript.jsx filetype so I can use vim-jsx for
" syntax highlighting
"
autocmd BufNewFile,BufRead *.tsx set filetype=typescript.jsx
autocmd BufNewFile,BufRead *.ts set filetype=typescript

View file

@ -1,4 +0,0 @@
"
" Set default fold for diff files
"
call aa#fold#set_fold('diff')

View file

@ -1,15 +0,0 @@
"
" Git commit message specific settings
"
"
"
" Enable spell by default
"
setlocal spell
"
" Make diff folds the default fold for commits. When running `git commit -v`
" all the file diffs will be folded
"
call aa#fold#set_fold('diff')

View file

@ -0,0 +1 @@
set conceallevel=0

View file

@ -1,6 +0,0 @@
"
" Mail commit message specific settings
"
"
setlocal spell

View file

@ -1,7 +0,0 @@
"
" Markdown file type specific settings
"
"
setlocal spell
call aa#languagetool#init()

View file

@ -0,0 +1,4 @@
" Required for formatting links with org
#setlocal conceallevel=2
#setlocal concealcursor=nc

View file

@ -1,8 +0,0 @@
"
" Set flods to be indent on php class files
"
if &ft == "php.class"
call aa#fold#set_fold('indent')
else
call aa#emmet#init()
endif

View file

@ -1,152 +1,55 @@
" Ade Attwood <adeattwood.co.uk>
" Vimrc is ordered in the options style
" to view all the options run :options
" and get the docs on all the settings
"
" Important
"
"call pathogen#infect()
set nocompatible
filetype plugin on
set clipboard=unnamedplus
"set t_Co=256
"
" Set leader as space bar
"
let mapleader="\<Space>"
" Use the system clipboard with yank and paste
set clipboard=unnamedplus
"
" Not sorted and new
"
set listchars=tab:▸\ ,extends:,precedes:
set pastetoggle=<F8>
set wildignore+=*/vendor/*,*/node_modules/*,*/runtime/*,*/public_html/*
set scrolloff=20
set signcolumn=yes
"
" Moving around, searching and pattern
"
" Setup better searching
set ignorecase
set incsearch
set smartcase
"
" Tags
"
" Stay 20 chars from the top and bottom of the buffer so I am always editing
" in context
set scrolloff=20
"
" Displaying text
"
set linebreak
set nowrap
call aa#functions#number_on(0)
cabb tognum call aa#functions#toggle_numbers()
"
" Highlighting and spelling
"
syntax on
set spelllang=en_gb
set cursorline
set nohlsearch
"
" Multiple windows
"
set laststatus=2
"
" Multiple tab pages
"
"
" Terminal
"
"
" Using the mouse
"
set mouse=a
"
" Printing
"
"
" Messages and info
"
set ruler
set showcmd
"
" Selecting text
"
"
" Editing text
"
set matchpairs+=<:>
set showmatch
"
" Tabs and indenting
"
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
filetype plugin indent on
"
" Folding
"
hi Folded ctermbg=0
set foldtext=aa#fold#fold_text()
" Highlight the current line where the cursor is on
set cursorline
let g:vim_json_conceal=0
command! -nargs=1 -complete=customlist,aa#fold#command_complete SetFold call aa#fold#set_fold(<f-args>)
call aa#fold#set_fold('marker')
" Relative line numbers, this set line numbers a swell so the current line is
" displayed correctly. If this is not set then the current line is always 0
set relativenumber
set number
"
" Diff mode
"
set conceallevel=0
" Ensure the signcolumn is on to stop jumping for LSP diagnostics
set signcolumn=yes
" Disable swap files
set noswapfile
" Disable line wrapping
set nowrap
packadd! command-t
"
" Mapping
"
cabb Q q
cabb W w
cabb WQ wq
cabb Wq wq
cabb __html set ft=html
cabb __php set ft=php
cabb aa <esc>vi[:EasyAlign =<CR>
cabb ap <esc>vip:EasyAlign =<CR>
cabb evim e ~/.vimrc
cabb sortp <esc>vip:sort<CR>
imap <c-h> <esc>I
imap <c-l> <esc>A
inoremap <C-Del> X<Esc>lbce
inoremap ,, <esc>A,
inoremap ;; <esc>A;
inoremap jj <esc>:w<cr>
nmap <silent> <Leader>s ]sz=
nnoremap <leader><leader> <c-^>
nnoremap <leader>d :call pdv#DocumentWithSnip()<cr>
nnoremap <silent> <Down> :resize -5<cr>
nnoremap <silent> <Right> :vertical resize +5<cr>
nnoremap <silent> <Up> :resize +5<cr>
nnoremap <silent> <leader>f za<cr>
nnoremap <silent> <leader>q :q<cr>
noremap <leader>g :tab Gstatus<cr>
noremap <leader>p :CommandT<cr>
noremap <silent> <Left> :vertical resize -5<cr>
noremap <silent> <leader>q :bdelete<cr>
noremap <silent> <leader>fs :w<cr>
noremap <silent> <leader>o :Open
noremap <silent> [b :bp<cr>
noremap <silent> ]b :bn<cr>
@ -154,79 +57,26 @@ noremap <silent> ]b :bn<cr>
noremap <silent> [q :cprevious<cr>
noremap <silent> ]q :cnext<cr>
noremap <silent> ]h :GitGutterNextHunk<cr>
noremap <silent> [h :GitGutterPrevHunk<cr>
inoremap <M-;> <esc>A;
noremap <F2> :Run make build<cr>
noremap <F3> :Run make test<cr>
noremap <F4> :Run make test FILE="%"<cr>
noremap <leader>; gcc
"vnoremap <leader>; gc
nnoremap <silent> <Leader>h :set nohlsearch<cr>:nohlsearch<cr>
nnoremap / :set hlsearch<cr>:nohlsearch<cr>/\v\c
nnoremap ? :set hlsearch<cr>:nohlsearch<cr>?
nnoremap * :set hlsearch<cr>:nohlsearch<cr>*
"
" Populate the command pallet with the `Ack` command followed by the visually
" selected text
"
vnoremap <leader>a <Esc>:Ack <c-r>=aa#buffer#GetVisualSelection()<cr>
"
" Reading and writing files
"
set autoread
"
" The swap file
"
set noswapfile
" Lint code with nvim-lint on save. This will lint all filetypes with cspell
" and then any other filetypes will be linted per the config.
au BufWritePost <buffer> lua require('lint').try_lint('cspell')
au BufWritePost <buffer> lua require('lint').try_lint()
"
" Command line editing
" Executing external commands
" Running make and jumping to errors
" Language specific
"
inoremap jj <esc>:w<cr>
nnoremap <leader><tab> <c-^>
set wildignore+=*/vendor/*,*/node_modules/*,*/runtime/*,*/public_html/*,*/pack/*
"
" Multi-byte characters
"
set fileencoding=utf-8
set encoding=utf-8
" Required for complietion with nvim-cmp
set completeopt=menu,menuone,noselect
"
" Various
"
autocmd BufNewFile,BufRead *.phtml set ft=html
"
" Plugins
"
" vim-airline
let g:airline#extensions#branch#enabled=1
let g:airline_theme='murmur'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#show_buffers = 1
let g:airline#extensions#tabline#show_splits = 0
let g:airline#extensions#tabline#show_tabs = 1
" pdv
let g:pdv_template_dir = $HOME . "/.config/nvim/UltiSnips/pdv_templates"
" indent-guides
let g:indent_guides_auto_colors = 1
"
" Text length markers
"
autocmd BufRead,TextChanged,TextChangedI *.pp,*.sh,*.bash,*.go,*.js,*.jsx,.ts,.tsx call aa#functions#show_column_if_line_too_long(80)
autocmd BufRead,TextChanged,TextChangedI *.php call aa#functions#show_column_if_line_too_long(120)
"
" Custom gitlab
"
let g:fugitive_gitlab_domains = ['https://git.zportal.co.uk']
" Format code on save
augroup fmt
autocmd!
autocmd BufWritePre * undojoin | Neoformat
augroup END

View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -1,13 +0,0 @@
"
" Highlights the active window in neo Vim. `ActiveWindow` is only available
" in neovim so
"
if has('nvim')
hi ActiveWindow ctermbg=00 | hi InactiveWindow ctermbg=22
set winhighlight=Normal:ActiveWindow,NormalNC:InactiveWindow
au VimEnter,WinEnter,BufEnter,BufWinEnter,FocusGained,CompleteDone * hi ActiveWindow ctermbg=00 | hi InactiveWindow ctermbg=22
au VimLeave,WinLeave,BufLeave,BufWinLeave,FocusLost * hi ActiveWindow ctermbg=22 | hi InactiveWindow ctermbg=22
else
hi Normal ctermbg=None
endif

View file

@ -1,32 +1,33 @@
"
" Set color theme
"
let base16colorspace=256
colorscheme base16-eighties
"
" Set tailing white space to errors
"
match ErrorMsg '\s\+$'
"
" Fix jsx end tag highlighting
"
" NOTE: This is only with vim regex highlighting, this dose not apply if you
" are using treesitter to highlighting
hi Tag ctermfg=04
hi xmlTag ctermfg=04
hi xmlTagName ctermfg=04
hi xmlEndTag ctermfg=04
"
" Highlight comments to be italic this also targets the language client
" diagnostics.
"
highlight Comment cterm=italic gui=italic
"
" Make coc diagnostics italic
"
highlight CocErrorSign cterm=italic gui=italic ctermfg=9 guifg=#ff0000
highlight CocWarningSign cterm=italic gui=italic ctermfg=130 guifg=#ff922b
highlight CocInfoSign cterm=italic gui=italic ctermfg=11 guifg=#fab005
highlight CocHintSign cterm=italic gui=italic ctermfg=12 guifg=#15aabf
" Remove underline from coursor line number
highlight CursorLineNr cterm=none
" Set the LSP diagnostics feedback to be italic
highlight DiagnosticError cterm=italic guibg=#51202A guifg=#FF0000 gui=italic
highlight DiagnosticWarn cterm=italic guibg=#51412A guifg=#FFA500 gui=italic
highlight DiagnosticInfo cterm=italic guibg=#1E535D guifg=#00FFFF gui=italic
highlight DiagnosticHint cterm=italic guibg=#1E205D guifg=#0000FF gui=italic
" hi ActiveWindow ctermbg=00 | hi InactiveWindow ctermbg=22
" set winhighlight=Normal:ActiveWindow,NormalNC:InactiveWindow
"
" au VimEnter,WinEnter,BufEnter,BufWinEnter,FocusGained,CompleteDone * hi ActiveWindow ctermbg=00 | hi InactiveWindow ctermbg=22
" au VimLeave,WinLeave,BufLeave,BufWinLeave,FocusLost * hi ActiveWindow ctermbg=22 | hi InactiveWindow ctermbg=22

View file

@ -0,0 +1,2 @@
require('Comment').setup()

View file

@ -0,0 +1,55 @@
local cmp = require'cmp'
local luasnip = require'luasnip'
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-j>'] = cmp.get_config().mapping['<Down>'],
['<C-k>'] = cmp.get_config().mapping['<Up>'],
['<CR>'] = cmp.mapping(function(_fallback)
if cmp.visible() then
cmp.confirm({ select = true })
else
vim.api.nvim_feedkeys('\n', 'nt', false)
end
end, { 'i', 's' }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = {
{ name = "luasnip" },
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'orgmode' }
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
})

View file

@ -1,40 +0,0 @@
"
" Defer command for starting work after vim has loaded
"
" This is biased from Greg Hurrell's Profiling and optimization screen cast in
" his implementation he is using the `CursorHold,CursorHoldI` auto command
" that didn't really work for me. This uses `timer_start` to set a timer when
" to start the work. This is then started on `VimEnter` when everything has
" loaded. There are two levels of defer one at `250ms` and `500ms` This is for
" calling functions that depend on something that has already been deferred.
"
" You can use this by adding a function to the user auto command `WincentSoftDefer`
"
" autocmd User WincentSoftDefer call s:do_work()
"
function HardDefer(timer)
augroup WincentIdleboot
autocmd!
augroup END
doautocmd User WincentHardDefer
autocmd! User WincentHardDefer
endfunction
function SoftDefer(timer)
augroup WincentIdleboot
autocmd!
augroup END
doautocmd User WincentSoftDefer
autocmd! User WincentSoftDefer
endfunction
augroup WincentIdleboot
autocmd!
if has('vim_starting')
autocmd VimEnter * call timer_start(250, 'SoftDefer')
autocmd VimEnter * call timer_start(500, 'HardDefer')
endif
augroup END

View file

@ -1,13 +0,0 @@
"
" Add deoplete plugin
"
function s:deoplete_init()
if has('nvim')
packadd deoplete
call deoplete#enable()
call deoplete#custom#source('ultisnips', 'rank', 9999)
endif
endfunction
"au User WincentHardDefer call s:deoplete_init()

View file

@ -1,12 +0,0 @@
"
" Init emmet on specified files
"
autocmd FileType html,css,scss,less,javascript.jsx,typescript.jsx call aa#emmet#init()
"let g:user_emmet_leader_key='<C-Z>'
"
" Make <c-e> expand emment expreson like sparkup did
"
"inoremap <silent> <c-e> <esc>:call emmet#expandAbbr(3,"")<cr>

View file

@ -0,0 +1,46 @@
" Open a file the same way you use :edit. This function will give you a prompt
" for a file with the default value of the directory the current file is in.
function s:open()
let file_name = expand(input("Open file: ", expand("%:h") . "/", "file"))
execute 'edit ' . file_name
endfunction
command! Open call s:open()
" Rename the current file on disk and remove all instances of it in vim and
" then switch to the new buffer.
function s:aa_rename()
let file_name = expand(input("New file name: ", expand("%:h") . "/", "file"))
if isdirectory(file_name) || filereadable(file_name)
echoerr "File '" . file_name . "' already exists unable to rename the file"
return
endif
" Rename the current file to the new name
let current_file = expand("%")
call rename(current_file, file_name)
" Remove the old buffer and remove it from the alternate file list and the
" jump list so you cant get back to this buffer with <C-o> or <C-^>
execute "bwipeout " . current_file
" Open the new file as a buffer
execute "edit " . file_name
endfunction
command! Rename call s:aa_rename()
" Copy the current buffer. This is the same as `saveas` with some checks
" around the new name of the file to prevent overriteing files that already
" exist.
function s:aa_copy()
let file_name = expand(input("New file name: ", expand("%:h") . "/", "file"))
if isdirectory(file_name) || filereadable(file_name)
echoerr "File '" . file_name . "' already exists unable to rename the file"
return
endif
" Rename the current file to the new name. This is run with `silent` to
" stop the write message from getting put in the status line.
silent execute "saveas " . file_name
endfunction
command! Copy call s:aa_copy()

View file

@ -1,183 +0,0 @@
if exists('g:vim_formatter_loaded')
finish
end
let g:vim_formatter_loaded = 1
"
" Set the global formatters definitions variable
"
if !exists('g:formatters')
let g:formatters = {}
endif
"
" Get the prettier config for the current project
"
if filereadable('./.prettierrc.js')
let s:prettier_config = '.prettierrc.js'
elseif filereadable('./.prettierrc')
let s:prettier_config = '.prettierrc'
else
let s:prettier_config = '~/.dotfiles/.prettierrc.js'
endif
"
" Set the base prettier command for formatting. This can be used on most of
" the file formats
"
let s:base_prettier_command = 'prettier --config ' . s:prettier_config . ' --stdin --stdin-filepath /tmp/formatted.'
"
" Typescript formatter definition
"
let g:formatters['typescript'] = s:base_prettier_command . 'ts'
let g:formatters['typescript.jsx'] = s:base_prettier_command . 'tsx'
"
" Javascript formatter definition
"
let g:formatters['javascript'] = s:base_prettier_command . 'js'
let g:formatters['javascript.jsx'] = s:base_prettier_command . 'jsx'
"
" HTML formatter definition
"
let g:formatters['html'] = s:base_prettier_command . 'html'
"
" Styling formatter definition
"
let g:formatters['css'] = s:base_prettier_command . 'css'
let g:formatters['scss'] = s:base_prettier_command . 'scss'
let g:formatters['less'] = s:base_prettier_command . 'less'
"
" JSON formatter definition
"
let g:formatters['json'] = s:base_prettier_command . 'json'
"
" YAML formatter definition
"
let g:formatters['yaml'] = s:base_prettier_command . 'yml'
"
" Markdown formatter definition
"
let g:formatters['markdown'] = s:base_prettier_command . 'md'
"
" Puppet formatter definition
"
let g:formatters['puppet'] = 'cat - > /tmp/format.pp && puppet-lint --no-autoloader_layout-check --fix /tmp/format.pp >/dev/null 2>&1 && cat /tmp/format.pp'
"
" PHP formatter definition
"
" This will use the `ruleset.xml` in the root of the project if one can be
" found. If not then it will fall back to use psr2 coding standards
"
if filereadable('./ruleset.xml')
let g:formatters['php'] = 'phpcbf --standard=./ruleset.xml -'
let g:formatters['php.class'] = 'phpcbf --standard=./ruleset.xml -'
else
let g:formatters['php'] = 'phpcbf --standard=psr2 -'
let g:formatters['php.class'] = 'phpcbf --standard=psr2 -'
endif
"
" Define if you want the plugin to format on save
"
if !exists('g:formatter_on_save')
let g:formatter_on_save = 1
endif
"
" Set the plugin to debug mode
"
if !exists('g:formatter_debug')
let g:formatter_debug = 1
endif
"
" Variable for enabling and disabling the formatters
"
if !exists('g:formatter_enabled')
let g:formatter_enabled = 1
endif
"
" Format the current buffers text biased on the file type and the formatters
" defined
"
function s:format()
"
" Exit is formatting has been disabled
"
if !g:formatter_enabled
return
endif
"
" Trim white space before formatting
"
%s/\s\+$//e
"
" Format the buffers content
"
let l:lines = s:format_text(join(getline(1, '$'), "\n"), &filetype)
"
" Replace the lines of the formatted text with the text in the buffer
"
call aa#buffer#Overwrite(1, line('$'), lines)
endfunction
"
" Formats defined lines biased on the type defined
"
" a:lines
" The text you want to format
"
" a:type
" The type formatter to use this will defined in the `g:formatters` variable
"
function s:format_text(lines, type)
let l:lines = a:lines
"
" Just return the lines if there is no formatters defined
"
if !exists("g:formatters['" . a:type . "']")
if g:formatter_debug == 1
echo '[formatter] No formatter defined for ' . a:type
endif
return split(lines, "\n")
endif
"
" Run the formatter command and return the output of the text
"
let l:command = g:formatters[a:type]
let l:formatted_lines = split(system(command, lines), "\n")
"
" Return original lines if formatter command returns an error
"
if v:shell_error > 1
echoerr '[formatter] ' . join(formatted_lines, "\n")
return split(lines, "\n")
endif
return formatted_lines
endfunction
"
" Defined the autocmd if the plugin is set to format on save
"
if g:formatter_on_save == 1
autocmd BufWritePre * call s:format()
endif

View file

@ -1,77 +0,0 @@
"
" Trims all traling white space from every line in a file
"
function! s:aa_trim_white_space()
%s/\s\+$//e
endfunction
command! -nargs=* -complete=file TrimWhiteSpace call s:aa_trim_white_space(<f-args>)
"
" Creates a new file or directory updateing the UI with and clearing the
" command t cache. This function uses the nerd tree functions to create files
" or directory. For more info on this you can open nerdtree and press `m` then
" `a` to add a node. If it is a file the file will be opened in a new buffer
"
" a:path
" Path to file or directory. Dirs end in /
"
function! s:aa_new(path)
call g:NERDTreePath.Create(a:path)
call commandt#Flush()
NERDTreeRefreshRoot
if filereadable(expand(a:path))
execute "e " . expand(a:path)
endif
endfunction
command! -nargs=1 -complete=file New call s:aa_new(<f-args>)
"
" Runs a shell command in the neovim terminal. This will open up a buffered
" terminal in a split at the bottom
"
" a:command
" The command you want the run in the terminal
"
function! s:aa_run(command)
if strlen($TMUX) > 0
if (&columns > 180)
let l:split = '-h'
else
let l:split = '-v'
endif
execute 'silent !tmux split-window -p 50 ' . l:split . ' && tmux send-keys "' . a:command . ' && exit" C-m'
return
endif
if has('nvim')
if (&columns > 180)
execute 'VTerm ' . a:command . ' && exit'
else
execute 'HTerm ' . a:command . ' && exit'
endif
endif
endfunction
command! -nargs=* -complete=shellcmd Run call s:aa_run(<q-args>)
"
" Git gutter alias commad commands to give them the same api as fugitive
"
command! GaddHunk :GitGutterStageHunk
command! GresetHunk :GitGutterUndoHunk
"
" Browse command to open urls in a browser. This is to help fugitive `Gbrowse`
" open urls in a browser rather that other programmes
"
function! s:browse(uri)
silent exec "!brave-browser '".a:uri."'"
endfunction
command! -nargs=1 Browse call s:browse(<f-args>)

View file

@ -1,4 +0,0 @@
"
" Enable js doc syntax
"
let g:javascript_plugin_jsdoc = 1

View file

@ -0,0 +1,47 @@
local lint = require('lint')
local severities = {
error = vim.diagnostic.severity.ERROR,
info = vim.diagnostic.severity.WARN,
}
lint.linters.psalm = {
cmd = 'psalm',
stdin = false,
args = {
'--output-format=json',
'--show-info=true'
},
-- ignore_exitcode = true,
parser = function(output, _)
if vim.trim(output) == '' then
return {}
end
local errors = vim.json.decode(output)
local diagnostics = {}
for _, err in ipairs(errors or {}) do
table.insert(diagnostics, {
lnum = err.line_from - 1,
end_lnum = err.line_to - 1,
col = err.column_from - 1,
end_col = err.column_to - 1,
message = err.message,
source = 'psalm',
severity = assert(severities[err.severity], 'missing mapping for severity ' .. err.severity),
})
end
return diagnostics
end
}
lint.linters_by_ft = {
php = {'phpcs'},
typescript = {'eslint'},
javascript = {'eslint'},
typescriptreact = {'eslint'},
javascriptreact = {'eslint'},
}

View file

@ -0,0 +1,51 @@
local lspconfig = require('lspconfig')
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
local opts = { noremap=true, silent=true }
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
-- TODO(ade): Sort out space. This will conflict with the leader key
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
end
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
capabilities.textDocument.completion.completionItem.snippetSupport = true
local servers = { 'tsserver', 'intelephense', 'psalm', 'gopls', 'html', 'cssls' }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup({
on_attach = on_attach,
capabilities = capabilities,
init_options = {
usePlaceholders = true,
}
})
end
lspconfig.emmet_ls.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = { 'html', 'typescriptreact', 'javascriptreact', 'css', 'scss' },
init_options = {
usePlaceholders = true,
}
})
-- Change the diagnostic signs
vim.fn.sign_define('DiagnosticSignError', { text = '', texthl = 'DiagnosticSignError', numhl = 'DiagnosticSignError' })
vim.fn.sign_define('DiagnosticSignHint', { text = '', texthl = 'DiagnosticSignHint', numhl = 'DiagnosticSignHint' })
vim.fn.sign_define('DiagnosticSignInfo', { text = '', texthl = 'DiagnosticSignInfo', numhl = 'DiagnosticSignInfo' })
vim.fn.sign_define('DiagnosticSignWarn', { text = '', texthl = 'DiagnosticSignWarn', numhl = 'DiagnosticSignWarn' })

View file

@ -1,38 +0,0 @@
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() :
\"\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
nmap <silent> gd <Plug>(coc-definition)
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
function! s:open_as_preview(callstr)
" e.g. the string should look like: +call cursor(<line>,<col>) <filename>
let m = matchlist(a:callstr, '^+call cursor(\(\d\+\),\s*\(\d\+\))\s\+\(.*\)')
if len(m) < 4 " TODO: more robust error handling
echohl WarningMsg | echom "ERROR: Invalid callstr format" | echohl None
return
endif
let linenr = m[1]
let filename = expand(m[3])
call quickui#preview#open(filename, {
\ 'cursor': linenr,
\ 'number' : 1,
\ 'persist': 0,
\ })
endfunction
command! -nargs=0 PreviewDefinition :call CocActionAsync('jumpDefinition', ':OpenAsPreview')
command! -nargs=* OpenAsPreview :call s:open_as_preview("<args>")
autocmd CursorHold * silent call CocActionAsync('highlight')

View file

@ -1,34 +0,0 @@
" Check if NERDTree is open or active
function! s:isNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
" file, and we're not in vimdiff
function! s:syncTree()
if &modifiable && s:isNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
function! ToggleNerdTree()
if s:isNERDTreeOpen()
NERDTreeClose
return
endif
set eventignore=BufEnter
NERDTreeFind
set eventignore=
endfunction
function s:nerdtree_init()
nmap <silent> <Leader>o :call ToggleNerdTree()<CR>
autocmd BufEnter * call s:syncTree()
packadd nerdtree
endfunction
au User WincentSoftDefer call s:nerdtree_init()

View file

@ -0,0 +1,11 @@
-- TODO(ade): Set up org capture into the website node dir
-- See https://github.com/AdeAttwood/Dotfiles/blob/86bf86d2010d7ec7b579e7b1c06632d5955f0a3c/site-modules/core/files/emacs/src/org.el#L107
require('orgmode').setup({
org_agenda_files = {'~/Code/src/github.com/AdeAttwood/Website/data/*'},
})
-- Dont folt heading on load.
vim.cmd[[autocmd FileType org setlocal nofoldenable]]
require('orgmode').setup_ts_grammar()

View file

@ -0,0 +1,100 @@
local ls = require('luasnip')
local s = ls.snippet
local sn = ls.snippet_node
local i = ls.insert_node
local f = ls.function_node
local t = ls.text_node
local d = ls.dynamic_node
local fmt = require('luasnip.extras.fmt').fmt
function p (trig, desc, snip)
return ls.parser.parse_snippet(
{ trig = trig, dscr = desc },
table.concat(snip, '\n')
)
end
ls.config.setup({
store_selection_keys="<Tab>",
update_events="InsertLeave,TextChangedI",
})
ls.add_snippets("all", {
p('todo', 'Todo comment', { 'TODO(${1:ade}): $0' })
})
ls.add_snippets("org", {
p('org-header', 'Org mode header block', {
'#+TITLE: $0',
'#+AUTHOR: Ade Attwood',
'#+EMAIL: hello@adeattwood.co.uk',
'#+DATE: $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}'
})
})
ls.add_snippets("php", {
p('#!', 'Shebang', { '#!/usr/bin/env php' }),
p( '/**', 'Block comment', {
'/**',
' * ${0}',
' */'
}),
s(
{trig = 'this', dscr = 'This shorthand'},
fmt("$this->{}", {
i(0),
})
),
s(
{trig = 'ai', dscr = 'Array item'},
fmt("'{}' => {}", {
i(1),
i(0),
})
)
})
local js_ts = {
p('#!', 'Shebang', { '#!/usr/bin/env node' }),
s(
{trig = 'import', dscr = 'Import statement'},
fmt("import {} from '{}'", {
i(0),
i(1)
})
),
s({trig = 'fn', dscr = 'Function'}, {
t('function '),
i(1),
t('('),
i(2),
t(')'),
t({' {', '\t'}),
i(0),
t({'', '}'})
}),
s({trig = 'useState', dscr = 'React useState hook'}, {
t('const ['),
i(1, 'state'),
t(', '),
f(function (args)
if args[1] == nil then
return ''
end
return 'set' .. args[1][1]:gsub("^%l", string.upper)
end, {1}),
t('] = React.useState('),
i(0),
t(');')
}),
p('log', 'Console log statement', { 'console.log(${0});' })
}
ls.add_snippets("typescriptreact", js_ts)
ls.add_snippets("typescript", js_ts)

View file

@ -0,0 +1,10 @@
" The most basic status line ever
function GitStatus()
return trim(system("git diff --shortstat 2> /dev/null | awk '{print \"+\"$4\" -\"$6}'"))
endfunction
function GitBranch()
return trim(system("git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'no-git'"))
endfunction
set statusline=\ %y%r\ %m%f:%l:%c%=[%{GitBranch()}]\ %{GitStatus()}\

View file

@ -1,78 +0,0 @@
"
" All of the good bits from `split_term`
" https://github.com/vimlab/split-term.vim/blob/master/plugin/split-term.vim
"
let s:force_vertical = exists('g:split_term_vertical') ? 1 : 0
let s:default_shell = exists('g:split_term_default_shell') ? g:split_term_default_shell : 0
au BufEnter * if &buftype == 'terminal' | :startinsert | endif
"
" Set split directions
"
set splitbelow
set splitright
" Opens up a new buffer, either vertical or horizontal. Count can be used to
" specify the number of visible columns or rows.
fun! s:openBuffer(count, vertical)
let cmd = a:vertical ? 'vnew' : 'new'
let cmd = a:count ? a:count . cmd : cmd
exe cmd
endf
" Opens a new terminal buffer, but instead of doing so using 'enew' (same
" window), it uses :vnew and :new instead. Usually, I want to open a new
" terminal and not replace my current buffer.
fun! s:openSplitTerm(args, count, vertical)
let direction = s:force_vertical ? 1 : a:vertical
call s:openBuffer(a:count, direction)
call s:openTerm(a:args)
endf
" Opens a new terminal buffer, but instead of doing so using split buffer, it
" uses :tabnew instead.
fun! s:openTabTerm(args)
exe 'tabnew'
call s:openTerm(a:args)
endf
" Open a new terminal in the active buffer, while defining default mappings
" for this plugin.
fun! s:openTerm(args)
let prevShell = &shell
if exists('g:split_term_default_shell')
exe 'set shell =' . s:default_shell
endif
exe 'terminal' a:args
"
" Turn off line numbers in terminal mode
"
call aa#functions#number_off(1)
exe 'startinsert'
"
" Add teminal mappings
"
tnoremap <buffer> <Esc> <C-\><C-n>
tnoremap <buffer> <expr> <C-v> '<C-\><C-N>pi'
tnoremap <buffer> <c-h> <C-\><C-n><C-w>h
tnoremap <buffer> <c-j> <C-\><C-n><C-w>j
tnoremap <buffer> <c-k> <C-\><C-n><C-w>k
tnoremap <buffer> <c-l> <C-\><C-n><C-w>l
if exists('g:split_term_default_shell')
exe 'set shell =' . prevShell
endif
endf
command! -count -nargs=* Term call s:openTerm(<q-args>)
command! -count -nargs=* VTerm call s:openSplitTerm(<q-args>, <count>, 1)
command! -count -nargs=* HTerm call s:openSplitTerm(<q-args>, <count>, 0)
command! -nargs=* TTerm call s:openTabTerm(<q-args>)

View file

@ -0,0 +1,12 @@
require'nvim-treesitter.configs'.setup {
indent = { enable = true },
rainbow = { enable = true },
highlight = {
-- `false` will disable the whole extension
enable = true,
additional_vim_regex_highlighting = true,
},
ensure_installed = {
"typescript", "javascript", "tsx", "php", "html", "go", "org"
},
}

View file

@ -1,16 +0,0 @@
"
" Config for UltiSnips config
"
let g:UltiSnipsSnippetsDir = "~/.vim/UltiSnips"
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:snips_author = "Ade Attwood"
let g:snips_email = "code@adeattwood.co.uk"
"
" Run super tab script on UltiSnipsExpandTrigger to enable ultisnips and emmet
" on tab press
"
au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=aa#supertab#expand()<cr>"

View file

@ -84,7 +84,7 @@ fi
#
source $ZSH/oh-my-zsh.sh
export EDITOR="emacsclient -nw"
export EDITOR="vim"
#
# Import local alases if the file exists

View file

@ -1,64 +1,79 @@
class core::vim {
file { "${user_home}/.vim":
file { "${user_home}/.config/nvim":
ensure => 'directory',
force => true,
owner => $user,
}
file { "${user_home}/.config/nvim/after":
ensure => 'link',
force => true,
owner => $user,
target => find_file('core/vim'),
target => find_file('core/vim/after'),
}
file { "${user_home}/.vimrc":
file { "${user_home}/.config/nvim/ftplugin":
ensure => 'link',
force => true,
owner => $user,
target => find_file('core/vim/ftplugin'),
}
file { "${user_home}/.config/nvim/plugin":
ensure => 'link',
force => true,
owner => $user,
target => find_file('core/vim/plugin'),
}
file { "${user_home}/.config/nvim/spell":
ensure => 'link',
force => true,
owner => $user,
target => find_file('core/vim/spell'),
}
file { "${user_home}/.config/nvim/init.vim":
ensure => 'link',
force => true,
owner => $user,
target => find_file('core/vim/init.vim'),
}
file { "${user_home}/.config/nvim":
ensure => 'link',
force => true,
owner => $user,
target => find_file('core/vim'),
}
$plugins_start= {
'auto-pairs' => { url => 'https://github.com/jiangmiao/auto-pairs.git' },
'base16-vim' => { url => 'https://github.com/chriskempson/base16-vim.git' },
'vim-easy-align' => { url => 'https://github.com/junegunn/vim-easy-align.git' },
'auto-pairs' => { url => 'git://github.com/jiangmiao/auto-pairs.git' },
'indent-line' => { url => 'https://github.com/Yggdroot/indentLine.git' },
'nerdcommenter' => { url => 'https://github.com/scrooloose/nerdcommenter.git' },
'pdv' => { url => 'https://github.com/tobyS/pdv.git' },
'vim-airline' => { url => 'https://github.com/vim-airline/vim-airline' },
'vim-fugitive' => { url => 'git://github.com/tpope/vim-fugitive.git' },
'vim-tmux-navigator' => { url => 'https://github.com/christoomey/vim-tmux-navigator.git' },
'ultisnips' => { url => 'https://github.com/SirVer/ultisnips.git' },
'vim-airline-themes' => { url => 'https://github.com/vim-airline/vim-airline-themes.git' },
'vim-javascript' => { url => 'https://github.com/pangloss/vim-javascript.git' },
'vim-jsx' => { url => 'https://github.com/mxw/vim-jsx.git' },
'command-t' => { url => 'https://github.com/wincent/command-t.git' },
'cmp_luasnip' => { url => 'https://github.com/saadparwaiz1/cmp_luasnip.git' },
'cmp-buffer' => { url => 'https://github.com/hrsh7th/cmp-buffer.git', revision => 'main' },
'cmp-nvim-lsp' => { url => 'https://github.com/hrsh7th/cmp-nvim-lsp.git', revision => 'main' },
'cmp-path' => { url => 'https://github.com/hrsh7th/cmp-path.git', revision => 'main' },
'Comment.nvim' => { url => 'https://github.com/numToStr/Comment.nvim.git' },
'ferret' => { url => 'https://github.com/wincent/ferret.git' },
#
# Nerdtree has now been loaded after vim start up
#
'nerdtree' => {
ensure => 'absent',
url => 'https://github.com/scrooloose/nerdtree.git',
},
}
exec { 'Compile command t':
path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ],
command => 'ruby extconf.rb && make',
cwd => "${find_file('core/vim')}/pack/bundle/start/command-t/ruby/command-t/ext/command-t",
provider => 'shell',
#require => [Vim::Plugin_start[command-t]],
'indent-line' => { url => 'https://github.com/Yggdroot/indentLine.git' },
'LuaSnip' => { url => 'https://github.com/L3MON4D3/LuaSnip.git' },
'nvim-cmp' => { url => 'https://github.com/hrsh7th/nvim-cmp.git', revision => 'main' },
'nvim-lint' => { url => 'https://github.com/mfussenegger/nvim-lint.git' },
'nvim-lspconfig' => { url => 'https://github.com/neovim/nvim-lspconfig.git' },
'nvim-treesitter' => { url => 'https://github.com/nvim-treesitter/nvim-treesitter.git' },
'orgmode' => { url => 'https://github.com/nvim-orgmode/orgmode.git' },
'vim-puppet' => { url => 'https://github.com/rodjek/vim-puppet.git' },
'vim-surround' => { url => 'https://github.com/tpope/vim-surround.git' },
'vim-tmux-navigator' => { url => 'https://github.com/christoomey/vim-tmux-navigator.git' },
}
create_resources(core::vim::plugin_start, $plugins_start)
$plugins_opt= {
'emmet-vim' => { url => 'https://github.com/mattn/emmet-vim.git' },
'nerdtree' => { url => 'https://github.com/scrooloose/nerdtree.git' },
'command-t' => { url => 'https://github.com/wincent/command-t.git' },
}
create_resources(core::vim::plugin_opt, $plugins_opt)
exec { 'Compile command t':
path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ],
command => 'ruby extconf.rb && make',
cwd => "${user_home}/.config/nvim/pack/bundle/opt/command-t/ruby/command-t/ext/command-t",
provider => 'shell',
#require => [Vim::Plugin_start[command-t]],
}
}

View file

@ -7,7 +7,7 @@
name = <%= scope.call_function('lookup', ["user_name"]) %>
[core]
editor = $ZSH/plugins/emacs/emacsclient.sh -nw
editor = vim
autocrlf = input
[merge]