Permalink
Browse files

Merge branch 'release/v0.5.0'

  • Loading branch information...
2 parents 17aa2fb + 2ed7c1c commit c2e507ecdc0c1015c5c6d5eebcec8d561470d307 @mrtazz committed Jun 3, 2012
Showing with 82 additions and 20 deletions.
  1. +17 −0 CHANGELOG.md
  2. +8 −6 README.md
  3. +54 −11 autoload/simplenote.vim
  4. +3 −3 plugin/simplenote.vim
View
@@ -1,5 +1,22 @@
# Changelog
+## 0.5.0 (06/03/2012)
+
+- make pretty formatting for note list
+- allow vertical splitting of scratch buffer
+- listing command (-l) takes parameter of max notes to fetch
+- update to simplenote.py v0.2.0
+- incorrectly fetched notes are not displayed anymore
+
+## 0.4.0 (02/08/2012)
+
+- refactor into autload plugin
+
+## 0.3.1 (11/23/2011)
+
+- add documentation for usage behind proxy
+- buffer write command updates note
+
## 0.3.0 (07/17/2011)
- UTF-8 support
View
@@ -21,16 +21,19 @@ with git for example), you can just set the variables in a different file (like
The plugin provides several commands to interact with your Simplenote account.
In order to retrieve a list of your notes execute
- :Simplenote -l
+ :Simplenote -l X
-This opens a new scratch buffer with a line-wise listing of your notes. You can
-navigate through these with the arrow keys and enter a note on hitting
-`Return`. Now that you see the content of the note, you can interact with this
-specific note:
+Where X is the number of notes to retrieve; omit X to retrieve all.
+This opens a new scratch buffer with a line-wise listing of your notes. When
+`let g:SimplenoteVertical=1` is set, the scratch buffer is opened as a vertical
+rather than a horizontal split window. You can then navigate through the notes
+with the arrow keys and enter a note on hitting `Return`. Now that you see the
+content of the note, you can interact with this specific note:
:Simplenote -u
updates the content of the current note with the content of the current buffer.
+The buffer write command `:w` is also mapped to update the current note.
If you want to delete the note, execute
:Simplenote -d
@@ -72,7 +75,6 @@ add these lines (with the correct values) to your `.vimrc`:
## Development
-- [Planned features](http://www.pivotaltracker.com/projects/288621)
- [Bugs and issue tracker](https://github.com/mrtazz/simplenote.vim/issues)
## Contribute
View
@@ -38,6 +38,14 @@ else
let s:password = ""
endif
+" vertical buffer
+if exists("g:SimplenoteVertical")
+ let s:vbuff = g:SimplenoteVertical
+else
+ let s:vbuff = 0
+endif
+
+
if (s:user == "") || (s:password == "")
let errmsg = "Simplenote credentials missing. Set g:SimplenoteUsername and "
let errmsg = errmsg . "g:SimplenotePassword. If you don't have an account you can "
@@ -55,18 +63,26 @@ let g:simplenote_scratch_buffer = 'Simplenote'
" Function that opens or navigates to the scratch buffer.
function! s:ScratchBufferOpen(name)
+ let exe_new = "new "
+ let exe_split = "split "
+
+ if s:vbuff > 0
+ let exe_new = "vert " . exe_new
+ let exe_split = "vert " . exe_split
+ endif
+
let scr_bufnum = bufnr(a:name)
if scr_bufnum == -1
- exe "new " . a:name
+ exe exe_new . a:name
else
let scr_winnum = bufwinnr(scr_bufnum)
if scr_winnum != -1
if winnr() != scr_winnum
exe scr_winnum . "wincmd w"
endif
else
- exe "split +buffer" . scr_bufnum
+ exe exe_split . "+buffer" . scr_bufnum
endif
endif
call s:ScratchBuffer()
@@ -374,6 +390,7 @@ class Request(urllib2.Request):
import vim
import time
+import math as m
from threading import Thread
from Queue import Queue
@@ -417,15 +434,33 @@ class SimplenoteVimInterface(object):
"""
# fetch first line and display as title
note_lines = note["content"].split("\n")
+
+ # get window width for proper formatting
+ width = vim.current.window.width
+
+ # Make room for the numbers regardless of their presence
+ # min num width is 5
+ width -= max(m.floor(m.log(len(vim.current.buffer))) + 2, 5)
+ width = int(width)
+
+
# format date
mt = time.localtime(float(note["modifydate"]))
- mod_time = time.strftime("%a, %d %b %Y %H:%M:%S", mt)
+ mod_time = time.strftime("[%a, %d %b %Y %H:%M:%S]", mt)
+
if len(note_lines) > 0:
- title = "%s [%s]" % (note_lines[0], mod_time)
+ title = str(note_lines[0])
else:
- title = "%s [%s]" % (note["key"], mod_time)
+ title = str(note["key"])
+
+ # Compress everything into the appropriate number of columns
+ title_width = width - len(mod_time) - 1
+ if len(title) > title_width:
+ title = title[:title_width]
+ elif len(title) < title_width:
+ title = title.ljust(title_width)
- return (str(title)[0:80])
+ return "%s %s" % (title, mod_time)
def get_notes_from_keys(self, key_list):
@@ -536,14 +571,14 @@ class SimplenoteVimInterface(object):
else:
print "Update failed.: %s" % note["key"]
- def list_note_index_in_scratch_buffer(self):
+ def list_note_index_in_scratch_buffer(self, qty=float("inf")):
""" get all available notes and display them in a scratchbuffer """
# Initialize the scratch buffer
self.scratch_buffer()
vim.command("setlocal modifiable")
# clear global note id storage
buffer = vim.current.buffer
- note_list, status = self.simplenote.get_note_list()
+ note_list, status = self.simplenote.get_note_list(qty)
# set global notes index object to notes
if status == 0:
note_titles = []
@@ -559,7 +594,8 @@ class SimplenoteVimInterface(object):
# map <CR> to call get_note()
vim.command("setl nomodifiable")
- vim.command("map <buffer><silent> <CR> <Esc>:call <SID>GetNoteToCurrentBuffer()<CR>")
+ vim.command("setlocal nowrap")
+ vim.command("nnoremap <buffer><silent> <CR> <Esc>:call <SID>GetNoteToCurrentBuffer()<CR>")
class NoteFetcher(Thread):
@@ -607,11 +643,18 @@ interface.update_note_from_current_buffer()
EOF
endfunction
-function! simplenote#SimpleNote(param)
+function! simplenote#SimpleNote(param, ...)
python << EOF
param = vim.eval("a:param")
+optionsexist = True if (float(vim.eval("a:0"))>=1) else False
if param == "-l":
- interface.list_note_index_in_scratch_buffer()
+ if optionsexist:
+ try:
+ interface.list_note_index_in_scratch_buffer(int(float(vim.eval("a:1"))))
+ except:
+ interface.list_note_index_in_scratch_buffer()
+ else:
+ interface.list_note_index_in_scratch_buffer()
elif param == "-d":
interface.trash_current_note()
View
@@ -4,9 +4,9 @@
" Author: Daniel Schauenberg <d@unwiredcouch.com>
" WebPage: http://github.com/mrtazz/simplenote.vim
" License: MIT
-" Version: 0.4.0
+" Version: 0.5.0
" Usage:
-" :Simplenote -l => list all notes
+" :Simplenote -l X => list X number of notes; omit X to list all
" :Simplenote -u => update a note from buffer
" :Simplenote -d => move note to trash
" :Simplenote -n => create new note from buffer
@@ -18,5 +18,5 @@
"
" set the simplenote command
-command! -nargs=1 Simplenote :call simplenote#SimpleNote(<f-args>)
+command! -nargs=+ Simplenote :call simplenote#SimpleNote(<f-args>)

0 comments on commit c2e507e

Please sign in to comment.