diff --git a/.vimrc b/.vimrc index 54c9426..d39e709 100644 --- a/.vimrc +++ b/.vimrc @@ -1,6 +1,6 @@ "" Vim configuration " Maintainer: Mariano Anaya -" Version: v0.5 +" Version: v0.6 " Created: 01 Jan 2014 """""""""""""""""""""""""""""" @@ -15,8 +15,6 @@ set incsearch set wildmenu set showmatch set history=50 -"" New escaping sequence, double-tab for returning to normal mode -inoremap "" \t handled properly & PEP8 set expandtab @@ -39,6 +37,8 @@ set cursorline set wildignore=*.pyc,**/__pycache__* set showmode set autoread +set autowrite +set autowriteall set hidden "" Where to open new windows @@ -168,15 +168,8 @@ map :call ToggleLangCheck() set pastetoggle= nnoremap e :set number! - -"" autocmd`s for python only -augroup Python - autocmd! - "" Shortcut for commenting out lines in python files - autocmd FileType python nnoremap c I# - "" Remove trailing white spaces on saving *.py files - autocmd BufWritePre *.py :%s/\s\+$//e -augroup END -"" autocmd`s for other file types autocmd FileType xml map :call FormatXML() +"" Remove trailing white spaces upon saving +autocmd BufWritePre * :%s/\s\+$//e +"" Python: Highlight everything let g:python_highlight_all = 1 diff --git a/Makefile b/Makefile index 200ae97..39a82f6 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ DIRS = \ $(HOME)/.vim/autoload \ $(HOME)/.vim/plugin \ $(HOME)/.vim/ftplugin \ + $(HOME)/.vim/after/ftplugin \ $(PACKAGES_DIR) BRANCH := master +REPO_HOME := https://github.com/rmariano/vim-config REPO_URL := https://raw.github.com/rmariano/vim-config REMOTELOC := $(REPO_URL)/$(BRANCH) @@ -26,17 +28,19 @@ RED := \e[91m all: install .PHONY: dev-deploy -dev-deploy: +dev-deploy: dirs @echo "Symlinking files..." ln -sfn $(PWD)/.vimrc $(HOME)/.vimrc ln -sfn $(SOURCE_COLORS) $(TARGET_COLORS) ln -sfn $(SOURCE_SYNTAX) $(TARGET_SYNTAX) + ln -sfn $(PWD)/after/ftplugin/*.vim $(HOME)/.vim/after/ftplugin/ .PHONY: deploy deploy: dirs clean cp -f $(PWD)/.vimrc $(HOME)/.vimrc cp -f $(SOURCE_COLORS) $(TARGET_COLORS) cp -f $(SOURCE_SYNTAX) $(TARGET_SYNTAX) + cp -fa $(PWD)/after/ftplugin $(HOME)/.vim/after .PHONY: dirs dirs: @@ -73,10 +77,10 @@ extras: flake8 fugitive nerdtree # make install BRANCH= .PHONY: install install: dirs - echo "Getting files from $(REMOTELOC)" - @wget -O $(HOME)/.vimrc $(REMOTELOC)/.vimrc - @wget -O $(TARGET_COLORS) $(REMOTELOC)/colors/tromso.vim - @wget -O $(TARGET_SYNTAX) $(REMOTELOC)/syntax/python.vim + rm -fr /tmp/vimconfig && mkdir -p /tmp/vimconfig + @wget -O /tmp/vimconfig/vimconfig.zip $(REPO_HOME)/archive/$(BRANCH).zip + @unzip -d /tmp/vimconfig /tmp/vimconfig/vimconfig.zip + @cd /tmp/vimconfig/vim-config-$(BRANCH) && make deploy && cd - # make changelog TAG= .PHONY: changelog @@ -101,4 +105,7 @@ release: $(PRECHANGELOG) .PHONY: clean clean: - rm -f $(HOME)/.vimrc $(TARGET_COLORS) $(TARGET_SYNTAX) + rm -fr $(HOME)/.vimrc \ + $(TARGET_COLORS) \ + $(TARGET_SYNTAX) \ + $(HOME)/.vim/after/ftplugin diff --git a/README.rst b/README.rst index 3a38a0a..3a8147b 100644 --- a/README.rst +++ b/README.rst @@ -65,68 +65,28 @@ want to start over, you could simply run ``make clean``, which will remove the files for this project (not the extra packages, though). -Colour scheme -------------- - -The colour scheme requires the terminal to support 256 colours. Most of the -terminals already support this, but some terminal multiplexers like ``tmux`` -might require to be run as: ``tmux -2`` in order to support this. - -In addition, just the command-line classic Vim version is supported, so no -support for ``Gvim`` or graphical versions is included for the colour scheme, -although pull requests are welcomed. - -Captures -^^^^^^^^ - -Here are some examples of how the colour scheme looks like. - -.. image:: https://rmariano.github.io/itarch/vim-capture1.png - :target: https://rmariano.github.io/itarch/vim-capture1.png - :width: 883px - :height: 391px - :alt: Vim capture 1 - :align: center - -Please note this might depend on the configuration of your terminal as well. - -.. image:: https://rmariano.github.io/itarch/vim-capture2.png - :target: https://rmariano.github.io/itarch/vim-capture2.png - :width: 574px - :height: 596px - :alt: Vim capture 2 - :align: center - - -Contributing ------------- - -If you want to try the project, and tweak the settings, I would recommend you -to clone the repository, and use the development deployment, which creates -symlinks of the files in this project, like: - -.. code:: bash - - make dev-deploy - -In addition, take a moment to read the contributing guidelines. - - Features -------- -* Mapping double ```` to ```` for faster access. - * `PEP-8 `_ general rules of text: automatically handling spaces instead of tabs, proper indentation, wrap text to 79 columns, margin set (toggle-able), etc. +* ```` + ``tw`` will highlight trailing white spaces. + +* ```` + ``w`` will remove them (they'll also be automatically removed + when saving :-) + * ``autoindent`` & ``smartindent``. * Function keys * ````: toggle spell check. - * ````: auto indent/format files (currently only XML support). + * ````: Correct files automatically + + * XML: auto-format & indent. + * Python: PEP-8, sort imports, and run ``flake8`` checks. + * ````: toggle paste mode * ```` + ``nh`` as a shortcut for ``:nohlsearch`` @@ -173,6 +133,52 @@ Features * Silent bells * Set hidden buffers +Colour scheme +------------- + +The colour scheme requires the terminal to support 256 colours. Most of the +terminals already support this, but some terminal multiplexers like ``tmux`` +might require to be run as: ``tmux -2`` in order to support this. + +In addition, just the command-line classic Vim version is supported, so no +support for ``Gvim`` or graphical versions is included for the colour scheme, +although pull requests are welcomed. + +Captures +^^^^^^^^ + +Here are some examples of how the colour scheme looks like. + +.. image:: https://rmariano.github.io/itarch/vim-capture1.png + :target: https://rmariano.github.io/itarch/vim-capture1.png + :width: 883px + :height: 391px + :alt: Vim capture 1 + :align: center + +Please note this might depend on the configuration of your terminal as well. + +.. image:: https://rmariano.github.io/itarch/vim-capture2.png + :target: https://rmariano.github.io/itarch/vim-capture2.png + :width: 574px + :height: 596px + :alt: Vim capture 2 + :align: center + + +Contributing +------------ + +If you want to try the project, and tweak the settings, I would recommend you +to clone the repository, and use the development deployment, which creates +symlinks of the files in this project, like: + +.. code:: bash + + make dev-deploy + +In addition, take a moment to read the contributing guidelines. + Dependencies ------------ diff --git a/after/ftplugin/python.vim b/after/ftplugin/python.vim new file mode 100644 index 0000000..25402f4 --- /dev/null +++ b/after/ftplugin/python.vim @@ -0,0 +1,17 @@ +"" Settings for Python + +"" Shortcut for commenting out lines in python files +nnoremap c I# + +function! AutofixPy() + echom "Correcting Python file" + if executable("autopep8") + execute ":silent %!autopep8 - 2> /dev/null" + endif + if executable("isort") + execute ":silent %!isort - 2>/dev/null" + endif + call Flake8() +endfunction + +map :call AutofixPy() diff --git a/changelog.rst b/changelog.rst index a7cfe2c..e074b71 100644 --- a/changelog.rst +++ b/changelog.rst @@ -1,6 +1,22 @@ Change Log ========== +v0.6 (2017-11-01) +----------------- +* Documentation: corrections & formatting, describe new installation process, + new functions, and mappings. +* Installation changed: ``deploy.sh`` removed and new Makefile instructions for + local and remote installation support. +* Python syntax highlighting: extended support for ``Python 3.6``. +* New mapping: ```` automatically corrects & formats the current file. +* Moves Python-specific configuration. +* ``deploy.sh`` deleted. +* Python: Highlight for ``__dict__`` +* Remove trailing white spaces in all files upon saving (not just ``*.py`` + files). +* ``autowrite`` & ``autowriteall``. +* Removed double tab mapping (```` no longer equals ````). + v0.5 (2017-03-18) ----------------- * Makefile: Improved installation and more (deploy, install extras, etc.). diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 7e40bae..0000000 --- a/deploy.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e -echo """ -##################################################### -#### DEPRECATED -#### Left only for backwards-compatibility purposes -#### Use Makefile instead as - - make install -##################################################### -""" - -make install -echo "Done"; diff --git a/syntax/python.vim b/syntax/python.vim index 7afc7c0..fe5d04c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -186,6 +186,8 @@ else syn match pythonStatement "\" display endif +syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc + " " Decorators (new in Python 2.4) " @@ -276,6 +278,11 @@ else syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + + syn region pythonFString start=+[fF]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonFString start=+[fF]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonFString start=+[fF]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonFString start=+[fF]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell endif if s:Python2Syntax() @@ -326,8 +333,9 @@ if s:Enabled("g:python_highlight_string_format") syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString - syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString + syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString + syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString + syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString contains=pythonStrInterpRegion,@pythonExpression endif endif @@ -370,28 +378,34 @@ if s:Python2Syntax() syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display syn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" display + + syn match pythonFloat "\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display + syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display + syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display else syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*\>" display syn match pythonOctError "\<0[oO]\=\o*\D\+\d*\>" display syn match pythonBinError "\<0[bB][01]*\D\+\d*\>" display - syn match pythonHexNumber "\<0[xX]\x\+\>" display - syn match pythonOctNumber "\<0[oO]\o\+\>" display - syn match pythonBinNumber "\<0[bB][01]\+\>" display + syn match pythonHexNumber "\<0[xX][_0-9a-fA-F]*\x\>" display + syn match pythonOctNumber "\<0[oO][_0-7]*\o\>" display + syn match pythonBinNumber "\<0[bB][_01]*[01]\>" display - syn match pythonNumberError "\<\d\+\D\>" display - syn match pythonNumberError "\<0\d\+\>" display + syn match pythonNumberError "\<\d[_0-9]*\D\>" display + syn match pythonNumberError "\<0[_0-9]\+\>" display + syn match pythonNumberError "\<\d[_0-9]*_\>" display syn match pythonNumber "\<\d\>" display - syn match pythonNumber "\<[1-9]\d\+\>" display - syn match pythonNumber "\<\d\+[jJ]\>" display + syn match pythonNumber "\<[1-9][_0-9]*\d\>" display + syn match pythonNumber "\<\d[jJ]\>" display + syn match pythonNumber "\<[1-9][_0-9]*\d[jJ]\>" display syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*\>" display syn match pythonBinError "\<0[bB][01]*[2-9]\d*\>" display -endif -syn match pythonFloat "\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display -syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display -syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display + syn match pythonFloat "\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>" display + syn match pythonFloat "\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>" display + syn match pythonFloat "\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=" display +endif " " Builtin objects and types @@ -479,6 +493,7 @@ endif syn keyword pythonConvention self syn keyword pythonConvention cls +syn keyword pythonConvention __dict__ if s:Enabled("g:python_slow_sync") @@ -540,6 +555,8 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonBytesError Error HiLink pythonBytesEscape Special HiLink pythonBytesEscapeError Error + HiLink pythonFString String + HiLink pythonStrInterpRegion Special endif HiLink pythonStrFormatting Special