1
0
mirror of https://github.com/gryf/.vim.git synced 2025-12-17 11:30:29 +01:00

Added vimblogger_ft, update for lucius colorscheme and pyflakes plugin

This commit is contained in:
2010-12-27 21:59:24 +01:00
parent a4fad23f26
commit 90fd776dc2
15 changed files with 1234 additions and 300 deletions

View File

@@ -22,12 +22,12 @@ ScriptID SourceID Filename
3252 13948 :AutoInstall: L9
### colors
1975 7471 lettuce.vim
2536 13588 lucius.vim
2536 14531 lucius.vim
1165 3741 tolerable.vim
# compiler
891 10365 pylint.vim
# ftplugin
2441 14288 pyflakes.vim
2441 14403 pyflakes.vim
30 9196 python_fn.vim
### indent
1936 7708 javascript.vim

View File

@@ -1,16 +1,6 @@
" Vim color file
" Lucius vim color file
" Maintainer: Jonathan Filip <jfilip1024@gmail.com>
" Last Modified: Mon Apr 19, 2010 10:24AM
" Version: 3.5
"
" GUI / 256 color terminal
"
" I started out trying to combine my favorite parts of other schemes and ended
" up with this (oceandeep, moria, peaksea, wombat, zenburn).
"
" This file also tries to have descriptive comments for each higlighting group
" so it is easy to understand what each part does.
set background=dark
hi clear
@@ -19,61 +9,48 @@ if exists("syntax_on")
endif
let colors_name="lucius"
" Some other colors to save
" blue: 3eb8e5
" green: 92d400
" c green: d5f876, cae682
" new blue: 002D62
" new gray: CCCCCC
" Base color
" ----------
" == Normal color ==
hi Normal guifg=#e0e0e0 guibg=#202020
hi Normal ctermfg=253 ctermbg=235
hi Normal ctermfg=253 ctermbg=234
" Comment Group
" -------------
" any comment
" == Comments ==
hi Comment guifg=#606060 gui=none
hi Comment ctermfg=240 cterm=none
" Constant Group
" --------------
" == Constants ==
" any constant
hi Constant guifg=#8cd0d3 gui=none
hi Constant ctermfg=116 cterm=none
hi Constant guifg=#70c0d8 gui=none
hi Constant ctermfg=74 cterm=none
" strings
hi String guifg=#80c0d9 gui=none
hi String guifg=#80c0d8 gui=none
hi String ctermfg=110 cterm=none
" character constant
hi Character guifg=#80c0d9 gui=none
hi Character guifg=#80c0d8 gui=none
hi Character ctermfg=110 cterm=none
" numbers decimal/hex
hi Number guifg=#8cd0d3 gui=none
hi Number ctermfg=116 cterm=none
hi Number guifg=#70c0d8 gui=none
hi Number ctermfg=74 cterm=none
" true, false
hi Boolean guifg=#8cd0d3 gui=none
hi Boolean ctermfg=116 cterm=none
hi Boolean guifg=#70c0d8 gui=none
hi Boolean ctermfg=74 cterm=none
" float
hi Float guifg=#8cd0d3 gui=none
hi Float ctermfg=116 cterm=none
hi Float guifg=#70c0d8 gui=none
hi Float ctermfg=74 cterm=none
" Identifier Group
" ----------------
" == Identifiers ==
" any variable name
hi Identifier guifg=#e6c080 gui=none
hi Identifier ctermfg=180 cterm=none
hi Identifier guifg=#86c6b6 gui=none
hi Identifier ctermfg=116 cterm=none
" function, method, class
hi Function guifg=#e6c080 gui=none
hi Function ctermfg=180 cterm=none
hi Function guifg=#86c6b6 gui=none
hi Function ctermfg=116 cterm=none
" Statement Group
" ---------------
" == Statements ==
" any statement
hi Statement guifg=#b3d38c gui=none
hi Statement ctermfg=150 cterm=none
@@ -97,93 +74,157 @@ hi Keyword guifg=#b3d38c gui=none
hi Keyword ctermfg=150 cterm=none
" Preprocessor Group
" ------------------
" == Preprocessor ==
" generic preprocessor
hi PreProc guifg=#e9dfaf gui=none
hi PreProc guifg=#e0e8b0 gui=none
hi PreProc ctermfg=187 cterm=none
" #include
hi Include guifg=#e9dfaf gui=none
hi Include guifg=#e0e8b0 gui=none
hi Include ctermfg=187 cterm=none
" #define
hi Define guifg=#e9dfaf gui=none
hi Define guifg=#e0e8b0 gui=none
hi Define ctermfg=187 cterm=none
" same as define
hi Macro guifg=#e9dfaf gui=none
hi Macro guifg=#e0e8b0 gui=none
hi Macro ctermfg=187 cterm=none
" #if, #else, #endif
hi PreCondit guifg=#e9dfaf gui=none
hi PreCondit guifg=#e0e8b0 gui=none
hi PreCondit ctermfg=187 cterm=none
" Type Group
" ----------
" == Types ==
" int, long, char
hi Type guifg=#93d6a9 gui=none
hi Type guifg=#90d0a0 gui=none
hi Type ctermfg=115 cterm=none
" static, register, volative
hi StorageClass guifg=#93d6a9 gui=none
hi StorageClass guifg=#90d0a0 gui=none
hi StorageClass ctermfg=115 cterm=none
" struct, union, enum
hi Structure guifg=#93d6a9 gui=none
hi Structure guifg=#90d0a0 gui=none
hi Structure ctermfg=115 cterm=none
" typedef
hi Typedef guifg=#93d6a9 gui=none
hi Typedef guifg=#90d0a0 gui=none
hi Typedef ctermfg=115 cterm=none
" Special Group
" -------------
" == Special ==
" any special symbol
hi Special guifg=#cca3b3 gui=none
hi Special ctermfg=181 cterm=none
hi Special guifg=#b0a0c0 gui=none
hi Special ctermfg=182 cterm=none
" special character in a constant
hi SpecialChar guifg=#cca3b3 gui=none
hi SpecialChar ctermfg=181 cterm=none
hi SpecialChar guifg=#b0a0c0 gui=none
hi SpecialChar ctermfg=182 cterm=none
" things you can CTRL-]
hi Tag guifg=#cca3b3 gui=none
hi Tag ctermfg=181 cterm=none
hi Tag guifg=#b0a0c0 gui=none
hi Tag ctermfg=182 cterm=none
" character that needs attention
hi Delimiter guifg=#cca3b3 gui=none
hi Delimiter ctermfg=181 cterm=none
hi Delimiter guifg=#b0a0c0 gui=none
hi Delimiter ctermfg=182 cterm=none
" special things inside a comment
hi SpecialComment guifg=#cca3b3 gui=none
hi SpecialComment ctermfg=181 cterm=none
hi SpecialComment guifg=#b0a0c0 gui=none
hi SpecialComment ctermfg=182 cterm=none
" debugging statements
hi Debug guifg=#cca3b3 guibg=NONE gui=none
hi Debug ctermfg=181 ctermbg=NONE cterm=none
hi Debug guifg=#b0a0c0 guibg=NONE gui=none
hi Debug ctermfg=182 ctermbg=NONE cterm=none
" Underlined Group
" ----------------
" == Text Markup ==
" text that stands out, html links
hi Underlined guifg=fg gui=underline
hi Underlined ctermfg=fg cterm=underline
" any erroneous construct
hi Error guifg=#e37170 guibg=#432323 gui=none
hi Error ctermfg=167 ctermbg=236 cterm=none
" todo, fixme, note, xxx
hi Todo guifg=#e0e090 guibg=NONE gui=underline
hi Todo ctermfg=186 ctermbg=NONE cterm=underline
" match parenthesis, brackets
hi MatchParen guifg=#00ff00 guibg=NONE gui=bold
hi MatchParen ctermfg=46 ctermbg=NONE cterm=bold
" the '~' and '@' and showbreak, '>' double wide char doesn't fit on line
hi NonText guifg=#404040 gui=none
hi NonText ctermfg=238 cterm=none
" meta and special keys used with map, unprintable characters
hi SpecialKey guifg=#405060
hi SpecialKey ctermfg=239
" titles for output from :set all, :autocmd, etc
hi Title guifg=#62bdde gui=none
hi Title ctermfg=74 cterm=none
" Ignore Group
" ------------
" == Ignore ==
" left blank, hidden
hi Ignore guifg=bg
hi Ignore ctermfg=bg
" Error Group
" -----------
" any erroneous construct
hi Error guifg=#e37170 guibg=#432323 gui=none
hi Error ctermfg=167 ctermbg=52 cterm=none
" == Text Selection ==
" character under the cursor
hi Cursor guifg=bg guibg=#a3e3ed
hi Cursor ctermfg=bg ctermbg=153
" like cursor, but used when in IME mode
hi CursorIM guifg=bg guibg=#96cdcd
hi CursorIM ctermfg=bg ctermbg=116
" cursor column
hi CursorColumn guifg=NONE guibg=#404448 gui=none
hi CursorColumn ctermfg=NONE ctermbg=236 cterm=none
" cursor line/row
hi CursorLine gui=NONE guibg=#404448 gui=none
hi CursorLine cterm=NONE ctermbg=236 cterm=none
" visual mode selection
hi Visual guifg=NONE guibg=#364458
hi Visual ctermfg=NONE ctermbg=24
" visual mode selection when vim is not owning the selection (x11 only)
hi VisualNOS guifg=fg gui=underline
hi VisualNOS ctermfg=fg cterm=underline
" highlight incremental search text; also highlight text replaced with :s///c
hi IncSearch guifg=#66ffff gui=reverse
hi IncSearch ctermfg=87 cterm=reverse
" hlsearch (last search pattern), also used for quickfix
hi Search guibg=#ffaa33 gui=none
hi Search ctermbg=214 cterm=none
" Todo Group
" ----------
" todo, fixme, note, xxx
hi Todo guifg=#efef8f guibg=NONE gui=underline
hi Todo ctermfg=228 ctermbg=NONE cterm=underline
" == UI ==
" normal item in popup
hi Pmenu guifg=#e0e0e0 guibg=#303840 gui=none
hi Pmenu ctermfg=253 ctermbg=233 cterm=none
" selected item in popup
hi PmenuSel guifg=#cae682 guibg=#505860 gui=none
hi PmenuSel ctermfg=186 ctermbg=237 cterm=none
" scrollbar in popup
hi PMenuSbar guibg=#505860 gui=none
hi PMenuSbar ctermbg=59 cterm=none
" thumb of the scrollbar in the popup
hi PMenuThumb guibg=#808890 gui=none
hi PMenuThumb ctermbg=102 cterm=none
" status line for current window
hi StatusLine guifg=#e0e0e0 guibg=#363946 gui=bold
hi StatusLine ctermfg=254 ctermbg=237 cterm=bold
" status line for non-current windows
hi StatusLineNC guifg=#767986 guibg=#363946 gui=none
hi StatusLineNC ctermfg=244 ctermbg=237 cterm=none
" tab pages line, not active tab page label
hi TabLine guifg=#b6bf98 guibg=#363946 gui=none
hi TabLine ctermfg=244 ctermbg=236 cterm=none
" tab pages line, where there are no labels
hi TabLineFill guifg=#cfcfaf guibg=#363946 gui=none
hi TabLineFill ctermfg=187 ctermbg=236 cterm=none
" tab pages line, active tab page label
hi TabLineSel guifg=#efefef guibg=#414658 gui=bold
hi TabLineSel ctermfg=254 ctermbg=236 cterm=bold
" column separating vertically split windows
hi VertSplit guifg=#777777 guibg=#363946 gui=none
hi VertSplit ctermfg=242 ctermbg=237 cterm=none
" line used for closed folds
hi Folded guifg=#d0e0f0 guibg=#202020 gui=none
hi Folded ctermfg=117 ctermbg=235 cterm=none
" column on side used to indicated open and closed folds
hi FoldColumn guifg=#c0c0d0 guibg=#363946 gui=none
hi FoldColumn ctermfg=117 ctermbg=238 cterm=none
" Spelling
" --------
" == Spelling ==
" word not recognized
hi SpellBad guisp=#ee0000 gui=undercurl
hi SpellBad ctermbg=196 cterm=undercurl
@@ -198,77 +239,10 @@ hi SpellLocal guisp=#ffa500 gui=undercur
hi SpellLocal ctermbg=214 cterm=undercurl
" Cursor
" ------
" character under the cursor
hi Cursor guifg=bg guibg=#a3e3ed
hi Cursor ctermfg=bg ctermbg=153
" like cursor, but used when in IME mode
hi CursorIM guifg=bg guibg=#96cdcd
hi CursorIM ctermfg=bg ctermbg=116
" cursor column
hi CursorColumn guifg=NONE guibg=#404448 gui=none
hi CursorColumn ctermfg=NONE ctermbg=236 cterm=none
" cursor line/row
hi CursorLine gui=NONE guibg=#404448 gui=none
hi CursorLine cterm=NONE ctermbg=236 cterm=none
" Misc
" ----
" directory names and other special names in listings
hi Directory guifg=#c0e0b0 gui=none
hi Directory ctermfg=151 cterm=none
" error messages on the command line
hi ErrorMsg guifg=#ee0000 guibg=NONE gui=none
hi ErrorMsg ctermfg=196 ctermbg=NONE cterm=none
" column separating vertically split windows
hi VertSplit guifg=#777777 guibg=#363946 gui=none
hi VertSplit ctermfg=242 ctermbg=237 cterm=none
" columns where signs are displayed (used in IDEs)
hi SignColumn guifg=#9fafaf guibg=#181818 gui=none
hi SignColumn ctermfg=145 ctermbg=233 cterm=none
" line numbers
hi LineNr guifg=#818698 guibg=#363946
hi LineNr ctermfg=245 ctermbg=237
" match parenthesis, brackets
hi MatchParen guifg=#00ff00 guibg=NONE gui=bold
hi MatchParen ctermfg=46 ctermbg=NONE cterm=bold
" the 'more' prompt when output takes more than one line
hi MoreMsg guifg=#2e8b57 gui=none
hi MoreMsg ctermfg=29 cterm=none
" text showing what mode you are in
hi ModeMsg guifg=#76d5f8 guibg=NONE gui=none
hi ModeMsg ctermfg=117 ctermbg=NONE cterm=none
" the '~' and '@' and showbreak, '>' double wide char doesn't fit on line
hi NonText guifg=#404040 gui=none
hi NonText ctermfg=238 cterm=none
" the hit-enter prompt (show more output) and yes/no questions
hi Question guifg=fg gui=none
hi Question ctermfg=fg cterm=none
" meta and special keys used with map, unprintable characters
hi SpecialKey guifg=#405060
hi SpecialKey ctermfg=239
" titles for output from :set all, :autocmd, etc
hi Title guifg=#62bdde gui=none
hi Title ctermfg=74 cterm=none
"hi Title guifg=#5ec8e5 gui=none
" warning messages
hi WarningMsg guifg=#e5786d gui=none
hi WarningMsg ctermfg=173 cterm=none
" current match in the wildmenu completion
hi WildMenu guifg=#cae682 guibg=#363946 gui=bold,underline
hi WildMenu ctermfg=16 ctermbg=186 cterm=bold
" color column highlighting
hi ColorColumn guifg=NONE guibg=#403630 gui=none
hi ColorColumn ctermfg=NONE ctermbg=94 cterm=none
" Diff
" ----
" == Diff ==
" added line
hi DiffAdd guifg=#80a090 guibg=#313c36 gui=none
hi DiffAdd ctermfg=fg ctermbg=22 cterm=none
hi DiffAdd ctermfg=fg ctermbg=22 cterm=none
" changed line
hi DiffChange guifg=NONE guibg=#4a343a gui=none
hi DiffChange ctermfg=fg ctermbg=52 cterm=none
@@ -280,74 +254,51 @@ hi DiffText guifg=#f05060 guibg=#4a343a gui=bold
hi DiffText ctermfg=203 ctermbg=52 cterm=bold
" Folds
" -----
" line used for closed folds
"hi Folded guifg=#91d6f8 guibg=#363946 gui=none
"hi Folded ctermfg=117 ctermbg=238 cterm=none
hi Folded guifg=#d0e0f0 guibg=#202020 gui=none
hi Folded ctermfg=117 ctermbg=235 cterm=none
" column on side used to indicated open and closed folds
hi FoldColumn guifg=#91d6f8 guibg=#363946 gui=none
hi FoldColumn guifg=#c0c0d0 guibg=#363946 gui=none
hi FoldColumn ctermfg=117 ctermbg=238 cterm=none
" == Misc ==
" directory names and other special names in listings
hi Directory guifg=#c0e0b0 gui=none
hi Directory ctermfg=151 cterm=none
" error messages on the command line
hi ErrorMsg guifg=#ee0000 guibg=NONE gui=none
hi ErrorMsg ctermfg=196 ctermbg=NONE cterm=none
" columns where signs are displayed (used in IDEs)
hi SignColumn guifg=#9fafaf guibg=#181818 gui=none
hi SignColumn ctermfg=145 ctermbg=233 cterm=none
" line numbers
hi LineNr guifg=#818698 guibg=#363946
hi LineNr ctermfg=245 ctermbg=237
" the 'more' prompt when output takes more than one line
hi MoreMsg guifg=#2e8b57 gui=none
hi MoreMsg ctermfg=29 cterm=none
" text showing what mode you are in
hi ModeMsg guifg=#76d5f8 guibg=NONE gui=none
hi ModeMsg ctermfg=117 ctermbg=NONE cterm=none
" the hit-enter prompt (show more output) and yes/no questions
hi Question guifg=fg gui=none
hi Question ctermfg=fg cterm=none
" warning messages
hi WarningMsg guifg=#e5786d gui=none
hi WarningMsg ctermfg=173 cterm=none
" current match in the wildmenu completion
hi WildMenu guifg=#cae682 guibg=#363946 gui=bold,underline
hi WildMenu ctermfg=16 ctermbg=186 cterm=bold
" color column highlighting
hi ColorColumn guifg=NONE guibg=#403630 gui=none
hi ColorColumn ctermfg=NONE ctermbg=95 cterm=none
" Search
" ------
" highlight incremental search text; also highlight text replaced with :s///c
hi IncSearch guifg=#66ffff gui=reverse
hi IncSearch ctermfg=87 cterm=reverse
" hlsearch (last search pattern), also used for quickfix
hi Search guibg=#ffaa33 gui=none
hi Search ctermbg=214 cterm=none
" == Vimwiki Colors ==
" Popup Menu
" ----------
" normal item in popup
hi Pmenu guifg=#e0e0e0 guibg=#303840 gui=none
hi Pmenu ctermfg=253 ctermbg=233 cterm=none
" selected item in popup
hi PmenuSel guifg=#cae682 guibg=#505860 gui=none
hi PmenuSel ctermfg=186 ctermbg=237 cterm=none
" scrollbar in popup
hi PMenuSbar guibg=#505860 gui=none
hi PMenuSbar ctermbg=59 cterm=none
" thumb of the scrollbar in the popup
hi PMenuThumb guibg=#808890 gui=none
hi PMenuThumb ctermbg=102 cterm=none
" Status Line
" -----------
" status line for current window
hi StatusLine guifg=#e0e0e0 guibg=#363946 gui=bold
hi StatusLine ctermfg=254 ctermbg=237 cterm=bold
" status line for non-current windows
hi StatusLineNC guifg=#767986 guibg=#363946 gui=none
hi StatusLineNC ctermfg=244 ctermbg=237 cterm=none
" Tab Lines
" ---------
" tab pages line, not active tab page label
hi TabLine guifg=#b6bf98 guibg=#363946 gui=none
hi TabLine ctermfg=244 ctermbg=236 cterm=none
" tab pages line, where there are no labels
hi TabLineFill guifg=#cfcfaf guibg=#363946 gui=none
hi TabLineFill ctermfg=187 ctermbg=236 cterm=none
" tab pages line, active tab page label
hi TabLineSel guifg=#efefef guibg=#414658 gui=bold
hi TabLineSel ctermfg=254 ctermbg=236 cterm=bold
" Visual
" ------
" visual mode selection
hi Visual guifg=NONE guibg=#364458
hi Visual ctermfg=NONE ctermbg=24
" visual mode selection when vim is not owning the selection (x11 only)
hi VisualNOS guifg=fg gui=underline
hi VisualNOS ctermfg=fg cterm=underline
hi VimwikiHeader1 guifg=#e0e8b0 gui=bold
hi VimWikiHeader1 ctermfg=187 cterm=none
hi VimwikiHeader2 guifg=#80c0d8 gui=bold
hi VimwikiHeader2 ctermfg=110 cterm=none
hi VimwikiHeader3 guifg=#b3d38c gui=bold
hi VimwikiHeader3 ctermfg=150 cterm=none
hi VimwikiHeader4 guifg=#86c6b6 gui=bold
hi VimwikiHeader4 ctermfg=116 cterm=none
hi VimwikiHeader5 guifg=#b0a0c0 gui=bold
hi VimwikiHeader5 ctermfg=182 cterm=none
hi VimwikiHeader6 guifg=#90d0a0 gui=bold
hi VimwikiHeader6 ctermfg=115 cterm=none

View File

@@ -126,16 +126,9 @@
:VimwikiToggleListItem vimwiki.txt /*:VimwikiToggleListItem*
:VimwikiUISelect vimwiki.txt /*:VimwikiUISelect*
:VimwikiVSplitLink vimwiki.txt /*:VimwikiVSplitLink*
AnsiEsc AnsiEsc.txt /*AnsiEsc*
AnsiEsc-contents AnsiEsc.txt /*AnsiEsc-contents*
AnsiEsc-copyright AnsiEsc.txt /*AnsiEsc-copyright*
AnsiEsc-history AnsiEsc.txt /*AnsiEsc-history*
AnsiEsc-manual AnsiEsc.txt /*AnsiEsc-manual*
AnsiEsc.txt AnsiEsc.txt /*AnsiEsc.txt*
ExtractSnips() snipMate.txt /*ExtractSnips()*
ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()*
Filename() snipMate.txt /*Filename()*
Id vimblogger_ft.txt /*Id*
ResetSnippets() snipMate.txt /*ResetSnippets()*
ShowMarksClearAll showmarks.txt /*ShowMarksClearAll*
ShowMarksClearMark showmarks.txt /*ShowMarksClearMark*
@@ -276,6 +269,7 @@ g:blogger_login vimblogger_ft.txt /*g:blogger_login*
g:blogger_maxarticles vimblogger_ft.txt /*g:blogger_maxarticles*
g:blogger_name vimblogger_ft.txt /*g:blogger_name*
g:blogger_pass vimblogger_ft.txt /*g:blogger_pass*
g:blogger_pygments_class vimblogger_ft.txt /*g:blogger_pygments_class*
g:blogger_stylesheets vimblogger_ft.txt /*g:blogger_stylesheets*
g:fuf_abbrevMap fuf.txt /*g:fuf_abbrevMap*
g:fuf_autoPreview fuf.txt /*g:fuf_autoPreview*

View File

@@ -1,4 +1,4 @@
*vimblogger_ft.txt* reStructuredText to Blogger Interface
*vimblogger_ft.txt* reStructuredText to Blogger interface
Author: Roman Dobosz, gryf73 at gmail com
Simple interface to create blog articles in rsST format. It provides
@@ -15,24 +15,50 @@ Other requirements:
- Python (tested with version 2.6, should work also in others)
- gdata http://code.google.com/p/gdata-python-client
- docutils http://docutils.sourceforge.net
- pygments http://pygments.org (optional)
- Pygments http://pygments.org (optional)
- Blogger account
-----------------------------------------------------------------------
Install~
Extract zip file into your ~/.vim.
Edit the vba file and type: >
:so %
========================================================================
Usage~
This plugin is targeting for people, who has blogger account, want to
use vim for creating blog articles and don't really likes to manually do
use VIm for creating blog articles and don't really likes to manually do
this in html.
Unfortunately it has several limitations, like you cannot use multiple
blogs or edit existing articles without reST source files. You have to
somehow convert it reStructuredText, add *Id* and then update it.
Before starting writing a post, at least |g:blogger_name| and
|g:blogger_login| has to be set up in |.vimrc|. Next, an article has to
be written using standard reST markup, |:Title:| added (not required,
but it's nice to have some title for a blog entry). Now,
|:PreviewBlogArticle| can be used for saving generated HTML page into
the file of the same name as reST file. Please note, that it'll silently
overwrite existing file, because it is treated as a temporary file.
When article is done, |:SendBlogArticle| will send it to the server.
Output provided by |:PreviewBlogArticle| without any
css stylesheet will look pretty raw, so it is generally good idea to
grab stylesheets from blog itself, tweak it a little, and add to list
in |g:blogger_stylesheets|. They will be automatically linked to
generated preview file.
Unfortunately, this script has several limitations, like it is
impossible to use multiple blogs or edit existing articles without reST
source files. It has to be somehow converted to reStructuredText, id of
an article added to |:Id:| docinfo item and then updated. Id of an
article is available through blogger account - every action for each
post listed on Posting->Edit Posts has URL with query string item
postID, for example:
>
http://www.blogger.com/post-edit.g?blogID=9876&postID=12345
<
-----------------------------------------------------------------------
Options~
@@ -45,10 +71,10 @@ g:blogger_browser (default: 0)
*g:blogger_name*
g:blogger_name (default: "")
This is blog name, which is part of the URL, and you was obligated
to enter it during blog creation. If you don't remember it, just
check first part od the URL of your blog, just after 'http://'.
Don't be confused with the blog title.
This is blog name, which is part of the URL, and user was obligated
to enter it during blog creation. If in doubt, check first part od
the URL of the blog, just after 'http://'. Note, that blog name may
differ from the blog title, but also could be the same.
*g:blogger_login*
g:blogger_login (default: "")
@@ -57,8 +83,8 @@ g:blogger_login (default: "")
*g:blogger_pass*
g:blogger_pass (default: "")
Password. If set to empty string, You'll be asked for it every time
you do any blogger activity.
Password. If set to empty string, user will be asked for it every
time if any blogger connectivity is performed.
*g:blogger_draft*
g:blogger_draft (default: 1)
@@ -84,6 +110,12 @@ g:blogger_stylesheets (default: [])
one wanted to save stylesheets from his own blog, so that article
can be displayed almost in the same way as in blog.
*g:blogger_pygments_class*
g:blogger_pygments_class (default: "")
Name of default CSS class for usage with Pygments. When not
provided or empty, it'll use defaults from Pygments: "highlight".
========================================================================
Commands~
@@ -110,33 +142,32 @@ Commands~
reST document structure~
It is assumed, that following template will be used:
>
:Id:
:Title: Title for the blog article
:Date:
:Modified:
:Tags: some, tags
-----8<-----
:Id:
:Title: Title for the blog
:Date:
:Modified:
:Tags: some, tags
Penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Nulla facilisis massa ut massa. Sed nisi purus, malesuada eu, porta
vulputate, suscipit auctor, nunc. Vestibulum convallis, augue eu luctus
malesuada, mi ante mattis odio, ac venenatis neque sem vitae nisi.
Penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla
facilisis massa ut massa. Sed nisi purus, malesuada eu, porta vulputate,
suscipit auctor, nunc. Vestibulum convallis, augue eu luctus malesuada,
mi ante mattis odio, ac venenatis neque sem vitae nisi.
.. more
.. more
heading
-------
heading
-------
**Congue** mi, quis posuere augue nulla a augue. Pellentesque sed est.
Mauris cursus urna id lectus. Integer dignissim feugiat eros. Sed tempor
volutpat dolor. Vestibulum vel lectus nec mauris semper adipiscing.
Aliquam tincidunt enim sit amet tellus. Sed mauris nulla, semper
tincidunt, luctus a, sodales eget, leo. Sed ligula augue, cursus et.
----->8-----
**Congue** mi, quis posuere augue nulla a augue. Pellentesque sed est.
Mauris cursus urna id lectus. Integer dignissim feugiat eros. Sed
tempor volutpat dolor. Vestibulum vel lectus nec mauris semper
adipiscing.
Aliquam tincidunt enim sit amet tellus. Sed mauris nulla, semper
tincidunt, luctus a, sodales eget, leo. Sed ligula augue, cursus et.
<
reST document (optionally) starts with *docinfo* section (first several
lines, that are starting from ":" character) separaded from other
content with one empty line.
@@ -173,18 +204,69 @@ All other items are ignored.
After docinfo block, article body should be placed using markup for
reStructuredText.
Additionally, if pytgments is installed, there is sourcecode directive, simple
syntax highlighter using Pygments module. Very simple usage could be as
follows:
Note, that `.. more' will became HTML comment `<!-- more -->' which will
prevent from displaying entire post on the bloggers front page, but will
not have any visible effect during preview in browser.
-----8<-----
.. sourcecode:: python
========================================================================
Pygments code highlighting~
import vim
print vim.current.buffer.name
Additionally, if Pygments is installed, there is ``sourcecode``
directive, simple syntax highlighter using Pygments module. Very simple
usage for Python code could be as follows:
>
.. sourcecode:: python
----->8-----
import vim
print vim.current.buffer.name
<
Note, that `sourcecode' directive requires argument with the name of the
lexer to use. If wrong/non existent lexer is provided, it will fall back
to `text' lexer. For more information about available lexers, please
refer to Pygments documentation.
Directive `sourcecode' supports two options: `:linenos:' and
`:cssclass:'.
`:linenos:' takes zero or one argument - if no arguments is provided,
line numbers will be visible starting form 1. Provided integer will be
the number of the first line.
`:cssclass:' can be use for changing default class name for block of
code. Default class can be changed by appropriate option for plugin
(see documentation), and defaults to "highlight".
It is possible to use VIm colorschemes like desert (which is distributed
with VIm), Zenburn, Lucius, Wombat, inkpot or any other with Pygments.
Assuming, that colorscheme `desert' should be used, there are two steps
to achive it.
First, python module containing Pygments `Style' class has to be
generated. There is appropriate conversion tool in Pygments
distribution - `scripts/vim2pygments.py'. Uage is simple as:
>
python Pygments/scripts/vim2pygments.py \
path/to/vim/colors/desert.vim > desert.py
<
Which will create new python module ``desert.py`` containing class
`DessertStyle`'.
To generate CSS stylesheet, it's enough to:
>
python rst2blogger/scripts/style2css.py desert.py \
-c VimDesert > desert.css
<
VimDesert is the name of the class, which passed as an argument to
`:cssclass:' option of directive `sourceocode'. It will be used as a
main CSS class for code top `<div>' element. So, above example will
looks like this:
>
.. sourcecode:: python
:cssclass: VimDesert
import vim
print vim.current.buffer.name
<
Note: All headings for generated HTML by |:SendBlogArticle| will be
shifted by 3, so the first heading will become <h3>, second <h4> and so
on, to fit into blogger template (well, most of them). Remember, that
@@ -194,6 +276,7 @@ limitation.
========================================================================
Changelog~
0.2 Pygments sourcecode directive improvements
0.1 First release
vim:tw=72:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl:

View File

@@ -13,6 +13,8 @@ setlocal softtabstop=4
setlocal tabstop=4
setlocal textwidth=78
setlocal colorcolumn=+1
" overwrite status line
setlocal statusline=%<%F\ %{TagInStatusLine()}\ %h%m%r%=%(%l,%c%V%)\ %3p%%
set wildignore+=*.pyc

View File

@@ -85,9 +85,9 @@ def check(buffer):
if vimenc:
contents = contents.decode(vimenc)
builtins = []
builtins = set(['__file__'])
try:
builtins = set(eval(vim.eval('string(g:pyflakes_builtins)')))
builtins.update(set(eval(vim.eval('string(g:pyflakes_builtins)'))))
except Exception:
pass

View File

@@ -26,22 +26,24 @@ Quick Installation
2. Download the latest release_.
3. Unzip ``pyflakes.vim`` and the ``pyflakes`` directory into
3. If you're using pathogen_, unzip the contents of ``pyflakes-vim.zip`` into
its own bundle directory, i.e. into ``~/.vim/bundle/pyflakes-vim/``.
Otherwise unzip ``pyflakes.vim`` and the ``pyflakes`` directory into
``~/.vim/ftplugin/python`` (or somewhere similar on your
`runtime path`_ that will be sourced for Python files).
.. _release: http://www.vim.org/scripts/script.php?script_id=2441
.. _pathogen: http://www.vim.org/scripts/script.php?script_id=2332
.. _runtime path: http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath'
Installation
------------
Running from source
-------------------
If you downloaded this from vim.org_, then just drop the contents of the zip
file into ``~/.vim/ftplugin/python``.
Otherwise, if you're running "from source," you'll need PyFlakes on your
PYTHONPATH somewhere. I recommend getting my PyFlakes_ fork, which retains
column number information and has therfore has more specific error locations.
If you're running pyflakes-vim "from source," you'll need the PyFlakes library
on your PYTHONPATH somewhere. (It is included in the vim.org zipfile.) I recommend
getting my PyFlakes_ fork, which retains column number information, giving more
specific error locations.
.. _vim.org: http://www.vim.org/scripts/script.php?script_id=2441
.. _PyFlakes: http://github.com/kevinw/pyflakes

View File

@@ -0,0 +1,649 @@
" File: pythonhelper.vim
" Author: Michal Vitecek <fuf-at-mageo-dot-cz>
" Version: 0.81
" Last Modified: Oct 24, 2002
"
" Modified by Marius Gedminas <mgedmin@b4net.lt>
"
" Overview
" --------
" Vim script to help moving around in larger Python source files. It displays
" current class, method or function the cursor is placed in on the status
" line for every python file. It's more clever than Yegappan Lakshmanan's
" taglist.vim because it takes into account indetation and comments to
" determine what tag the cursor is placed in.
"
" Requirements
" ------------
" This script needs only VIM compiled with Python interpreter. It doesn't rely
" on exuberant ctags utility. You can determine whether your VIM has Python
" support by issuing command :ver and looking for +python in the list of
" features.
"
" Note: The script displays current tag on the status line only in NORMAL
" mode. This is because CursorHold event is fired up only in this mode.
" However if you badly need to know what tag you are in even in INSERT or
" VISUAL mode, contact me on the above specified email address and I'll send
" you a patch that enables firing up CursorHold event in those modes as well.
"
" Installation
" ------------
" 1. Make sure your Vim has python feature on (+python). If not, you will need
" to recompile it with --with-pythoninterp option to the configure script
" 2. Copy script pythonhelper.vim to the $HOME/.vim/plugin directory
" 3. Run Vim and open any python file.
"
" Marius Gedminas <marius@gedmin.as>:
" 4. change 'statusline' to include
" %{TagInStatusLine()}
"
if has("python")
python << EOS
# import of required modules {{{
import vim
import time
import sys
import re
# }}}
# global dictionaries of tags and their line numbers, keys are buffer numbers {{{
TAGS = {}
TAGLINENUMBERS = {}
BUFFERTICKS = {}
# }}}
# class PythonTag() {{{
class PythonTag:
# DOC {{{
"""A simple storage class representing a python tag.
"""
# }}}
# STATIC VARIABLES {{{
# tag type IDs {{{
TAGTYPE_CLASS = 0
TAGTYPE_METHOD = 1
TAGTYPE_FUNCTION = 2
# }}}
# tag type names {{{
typeName = {
TAGTYPE_CLASS : "class",
TAGTYPE_METHOD : "method",
TAGTYPE_FUNCTION : "function",
}
# }}}
# }}}
# METHODS {{{
def __init__(self, type, name, fullName, lineNumber, indentLevel, parentTag):
# DOC {{{
"""Initializes instances of class PythonTag().
Parameters
type -- tag type
name -- short tag name
fullName -- full tag name (in dotted notation)
lineNumber -- line number on which the tag starts
indentLevel -- indentation level of the tag
"""
# }}}
# CODE {{{
self.type = type
self.name = name
self.fullName = fullName
self.lineNumber = lineNumber
self.indentLevel = indentLevel
self.parentTag = parentTag
# }}}
def __str__(self):
# DOC {{{
"""Returns a string representation of the tag.
"""
# }}}
# CODE {{{
return "%s (%s) [%s, %u, %u]" % (self.name, PythonTag.typeName[self.type],
self.fullName, self.lineNumber, self.indentLevel,)
# }}}
__repr__ = __str__
# }}}
# }}}
# class SimplePythonTagsParser() {{{
class SimplePythonTagsParser:
# DOC {{{
"""Provides a simple python tag parser. Returns list of PythonTag()
instances.
"""
# }}}
# STATIC VARIABLES {{{
# how many chars a single tab represents (visually)
TABSIZE = 8
# regexp used to get indentation and strip comments
commentsIndentStripRE = re.compile('([ \t]*)([^\n#]*).*')
# regexp used to get class name
classRE = re.compile('class[ \t]+([a-zA-Z0-9_]+)[ \t]*([(:].*|$)')
# regexp used to get method or function name
methodRE = re.compile('def[ \t]+([^(]+).*')
# }}}
# METHODS {{{
def __init__(self, source):
# DOC {{{
"""Initializes the instance of class SimplePythonTagsParser().
Parameters
source -- source for which the tags will be generated. It must
provide callable method readline (i.e. as file objects do).
"""
# }}}
# CODE {{{
# make sure source has readline() method {{{
if (not(hasattr(source, 'readline') and
callable(source.readline))):
raise AttributeError("Source must have callable readline method.")
# }}}
# remember what the source is
self.source = source
# }}}
def getTags(self):
# DOC {{{
"""Determines all the tags for the buffer. Returns tuple in format
(tagLineNumbers, tags,).
"""
# }}}
# CODE {{{
tagLineNumbers = []
tags = {}
# list (stack) of all currently active tags
tagsStack = []
lineNumber = 0
while 1:
# get next line
line = self.source.readline()
# finish if this is the end of the source {{{
if (line == ''):
break
# }}}
lineNumber += 1
lineMatch = self.commentsIndentStripRE.match(line)
lineContents = lineMatch.group(2)
# class tag {{{
tagMatch = self.classRE.match(lineContents)
if (tagMatch):
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
tagMatch.group(1), self.tagClassTypeDecidingMethod)
tagLineNumbers.append(lineNumber)
tags[lineNumber] = currentTag
# }}}
# function/method/none tag {{{
else:
tagMatch = self.methodRE.match(lineContents)
if (tagMatch):
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
tagMatch.group(1), self.tagFunctionTypeDecidingMethod)
tagLineNumbers.append(lineNumber)
tags[lineNumber] = currentTag
# }}}
# return the tags data for the source
return (tagLineNumbers, tags,)
# }}}
def getPreviousTag(self, tagsStack):
# DOC {{{
"""Returns the previous tag (instance of PythonTag()) from the
specified tag list if possible. If not, returns None.
Parameters
tagsStack -- list (stack) of currently active PythonTag() instances
"""
# }}}
# CODE {{{
if (len(tagsStack)):
previousTag = tagsStack[-1]
else:
previousTag = None
# return the tag
return previousTag
# }}}
def computeIndentLevel(self, indentChars):
# DOC {{{
"""Computes indent level from the specified string.
Parameters
indentChars -- white space before any other character on line
"""
# }}}
# CODE {{{
indentLevel = 0
for char in indentChars:
if (char == '\t'):
indentLevel += self.TABSIZE
else:
indentLevel += 1
return indentLevel
# }}}
def getPythonTag(self, tagsStack, lineNumber, indentChars, tagName, tagTypeDecidingMethod):
# DOC {{{
"""Returns instance of PythonTag() based on the specified data.
Parameters
tagsStack -- list (stack) of tags currently active. Note: Modified
in this method!
lineNumber -- current line number
indentChars -- characters making up the indentation level of the
current tag
tagName -- short name of the current tag
tagTypeDecidingMethod -- reference to method that is called to
determine type of the current tag
"""
# }}}
# CODE {{{
indentLevel = self.computeIndentLevel(indentChars)
previousTag = self.getPreviousTag(tagsStack)
# code for enclosed tag {{{
while (previousTag):
if (previousTag.indentLevel >= indentLevel):
del tagsStack[-1]
else:
tagType = tagTypeDecidingMethod(previousTag.type)
tag = PythonTag(tagType, tagName, "%s.%s" % (previousTag.fullName, tagName,), lineNumber, indentLevel, previousTag)
tagsStack.append(tag)
return tag
previousTag = self.getPreviousTag(tagsStack)
# }}}
# code for tag in top indent level {{{
else:
tagType = tagTypeDecidingMethod(None)
tag = PythonTag(tagType, tagName, tagName, lineNumber, indentLevel, None)
tagsStack.append(tag)
return tag
# }}}
# }}}
def tagClassTypeDecidingMethod(self, previousTagsType):
# DOC {{{
"""Returns tag type of the current tag based on its previous tag (super
tag) for classes.
"""
# }}}
# CODE {{{
return PythonTag.TAGTYPE_CLASS
# }}}
def tagFunctionTypeDecidingMethod(self, previousTagsType):
# DOC {{{
"""Returns tag type of the current tag based on its previous tag (super
tag) for functions/methods.
"""
# }}}
# CODE {{{
if (previousTagsType == PythonTag.TAGTYPE_CLASS):
return PythonTag.TAGTYPE_METHOD
else:
return PythonTag.TAGTYPE_FUNCTION
# }}}
# }}}
# }}}
# class VimReadlineBuffer() {{{
class VimReadlineBuffer:
# DOC {{{
"""A simple wrapper class around vim's buffer that provides readline
method.
"""
# }}}
# METHODS {{{
def __init__(self, vimBuffer):
# DOC {{{
"""Initializes the instance of class VimReadlineBuffer().
Parameters
vimBuffer -- VIM's buffer
"""
# }}}
# CODE {{{
self.vimBuffer = vimBuffer
self.currentLine = -1
self.bufferLines = len(vimBuffer)
# }}}
def readline(self):
# DOC {{{
"""Returns next line from the buffer. If all the buffer has been read,
returns empty string.
"""
# }}}
# CODE {{{
self.currentLine += 1
# notify end of file if we reached beyond the last line {{{
if (self.currentLine == self.bufferLines):
return ''
# }}}
# return the line with added newline (vim stores the lines without newline)
return "%s\n" % (self.vimBuffer[self.currentLine],)
# }}}
# }}}
# }}}
def getNearestLineIndex(row, tagLineNumbers):
# DOC {{{
"""Returns index of line in tagLineNumbers list that is nearest to the
current cursor row.
Parameters
row -- current cursor row
tagLineNumbers -- list of tags' line numbers (ie. their position)
"""
# }}}
# CODE {{{
nearestLineNumber = -1
nearestLineIndex = -1
i = 0
for lineNumber in tagLineNumbers:
# if the current line is nearer the current cursor position, take it {{{
if (nearestLineNumber < lineNumber <= row):
nearestLineNumber = lineNumber
nearestLineIndex = i
# }}}
# if we've got past the current cursor position, let's end the search {{{
if (lineNumber >= row):
break
# }}}
i += 1
return nearestLineIndex
# }}}
def getTags(bufferNumber, changedTick):
# DOC {{{
"""Reads the tags for the specified buffer number. Returns tuple
(taglinenumber[buffer], tags[buffer],).
Parameters
bufferNumber -- number of the current buffer
changedTick -- ever increasing number used to tell if the buffer has
been modified since the last time
"""
# }}}
# CODE {{{
global TAGLINENUMBERS, TAGS, BUFFERTICKS
# return immediately if there's no need to update the tags {{{
if ((BUFFERTICKS.has_key(bufferNumber)) and (BUFFERTICKS[bufferNumber] == changedTick)):
return (TAGLINENUMBERS[bufferNumber], TAGS[bufferNumber],)
# }}}
# get the tags {{{
simpleTagsParser = SimplePythonTagsParser(VimReadlineBuffer(vim.current.buffer))
tagLineNumbers, tags = simpleTagsParser.getTags()
# }}}
# update the global variables {{{
TAGS[bufferNumber] = tags
TAGLINENUMBERS[bufferNumber] = tagLineNumbers
BUFFERTICKS[bufferNumber] = changedTick
# }}}
# return the tags data
return (tagLineNumbers, tags,)
# }}}
def findTag(bufferNumber, changedTick):
# DOC {{{
"""Tries to find the best tag for the current cursor position.
Parameters
bufferNumber -- number of the current buffer
changedTick -- ever increasing number used to tell if the buffer has
been modified since the last time
"""
# }}}
# CODE {{{
try:
# get the tags data for the current buffer {{{
tagLineNumbers, tags = getTags(bufferNumber, changedTick)
# }}}
# link to vim internal data {{{
currentBuffer = vim.current.buffer
currentWindow = vim.current.window
row, col = currentWindow.cursor
# }}}
# get the index of the nearest line
nearestLineIndex = getNearestLineIndex(row, tagLineNumbers)
# if any line was found, try to find if the tag is appropriate {{{
# (ie. the cursor can be below the last tag but on a code that has nothing
# to do with the tag, because it's indented differently, in such case no
# appropriate tag has been found.)
if (nearestLineIndex > -1):
nearestLineNumber = tagLineNumbers[nearestLineIndex]
tagInfo = tags[nearestLineNumber]
# walk through all the lines in range (nearestTagLine, cursorRow) {{{
for i in xrange(nearestLineNumber + 1, row):
line = currentBuffer[i]
# count the indentation of the line, if it's lower that the tag's, the found tag is wrong {{{
if (len(line)):
# compute the indentation of the line {{{
lineStart = 0
j = 0
while ((j < len(line)) and (line[j].isspace())):
if (line[j] == '\t'):
lineStart += SimplePythonTagsParser.TABSIZE
else:
lineStart += 1
j += 1
# if the line contains only spaces, it doesn't count {{{
if (j == len(line)):
continue
# }}}
# if the next character is # (python comment), this line doesn't count {{{
if (line[j] == '#'):
continue
# }}}
# }}}
# if the line's indentation starts before or at the nearest tag's one, the tag is wrong {{{
while tagInfo is not None and lineStart <= tagInfo.indentLevel:
tagInfo = tagInfo.parentTag
# }}}
# }}}
# }}}
else:
tagInfo = None
# }}}
# describe the cursor position (what tag it's in) {{{
tagDescription = ""
if tagInfo is not None:
## tagDescription = "[in %s (%s)]" % (tagInfo.fullName, PythonTag.typeName[tagInfo.type],)
tagDescription = "[%s]" % (tagInfo.fullName, )
# }}}
# update the variable for the status line so it will be updated next time
vim.command("let w:PHStatusLine=\"%s\"" % (tagDescription,))
except:
# spit out debugging information {{{
ec, ei, tb = sys.exc_info()
while (tb != None):
if (tb.tb_next == None):
break
tb = tb.tb_next
print "ERROR: %s %s %s:%u" % (ec.__name__, ei, tb.tb_frame.f_code.co_filename, tb.tb_lineno,)
time.sleep(0.5)
# }}}
# }}}
def deleteTags(bufferNumber):
# DOC {{{
"""Removes tags data for the specified buffer number.
Parameters
bufferNumber -- number of the buffer
"""
# }}}
# CODE {{{
global TAGS, TAGLINENUMBERS, BUFFERTICKS
try:
del TAGS[bufferNumber]
del TAGLINENUMBERS[bufferNumber]
del BUFFERTICKS[bufferNumber]
except:
pass
# }}}
EOS
" VIM functions {{{
function! PHCursorHold()
" only python is supported {{{
if (!exists('b:current_syntax') || (b:current_syntax != 'python'))
let w:PHStatusLine = ''
return
endif
" }}}
" call python function findTag() with the current buffer number and changed ticks
execute 'python findTag(' . expand("<abuf>") . ', ' . b:changedtick . ')'
endfunction
function! PHBufferDelete()
" set PHStatusLine for this window to empty string
let w:PHStatusLine = ""
" call python function deleteTags() with the cur
execute 'python deleteTags(' . expand("<abuf>") . ')'
endfunction
function! TagInStatusLine()
" return value of w:PHStatusLine in case it's set
if (exists("w:PHStatusLine"))
return w:PHStatusLine
" otherwise just return empty string
else
return ""
endif
endfunction
" }}}
" event binding, vim customizing {{{
" autocommands binding
if v:version >= 700
autocmd CursorMoved * call PHCursorHold()
else
autocmd CursorHold * call PHCursorHold()
endif
autocmd BufDelete * silent call PHBufferDelete()
"" " time that determines after how long time of no activity the CursorHold event
"" " is fired up
"" set updatetime=1000
""
"" " color of the current tag in the status line (bold cyan on black)
"" highlight User1 gui=bold guifg=cyan guibg=black
"" " color of the modified flag in the status line (bold black on red)
"" highlight User2 gui=bold guifg=black guibg=red
"" " the status line will be displayed for every window
"" set laststatus=2
"" " set the status line to display some useful information
"" set stl=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ \ \ \ [buf\ %n]
" }}}
" vim:foldmethod=marker
endif " has("python")

View File

@@ -9,7 +9,8 @@ setlocal formatoptions=tcq "set VIms default
let g:blogger_login="gryf73"
let g:blogger_name="rdobosz"
let g:blogger_browser=1
let g:blogger_stylesheets=["css/widget_css_2_bundle.css", "css/style_custom.css", "css/style_blogger.css"]
let g:blogger_stylesheets=["css/widget_css_2_bundle.css", "css/style_custom.css", "css/style_blogger.css", "css/wombat_pygments.css", "css/lucius_pygments.css"]
let g:blogger_pygments_class="wombat"
map <F6> :PreviewBlogArticle<cr>
map <F7> :SendBlogArticle<cr>

View File

@@ -13,6 +13,11 @@ from xml.parsers.expat import ExpatError
import vim
from rst2blogger.rest import blogPreview, blogArticleString
try:
from rst2blogger.rest import register
except ImportError:
pass
from rst2blogger.blogger import VimBlogger
@@ -35,6 +40,11 @@ class Rst2Blogger(object):
self.maxarticles = int(vim.eval("g:blogger_maxarticles"))
self.confirm_del = int(vim.eval("g:blogger_confirm_del"))
self.stylesheets = vim.eval("g:blogger_stylesheets")
self.pygments_class = vim.eval("g:blogger_pygments_class")
try:
register(self.pygments_class)
except NameError:
pass
def preview(self):
"""

View File

@@ -17,6 +17,31 @@ try:
from pygments.lexers import get_lexer_by_name, TextLexer
from pygments.formatters import HtmlFormatter
def register(cssclass=None):
if cssclass:
Pygments.cssclass = cssclass
directives.register_directive('sourcecode', Pygments)
def _positive_int_or_1(argument):
"""
Converts the argument into an integer. Returns positive integer. In
case of integers smaller than 1, returns 1. In case of None, returns
1.
"""
if argument is None:
return 1
retval = 1
try:
retval = int(argument)
except ValueError:
pass
if retval < 1:
return 1
return retval
class Pygments(Directive):
"""
Source code syntax highlighting.
@@ -24,7 +49,11 @@ try:
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {'linenos': _positive_int_or_1,
'cssclass': directives.unchanged_required}
has_content = True
cssclass = None
def run(self):
self.assert_has_content()
@@ -33,12 +62,26 @@ try:
except ValueError:
# no lexer found - use the text one instead of an exception
lexer = TextLexer()
# take an arbitrary option if more than one is given
formatter = HtmlFormatter(noclasses=True)
kwargs = {'full': False,
'noclasses': False}
if self.options and 'linenos' in self.options:
kwargs['linenos'] = 'inline'
kwargs['linenostart'] = self.options['linenos']
if Pygments.cssclass:
kwargs['cssclass'] = Pygments.cssclass
if self.options and 'cssclass' in self.options:
kwargs['cssclass'] = self.options['cssclass']
formatter = HtmlFormatter(**kwargs)
parsed = highlight(u'\n'.join(self.content), lexer, formatter)
return [nodes.raw('', parsed, format='html')]
directives.register_directive('sourcecode', Pygments)
register()
except ImportError:
pass

View File

@@ -0,0 +1,73 @@
#!/usr/bin/env python
"""
Generate CSS stylesheet out of provided Style class module, which is an output
from the vim2pygments.py[1] script.
That stylesheet (with any necessary, additional modifications) can be used
with vimblogger_ft[2] VIm plugin, but also for general pygments usage.
Usage:
style2css <module>
[1] vim2pygments is part of the Pygments module, and can be found in scripts
directory of the Pygments <http://pygments.org> distribution.
[2] <http://www.vim.org/scripts/script.php?script_id=3367>
"""
import optparse
import os
from pygments.formatters import HtmlFormatter
class Pygments2CSS(object):
def __init__(self, modulefn, cssclass):
self.style_class = None
self.cssclass = cssclass
if not self.cssclass.startswith("."):
self.cssclass = "." + self.cssclass
mod = os.path.splitext(os.path.basename(modulefn))[0]
try:
module = __import__("%s" % mod)
except ImportError:
print('Error: %s should be in PYTHONPATH or current'
' directory, and should contain valid Style derived'
' class' % modulefn)
raise
for item in dir(module):
if item != 'Style' and item.endswith('Style'):
self.style_class = getattr(module, item)
break
else:
raise ValueError("Error: Wrong module?")
def out(self):
formatter = HtmlFormatter(style=self.style_class)
print "%s { background-color: %s }" % \
(self.cssclass, self.style_class.background_color)
for line in formatter.get_style_defs().split("\n"):
print "%s" % self.cssclass, line
if __name__ == "__main__":
parser = optparse.OptionParser("usage: %prog [options] stylefile.py\n"
"Where stylefile.py is a product of the"
" vim2pygments.py script Pygments "
"distribution.")
parser.add_option("-c", "--class",
dest="cssclass",
type="str",
help="Main CSS class name. Defaults to 'syntax'",
default="syntax")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("stylefile.py is required")
if not (os.path.exists(args[0]) and os.path.isfile(args[0])):
parser.error("%s not found" % args[0])
p2css = Pygments2CSS(args[0], options.cssclass)
p2css.out()

View File

@@ -278,7 +278,8 @@ class TestRst2BloggerPreview(unittest.TestCase):
Try to post not well formed html
"""
Eval.value = 1
print self.obj.preview()
self.assertEqual(self.obj.preview(),
'Generated HTML has been opened in browser')
def test_preview_save_to_file(self):
"""

View File

@@ -11,6 +11,69 @@ sys.path.insert(0, this_dir)
from rst2blogger.rest import blogArticleString, blogPreview
from rst2blogger.tests.shared import REST_ARTICLE
LINENOS1 = """
.. sourcecode:: python
:linenos:
import vim
print vim.current.buffer.name
"""
LINENOS2 = """
.. sourcecode:: python
:linenos: -1
import vim
print vim.current.buffer.name
"""
LINENOS3 = """
.. sourcecode:: python
:linenos: 0
import vim
print vim.current.buffer.name
"""
LINENOS4 = """
.. sourcecode:: python
:linenos: 12
import vim
print vim.current.buffer.name
"""
LINENOS5 = """
.. sourcecode:: python
:linenos: this is wrong
import vim
print vim.current.buffer.name
"""
CSSCLASS1 = """
.. sourcecode:: python
:cssclass:
import vim
print vim.current.buffer.name
"""
CSSCLASS2 = """
.. sourcecode:: python
:cssclass: Dessert256
import vim
print vim.current.buffer.name
"""
class TestBlogPreview(unittest.TestCase):
"""
@@ -75,5 +138,64 @@ class TestBlogArticleString(unittest.TestCase):
self.assertEqual(attrs['date'], "2010-12-12T12:36:36+01:00")
self.assertEqual(attrs['tags'], "this is a test, Blogger, rest")
class TestBlogArticlePytgments(unittest.TestCase):
"""
Test cases for sourcecode directive
"""
def test_linenos_no_args(self):
"""
Test linenos option with no additional arguments
"""
html_out, _ = blogArticleString(LINENOS1)
self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
def test_linenos_with_arg1(self):
"""
Test linenos option with correct argument type but wrong value.
Should count from 1 in this case.
"""
html_out, _ = blogArticleString(LINENOS2)
self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
def test_linenos_with_arg2(self):
"""
Test linenos option with correct argument type but wrong value.
Should count from 1 in this case.
"""
html_out, _ = blogArticleString(LINENOS3)
self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
def test_linenos_with_arg3(self):
"""
Test linenos option with correct argument type and correct value.
Should count from 1 in this case.
"""
html_out, _ = blogArticleString(LINENOS4)
self.assertTrue('<pre><span class="lineno">12</span>' in html_out)
def test_linenos_with_wrong_arg(self):
"""
Test linenos option with wrong argument type. Should count from 1.
"""
html_out, _ = blogArticleString(LINENOS5)
self.assertTrue('<pre><span class="lineno">1</span>' in html_out)
def test_cssclass_failure(self):
"""
Test cssclass option with no arguments. Should complain with system
message.
"""
html_out, _ = blogArticleString(CSSCLASS1)
self.assertTrue('System Message: ERROR/3' in html_out)
def test_cssclass_correct(self):
"""
Test cssclass option with Dessert256 as an argument. Should be used as
a main div CSS class.
"""
html_out, _ = blogArticleString(CSSCLASS2)
self.assertTrue('<div class="Dessert256">' in html_out)
if __name__ == "__main__":
unittest.main()

View File

@@ -1,6 +1,7 @@
" reST to blogger vim interface.
" Provide some convinient commands for creating preview from the reST file
" and to send articles to blog.
" VERSION: 0.2
if exists("b:did_rst_plugin")
finish " load only once
@@ -44,6 +45,10 @@ if !exists("g:blogger_stylesheets")
let g:blogger_stylesheets = []
endif
if !exists("g:blogger_pygments_class")
let g:blogger_pygments_class = ""
endif
python << EOF
import os
import sys
@@ -53,10 +58,8 @@ import vim
scriptdir = os.path.dirname(vim.eval('expand("<sfile>")'))
sys.path.insert(0, scriptdir)
try:
from rst2blogger.main import Rst2Blogger
except ImportError:
print "Plugin vimblogger cannot be loaded, due to lack of required modules"
# Will raise exception, if one of required moudles is missing
from rst2blogger.main import Rst2Blogger
EOF
if !exists(":PreviewBlogArticle")