From 033d06993ee05e1f521a6801e3e2d76e4e41f56f Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 26 Sep 2010 12:34:11 +0200 Subject: [PATCH] Modified wombat color theme (colors for column adn visual block) Modified class for reST, added support for acronyms html Cosmetic changes on pylint python module Removed leftovers from nerd tree plugin --- .vimrc | 3 +- bin/pylint_parseable.py | 13 +- colors/wombat256grf.vim | 10 +- ftplugin/python/pep8_fn.vim | 5 +- ftplugin/python/pylint_fn.vim | 9 +- ftplugin/rst/commons.vim | 20 +++ nerdtree_plugin/exec_menuitem.vim | 41 ------- nerdtree_plugin/fs_menu.vim | 194 ------------------------------ 8 files changed, 44 insertions(+), 251 deletions(-) delete mode 100644 nerdtree_plugin/exec_menuitem.vim delete mode 100644 nerdtree_plugin/fs_menu.vim diff --git a/.vimrc b/.vimrc index 1b974cf..b8220d8 100644 --- a/.vimrc +++ b/.vimrc @@ -72,7 +72,7 @@ set noswapfile :let html_ignore_folding = 1 :let html_use_encoding = "utf-8" "}}} -"COMMON: specific vim behaviour for Python files {{{ +"COMMON: specific vim behaviour {{{ " "remove all trailing whitespace for specified files before write autocmd BufWritePre *.py :call StripTrailingWhitespaces() @@ -183,7 +183,6 @@ map :lprevious map :lnext map :QFix map :LWin -map :call ToggleQFonValidate() "remove trailing whitespaces map :%s/\s\+$// diff --git a/bin/pylint_parseable.py b/bin/pylint_parseable.py index e26ff02..0ec2ef6 100755 --- a/bin/pylint_parseable.py +++ b/bin/pylint_parseable.py @@ -20,8 +20,11 @@ def parsable_pylint(filename): """ Simple wrapper for pylint checker. Provides nice, parseable output. filename - python fileneame to check - returns list of dicts of errors, i.e.: - [{'lnum': 5, 'col': 10, 'type': 'C0324', text: 'Comma not followed by a space'}, + + Returns list of dicts of errors, i.e.: + [{'lnum': 5, 'col': 10, 'type': 'C0324', + 'text': 'Comma not followed by a space'}, + {'lnum': 12, 'type': 'C0111', 'text': 'Missing docstring'}, .... ] @@ -38,6 +41,7 @@ def parsable_pylint(filename): lint.Run(args, reporter=reporter, exit=False) sys.stderr = SYS_STDERR + # see, if we have other errors than 'No config found...' message DUMMY_STDERR.seek(0) error_list = DUMMY_STDERR.readlines() DUMMY_STDERR.truncate(0) @@ -77,9 +81,8 @@ if __name__ == "__main__": for line in parsable_pylint(args[0]): line['short'] = line['type'][0] line['fname'] = args[0] - if 'col' in line: - out = "%(fname)s: %(short)s: %(lnum)s: %(col)s: %(type)s %(text)s" - else: + out = "%(fname)s: %(short)s: %(lnum)s: %(col)s: %(type)s %(text)s" + if 'col' not in line: out = "%(fname)s: %(short)s: %(lnum)s: 0: %(type)s %(text)s" print out % line diff --git a/colors/wombat256grf.vim b/colors/wombat256grf.vim index b878a50..4eb898f 100644 --- a/colors/wombat256grf.vim +++ b/colors/wombat256grf.vim @@ -1,6 +1,6 @@ " Vim color file " Maintainer: David Liang (bmdavll at gmail dot com) -" Last Change: November 28 2008 +" Last Change: 2010-09-13 " " wombat256.vim - a modified version of Wombat by Lars Nielsen that also " works on xterms with 88 or 256 colors. The algorithm for approximating the @@ -15,7 +15,7 @@ if version > 580 endif endif -let g:colors_name = "wombat256" +let g:colors_name = "wombat256grf" if !has("gui_running") && &t_Co != 88 && &t_Co != 256 finish @@ -251,10 +251,10 @@ call X("CursorColumn", "", "2d2d2d", "") "CursorIM "Question "IncSearch -call X("Search", "444444", "af87d7", "") +call X("Search", "444444", "ffab4b", "") call X("MatchParen", "ecee90", "857b6f", "bold") call X("SpecialKey", "6c6c6c", "2d2d2d", "none") -call X("Visual", "ecee90", "597418", "none") +call X("Visual", "", "26512D", "none") call X("LineNr", "857b6f", "121212", "none") call X("SignColumn", "", "121212", "none") call X("Folded", "a0a8b0", "404048", "none") @@ -337,7 +337,7 @@ call X("DiffChange", "", "424242", "bold") " DiffText xxx term=reverse cterm=bold ctermbg=9 " VIm 7.3 features -call X("ColorColumn", "", "121212", "") +call X("ColorColumn", "", "32322e", "") if ! has('gui_running') " spell, make it underline, and less bright colors. only for terminal diff --git a/ftplugin/python/pep8_fn.vim b/ftplugin/python/pep8_fn.vim index 5c48ad0..96b2ae3 100644 --- a/ftplugin/python/pep8_fn.vim +++ b/ftplugin/python/pep8_fn.vim @@ -2,6 +2,7 @@ " Author: Roman 'gryf' Dobosz (gryf73 at gmail.com) " Version: 1.0 " Last Modified: 2010-09-12 +" Description: {{{ " " Overview " -------- @@ -42,6 +43,8 @@ " [2] http://pypi.python.org/pypi/pep8 " [3] http://www.vim.org/scripts/script.php?script_id=2441 " [4] http://pypi.python.org/pypi/setuptools +" +" }}} if exists("b:did_pep8_plugin") finish " only load once @@ -53,7 +56,7 @@ if !exists("b:did_pep8_init") let b:did_pep8_init = 0 if !has('python') - echoerr "Error: the pep8_fn.vim plugin requires Vim to be compiled with +python" + echoerr "pep8_fn.vim plugin requires Vim to be compiled with +python" finish endif diff --git a/ftplugin/python/pylint_fn.vim b/ftplugin/python/pylint_fn.vim index 28d36bf..6e045eb 100644 --- a/ftplugin/python/pylint_fn.vim +++ b/ftplugin/python/pylint_fn.vim @@ -1,8 +1,10 @@ -" File: pythonlint.vim +" File: pylint_fn.vim " Author: Roman 'gryf' Dobosz (gryf73 at gmail.com) " Version: 1.0 " Last Modified: 2010-09-11 " +" Description: " {{{ +" " Overview " -------- " This plugin provides ":Pylint" command, which put pylint result into quickfix @@ -18,7 +20,7 @@ " " Installation " ------------ -" 1. Copy the pythonlint.vim file to the $HOME/.vim/ftplugin/python or +" 1. Copy the pylint_fn.vim file to the $HOME/.vim/ftplugin/python or " $HOME/vimfiles/ftplugin/python or $VIM/vimfiles/ftplugin/python " directory. If python directory doesn't exists, it should be created. " Refer to the following Vim help topics for more information about Vim @@ -40,6 +42,7 @@ " [1] http://www.logilab.org/project/pylint " [2] http://www.vim.org/scripts/script.php?script_id=2441 " [3] http://pypi.python.org/pypi/setuptools +" }}} if exists("b:did_pylint_plugin") finish " only load once @@ -51,7 +54,7 @@ if !exists("b:did_pylint_init") let b:did_pylint_init = 0 if !has('python') - echoerr "Error: the pythonlint.vim plugin requires Vim to be compiled with +python" + echoerr "Error: pylint_fn.vim requires Vim to be compiled with +python" finish endif diff --git a/ftplugin/rst/commons.vim b/ftplugin/rst/commons.vim index 2b8c3f7..7d7d44e 100644 --- a/ftplugin/rst/commons.vim +++ b/ftplugin/rst/commons.vim @@ -12,10 +12,15 @@ map :call Rst2Blogger() " suitable to copy and paste into blogger post. fun Rst2Blogger() python << EOF +import re + from docutils import core +from docutils import nodes from docutils.writers.html4css1 import Writer, HTMLTranslator + import vim + class NoHeaderHTMLTranslator(HTMLTranslator): def __init__(self, document): HTMLTranslator.__init__(self,document) @@ -41,6 +46,21 @@ class NoHeaderHTMLTranslator(HTMLTranslator): def depart_section(self, node): pass + def visit_acronym(self, node): + node_text = node.children[0].astext() + node_text = node_text.replace('\n', ' ') + patt = re.compile(r'^(.+)\s<(.+)>') + + if patt.match(node_text): + node.children[0] = nodes.Text(patt.match(node_text).groups()[0]) + self.body.append(\ + self.starttag(node, 'acronym', + '', title=patt.match(node_text).groups()[1])) + + else: + self.body.append(self.starttag(node, 'acronym', '')) + + _w = Writer() _w.translator_class = NoHeaderHTMLTranslator diff --git a/nerdtree_plugin/exec_menuitem.vim b/nerdtree_plugin/exec_menuitem.vim deleted file mode 100644 index e7a7c53..0000000 --- a/nerdtree_plugin/exec_menuitem.vim +++ /dev/null @@ -1,41 +0,0 @@ -" ============================================================================ -" File: exec_menuitem.vim -" Description: plugin for NERD Tree that provides an execute file menu item -" Maintainer: Martin Grenfell -" Last Change: 22 July, 2009 -" License: This program is free software. It comes without any warranty, -" to the extent permitted by applicable law. You can redistribute -" it and/or modify it under the terms of the Do What The Fuck You -" Want To Public License, Version 2, as published by Sam Hocevar. -" See http://sam.zoy.org/wtfpl/COPYING for more details. -" -" ============================================================================ -if exists("g:loaded_nerdtree_exec_menuitem") - finish -endif -let g:loaded_nerdtree_exec_menuitem = 1 - -call NERDTreeAddMenuItem({ - \ 'text': '(!)Execute file', - \ 'shortcut': '!', - \ 'callback': 'NERDTreeExecFile', - \ 'isActiveCallback': 'NERDTreeExecFileActive' }) - -function! NERDTreeExecFileActive() - let node = g:NERDTreeFileNode.GetSelected() - return !node.path.isDirectory && node.path.isExecutable -endfunction - -function! NERDTreeExecFile() - let treenode = g:NERDTreeFileNode.GetSelected() - echo "==========================================================\n" - echo "Complete the command to execute (add arguments etc):\n" - let cmd = treenode.path.str({'escape': 1}) - let cmd = input(':!', cmd . ' ') - - if cmd != '' - exec ':!' . cmd - else - echo "Aborted" - endif -endfunction diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim deleted file mode 100644 index e25b38c..0000000 --- a/nerdtree_plugin/fs_menu.vim +++ /dev/null @@ -1,194 +0,0 @@ -" ============================================================================ -" File: fs_menu.vim -" Description: plugin for the NERD Tree that provides a file system menu -" Maintainer: Martin Grenfell -" Last Change: 17 July, 2009 -" License: This program is free software. It comes without any warranty, -" to the extent permitted by applicable law. You can redistribute -" it and/or modify it under the terms of the Do What The Fuck You -" Want To Public License, Version 2, as published by Sam Hocevar. -" See http://sam.zoy.org/wtfpl/COPYING for more details. -" -" ============================================================================ -if exists("g:loaded_nerdtree_fs_menu") - finish -endif -let g:loaded_nerdtree_fs_menu = 1 - -call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) -call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) -call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if g:NERDTreePath.CopyingSupported() - call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) -endif - -"FUNCTION: s:echo(msg){{{1 -function! s:echo(msg) - redraw - echomsg "NERDTree: " . a:msg -endfunction - -"FUNCTION: s:echoWarning(msg){{{1 -function! s:echoWarning(msg) - echohl warningmsg - call s:echo(a:msg) - echohl normal -endfunction - -"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is deleted -" -"Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! s:promptToDelBuffer(bufnum, msg) - echo a:msg - if nr2char(getchar()) ==# 'y' - exec "silent bdelete! " . a:bufnum - endif -endfunction - -"FUNCTION: NERDTreeAddNode(){{{1 -function! NERDTreeAddNode() - let curDirNode = g:NERDTreeDirNode.GetSelected() - - let newNodeName = input("Add a childnode\n". - \ "==========================================================\n". - \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . - \ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash()) - - if newNodeName ==# '' - call s:echo("Node Creation Aborted.") - return - endif - - try - let newPath = g:NERDTreePath.Create(newNodeName) - let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) - - let newTreeNode = g:NERDTreeFileNode.New(newPath) - if parentNode.isOpen || !empty(parentNode.children) - call parentNode.addChild(newTreeNode, 1) - call NERDTreeRender() - call newTreeNode.putCursorHere(1, 0) - endif - catch /^NERDTree/ - call s:echoWarning("Node Not Created.") - endtry -endfunction - -"FUNCTION: NERDTreeMoveNode(){{{1 -function! NERDTreeMoveNode() - let curNode = g:NERDTreeFileNode.GetSelected() - let newNodePath = input("Rename the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path for the node: \n" . - \ "", curNode.path.str()) - - if newNodePath ==# '' - call s:echo("Node Renaming Aborted.") - return - endif - - try - let bufnum = bufnr(curNode.path.str()) - - call curNode.rename(newNodePath) - call NERDTreeRender() - - "if the node is open in a buffer, ask the user if they want to - "close that buffer - if bufnum != -1 - let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:promptToDelBuffer(bufnum, prompt) - endif - - call curNode.putCursorHere(1, 0) - - redraw - catch /^NERDTree/ - call s:echoWarning("Node Not Renamed.") - endtry -endfunction - -" FUNCTION: NERDTreeDeleteNode() {{{1 -function! NERDTreeDeleteNode() - let currentNode = g:NERDTreeFileNode.GetSelected() - let confirmed = 0 - - if currentNode.path.isDirectory - let choice =input("Delete the current node\n" . - \ "==========================================================\n" . - \ "STOP! To delete this entire directory, type 'yes'\n" . - \ "" . currentNode.path.str() . ": ") - let confirmed = choice ==# 'yes' - else - echo "Delete the current node\n" . - \ "==========================================================\n". - \ "Are you sure you wish to delete the node:\n" . - \ "" . currentNode.path.str() . " (yN):" - let choice = nr2char(getchar()) - let confirmed = choice ==# 'y' - endif - - - if confirmed - try - call currentNode.delete() - call NERDTreeRender() - - "if the node is open in a buffer, ask the user if they want to - "close that buffer - let bufnum = bufnr(currentNode.path.str()) - if buflisted(bufnum) - let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:promptToDelBuffer(bufnum, prompt) - endif - - redraw - catch /^NERDTree/ - call s:echoWarning("Could not remove node") - endtry - else - call s:echo("delete aborted") - endif - -endfunction - -" FUNCTION: NERDTreeCopyNode() {{{1 -function! NERDTreeCopyNode() - let currentNode = g:NERDTreeFileNode.GetSelected() - let newNodePath = input("Copy the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path to copy the node to: \n" . - \ "", currentNode.path.str()) - - if newNodePath != "" - "strip trailing slash - let newNodePath = substitute(newNodePath, '\/$', '', '') - - let confirmed = 1 - if currentNode.path.copyingWillOverwrite(newNodePath) - call s:echo("Warning: copying may overwrite files! Continue? (yN)") - let choice = nr2char(getchar()) - let confirmed = choice ==# 'y' - endif - - if confirmed - try - let newNode = currentNode.copy(newNodePath) - call NERDTreeRender() - call newNode.putCursorHere(0, 0) - catch /^NERDTree/ - call s:echoWarning("Could not copy node") - endtry - endif - else - call s:echo("Copy aborted.") - endif - redraw -endfunction - -" vim: set sw=4 sts=4 et fdm=marker: