I broke up with neovim....vim is my best friend now
This commit is contained in:
710
dot_vim/plugged/vim-project/doc/project.txt
Normal file
710
dot_vim/plugged/vim-project/doc/project.txt
Normal file
@@ -0,0 +1,710 @@
|
||||
*project.txt* Plugin for managing multiple projects with multiple sources
|
||||
For Vim version 6.x and Vim version 7.x.
|
||||
Last Change: Fri 13 Oct 2006 10:20:13 AM EDT
|
||||
|
||||
|
||||
By Aric Blumer
|
||||
aricvim email-at-sign charter.net
|
||||
|
||||
*project* *project-plugin*
|
||||
Contents:
|
||||
|
||||
Commands...................|project-invoking|
|
||||
Inheritance.............|project-inheritance|
|
||||
Mappings...................|project-mappings|
|
||||
Adding Mappings.....|project-adding-mappings|
|
||||
Settings...................|project-settings|
|
||||
Example File................|project-example|
|
||||
Tips...........................|project-tips|
|
||||
|
||||
|
||||
You can use this plugin's basic functionality to set up a list of
|
||||
frequently-accessed files for easy navigation. The list of files will be
|
||||
displayed in a window on the left side of the Vim window, and you can press
|
||||
<Return> or double-click on filenames in the list to open the files. I find
|
||||
this easier to use than having to navigate a directory hierarchy with the
|
||||
|file-explorer|.
|
||||
|
||||
You can also instruct the Plugin to change to a directory and to run Vim
|
||||
scripts when you select a file. These scripts can, for example, modify the
|
||||
environment to include compilers in $PATH. This makes it very easy to use
|
||||
quickfix with multiple projects that use different environments.
|
||||
|
||||
Other features include:
|
||||
o Loading/Unloading all the files in a Project (\l, \L, \w, and \W)
|
||||
o Grepping all the files in a Project (\g and \G)
|
||||
o Running a user-specified script on a file (can be used to launch an
|
||||
external program on the file) (\1 through \9)
|
||||
o Running a user-specified script on all the files in a Project
|
||||
(\f1-\f9 and \F1-\F9)
|
||||
o High degree of user-configurability
|
||||
o Also works with |netrw| using the XXXX://... notation where XXXX is
|
||||
ftp, rcp, scp, or http.
|
||||
|
||||
All of this is specified within a simple text file and a few global variables
|
||||
in your vimrc file.
|
||||
|
||||
You must set 'nocompatible' in your |vimrc| file to use this plugin. You can
|
||||
stop the plugin from being loaded by setting the "loaded_project" variable: >
|
||||
:let loaded_project = 1
|
||||
|
||||
|
||||
==============================================================================
|
||||
COMMANDS *project-invoking*
|
||||
|
||||
You can use the plugin by placing it in your plugin directory (e.g.,
|
||||
~/.vim/plugin). See |add-global-plugin|. When you start vim the next time, you
|
||||
then enter the command >
|
||||
:Project
|
||||
or >
|
||||
:Project {file}
|
||||
|
||||
If you do not specify the filename, $HOME/.vimprojects is used.
|
||||
|
||||
To have Vim come up with the Project Window enabled automatically (say, from a
|
||||
GUI launcher), run Vim like this: [g]vim +Project
|
||||
|
||||
Note that you can invoke :Project on only one file at a time. If you wish to
|
||||
change the Project File, do a :bwipe in the Project Buffer, then re-invoke the
|
||||
Plugin as described above.
|
||||
|
||||
Several Projects can be kept and displayed in the same file, each in a fold
|
||||
delimited by { and } (see |fold.txt|). There can be any number of nested
|
||||
folds to provide you with a Project hierarchy. Any line without a { or a } in
|
||||
the file is considered to be a filename. Blank lines are ignored, and any
|
||||
text after a # is ignored.
|
||||
|
||||
Because the plugin uses standard Vim folds, you can use any of the
|
||||
|fold-commands|. You can double-click on the first line of a fold to open and
|
||||
close it. You can select a file to open by putting the cursor on its name and
|
||||
pressing <Return> or by double-clicking on it. The plugin will create a new
|
||||
window to the right or use the |CTRL-W_p| equivalent if it exists.
|
||||
|
||||
*project-syntax*
|
||||
Each Project Entry has this form:
|
||||
|
||||
project_entry ::=
|
||||
<Description>={projpath} [{options}] {
|
||||
[ filename ]
|
||||
[ project_entry ]
|
||||
}
|
||||
|
||||
{options} is one or more of the following (on the same line):
|
||||
CD={path}
|
||||
in={filename}
|
||||
out={filename}
|
||||
filter="{pat}"
|
||||
flags={flag}
|
||||
|
||||
Note that a project_entry can reside within a project_entry. This allows you
|
||||
to set up a hierarchy within your Project.
|
||||
|
||||
The <Description> will be displayed in the foldtext and cannot contain "=".
|
||||
There can be no space character directly on either side of the =.
|
||||
|
||||
The {projpath} is the path in which the files listed in the Project's fold
|
||||
will be found, and it may contain environment variables. If the path is a
|
||||
relative path, then the plugin constructs the whole path from the Project's
|
||||
parent, grandparent, etc., all the way up the hierarchy. An outermost
|
||||
project_entry must have an absolute path. See the |project-inheritance|
|
||||
example below. {projpath} may contain spaces, but they must be escaped like
|
||||
normal Vim escapes. Here are two examples of the same directory:
|
||||
>
|
||||
Example=/my/directory/with\ spaces {
|
||||
}
|
||||
Example="/my/directory/with spaces" {
|
||||
}
|
||||
|
||||
I recommend this for Windows<77>: >
|
||||
|
||||
Example="c:\My Documents" {
|
||||
}
|
||||
|
||||
But Vim is smart enough to do this, too: >
|
||||
|
||||
Example=c:\My\ Documents {
|
||||
}
|
||||
|
||||
CD= provides the directory that Vim will change to when you select a file in
|
||||
that fold (using |:cd|). This allows you, for example, to enter |:make| to use
|
||||
the local Makefile. A CD=. means that Vim will make {projpath} or its
|
||||
inherited equivalent the current working directory. When CD is omitted, the
|
||||
directory is not changed. There can be no space on either side of the =. The
|
||||
value of CD can also be a relative path from a parent's CD. See the
|
||||
|project-inheritance| example below. This directive is ignored for |netrw|
|
||||
projects. Spaces are allowed in the path as for {projpath}.
|
||||
|
||||
in= and out= provide the means to run arbitrary Vim scripts whenever you enter
|
||||
or leave a file's buffer (see the |BufEnter| and |BufLeave| autocommand
|
||||
events). The idea is to have a Vim script that sets up or tears down the
|
||||
environment for the Project like this:
|
||||
|
||||
in.vim: >
|
||||
let $PROJECT_HOME='~/my_project'
|
||||
" Put the compiler in $PATH
|
||||
if $PATH !~ '/path/to/my/compiler'
|
||||
let $PATH=$PATH.':/path/to/my/compiler'
|
||||
endif
|
||||
|
||||
out.vim: >
|
||||
" Remove compiler from $PATH
|
||||
if $PATH =~ '/path/to/my/compiler'
|
||||
let $PATH=substitute($PATH, ':/path/to/my/compiler', '', 'g')
|
||||
endif
|
||||
|
||||
Then you can use :make with the proper environment depending on what file you
|
||||
are currently editing. If the path to the script is relative, then it is
|
||||
relative from {projpath}. These directives are inherited by Subprojects
|
||||
unless the Subproject specifies its own. For use with |netrw| projects, the
|
||||
paths specified for in= and out= must be absolute and local.
|
||||
|
||||
filter= specifies a |glob()| file pattern. It is used to regenerate the list
|
||||
of files in a Project fold when using the \r (<LocalLeader>r) map in the
|
||||
Project Window. The filter value must be in quotes because it can contain
|
||||
multiple file patterns. If filter is omitted, then the * pattern is used.
|
||||
There can be no space on either side of the =. A Subproject will inherit the
|
||||
filter of its parent unless it specifies its own filter.
|
||||
|
||||
flags= provides the means to enable/disable features for a particular fold.
|
||||
The general mnemonic scheme is for lower case to turn something off and upper
|
||||
case to turn something on. {flag} can contain any of the following
|
||||
characters:
|
||||
|
||||
flag Description ~
|
||||
|
||||
l Turn off recursion for this fold for \L. Subfolds are also
|
||||
blocked from the recursion.
|
||||
|
||||
r Turn off refresh. When present, do not refresh this fold when
|
||||
\r or \R is used. This does not affect subfold recursion.
|
||||
|
||||
S Turn on sorting for refresh and create.
|
||||
|
||||
s Turn off sorting for refresh and create.
|
||||
|
||||
T Turn on top gravity. Forces folds to the top of the current
|
||||
fold when refreshing. It has the same affect as the 'T' flag
|
||||
in g:proj_flags, but controls the feature on a per-fold basis.
|
||||
|
||||
t Turn off top gravity. Forces folds to the bottom of the
|
||||
current fold when refreshing.
|
||||
|
||||
w Turn off recursion for this fold for \W. Subfolds are also
|
||||
blocked from the recursion.
|
||||
|
||||
|
||||
Flags are not inherited by Subprojects.
|
||||
|
||||
Any text outside a fold is ignored.
|
||||
|
||||
|
||||
==============================================================================
|
||||
INHERITANCE *project-inheritance*
|
||||
|
||||
It's best to show inheritance by comparing these two Project Files:
|
||||
>
|
||||
Parent=~/my_project CD=. filter="Make* *.mk" flags=r {
|
||||
Child1=c_code {
|
||||
}
|
||||
Child2=include CD=. filter="*.h" {
|
||||
}
|
||||
}
|
||||
|
||||
Child1's path is "~/my_project/c_code" because ~/my_project is inherited. It
|
||||
also inherits the CD from Parent. Since Parent has CD=., the Parent's cwd is
|
||||
"~/my_project". Child1 therefore inherits a CD of "~/my_project". Finally,
|
||||
Child1 inherits the filter from Parent. The flags are not inherited.
|
||||
|
||||
Child2 only inherits the "~/my_project" from Parent.
|
||||
|
||||
Thus, the example above is exactly equivalent to this:
|
||||
>
|
||||
Parent=~/my_project CD=. filter="Make* *.mk" flags=r {
|
||||
Child1=~/my_project/c_code CD=~/my_project filter="Make* *.mk" {
|
||||
}
|
||||
Child2=~/my_project/include CD=~/my_project/include filter="*.h" {
|
||||
}
|
||||
}
|
||||
|
||||
(For a real Project, Child1 would not want to inherit its parent's filter, but
|
||||
this example shows the concept.) You can always enter \i to display what the
|
||||
cursor's project inherits.
|
||||
|
||||
|
||||
==============================================================================
|
||||
MAPPINGS *project-mappings*
|
||||
|
||||
Map Action ~
|
||||
|
||||
\r Refreshes the Project fold that the cursor is in by placing in the
|
||||
fold all the files that match the filter. The Project is refreshed
|
||||
using an indent of one space for every foldlevel in the hierarchy.
|
||||
|
||||
You may place a "# pragma keep" (without the quotes) at the end of a
|
||||
line, and the file entry on that line will not be removed when you
|
||||
refresh. This is useful, for example, when you have . as an entry so
|
||||
you can easily browse the directory.
|
||||
|
||||
Note that this mapping is actually <LocalLeader>r, and the default of
|
||||
|<LocalLeader>| is \.
|
||||
|
||||
This does not work for Projects using |netrw|.
|
||||
|
||||
\R Executes \r recursively in the current fold and all folds below.
|
||||
This does not work for Projects using |netrw|.
|
||||
|
||||
\c Creates a Project fold entry. It asks for the description, the path
|
||||
to the files, the CD parameter, and the filename |glob()| pattern.
|
||||
From this information, it will create the Project Entry below the
|
||||
cursor.
|
||||
|
||||
This does not work for Projects using |netrw|.
|
||||
|
||||
\C Creates a Project fold entry like \c, but recursively includes all the
|
||||
subdirectories.
|
||||
|
||||
<Return>
|
||||
Select a file to open in the |CTRL-W_p| window or in a new window. If
|
||||
the cursor is on a fold, open or close it.
|
||||
|
||||
<S-Return>
|
||||
\s
|
||||
Same as <Return> but horizontally split the target window.
|
||||
<LocalLeader>s is provided for those terminals that don't recognize
|
||||
<S-Return>.
|
||||
|
||||
\S
|
||||
Load all files in a project by doing horizontal splits.
|
||||
|
||||
<C-Return>
|
||||
\o
|
||||
Same as <Return> but ensure that the opened file is the only other
|
||||
window. <LocalLeader>o is provided for those terminals that don't
|
||||
recognize <C-Return>.
|
||||
|
||||
<M-Return>
|
||||
\v
|
||||
Same as <Return> but only display the file--the cursor stays in the
|
||||
Project Window.
|
||||
|
||||
<2-LeftMouse>
|
||||
(Double-click) If on a closed fold, open it. If on an open fold
|
||||
boundary, close it. If on a filename, open the file in the |CTRL-W_p|
|
||||
window or in a new window.
|
||||
|
||||
<S-2-LeftMouse>
|
||||
Same as <S-Return>.
|
||||
|
||||
<C-2-LeftMouse>
|
||||
Same as <C-Return>.
|
||||
|
||||
<RightMouse>
|
||||
Increase the width of the Project Window by g:proj_window_increment or
|
||||
toggle between a width of
|
||||
g:proj_window_width + g:proj_window_increment
|
||||
and
|
||||
g:proj_window_width.
|
||||
|
||||
Whether you toggle or monotonically increase the width is determined
|
||||
by the 't' flag of the g:proj_flags variable (see |project-flags|).
|
||||
|
||||
Note that a Right Mouse click will not automatically place the cursor
|
||||
in the Project Window if it is in a different window. The window will
|
||||
go back to the g:proj_window_width width when you leave the window.
|
||||
|
||||
<space> Same as <RightMouse>
|
||||
|
||||
<CTRL-Up>
|
||||
\<Up>
|
||||
Move the text or fold under the cursor up one row. This may not work
|
||||
in a terminal because the terminal is unaware of this key combination.
|
||||
<LocalLeader><Up> is provided for those terminals that don't recognize
|
||||
<C-Up>.
|
||||
|
||||
|
||||
<CTRL-Down>
|
||||
\<Down>
|
||||
Move the text or fold under the cursor down one row. This may not work
|
||||
in a terminal because the terminal is unaware of this key combination.
|
||||
<LocalLeader><Down> is provided for those terminals that don't
|
||||
recognize <C-Down>.
|
||||
|
||||
\i Show in the status line the completely resolved and inherited
|
||||
parameters for the fold the cursor is in. This is intended for
|
||||
debugging your relative path and inherited parameters for manually
|
||||
entered Projects.
|
||||
|
||||
\I Show in the status line the completely resolved filename. Uses the
|
||||
Project_GetFname(line('.')) function.
|
||||
|
||||
\1 - \9
|
||||
Run the command specified in g:proj_run{x} where {x} is the number
|
||||
of the key. See the documentation of g:proj_run1 below.
|
||||
|
||||
\f1-\f9
|
||||
Run the command specified in g:proj_run_fold{x} where {x} is the
|
||||
number of the key. The command is run on the files at the current
|
||||
Project level. See the |project-settings| below.
|
||||
|
||||
\F1-\F9
|
||||
Run the command specified in g:proj_run_fold{x} where {x} is the
|
||||
number of the key. The command is run on the files at the current
|
||||
Project level and all Subprojects. See the |project-settings| below.
|
||||
|
||||
\0 Display the commands that are defined for \1 through \9.
|
||||
|
||||
\f0 Display the commands that are defined for \f1 through \f9 and \F1
|
||||
through \F0. Same as \F0.
|
||||
|
||||
\l Load all the files in the current Project level into Vim. While files
|
||||
are being loaded, you may press any key to stop.
|
||||
|
||||
\L Load all the files in the current Project and all Subprojects into
|
||||
Vim. Use this mapping with caution--I wouldn't suggest using \L to
|
||||
load a Project with thousands of files. (BTW, my Project file has more
|
||||
than 5,300 files in it!) While files are being loaded, you may press
|
||||
any key to stop.
|
||||
|
||||
\w Wipe all the files in the current Project level from Vim. (If files
|
||||
are modified, they will be saved first.) While files are being wiped,
|
||||
you may press any key to stop.
|
||||
|
||||
\W Wipe all the files in the current Project and all Subprojects from
|
||||
Vim. (If files are modified, they will be saved first.) While files
|
||||
are being wiped, you may press any key to stop.
|
||||
|
||||
\g Grep all the files in the current Project level.
|
||||
|
||||
\G Grep all the files in the current Project level and all Subprojects.
|
||||
|
||||
\e Set up the Environment for the Project File as though you had selected
|
||||
it with <Return>. This allows you to do a \e and a :make without
|
||||
having to open any files in the project.
|
||||
|
||||
\E Explore (using |file-explorer|) the directory of the project the
|
||||
cursor is in. Does not work with netrw.
|
||||
|
||||
<F12> When the 'g' flag is present in g:proj_flags (see |project-flags|)
|
||||
this key toggles the Project Window open and closed. You may remap
|
||||
this toggle function by putting the following in your vimrc and
|
||||
replacing <Leader>P with whatever key combination you wish:
|
||||
|
||||
nmap <silent> <Leader>P <Plug>ToggleProject
|
||||
|
||||
Note that the Project Plugin remaps :help because the Help Window and the
|
||||
Project Window get into a fight over placement. The mapping avoids the
|
||||
problem.
|
||||
|
||||
==============================================================================
|
||||
ADDING MAPPINGS *project-adding-mappings*
|
||||
|
||||
You can add your own mappings or change the mappings of the plugin by placing
|
||||
them in the file $HOME/.vimproject_mappings. This file, if it exists, will be
|
||||
sourced when the plugin in loaded. Here is an example that will count the
|
||||
number of entries in a project when you press \K (Kount, C is taken :-): >
|
||||
|
||||
function! s:Wc()
|
||||
let b:loadcount=0
|
||||
function! SpawnExec(infoline, fname, lineno, data)
|
||||
let b:loadcount = b:loadcount + 1
|
||||
if getchar(0) != 0 | let b:stop_everything=1 | endif
|
||||
endfunction
|
||||
call Project_ForEach(1, line('.'), "*SpawnExec", 0, '')
|
||||
delfunction SpawnExec
|
||||
echon b:loadcount." Files\r"
|
||||
unlet b:loadcount
|
||||
if exists("b:stop_everything")
|
||||
unlet b:stop_everything
|
||||
echon "Aborted.\r"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <buffer> <silent> <LocalLeader>K :call <SID>Wc()<CR>
|
||||
|
||||
Here's another example of how I integrated the use of perforce with the plugin
|
||||
in my $HOME/.vimproject_mappings:
|
||||
>
|
||||
function! s:DoP4(cmd)
|
||||
let name=Project_GetFname(line('.'))
|
||||
let dir=substitute(name, '\(.*\)/.*', '\1', 'g')
|
||||
exec 'cd '.dir
|
||||
exec "!".a:cmd.' '.Project_GetFname(line('.'))
|
||||
cd -
|
||||
endfunction
|
||||
|
||||
nmap <buffer> <silent> \pa :call <SID>DoP4("p4add")<CR>
|
||||
nmap <buffer> <silent> \pe :call <SID>DoP4("p4edit")<CR>
|
||||
<
|
||||
(Note that I CD to the directory the file is in so I can pick of the $P4CONFIG
|
||||
file. See the perforce documentation.)
|
||||
|
||||
This creates the mappings \pe to check out the file for edit and \pa to add
|
||||
the file to the depot.
|
||||
|
||||
Here is another example where I remap the <Return> mapping to use an external
|
||||
program to launch a special kind of file (in this case, it launches ee to view
|
||||
a jpg file). It is a bit contrived, but it works.
|
||||
>
|
||||
let s:sid = substitute(maparg('<Return>', 'n'), '.*\(<SNR>.\{-}\)_.*', '\1', '')
|
||||
function! s:LaunchOrWhat()
|
||||
let fname=Project_GetFname(line('.'))
|
||||
if fname =~ '\.jpg$'
|
||||
exec 'silent! !ee "'.fname.'"&'
|
||||
else
|
||||
call {s:sid}_DoFoldOrOpenEntry('', 'e')
|
||||
endif
|
||||
endfunction
|
||||
nnoremap <buffer> <silent> <Return> \|:call <SID>LaunchOrWhat()<CR>
|
||||
<
|
||||
If the file ends in .jpg, the external program is launched, otherwise the
|
||||
original mapping of <Return> is run.
|
||||
|
||||
==============================================================================
|
||||
SETTINGS *project-settings*
|
||||
|
||||
You can set these variables in your vimrc file before the plugin is loaded to
|
||||
change its default behavior
|
||||
|
||||
g:proj_window_width
|
||||
The width of the Project Window that the plugin attempts to maintain.
|
||||
Default: 24
|
||||
|
||||
The Project Plugin is not always successful in keeping the window
|
||||
where I want it with the size specified here, but it does a decent
|
||||
job.
|
||||
|
||||
g:proj_window_increment
|
||||
The increment by which to increase the width of the Project Window
|
||||
when pressing <space> or clicking the <LeftMouse>. Default: 100
|
||||
(See |project-mappings|.)
|
||||
|
||||
*project-flags*
|
||||
g:proj_flags
|
||||
Default: "imst"
|
||||
Various flags to control the behavior of the Project Plugin. This
|
||||
variable can contain any of the following character flags.
|
||||
|
||||
flag Description ~
|
||||
|
||||
b When present, use the |browse()| when selecting directories
|
||||
for \c and \C. This is off by default for Windows, because
|
||||
the windows browser does not allow you to select directories.
|
||||
|
||||
c When present, the Project Window will automatically close when
|
||||
you select a file.
|
||||
|
||||
F Float the Project Window. That is, turn off automatic
|
||||
resizing and placement. This allows placement between other
|
||||
windows that wish to share similar placement at the side of
|
||||
the screen. It is also particularly helpful for external
|
||||
window managers.
|
||||
|
||||
g When present, the mapping for <F12> will be created to toggle
|
||||
the Project Window open and closed.
|
||||
|
||||
i When present, display the filename and the current working
|
||||
directory in the command line when a file is selected for
|
||||
opening.
|
||||
|
||||
l When present, the Project Plugin will use the |:lcd| command
|
||||
rather than |:cd| to change directories when you select a file
|
||||
to open. This flag is really obsolete and not of much use
|
||||
because of L below.
|
||||
|
||||
L Similar to l, but install a BufEnter/Leave |:autocommand| to
|
||||
ensure that the current working directory is changed to the
|
||||
one specified in the fold CD specification whenever that
|
||||
buffer is active. (|:lcd| only changes the CWD for a window,
|
||||
not a buffer.)
|
||||
|
||||
m Turn on mapping of the |CTRL-W_o| and |CTRL-W_CTRL_O| normal
|
||||
mode commands to make the current buffer the only visible
|
||||
buffer, but keep the Project Window visible, too.
|
||||
|
||||
n When present, numbers will be turned on for the project
|
||||
window.
|
||||
|
||||
s When present, the Project Plugin will use syntax highlighting
|
||||
in the Project Window.
|
||||
|
||||
S Turn on sorting for refresh and create.
|
||||
|
||||
t When present, toggle the size of the window rather than just
|
||||
increase the size when pressing <space> or right-clicking.
|
||||
See the entry for <RightMouse> in |project-mappings|.
|
||||
|
||||
T When present, put Subproject folds at the top of the fold when
|
||||
refreshing.
|
||||
|
||||
v When present, use :vimgrep rather than :grep when using \G.
|
||||
|
||||
g:proj_run1 ... g:proj_run9
|
||||
Contains a Vim command to execute on the file. See the
|
||||
mappings of \1 to \9 above.
|
||||
|
||||
%f is replaced with the full path and filename
|
||||
%F is replaced with the full path and filename with spaces
|
||||
quoted
|
||||
%n is replaced with the filename alone
|
||||
%N is replaced with the filename alone with spaces quoted
|
||||
%h is replaced with the home directory
|
||||
%H is replaced with the home directory with spaces quoted
|
||||
%r is replaced with the directory relative to the CD path
|
||||
%R is replaced with the directory relative to the CD path
|
||||
with spaces quoted
|
||||
%d is replaced with the CD directory.
|
||||
%D is replaced with the CD directory.with spaces quoted
|
||||
%% is replaced with a single % that is not used in
|
||||
expansion.
|
||||
|
||||
(Deprecated: %s is also replaced with the full path and
|
||||
filename for backward compatibility.)
|
||||
|
||||
For example, gvim will be launched on the file under the
|
||||
cursor when you enter \3 if the following is in your vimrc
|
||||
file: >
|
||||
let g:proj_run3='silent !gvim %f'
|
||||
< Here are a few other examples: >
|
||||
let g:proj_run1='!p4 edit %f'
|
||||
let g:proj_run2='!p4 add %f'
|
||||
let g:proj_run4="echo 'Viewing %f'|sil !xterm -e less %f &"
|
||||
<
|
||||
On Windows systems you will want to put the %f, %h, and %d in
|
||||
single quotes to avoid \ escaping.
|
||||
|
||||
g:proj_run_fold1 ... g:proj_run_fold9
|
||||
Contains a Vim command to execute on the files in a fold. See
|
||||
the mappings of \f1 to \f9 and \F1 to \F9 above.
|
||||
|
||||
%f is the filename, %h is replaced with the project home
|
||||
directory, and %d is replaced with the CD directory. Multiple
|
||||
filenames can be handled in two ways:
|
||||
|
||||
The first (default) way is to have %f replaced with all the
|
||||
absolute filenames, and the command is run once. The second
|
||||
is to have the command run for each of the non-absolute
|
||||
filenames (%f is replaced with one filename at a time). To
|
||||
select the second behavior, put an '*' character at the
|
||||
beginning of the g:proj_run_fold{x} variable. (The '*' is
|
||||
stripped before the command is run.)
|
||||
|
||||
For example, note the difference between the following: >
|
||||
let g:proj_run_fold3="*echo '%h/%f'"
|
||||
let g:proj_run_fold4="echo '%f'"
|
||||
<
|
||||
Note that on Windows systems, you will want the %f, %h, and %c
|
||||
within single quotes, or the \ in the paths will cause
|
||||
problems. The alternative is to put them in |escape()|.
|
||||
|
||||
|
||||
==============================================================================
|
||||
PROJECT EXAMPLE FILE *project-example*
|
||||
|
||||
Here is an example ~/.vimprojects file: >
|
||||
|
||||
1 My Project=~/c/project CD=. in=in.vim out=out.vim flags=r {
|
||||
2 Makefile
|
||||
3 in.vim
|
||||
4 out.vim
|
||||
5 GUI Files=. filter="gui*.c gui*.h" {
|
||||
6 gui_window.c
|
||||
7 gui_dialog.c
|
||||
8 gui_list.c
|
||||
9 gui.h # Header file
|
||||
10 }
|
||||
11 Database Files=. filter="data*.c data*.h" {
|
||||
12 data_read.c
|
||||
13 data_write.c
|
||||
14 data.h
|
||||
15 }
|
||||
16 OS-Specific Files {
|
||||
17 Win32=. filter="os_win32*.c os_win32*.h" {
|
||||
18 os_win32_gui.c
|
||||
19 os_win32_io.c
|
||||
20 }
|
||||
21 Unix=. filter="os_unix*.c os_unix*.h" {
|
||||
22 os_unix_gui.c
|
||||
23 os_unix_io.c
|
||||
24 }
|
||||
25 }
|
||||
26 }
|
||||
|
||||
(Don't type in the line numbers, of course.)
|
||||
|
||||
|
||||
==============================================================================
|
||||
TIPS ON USING PROJECT PLUGIN *project-tips*
|
||||
|
||||
1. You can create a Project Entry by entering this: >
|
||||
|
||||
Label=~/wherever CD=. filter="*.c *.h" {
|
||||
}
|
||||
<
|
||||
Then you can put the cursor in the fold and press \r. The script will fill
|
||||
in the files (C files in this case) from this directory for you. This is
|
||||
equivalent to \c without any dialogs.
|
||||
|
||||
2. You can edit the Project File at any time to add, remove, or reorder files
|
||||
in the Project list.
|
||||
|
||||
3. If the Project Window ever gets closed, you can just enter >
|
||||
:Project
|
||||
< to bring it back again. (You don't need to give it the filename; the
|
||||
plugin remembers.)
|
||||
|
||||
If you have the 'm' flag set in g:proj_flags, then you get the Project
|
||||
Window to show up again by pressing |CTRL-W_o|. This, of course, will
|
||||
close any other windows that may be open that the cursor is not in.
|
||||
|
||||
4. Adding files to a Project is very easy. To add, for example, the 'more.c'
|
||||
file to the Project, just insert the filename in the Project Entry then
|
||||
hit <Return> on it.
|
||||
|
||||
5. When |quickfix| loads files, it is not equivalent to pressing <Return> on
|
||||
a filename, so the directory will not be changed and the scripts will not
|
||||
be run. (If I could make this otherwise, I would.) The solution is to use
|
||||
the \L key to load all of the files in the Project before running
|
||||
quickfix.
|
||||
|
||||
6. If the Project window gets a bit cluttered with folds partially
|
||||
open/closed, you can press |zM| to close everything and tidy it up.
|
||||
|
||||
7. For advanced users, I am exporting the function Project_GetAllFnames()
|
||||
which returns all the filenames within a fold and optionally all its
|
||||
Subprojects. Also, I export Project_ForEach() for running a function for
|
||||
each filename in the project. See the code for examples on how to use
|
||||
these. Finally, I export Project_GetFname(line_number) so that you can
|
||||
write your own mappings and get the filename for it.
|
||||
|
||||
8. Some people have asked how to do a global mapping to take the cursor to
|
||||
the Project window. One of my goals for the plugin is for it to be as
|
||||
self-contained as possible, so I'm not going to add it by default. But you
|
||||
can put this in your vimrc:
|
||||
>
|
||||
nmap <silent> <Leader>P :Project<CR>
|
||||
|
||||
<
|
||||
9. You can put the . entry in a project, and it will launch the
|
||||
|file-explorer| plugin on the directory. To avoid removal when you
|
||||
refresh, make the entry look like this:
|
||||
>
|
||||
. # pragma keep
|
||||
<
|
||||
==============================================================================
|
||||
THANKS
|
||||
|
||||
The following people have sent me patches to help with the Project
|
||||
Plugin development:
|
||||
|
||||
Tomas Zellerin
|
||||
Lawrence Kesteloot
|
||||
Dave Eggum
|
||||
A Harrison
|
||||
Thomas Link
|
||||
Richard Bair
|
||||
Eric Arnold
|
||||
Peter Jones
|
||||
Eric Van Dewoestine
|
||||
|
||||
|
||||
vim:ts=8 sw=8 noexpandtab tw=78 ft=help:
|
||||
12
dot_vim/plugged/vim-project/doc/tags
Normal file
12
dot_vim/plugged/vim-project/doc/tags
Normal file
@@ -0,0 +1,12 @@
|
||||
project project.txt /*project*
|
||||
project-adding-mappings project.txt /*project-adding-mappings*
|
||||
project-example project.txt /*project-example*
|
||||
project-flags project.txt /*project-flags*
|
||||
project-inheritance project.txt /*project-inheritance*
|
||||
project-invoking project.txt /*project-invoking*
|
||||
project-mappings project.txt /*project-mappings*
|
||||
project-plugin project.txt /*project-plugin*
|
||||
project-settings project.txt /*project-settings*
|
||||
project-syntax project.txt /*project-syntax*
|
||||
project-tips project.txt /*project-tips*
|
||||
project.txt project.txt /*project.txt*
|
||||
1
dot_vim/plugged/vim-project/dot_git/HEAD
Normal file
1
dot_vim/plugged/vim-project/dot_git/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
0
dot_vim/plugged/vim-project/dot_git/branches/.keep
Normal file
0
dot_vim/plugged/vim-project/dot_git/branches/.keep
Normal file
11
dot_vim/plugged/vim-project/dot_git/config
Normal file
11
dot_vim/plugged/vim-project/dot_git/config
Normal file
@@ -0,0 +1,11 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
[remote "origin"]
|
||||
url = https://github.com/shemerey/vim-project.git
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
||||
1
dot_vim/plugged/vim-project/dot_git/description
Normal file
1
dot_vim/plugged/vim-project/dot_git/description
Normal file
@@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message taken by
|
||||
# applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit. The hook is
|
||||
# allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
:
|
||||
24
dot_vim/plugged/vim-project/dot_git/hooks/commit-msg.sample
Normal file
24
dot_vim/plugged/vim-project/dot_git/hooks/commit-msg.sample
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IPC::Open2;
|
||||
|
||||
# An example hook script to integrate Watchman
|
||||
# (https://facebook.github.io/watchman/) with git to speed up detecting
|
||||
# new and modified files.
|
||||
#
|
||||
# The hook is passed a version (currently 2) and last update token
|
||||
# formatted as a string and outputs to stdout a new update token and
|
||||
# all files that have been modified since the update token. Paths must
|
||||
# be relative to the root of the working tree and separated by a single NUL.
|
||||
#
|
||||
# To enable this hook, rename this file to "query-watchman" and set
|
||||
# 'git config core.fsmonitor .git/hooks/query-watchman'
|
||||
#
|
||||
my ($version, $last_update_token) = @ARGV;
|
||||
|
||||
# Uncomment for debugging
|
||||
# print STDERR "$0 $version $last_update_token\n";
|
||||
|
||||
# Check the hook interface version
|
||||
if ($version ne 2) {
|
||||
die "Unsupported query-fsmonitor hook version '$version'.\n" .
|
||||
"Falling back to scanning...\n";
|
||||
}
|
||||
|
||||
my $git_work_tree = get_working_dir();
|
||||
|
||||
my $retry = 1;
|
||||
|
||||
my $json_pkg;
|
||||
eval {
|
||||
require JSON::XS;
|
||||
$json_pkg = "JSON::XS";
|
||||
1;
|
||||
} or do {
|
||||
require JSON::PP;
|
||||
$json_pkg = "JSON::PP";
|
||||
};
|
||||
|
||||
launch_watchman();
|
||||
|
||||
sub launch_watchman {
|
||||
my $o = watchman_query();
|
||||
if (is_work_tree_watched($o)) {
|
||||
output_result($o->{clock}, @{$o->{files}});
|
||||
}
|
||||
}
|
||||
|
||||
sub output_result {
|
||||
my ($clockid, @files) = @_;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# binmode $fh, ":utf8";
|
||||
# print $fh "$clockid\n@files\n";
|
||||
# close $fh;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
print $clockid;
|
||||
print "\0";
|
||||
local $, = "\0";
|
||||
print @files;
|
||||
}
|
||||
|
||||
sub watchman_clock {
|
||||
my $response = qx/watchman clock "$git_work_tree"/;
|
||||
die "Failed to get clock id on '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub watchman_query {
|
||||
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
|
||||
or die "open2() failed: $!\n" .
|
||||
"Falling back to scanning...\n";
|
||||
|
||||
# In the query expression below we're asking for names of files that
|
||||
# changed since $last_update_token but not from the .git folder.
|
||||
#
|
||||
# To accomplish this, we're using the "since" generator to use the
|
||||
# recency index to select candidate nodes and "fields" to limit the
|
||||
# output to file names only. Then we're using the "expression" term to
|
||||
# further constrain the results.
|
||||
my $last_update_line = "";
|
||||
if (substr($last_update_token, 0, 1) eq "c") {
|
||||
$last_update_token = "\"$last_update_token\"";
|
||||
$last_update_line = qq[\n"since": $last_update_token,];
|
||||
}
|
||||
my $query = <<" END";
|
||||
["query", "$git_work_tree", {$last_update_line
|
||||
"fields": ["name"],
|
||||
"expression": ["not", ["dirname", ".git"]]
|
||||
}]
|
||||
END
|
||||
|
||||
# Uncomment for debugging the watchman query
|
||||
# open (my $fh, ">", ".git/watchman-query.json");
|
||||
# print $fh $query;
|
||||
# close $fh;
|
||||
|
||||
print CHLD_IN $query;
|
||||
close CHLD_IN;
|
||||
my $response = do {local $/; <CHLD_OUT>};
|
||||
|
||||
# Uncomment for debugging the watch response
|
||||
# open ($fh, ">", ".git/watchman-response.json");
|
||||
# print $fh $response;
|
||||
# close $fh;
|
||||
|
||||
die "Watchman: command returned no output.\n" .
|
||||
"Falling back to scanning...\n" if $response eq "";
|
||||
die "Watchman: command returned invalid output: $response\n" .
|
||||
"Falling back to scanning...\n" unless $response =~ /^\{/;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub is_work_tree_watched {
|
||||
my ($output) = @_;
|
||||
my $error = $output->{error};
|
||||
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
|
||||
$retry--;
|
||||
my $response = qx/watchman watch "$git_work_tree"/;
|
||||
die "Failed to make watchman watch '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
$output = $json_pkg->new->utf8->decode($response);
|
||||
$error = $output->{error};
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# close $fh;
|
||||
|
||||
# Watchman will always return all files on the first query so
|
||||
# return the fast "everything is dirty" flag to git and do the
|
||||
# Watchman query just to get it over with now so we won't pay
|
||||
# the cost in git to look up each individual file.
|
||||
my $o = watchman_clock();
|
||||
$error = $output->{error};
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
output_result($o->{clock}, ("/"));
|
||||
$last_update_token = $o->{clock};
|
||||
|
||||
eval { launch_watchman() };
|
||||
return 0;
|
||||
}
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub get_working_dir {
|
||||
my $working_dir;
|
||||
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
|
||||
$working_dir = Win32::GetCwd();
|
||||
$working_dir =~ tr/\\/\//;
|
||||
} else {
|
||||
require Cwd;
|
||||
$working_dir = Cwd::cwd();
|
||||
}
|
||||
|
||||
return $working_dir;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare a packed repository for use over
|
||||
# dumb transports.
|
||||
#
|
||||
# To enable this hook, rename this file to "post-update".
|
||||
|
||||
exec git update-server-info
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed
|
||||
# by applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
:
|
||||
49
dot_vim/plugged/vim-project/dot_git/hooks/pre-commit.sample
Normal file
49
dot_vim/plugged/vim-project/dot_git/hooks/pre-commit.sample
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --type=bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git merge" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message to
|
||||
# stderr if it wants to stop the merge commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-merge-commit".
|
||||
|
||||
. git-sh-setup
|
||||
test -x "$GIT_DIR/hooks/pre-commit" &&
|
||||
exec "$GIT_DIR/hooks/pre-commit"
|
||||
:
|
||||
53
dot_vim/plugged/vim-project/dot_git/hooks/pre-push.sample
Normal file
53
dot_vim/plugged/vim-project/dot_git/hooks/pre-push.sample
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
#
|
||||
# Information about the commits which are being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
#
|
||||
# <local ref> <local oid> <remote ref> <remote oid>
|
||||
#
|
||||
# This sample shows how to prevent push of commits where the log message starts
|
||||
# with "WIP" (work in progress).
|
||||
|
||||
remote="$1"
|
||||
url="$2"
|
||||
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
|
||||
while read local_ref local_oid remote_ref remote_oid
|
||||
do
|
||||
if test "$local_oid" = "$zero"
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if test "$remote_oid" = "$zero"
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_oid"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_oid..$local_oid"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
|
||||
if test -n "$commit"
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
169
dot_vim/plugged/vim-project/dot_git/hooks/pre-rebase.sample
Normal file
169
dot_vim/plugged/vim-project/dot_git/hooks/pre-rebase.sample
Normal file
@@ -0,0 +1,169 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||
#
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||
# its job, and can prevent the command from running by exiting with
|
||||
# non-zero status.
|
||||
#
|
||||
# The hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- the upstream the series was forked from.
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||
#
|
||||
# This sample shows how to prevent topic branches that are already
|
||||
# merged to 'next' branch from getting rebased, because allowing it
|
||||
# would result in rebasing already published history.
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
# on top of master. Is it OK to rebase it?
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
/^([0-9a-f]+) /;
|
||||
($1 => 1);
|
||||
} split(/\n/, $ARGV[1]);
|
||||
for my $elem (map {
|
||||
/^([0-9a-f]+) (.*)$/;
|
||||
[$1 => $2];
|
||||
} split(/\n/, $ARGV[2])) {
|
||||
if (!exists $not_in_next{$elem->[0]}) {
|
||||
if ($msg) {
|
||||
print STDERR $msg;
|
||||
undef $msg;
|
||||
}
|
||||
print STDERR " $elem->[1]\n";
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
This sample hook safeguards topic branches that have been
|
||||
published from being rewound.
|
||||
|
||||
The workflow assumed here is:
|
||||
|
||||
* Once a topic branch forks from "master", "master" is never
|
||||
merged into it again (either directly or indirectly).
|
||||
|
||||
* Once a topic branch is fully cooked and merged into "master",
|
||||
it is deleted. If you need to build on top of it to correct
|
||||
earlier mistakes, a new topic branch is created by forking at
|
||||
the tip of the "master". This is not strictly necessary, but
|
||||
it makes it easier to keep your history simple.
|
||||
|
||||
* Whenever you need to test or publish your changes to topic
|
||||
branches, merge them into "next" branch.
|
||||
|
||||
The script, being an example, hardcodes the publish branch name
|
||||
to be "next", but it is trivial to make it configurable via
|
||||
$GIT_DIR/config mechanism.
|
||||
|
||||
With this workflow, you would want to know:
|
||||
|
||||
(1) ... if a topic branch has ever been merged to "next". Young
|
||||
topic branches can have stupid mistakes you would rather
|
||||
clean up before publishing, and things that have not been
|
||||
merged into other branches can be easily rebased without
|
||||
affecting other people. But once it is published, you would
|
||||
not want to rewind it.
|
||||
|
||||
(2) ... if a topic branch has been fully merged to "master".
|
||||
Then you can delete it. More importantly, you should not
|
||||
build on top of it -- other people may already want to
|
||||
change things related to the topic as patches against your
|
||||
"master", so if you need further changes, it is better to
|
||||
fork the topic (perhaps with the same name) afresh from the
|
||||
tip of "master".
|
||||
|
||||
Let's look at this example:
|
||||
|
||||
o---o---o---o---o---o---o---o---o---o "next"
|
||||
/ / / /
|
||||
/ a---a---b A / /
|
||||
/ / / /
|
||||
/ / c---c---c---c B /
|
||||
/ / / \ /
|
||||
/ / / b---b C \ /
|
||||
/ / / / \ /
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||
|
||||
|
||||
A, B and C are topic branches.
|
||||
|
||||
* A has one fix since it was merged up to "next".
|
||||
|
||||
* B has finished. It has been fully merged up to "master" and "next",
|
||||
and is ready to be deleted.
|
||||
|
||||
* C has not merged to "next" at all.
|
||||
|
||||
We would want to allow C to be rebased, refuse A, and encourage
|
||||
B to be deleted.
|
||||
|
||||
To compute (1):
|
||||
|
||||
git rev-list ^master ^topic next
|
||||
git rev-list ^master next
|
||||
|
||||
if these match, topic has not merged in next at all.
|
||||
|
||||
To compute (2):
|
||||
|
||||
git rev-list master..topic
|
||||
|
||||
if this is empty, it is fully merged to "master".
|
||||
|
||||
DOC_END
|
||||
24
dot_vim/plugged/vim-project/dot_git/hooks/pre-receive.sample
Normal file
24
dot_vim/plugged/vim-project/dot_git/hooks/pre-receive.sample
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to make use of push options.
|
||||
# The example simply echoes all push options that start with 'echoback='
|
||||
# and rejects all pushes when the "reject" push option is used.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare the commit log message.
|
||||
# Called by "git commit" with the name of the file that has the
|
||||
# commit message, followed by the description of the commit
|
||||
# message's source. The hook's purpose is to edit the commit
|
||||
# message file. If the hook fails with a non-zero status,
|
||||
# the commit is aborted.
|
||||
#
|
||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||
|
||||
# This hook includes three examples. The first one removes the
|
||||
# "# Please enter the commit message..." help message.
|
||||
#
|
||||
# The second includes the output of "git diff --name-status -r"
|
||||
# into the message, just before the "git status" output. It is
|
||||
# commented because it doesn't cope with --amend or with squashed
|
||||
# commits.
|
||||
#
|
||||
# The third example adds a Signed-off-by line to the message, that can
|
||||
# still be edited. This is rarely a good idea.
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_SOURCE=$2
|
||||
SHA1=$3
|
||||
|
||||
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
||||
|
||||
# case "$COMMIT_SOURCE,$SHA1" in
|
||||
# ,|template,)
|
||||
# /usr/bin/perl -i.bak -pe '
|
||||
# print "\n" . `git diff --cached --name-status -r`
|
||||
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
||||
# *) ;;
|
||||
# esac
|
||||
|
||||
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
||||
# if test -z "$COMMIT_SOURCE"
|
||||
# then
|
||||
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
||||
# fi
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to update a checked-out tree on a git push.
|
||||
#
|
||||
# This hook is invoked by git-receive-pack(1) when it reacts to git
|
||||
# push and updates reference(s) in its repository, and when the push
|
||||
# tries to update the branch that is currently checked out and the
|
||||
# receive.denyCurrentBranch configuration variable is set to
|
||||
# updateInstead.
|
||||
#
|
||||
# By default, such a push is refused if the working tree and the index
|
||||
# of the remote repository has any difference from the currently
|
||||
# checked out commit; when both the working tree and the index match
|
||||
# the current commit, they are updated to match the newly pushed tip
|
||||
# of the branch. This hook is to be used to override the default
|
||||
# behaviour; however the code below reimplements the default behaviour
|
||||
# as a starting point for convenient modification.
|
||||
#
|
||||
# The hook receives the commit with which the tip of the current
|
||||
# branch is going to be updated:
|
||||
commit=$1
|
||||
|
||||
# It can exit with a non-zero status to refuse the push (when it does
|
||||
# so, it must not modify the index or the working tree).
|
||||
die () {
|
||||
echo >&2 "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Or it can make any necessary changes to the working tree and to the
|
||||
# index to bring them to the desired state when the tip of the current
|
||||
# branch is updated to the new commit, and exit with a zero status.
|
||||
#
|
||||
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
|
||||
# in order to emulate git fetch that is run in the reverse direction
|
||||
# with git push, as the two-tree form of git read-tree -u -m is
|
||||
# essentially the same as git switch or git checkout that switches
|
||||
# branches while keeping the local changes in the working tree that do
|
||||
# not interfere with the difference between the branches.
|
||||
|
||||
# The below is a more-or-less exact translation to shell of the C code
|
||||
# for the default behaviour for git's push-to-checkout hook defined in
|
||||
# the push_to_deploy() function in builtin/receive-pack.c.
|
||||
#
|
||||
# Note that the hook will be executed from the repository directory,
|
||||
# not from the working tree, so if you want to perform operations on
|
||||
# the working tree, you will have to adapt your code accordingly, e.g.
|
||||
# by adding "cd .." or using relative paths.
|
||||
|
||||
if ! git update-index -q --ignore-submodules --refresh
|
||||
then
|
||||
die "Up-to-date check failed"
|
||||
fi
|
||||
|
||||
if ! git diff-files --quiet --ignore-submodules --
|
||||
then
|
||||
die "Working directory has unstaged changes"
|
||||
fi
|
||||
|
||||
# This is a rough translation of:
|
||||
#
|
||||
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
|
||||
if git cat-file -e HEAD 2>/dev/null
|
||||
then
|
||||
head=HEAD
|
||||
else
|
||||
head=$(git hash-object -t tree --stdin </dev/null)
|
||||
fi
|
||||
|
||||
if ! git diff-index --quiet --cached --ignore-submodules $head --
|
||||
then
|
||||
die "Working directory has staged changes"
|
||||
fi
|
||||
|
||||
if ! git read-tree -u -m "$commit"
|
||||
then
|
||||
die "Could not update working tree to new HEAD"
|
||||
fi
|
||||
128
dot_vim/plugged/vim-project/dot_git/hooks/update.sample
Normal file
128
dot_vim/plugged/vim-project/dot_git/hooks/update.sample
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to block unannotated tags from entering.
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||
#
|
||||
# To enable this hook, rename this file to "update".
|
||||
#
|
||||
# Config
|
||||
# ------
|
||||
# hooks.allowunannotated
|
||||
# This boolean sets whether unannotated tags will be allowed into the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowdeletetag
|
||||
# This boolean sets whether deleting tags will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowmodifytag
|
||||
# This boolean sets whether a tag may be modified after creation. By default
|
||||
# it won't be.
|
||||
# hooks.allowdeletebranch
|
||||
# This boolean sets whether deleting branches will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.denycreatebranch
|
||||
# This boolean sets whether remotely creating branches will be denied
|
||||
# in the repository. By default this is allowed.
|
||||
#
|
||||
|
||||
# --- Command line
|
||||
refname="$1"
|
||||
oldrev="$2"
|
||||
newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
allowunannotated=$(git config --type=bool hooks.allowunannotated)
|
||||
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
|
||||
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
|
||||
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
|
||||
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
|
||||
|
||||
# check for no description
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
exit 0
|
||||
BIN
dot_vim/plugged/vim-project/dot_git/index
Normal file
BIN
dot_vim/plugged/vim-project/dot_git/index
Normal file
Binary file not shown.
6
dot_vim/plugged/vim-project/dot_git/info/exclude
Normal file
6
dot_vim/plugged/vim-project/dot_git/info/exclude
Normal file
@@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
2
dot_vim/plugged/vim-project/dot_git/logs/HEAD
Normal file
2
dot_vim/plugged/vim-project/dot_git/logs/HEAD
Normal file
@@ -0,0 +1,2 @@
|
||||
0000000000000000000000000000000000000000 e8551443c15c566bfb284e9ba0ee0d0df2b02c9b LinlyBoi <libkyy@e.email> 1673460162 +0200 clone: from https://github.com/shemerey/vim-project.git
|
||||
e8551443c15c566bfb284e9ba0ee0d0df2b02c9b e8551443c15c566bfb284e9ba0ee0d0df2b02c9b LinlyBoi <libkyy@e.email> 1673460166 +0200 checkout: moving from master to master
|
||||
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 e8551443c15c566bfb284e9ba0ee0d0df2b02c9b LinlyBoi <libkyy@e.email> 1673460162 +0200 clone: from https://github.com/shemerey/vim-project.git
|
||||
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 e8551443c15c566bfb284e9ba0ee0d0df2b02c9b LinlyBoi <libkyy@e.email> 1673460162 +0200 clone: from https://github.com/shemerey/vim-project.git
|
||||
Binary file not shown.
Binary file not shown.
2
dot_vim/plugged/vim-project/dot_git/packed-refs
Normal file
2
dot_vim/plugged/vim-project/dot_git/packed-refs
Normal file
@@ -0,0 +1,2 @@
|
||||
# pack-refs with: peeled fully-peeled sorted
|
||||
e8551443c15c566bfb284e9ba0ee0d0df2b02c9b refs/remotes/origin/master
|
||||
1
dot_vim/plugged/vim-project/dot_git/refs/heads/master
Normal file
1
dot_vim/plugged/vim-project/dot_git/refs/heads/master
Normal file
@@ -0,0 +1 @@
|
||||
e8551443c15c566bfb284e9ba0ee0d0df2b02c9b
|
||||
@@ -0,0 +1 @@
|
||||
ref: refs/remotes/origin/master
|
||||
0
dot_vim/plugged/vim-project/dot_git/refs/tags/.keep
Normal file
0
dot_vim/plugged/vim-project/dot_git/refs/tags/.keep
Normal file
1
dot_vim/plugged/vim-project/dot_git/shallow
Normal file
1
dot_vim/plugged/vim-project/dot_git/shallow
Normal file
@@ -0,0 +1 @@
|
||||
e8551443c15c566bfb284e9ba0ee0d0df2b02c9b
|
||||
1293
dot_vim/plugged/vim-project/plugin/project.vim
Normal file
1293
dot_vim/plugged/vim-project/plugin/project.vim
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user