Browse files

Version 0.21

bugfixes mostly
added more snippets
added easier navigation through wrapped lines
  • Loading branch information...
1 parent 6f450be commit ab9e072802c516eb9fb17ffe423167be1169a521 @kamil-s kamil-s committed with Dec 24, 2012
Showing with 124 additions and 64 deletions.
  1. +25 −16 doc/tex_alt.txt
  2. +2 −0 ftdetect/tex_alt.vim
  3. +41 −42 ftplugin/tex_alt.vim
  4. +55 −1 snippets/tex_alt.snippets
  5. +1 −5 syntax/tex_alt.vim
View
41 doc/tex_alt.txt
@@ -1,4 +1,4 @@
-*tex_alt.txt* For Vim version 7.3 Last change: 2012 December 18
+*tex_alt.txt* For Vim version 7.3 Last change: 2012 December 25
@@ -17,7 +17,7 @@ CONTENTS *tex_alt-contents*
tex_alt is an alternative, lightweight support for LaTeX in Vim. There are
many bundles that aim to do the same thing and possibly do it better, but this
-one is mine. Also, it’s much faster.
+one is mine. Also, it scrolls so much faster.
The problem with the out-of-the-box support, is that its both missing many
useful features, and slow. Packages such as atp-vim and others are fantastic
@@ -41,12 +41,12 @@ What tex_alt provides:
* autocompletion for commands and tags,
* auto tag regeneration on file open and save,
* basic compilation with a QuickFix window,
-* some more convenience settings.
+* some more convenience settings and mappings.
What tex_alt doesn’t provide:
* support for BibTeX,
* support for mathematics, and
-* almost and IDE kind of behaviour in general.
+* almost any IDE kind of behaviour in general.
==============================================================================
@@ -66,10 +66,6 @@ to be able to access this file through Vim’s help.
-----
-If you want Vim to automatically assume all .tex files are tex_alt, append
-this to your ~/.vimrc: >
- autocmd BufRead,BufNewFile *.tex set filetype=tex_alt
-
If you want to make full use of tex_alt, you will also need to install:
* Ctags (http://ctags.sourceforge.net/),
* Kellys colorscheme (http://www.vim.org/scripts/script.php?script_id=2463),
@@ -95,29 +91,38 @@ to disable auto regeneration of tags on file open and save.
-----
-tex_alt will map two keys:
-* <F9> to compile the currently focused file and open the |quickfix| window, and
-* <F12> to toggle the |tagbar| window.
+tex_alt will map three keys:
+* <F9> to compile the currently focused file and open the |quickfix| window,
+* <F12> to toggle the |tagbar| window, and
+* <Leader>w to toggle line wrapping on and off.
+
+Also the behaviour of the arrows and <Home> and <End> will be redefined to
+make moving through long lines more Word-like.
tex_alt will automatically open a completion popup (|ins-completion|) when it
recognizes that you typed a backslash, ‘include{’, ‘includegraphics{’,
‘input{’, or ‘ref{’. You can keep typing, or use the arrow keys or <C-n> and
-<C-p> to choose the word you meant to write. When it is highlighted, hit
-Enter or <C-y> to insert it. Cancel by pressing <C-e>.
+<C-p> to choose the word you meant to write. When it is highlighted (the first
+proposition is highlighted automatically, hit Enter, Tab or <C-y> to insert
+it. Cancel by pressing <C-e> or <Right>.
The dictionary is in ftplugin/tex_alt.dict. You can add and delete words in it
to better adjust it to your needs.
If you installed |snipMate| (see above), you will be also able to use snippets.
-The list in tex_alt is not long, but they are very easy to write (see the
-‘snippets’ directory). To give you an idea, type ‘beg’ and press <Tab>.
+The list in tex_alt is not too long, and essentially only includes the basic
+environments and sections, but snipMate snippets are very easy to write (see
+the ‘snippets’ directory). To give you an idea, type ‘beg’ and press <Tab>.
tex_alt also provides Ctags definitions for TeX which I think are smarter than
what can be found on the web, because they extract labels from inside section
names. It’s not very nice to have tagbar display section name that begins
with ‘\label{…’.
Apart from the above, some options will be set to make writing LaTeX in vim
-more pleasurable. You can inspect and adjust them in ftplugin/tex_alt.vim.
+more pleasurable. In particular, this includes mappings for more intuitive
+moving through wrapped lines, ignoring LaTeX auxiliary files when completing
+file names in the command lines, and others. You can inspect and adjust them
+in ftplugin/tex_alt.vim.
==============================================================================
@@ -128,6 +133,10 @@ The license is GPL3+. You can contact me at kamil.stachowski@at@gmail.com.
There is absolutely no guarantee whatsoever. Potentially, this bundle could
even drink up your coffee.
+0.21 2012.12.25
+ bugfixes mostly
+ added more snippets
+ added easier navigation through wrapped lines
0.2 2012.12.18
syntax rewritten from scratch
added autocompletion for commands, includes and tags
View
2 ftdetect/tex_alt.vim
@@ -0,0 +1,2 @@
+" assume all .tex files are tex_alt
+autocmd BufNewFile,BufRead *.tex set filetype=tex_alt
View
83 ftplugin/tex_alt.vim
@@ -19,16 +19,32 @@ let b:tex_alt_auto_tags = 1
" =======================================================================================
-" - autocommands & maps -----------------------------------------------------------------
+" - autocommands ------------------------------------------------------------------------
+
" update tags on file open and save
if b:tex_alt_auto_tags
autocmd! BufRead,BufWrite *.tex call <SID>GenerateTags()
endif
+
+" - maps --------------------------------------------------------------------------------
+
+
" compile and open the quickfix window
nnoremap <F9> :w<CR>:silent make % \| redraw! \| cw<CR>
nnoremap <F12> :TagbarToggle<CR>
+nnoremap <silent> <Leader>w :set wrap!<CR>
+
+" reasonable moving thrgough wrapped lines
+noremap <Up> gk
+noremap <Down> gj
+noremap <expr> <Home> &wrap ? "g\<Home>" : "^"
+noremap <expr> <End> &wrap ? "g\<End>" : "$"
+inoremap <expr> <Up> pumvisible() ? "\<Up>" : "\<C-o>gk"
+inoremap <expr> <Down> pumvisible() ? "\<Down>" : "\<C-o>gj"
+inoremap <expr> <Home> &wrap ? "\<C-o>g\<Home>" : "\<C-o>^"
+inoremap <expr> <End> &wrap ? "\<C-o>g\<End>" : "\<C-o>$"
" - completion --------------------------------------------------------------------------
@@ -39,8 +55,6 @@ setlocal completefunc=TexAltAutoComplete
" let the user keep typing after the menu pops up,
" and open the menu even if there is nothing to match against yet
setlocal completeopt=longest,menuone
-" make sure traditional LaTeX labels are understood
-setlocal iskeyword+=:,-
" set the location of the dictionary
let s:dictPath = fnameescape (expand("<sfile>:h") . "/tex_alt.dict")
if &dictionary == ""
@@ -51,10 +65,10 @@ endif
" smaller popup
setlocal pumheight=20
" auto completion popup
-inoremap \ \<C-x><C-u><C-n>
-inoremap <expr> { <SID>CheckComplKeyword()
+inoremap <buffer> \ \<C-x><C-u>
+inoremap <buffer> { {<C-x><C-u>
" alternative key shortcut for completion
-inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
+exe 'ino <buffer> <expr> <Tab> pumvisible() ? "\<C-y>" : "' . maparg("<Tab>", "i") . '"'
" - options -----------------------------------------------------------------------------
@@ -65,6 +79,8 @@ filetype indent off
setlocal synmaxcol=3000
" exclude from autocompletion in file selection
setlocal wildignore=*.aux,*.dvi,*.log,*.pdf
+" this is probably more often needed
+setlocal wrap
" compilation
let &makeprg = b:tex_alt_flavour . " -file-line-error -interaction=nonstopmode $*"
@@ -92,87 +108,70 @@ let g:tagbar_type_tex_alt = {
" =======================================================================================
-" - s:CheckComplKeyword -----------------------------------------------------------------
-
-function! s:CheckComplKeyword ()
- " Note: All new keywords must be added here, not just
- " to TexAltAutoComplete below.
- if getline('.') =~ '\(include\(graphics\)\=\|input\|ref\)$'
- return "{\<C-x>\<C-u>\<Down>"
- else
- return "{"
- endif
-endfunction
-
-" - s:GenerateTags ----------------------------------------------------------------------
-
-function! s:GenerateTags ()
- silent exe ":!ctags " . expand("%:p:h") . "/*.tex &> /dev/null &"
-endfunction
-
" - TexAltAutoComplete ------------------------------------------------------------------
function! TexAltAutoComplete (findstart, base)
" The function is run twice:
" the first time, it finds out what kind of completion is required,
" and the second time it does the actual completion.
- " This function will only do any work if it’s run immediately
- " after the trigger (\ or {) is typed.
- " Note: If ever to be extended, the new keywords must also be added
- " to s:CheckComplKeyword above.
+ " This function will only work properly if it’s run immediately
+ " after the trigger is typed (\ or {).
if a:findstart " the first run
- if getline('.') =~ "\\\\$"
+ let line = getline('.')[0:col('.')-2]
+ if line =~ "\\\\$"
let s:complMode = 'dict'
return col('.')-1
- elseif getline('.') =~ 'includegraphics{$'
+ elseif line =~ 'includegraphics{$'
let s:complMode = "incl-gr"
return col('.')-1
- elseif getline('.') =~ '\(include\|input\){$'
+ elseif line =~ '\(include\|input\){$'
let s:complMode = "incl-tex"
return col('.')-1
- elseif getline('.') =~ 'ref{$'
+ elseif line =~ 'ref{$'
let s:complMode = "ref"
return col('.')-1
else
return -3
endif
else " the second run
+ let res = []
if s:complMode == "dict"
let tmp = split (&dictionary, ",")
- let res = []
for i in tmp
let res = res + readfile (i)
endfor
- return res
elseif s:complMode == "incl-gr"
setlocal wildignore-=*.pdf
let tmp = split (globpath('.','*.eps\|gif\|jpeg\|jpg\|pdf\|png'))
setlocal wildignore+=*.pdf
- let res = []
for i in tmp
call add (res, i[2:-1])
endfor
- return res
elseif s:complMode == "incl-tex"
let tmp = split (globpath('.','*.tex'))
- let res = []
for i in tmp
call add (res, i[2:-5])
endfor
- return res
elseif s:complMode == "ref"
let tmp = filter (taglist ("^"), 'v:val["kind"]=="l"')
- let res = []
for i in tmp
call add (res, {"word":i["name"], "menu":i["filename"]})
endfor
- return res
- else
- return []
endif
+ if res != []
+ call feedkeys ("\<Down>", "n")
+ endif
+ return res
endif
endfunction
+" - s:GenerateTags ----------------------------------------------------------------------
+
+function! s:GenerateTags ()
+ let tmp = expand ("%:p:h")
+ silent exe ":!rm -rf ".tmp."/tags; ctags -R ".tmp."/*.tex &> /dev/null &"
+endfunction
+
" =======================================================================================
View
56 snippets/tex_alt.snippets
@@ -1,3 +1,5 @@
+# environments
+
# begin
snippet beg
\begin{${1:env}}
@@ -13,13 +15,65 @@ snippet enum
\begin{enumerate}
\item ${1}
\end{enumerate}
+# item
+snippet i
+ \item ${1}
+# item[]
+snippet i[
+ \item[${1}] ${2}
# itemize
snippet item
\begin{itemize}
\item ${1}
\end{itemize}
# tabular
snippet tab
- \begin{${1:tabular}}{${2:c}}
+ \begin{${1:tabular}}{${2}}
${3}
\end{$1}
+
+
+# sections
+
+# part
+snippet part
+ \part{${1:title}}
+ \label{part:${2:$1}}
+
+ ${3}
+# chapter
+snippet chap
+ \chapter{${1:title}}
+ \label{chap:${2:$1}}
+
+ ${3}
+# section
+snippet sec
+ \section{${1:title}}
+ \label{sec:${2:$1}}
+
+ ${3}
+# subsection
+snippet ssec
+ \subsection{${1:title}}
+ \label{ssec:${2:$1}}
+
+ ${3}
+# subsubsection
+snippet sssec
+ \subsubsection{${1:title}}
+ \label{sssec:${2:$1}}
+
+ ${3}
+# paragraph
+snippet par
+ \paragraph{${1:title}}
+ \label{par:${2:$1}}
+
+ ${3}
+# subparagraph
+snippet spar
+ \subparagraph{${1:title}}
+ \label{subpar:${2:$1}}
+
+ ${3}
View
6 syntax/tex_alt.vim
@@ -9,15 +9,11 @@ scriptencoding utf-8
" = brew ================================================================================
-" save some
-let s:save_iskeyword=&iskeyword
-
" has to be the first so that I can override it later
syn include @R syntax/r.vim
syn region texaltR start="<%" keepend end="%>" contains=@R
-" restore some
-let &iskeyword=s:save_iskeyword
+setlocal iskeyword+=:,-
" = definitions =========================================================================

0 comments on commit ab9e072

Please sign in to comment.