adjust snippets usage to the right track with neosnippets

This commit is contained in:
hophacker 2020-09-19 22:10:40 +08:00
parent 9ec9e357b2
commit 4441261cb6
9 changed files with 26 additions and 168 deletions

View File

@ -1,84 +0,0 @@
snippet reactConnectedRoute "React template" b
import React from 'react'
import { connect } from 'react-redux'
import { isLogin } from 'utils/self'
import { Redirect, Route } from 'react-router-dom'
export default connect((state, ownProps) => {
const { self } = state
return { self }
})(({ component: Component, ...rest }) => {
const { self } = rest
return <Route
{...rest}
render={props => isLogin(self) ? <Component {...props} /> : <Redirect
to={{
pathname: '/login',
state: { from: props.location }
}} />
}
/>
})
endsnippet
snippet reactComponent "React template" b
import React, { Component } from 'react'
export default class extends Component {
render () {
}
}
endsnippet
snippet reactConnect "React template" b
import component from './component'
import { connect } from 'react-redux'
export default connect((state, ownProps) => ({
}), {
})(component)
endsnippet
snippet TODO "Javascript Todo" b
// TODO: ${1:desc} `echo $USER` `!v strftime("%c")` ${2}
endsnippet
snippet connect "react redux connect" b
export default connect((state, ownProps) => {
return {
}
})($1)
endsnippet
snippet Card "Default Expandable Card" b
<Card initiallyExpanded={false} className="MT-5">
<CardTitle showExpandableButton title="$1" />
<CardText expandable>
</CardText>
<CardActions expandable>
<RaisedButton primary label="保存" onTouchTap={$2} />
</CardActions>
</Card>
endsnippet
snippet redux "redux" b
export const SET_${1/\w/\u$0/g} = 'SET_${1/\w/\u$0/g}'
import {store} from 'redux/store'
import {Map} from 'immutable'
export default function (${1} = Map({}), action) {
// let {$1Id} = action
switch (action.type) {
case SET_${1/\w/\u$0/g}:
return action.$1
default:
return $1
}
}
export function set${1/\w+\s*/\u$0/} ($1) {
store.dispatch({
type: SET_${1/\w/\u$0/g},
$1
})
}
endsnippet

View File

@ -1,42 +0,0 @@
snippet options "bash command options" b
while true; do
case "\$1" in
-a | --asset )
ASSET=true; shift ;;
-e | --environment )
case "\$2" in
"production" | "development")
RAILS_ENV=$\2
ACCOUNT_ROOT=http://account.rallets.com/
SERVER_ROOT=http://rallets.com/
shift 2
;;
*)
RAILS_ENV=development
ACCOUNT_ROOT=http://account.rallets.com/
SERVER_ROOT=http://apitest.rallets.com/
shift 2
;;
esac
;;
-d | --delayed-job )
DELAYED_JOB=true; shift ;;
-- ) shift; break ;;
-h | --help )
echo "usage:
[-a | --asset] precompile assets
[-d | --delayed-job] run delayed job for queuing sending emails
[-e | --environment] provides environment which rails will run in
[-h | --help] view manual
"
exit;;
* ) break ;;
esac
done
endsnippet
snippet OS "Determine whether it's Mac/Linux/Windows" b
if [ "$(uname)" == "Darwin" ]; then
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
fi
endsnippet

View File

@ -1,6 +0,0 @@
snippet Host "Description" b
Host ${1}
Hostname ${2}
IdentityFile ~/.ssh/rallets
User root
endsnippet

View File

@ -1,18 +0,0 @@
snippet getopts "Deal with shell parameters" b
BOOL=false
VAVLUE=''
while getopts ":bv:" o; do
case "${o}" in
b)
BOOL=true
;;
v)
VALUE=${OPTARG}
;;
*)
echo "Usage: $1 [-b] [-v VALUE]"
return
;;
esac
done
endsnippet

View File

@ -13,8 +13,6 @@ let vimsettings = '~/.yadr/SpaceVim.d/autoload/settings'
let uname = system("uname -s")
for fpath in split(globpath(vimsettings, '*.vim'), '\n')
echom fpath
if (fpath == expand(vimsettings) . "/yadr-keymap-mac.vim") && uname[:4] ==? "linux"
continue " skip mac mappings for linux
endif

View File

@ -0,0 +1,19 @@
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-e> <Plug>(neosnippet_expand_or_jump)
smap <C-e> <Plug>(neosnippet_expand_or_jump)
xmap <C-e> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif

View File

@ -1,15 +0,0 @@
let vimsettings = '~/.vim/settings'
let uname = system("uname -s")
for fpath in split(globpath(vimsettings, '*.vim'), '\n')
if (fpath == expand(vimsettings) . "/yadr-keymap-mac.vim") && uname[:4] ==? "linux"
continue " skip mac mappings for linux
endif
if (fpath == expand(vimsettings) . "/yadr-keymap-linux.vim") && uname[:4] !=? "linux"
continue " skip linux mappings for mac
endif
exe 'source' fpath
endfor

View File

@ -1,4 +1,3 @@
echom 'shit'
" ========================================
" General vim sanity improvements
" ========================================

View File

@ -0,0 +1,7 @@
snippet OS
options head
abbr determine OS type(Mac/Linux/Windows)
if [ "$(uname)" == "Darwin" ]; then
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
fi