forked from vim-scripts/h2cppx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
96 lines (63 loc) · 2.58 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
h2cppx(vim-port): Parse C++ header files and generate C++ implementation code
===========================================================================
**This is a Python 3 port of:** [https://github.com/vim-scripts/h2cppx](https://github.com/vim-scripts/h2cppx)
**Purpose:** Parse the C++ header file and generate C++ implementation code
**Required:** Python 3.x
**Author:** xiaok
**Python modules required:**
cheetah3 yaml
**Already included modules:**
pyvisitor CppHeaderParser (modified)
Installation
------------
Make sure you have "yaml" and "cheetah3" modules installed:
pip install cheetah3 yaml
Use your favorite plugin manager to install the plugin:
Example fo vim-plug:
Add `Plug 'coldspark29/h2cppx-vim'` to ~/.vimrc and install it,then:
Mapping example:
e.g.:
nmap <F3> :H2cppx<ESC>
nmap <F4> :H2cppxLine<ESC>
nmap <F3>p :CpH2cppx<ESC>
nmap <F4>p :CpH2cppxLine<ESC>
nmap <F5> :H2cppxAuto<ESC>
Configuration
------
If the plugin can't find the python path in your computer,
you need set `g:python_path` in the .vimrc file:
let g:h2cppx_python_path = '/usr/bin/python'
You can specify the file name extension as follows:
(default is `.cpp`)
let g:h2cppx_postfix = 'cxx'
Five code-generation template files are provided by default.
You can configure them in `.vimrc` by specifiying templates 0-4:
(default is `template1`)
let g:h2cppx_template = 'template4'
If needed, you can refer to the default template and write your own template
files. Use the absolute path to configure it:
let g:h2cppx_template = '/home/xxx/.../xxx'
Finally, you can add a configuration file `.h2cppx_conf` in your project
directory to help the plugin search for a .cpp file. Otherwise the plugin will use
`.cpp` file in your header file directory.
The configuration file might look like:
/home/test/temp/src
src1
src2
See the project_sample directory.
Usage
-----
The plugin function description:
* :H2cppx
Parse the C++ header file and generate .cpp file with the same name
* :CpH2cppx
Store file content in the register instead of creating a file. Paste with "p".
* :H2cppxLine
Generate C++ code of the line under the cursor, and append it at the end of the .cpp file.
* :CpH2cppxLine
Generate C++ code of the line under the cursor and store it in a register. Paste with "p".
* :H2cppxAuto (Recommended)
Auto Contrast header and implementation files. Find
function declarations in the header file and append
the newly added to the implementation file. If the
file does not exist a new file is created!