Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Copied snippets from base modes to TreeSitter modes. #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/acm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: accumulate
# key: acm
# --
auto sum = std::accumulate(std::begin(${1:container}), std::end($1), 0);
$0
9 changes: 9 additions & 0 deletions snippets/c++-ts-mode/ajf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: adjacent_find
# key: ajf
# --
auto pos = std::adjacent_find(std::begin(${1:container}), std::end($1));
if (pos != std::end($1)) {
$2
}
$0
10 changes: 10 additions & 0 deletions snippets/c++-ts-mode/alo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: all_of
# key: alo
# --
if (std::all_of(std::begin(${1:container}), std::end($1), []($2) {
$3
})) {
$4
}
$0
10 changes: 10 additions & 0 deletions snippets/c++-ts-mode/ano
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: any_of
# key: ano
# --
if (std::any_of(std::begin(${1:container}), std::end($1), []($2) {
$3
})) {
$4
}
$0
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/assert
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: assert
# key: ass
# --
assert($0);
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/beginend
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: v.begin(), v.end()
# key: beginend
# --
${1:v}.begin(), $1.end()
7 changes: 7 additions & 0 deletions snippets/c++-ts-mode/boost_require
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: boost_require
# key: req
# group: boost
# --
BOOST_REQUIRE( ${1:condition} );
$0
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/cerr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: cerr
# key: err
# --
cerr << $0;
7 changes: 7 additions & 0 deletions snippets/c++-ts-mode/cin
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: cin
# key: cin
# --
`(progn (goto-char (point-min)) (unless (re-search-forward
"^using\\s-+namespace std;" nil 'no-error) "std::"))
`cin >> $0;
11 changes: 11 additions & 0 deletions snippets/c++-ts-mode/class
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: class
# key: cls
# --
class ${1:Name}
{
public:
${1:$(yas-c++-class-name yas-text)}();
${2:virtual ~${1:$(yas-c++-class-name yas-text)}();}
};
$0
46 changes: 46 additions & 0 deletions snippets/c++-ts-mode/class11
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- mode: snippet -*-
# name: class11
# key: cls11
# group: c++11
# uuid: d7c41f87-9b8a-479d-bb12-89f4cbdd46a7
# contributor: Ved Vyas
#
## Snippet for C++11 classes based on c++-mode/class. Allows for Rule of
## [0, All]. A choice between ";", " = default;", and " = delete;" is presented
## for each method. The methods and some of the optional keywords/specifiers are
## exposed as fields that users can easily skip-and-clear.
## Hackish query-replace-regexp to renumber non-mirror fields in the region
## between public and protected (can use N as a field number in the snippet):
## \${[0-9N]*:\([^\$]\) -> ${\,(+ 2 \#):\1
##
## References
## 1. http://en.cppreference.com/w/cpp/language/rule_of_three#Rule_of_five
## 2. https://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29#Example_in_C.2B.2B
## 3. http://stackoverflow.com/a/4782927
# --
class ${1:Name}
{
public:
${2: ${3://! Default constructor
}${1:$(yas-c++-class-name yas-text)}()${4:;$(yas-c++-class-method-declare-choice)}

}${5: ${6://! Copy constructor
}${1:$(yas-c++-class-name yas-text)}(const ${1:$(yas-c++-class-name yas-text)} &other)${7:;$(yas-c++-class-method-declare-choice)}

}${8: ${9://! Move constructor
}${1:$(yas-c++-class-name yas-text)}(${1:$(yas-c++-class-name yas-text)} &&other)${10: noexcept}${11:;$(yas-c++-class-method-declare-choice)}

}${12: ${13://! Destructor
}${14:virtual }~${1:$(yas-c++-class-name yas-text)}()${15: noexcept}${16:;$(yas-c++-class-method-declare-choice)}

}${17: ${18://! Copy assignment operator
}${1:$(yas-c++-class-name yas-text)}& operator=(const ${1:$(yas-c++-class-name yas-text)} &other)${19:;$(yas-c++-class-method-declare-choice)}

}${20: ${21://! Move assignment operator
}${1:$(yas-c++-class-name yas-text)}& operator=(${1:$(yas-c++-class-name yas-text)} &&other)${22: noexcept}${23:;$(yas-c++-class-method-declare-choice)}

}$0

protected:
private:
};
8 changes: 8 additions & 0 deletions snippets/c++-ts-mode/cni
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: count_if
# key: cni
# --
auto n = std::count_if(std::begin(${1:container}), std::end($1), []($2) {
$3
});
$0
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/cnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: count
# key: cnt
# --
auto n = std::count(std::begin(${1:container}), std::end($1), $2);
$0
8 changes: 8 additions & 0 deletions snippets/c++-ts-mode/const_[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: const_[]
# key: c[
# --
const ${1:Name}& operator[](${2:int index}) const
{
$0
}
8 changes: 8 additions & 0 deletions snippets/c++-ts-mode/constructor
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: constructor
# key: ct
# --
${1:Name}::$1(${2:args}) ${3: : ${4:init}}
{
$0
}
8 changes: 8 additions & 0 deletions snippets/c++-ts-mode/cout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: York Zhao <[email protected]>
# name: cout
# key: cout
# --
`(progn (goto-char (point-min)) (unless (re-search-forward
"^using\\s-+namespace std;" nil 'no-errer) "std::"))
`cout << $0${1:} << "${2:\n}";
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/cpb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: copy_backward
# key: cpb
# --
std::copy_backward(std::begin(${1:container}), std::end($1), std::end($1));
$0
9 changes: 9 additions & 0 deletions snippets/c++-ts-mode/cpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: copy_if
# key: cpi
# --
std::copy_if(std::begin(${1:container}), std::end($1), std::begin($2),
[]($3) {
$4
});
$0
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/cpn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: copy_n
# key: cpn
# --
std::copy_n(std::begin(${1:container}), $2, std::end($1));
$0
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: cpp
# key: cpp
# --
#include "`(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`.h"
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/cpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: copy
# key: cpy
# --
std::copy(std::begin(${1:container}), std::end($1), std::begin($2));
$0
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/cstd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: cstd
# key: cstd
# --
#include <cstdlib>
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/d+=
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: d+=
# key: d+=
# --
${1:Name}& operator+=(${2:const $1 &});
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/d_operator
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: d_operator<<
# key: <<
# --
friend std::ostream& operator<<(std::ostream&, const ${1:Name}&);
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/d_operator[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: d_operator[]
# key: [
# --
${1:Name}& operator[](${2:int index});
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/d_operator[]_const
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: d_operator[]_const
# key: c[
# --
const ${1:Name}& operator[](${2:int index}) const;
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/d_operator_istream
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: d_operator>>
# key: >>
# --
friend std::istream& operator>>(std::istream&, const ${1:Name}&);
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: delete
# key: dl
# --
delete ${1:pointer};
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/delete[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: delete[]
# key: dla
# --
delete[] ${1:arr};
7 changes: 7 additions & 0 deletions snippets/c++-ts-mode/doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: doc
# key: doc
# --
/**
* $0
*/
5 changes: 5 additions & 0 deletions snippets/c++-ts-mode/dynamic_casting
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: dynamic_casting
# key: cast
# --
check_and_cast<${1:Name} *>(${2:msg});
7 changes: 7 additions & 0 deletions snippets/c++-ts-mode/enum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: enum
# key: enum
# --
enum ${1:NAME}{
$0
};
8 changes: 8 additions & 0 deletions snippets/c++-ts-mode/eql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: equal
# key: eql
# --
if (std::equal(std::begin(${1:container}), std::end($1), std::begin($2))) {
$3
}
$0
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/erm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: remove
# key: erm
# --
${1:container}.erase(std::remove(std::begin($1), std::end($1), $2), std::end($1));
$0
10 changes: 10 additions & 0 deletions snippets/c++-ts-mode/ffo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: find_first_of
# key: ffo
# --
auto pos = std::find_first_of(std::begin(${1:container}), std::end($1),
std::begin($2), std::end($3));
if (pos != std::end($1)) {
$4
}
$0
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/fil
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: fill
# key: fil
# --
std::fill(std::begin(${1:container}), std::end($1), $2);
$0
11 changes: 11 additions & 0 deletions snippets/c++-ts-mode/fin
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: find_if_not
# key: fin
# --
auto pos = std::find_if_not(std::begin(${1:container}), std::end($1),[]($2) {
$3
});
if (pos != std::end($1)) {
$4
}
$0
9 changes: 9 additions & 0 deletions snippets/c++-ts-mode/fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: fixture
# key: fixt
# --
BOOST_FIXTURE_TEST_SUITE( ${1:name}, ${2:Fixture} )

$0

BOOST_AUTO_TEST_SUITE_END()
6 changes: 6 additions & 0 deletions snippets/c++-ts-mode/fln
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: fill_n
# key: fln
# --
std::fill_n(std::begin(${1:container}), $2, $3);
$0
9 changes: 9 additions & 0 deletions snippets/c++-ts-mode/fnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: find
# key: fnd
# --
auto pos = std::find(std::begin(${1:container}), std::end($1), $2);
if (pos != std::end($1)) {
$3
}
$0
10 changes: 10 additions & 0 deletions snippets/c++-ts-mode/fne
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: find_end
# key: fne
# --
auto pos = std::find_std::end(std::begin(${1:container}), std::end($1),
std::begin($2), std::end($3));
if (pos != std::end($1)) {
$4
}
$0
11 changes: 11 additions & 0 deletions snippets/c++-ts-mode/fni
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: find_if
# key: fni
# --
auto pos = std::find_if(std::begin(${1:container}), std::end($1), []($2) {
$3
});
if (pos != std::end($1)) {
$4
}
$0
Loading