Commit Graph

54 Commits

Author SHA1 Message Date
Victor Koronen
a51eb77269 Move documentation into README and doc/
* Moves general documentation, such as the description and installation
  instructions, to a new README file at the root of the repo.
* Moves detailed documentation, such at command descriptions, into a text file
  under doc/ that can be indexed and searched through using Vim's `:help` command.
2014-01-25 15:26:39 +01:00
nachoalonso
6e9f52a160 Use filereadable() instead of glob() to detect whether a file exists.
glob() reports false positives if the filename has metacharacters in it
(e.g., "[...]"), which causes Vim to incorrectly open a new, blank
buffer instead of the specified file.

Closes jamessan/vim-gnupg#12

Signed-off-by: James McCoy <vega.james@gmail.com>
2013-09-09 21:05:25 -04:00
James McCoy
15fd394fc5 Restore the :silent command when encrypting the buffer
This was lost in the refactor of external command handling, commit
7d102c843, and was causing an unnecessary "Press ENTER …" prompt to be
emitted whenever the buffer was written out.

Signed-off-by: James McCoy <vega.james@gmail.com>
2013-06-14 23:03:58 -04:00
James McCoy
27ea958f5b Allow definition of actions specific to GnuPG-managed buffers
If there are specific actions that should take place when editing a
GnuPG-managed buffer, an autocmd for the User event and GnuPG pattern
can be defined.  For example, the following will set 'textwidth' to 72
for all GnuPG-encrypted buffers:

    autocmd User GnuPG setl textwidth=72

This will be triggered before any BufRead or BufNewFile autocmds, and
therefore will not take precedence over settings specific to any
filetype that may get set.

Closes jamessan/vim-gnupg#10

Signed-off-by: James McCoy <vega.james@gmail.com>
2013-04-23 22:32:13 -04:00
James McCoy
5ec1093bd7 Merge pull request #8 from Jonty/edit-recipients-on-new-file
Edit recipients when opening a new file
2013-02-22 12:42:21 -08:00
Jonty Wareing
3e060c5ea0 Edit recipients when opening a new file
The previous behaviour of this plugin was to open the recipient pane
immediately after opening a new file with the correct extension. The
documentation states that this should still occur, so this commit
implements the behaviour in a slightly different manner than the old
plugin.
2013-02-22 19:59:12 +00:00
Jonty Wareing
2fb7599083 Do not trigger encrypt on BufWrite etc in settings
If a user :w's when in the options or recipient panes the global
bufwrite handlers will be called, triggering an attempt to encrypt the
file. The user will be dropped into the command line recipient adding
process, and the recipients listed in the buffer will be ignored.

This commit checks to see if a buffer is a child of another by looking
for the buffer local var containing the parent buffer name, and only
runs the encryption if it is not present.
2013-02-22 19:58:36 +00:00
James McCoy
57695361bb Document g:GPGFilePattern 2013-02-10 11:59:44 -05:00
James McCoy
6c758903e6 Merge pull request #4 from vaz/master 2013-02-10 11:57:54 -05:00
matt-garman
faa3d652e3 Update plugin/gnupg.vim
Need to use copy() when setting b:GPGRecipients in GPGDecrypt(), otherwise the local variable will act as a reference to the global one.  The result will be that the global default recipient list will become a super-set of recipients as multiple gpg files are opened.
2013-02-05 11:52:40 -06:00
Vaz Allen
99ea6ced65 Add g:GPGFilePattern to allow custom target filename patterns.
This can be really handy when using vim as an external editor
for a program (via temporary files) that you'd like to be able to
encrypt based on the temp file's name (for example, when using
vim as an external editor for Notational Velocity).
2013-02-05 01:38:25 -08:00
James McCoy
dcb9d3764a Show all uids when disambiguating a key.
Previously, only a contiguous block of uids would be presented to the
user when trying to disambiguate a key.  This happened because a key may
have other fields interspersed among the uids, like UAT.

Signed-off-by: James McCoy <vega.james@gmail.com>
2013-01-27 20:59:18 -05:00
James McCoy
2f1d2c8244 Return a dictionary from GPGCheckRecipients
This is a step towards reporting keys that aren't valid for encryption
instead of just ignoring them.

Signed-off-by: James McCoy <vega.james@gmail.com>
2013-01-25 07:49:57 -05:00
James McCoy
7e6816802b Only define "unknown recipient" syntax if there are unknown recipients
Signed-off-by: James McCoy <vega.james@gmail.com>
2013-01-24 23:12:08 -05:00
James McCoy
68d35c30b2 Log v:shell_error after executing a shell command
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-12-21 21:16:38 -05:00
James McCoy
419695dd0f Run tty in a shell that has stdin attached to a tty
Using system('tty') will always report "not a tty", since the spawned shell
has stdin redirected.  In order to get an accurate value for $GPG_TTY when
it's not already set, read the output of the tty command using :!.

This requires a bit more setup/teardown to ensure the buffer and user's undo
state aren't affected, but it's the only way to accurately determine the
user's tty.

Closes: #1
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-10-28 22:53:07 -04:00
James McCoy
4a649a2dce Reduce "$GPG_TTY unset" message to one line and highlight as a warning.
It's possible that gpg will work fine without $GPG_TTY being set (e.g., when
using a GUI pinentry program).  Therefore, the message should be classified as
a warning, not an error.

Also, use a single :echom to ensure the user sees the entire message, not just
"gpg-agent might not work."

First part of GH #1

Signed-off-by: James McCoy <vega.james@gmail.com>
2012-10-28 22:39:46 -04:00
James McCoy
8786427bb3 Ignore keys that aren't usable for encryption rather than just expired keys
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-31 22:31:04 -04:00
Thomas Arendsen Hein
ff9c9a8366 Do not echo debug messages when redirecting to a log file
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-31 21:22:03 -04:00
James McCoy
70cfdc99bd Use "silent doautocmd" to suppress annoying "No matching autocmds" message
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-31 21:17:07 -04:00
James McCoy
8b38e3e859 Change autocmd check to look for GnuPG group
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-31 00:31:56 -04:00
James McCoy
0f4778240f Ignore expired keys.
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-31 00:31:36 -04:00
James McCoy
9329403402 GPGFinishRecipientsBuffer: Use the GPG ID, if present, to avoid repeat prompts
Whenever GPGFinishRecipientsBuffer is called, the buffer is processed to
convert names to IDs.  However, this was ignoring any existing ID information
in the buffer.  This meant that if a person had multiple keys, the user would
be prompted to disambiguate the keys after every :GPGEditRecipients session.

Parsing the ID out of the recipients buffer avoids the unnecessary prompting.

Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 23:48:43 -04:00
James McCoy
b2b4e7525c Pull the key pattern out to a constant
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 23:48:24 -04:00
James McCoy
ac45a5969e Don't wipeout the current buffer if FileReadCmd failed
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 22:18:34 -04:00
James McCoy
1354f3447d Suppress "N more lines" message when editing a file
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 22:18:01 -04:00
James McCoy
256810ab64 Only disable swapfile, undofile, and viminfo when editing a file.
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 22:17:05 -04:00
James McCoy
bceace5df6 Indicate whether GPGInit/GPGDecrypt were invoked from BufReadCmd
Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 22:15:46 -04:00
James McCoy
d7361d413c Clear undo history as the last step of BufReadCmd
After opening a file, an immediate "u"/":undo" would remove the entire
contents of the buffer.  Even worse, this would not set 'modified', so there
would be no indication that wasn't the actual initial state of the buffer.

Discarding undo history for a buffer requires a few steps, including making a
change.  Luckily, a change is already being made (deleting the extra line left
after ":r !" the decrypted file), so discarding undo history can piggy-back on
top of that.

Signed-off-by: James McCoy <vega.james@gmail.com>
2012-05-30 21:02:40 -04:00
Alex Efros
42c2d46aa2 added doautocmd BufWritePre 2012-01-14 00:37:31 +02:00
James McCoy
648fa8821d Document the g:GPGHomedir option
Signed-off-by: James McCoy <vega.james@gmail.com>
2011-11-23 17:09:42 -05:00
James McCoy
5394d0c1f1 Add support for specifying an alternate --homedir
Reported-By: Matt Callaway <matt.callaway@gmail.com>
Signed-off-by: James McCoy <vega.james@gmail.com>
2011-11-23 16:38:38 -05:00
James McCoy
7d102c843a Consolidate handling of system()/:execute calls
Signed-off-by: James McCoy <vega.james@gmail.com>
2011-11-23 16:14:56 -05:00
James Vega
e2e53bc315 Resolve the filename when saving to follow symlinks.
Signed-off-by: James Vega <vega.james@gmail.com>
2011-10-18 22:00:02 -04:00
James Vega
21eed8f06b Initialize b:GPGRecipients with g:GPGDefaultRecipients
Signed-off-by: James Vega <vega.james@gmail.com>
2011-10-13 17:22:09 -04:00
James Vega
df5f4d51bf Correctly handle the different keyid-format options
Signed-off-by: James Vega <vega.james@gmail.com>
2011-08-13 18:00:27 -04:00
James Vega
d19a59165d Add g:GPGUsePipes variable to avoid saving unencrypted data to tempfiles
Signed-off-by: James Vega <vega.james@gmail.com>
2011-08-09 21:24:44 -04:00
James Vega
ea09d9fd0e Disable 'undofile' for the buffer, if the option exists
Signed-off-by: James Vega <vega.james@gmail.com>
2011-06-26 15:40:34 -04:00
James Vega
589b6d1851 Update docs to show my takeover of gnupg.vim
Signed-off-by: James Vega <vega.james@gmail.com>
2011-05-24 07:28:02 -04:00
James Vega
5739223478 Set 'noshelltemp' when executing gnupg
This is another step to prevent writing out sensitive information to disk.
Typically, when running an external command, Vim writes the command input (the
buffer in this case) to a file in a private temp directory.  When
'noshelltemp' is set and the system supports it, Vim uses pipes to the child
process to handle this instead.

Signed-off-by: James Vega <vega.james@gmail.com>
2011-05-24 01:21:19 -04:00
James Vega
11760e451a Bump minimum Vim version to 7.2
The two argument form of shellescape() is now being used, and that was
introduced in the pre-releases of 7.2.

Signed-off-by: James Vega <vega.james@gmail.com>
2011-05-24 01:16:05 -04:00
James Vega
7ec46a5c12 Check for our BufReadCmd to see if the plugin has been loaded.
Signed-off-by: James Vega <vega.james@gmail.com>
2011-05-24 01:14:45 -04:00
James Vega
987c1c1c08 Refactor to use *WriteCmd/*ReadCmd autocommands.
With this change, we're able to properly handle errors from shell commands.
This means no more overwriting the original file when an incorrect password is
entered or some other similar scenario.

Also, move the handling of entering recipients to gpg itself instead of
mimicking that in Vim itself.

Signed-off-by: James Vega <vega.james@gmail.com>
2011-05-24 01:14:39 -04:00
Markus Braun
724e194cfb release candidate for gnupg.vim
- better '*.asc' handling
- better filename escaping
- better handling of multiple keyrings
2011-05-24 00:53:44 -04:00
Markus Braun
5ae32bcde1 releasing gnupg.vim 3026
- fix a bug by using a sh compatible setting for 'shellredir' on unix systems. when 'shell' was set to csh or tcsh by the user and the system has /bin/sh linked to dash the plugin didn't work.
2011-05-23 23:18:33 -04:00
Markus Braun
a878b06964 releasing gnupg.vim 2782
- show more information (key id and creation time) of keys in GPGEditRecipients, GPGViewRecipients and during selecting in case of a ambiguous key.
2011-05-23 23:17:37 -04:00
Markus Braun
e488aea931 releasing gnupg.vim 2773
- fix a bug in detecting windows platforms
- added g:GPGPreferSign to sign encrypted files by default (thanks to Tim Swast).
2011-05-23 23:16:42 -04:00
Markus Braun
7fd5c92bce releasing gnupg.vim 2276
- added support for default recipients via the variable g:GPGDefaultRecipients.
- fixed an wrong error message with symmetric encryption and set recipients (thanks to Sebastian Luettich).
- create a empty new buffer on leaving vim to wipe out sensitive data on console.
- make sure senisitive data is never written unencrypted to disk.
2011-05-23 23:15:53 -04:00
Markus Braun
4b5db78267 releasing gnupg.vim 2249
- rewritten lots of code to use lists feature of vim 7 instead of my own implementation
- added a n option to change the name and location of GPG executable
- try to get GPG_TTY dynamically.
2011-05-23 23:14:29 -04:00
Markus Braun
77df8bb864 releasing gnupg.vim 1933
- changed parsin to work with gpg2 correctly
- save/restore view of saved window
- fix a bug when encoding and fileencoding is different
- restructured autocommand triggers
- added a debug command and debug messages
2011-05-23 23:13:29 -04:00