forked from WolfgangMehner/vim-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatex-support.vim
More file actions
1594 lines (1517 loc) · 64.8 KB
/
latex-support.vim
File metadata and controls
1594 lines (1517 loc) · 64.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"===============================================================================
"
" File: latex-support.vim
"
" Description: LaTeX support (VIM Version 7.0+)
"
" Write LaTeX scripts by inserting comments, statements,
" variables and builtins.
"
" VIM Version: 7.0+
" Author: Dr. Fritz Mehner (fgm), [email protected]
" Organization: FH Südwestfalen, Iserlohn
" Version: see variable g:LatexSupportVersion below.
" Created: 27.12.2012
" License: Copyright (c) 2012-2014, Dr. Fritz Mehner
" This program is free software; you can redistribute it and/or
" modify it under the terms of the GNU General Public License as
" published by the Free Software Foundation, version 2 of the
" License.
" This program is distributed in the hope that it will be
" useful, but WITHOUT ANY WARRANTY; without even the implied
" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
" PURPOSE.
" See the GNU General Public License version 2 for more details.
"===============================================================================
"
if v:version < 700
echohl WarningMsg | echo 'plugin latex-support.vim needs Vim version >= 7'| echohl None
finish
endif
"
" Prevent duplicate loading:
"
if exists("g:LatexSupportVersion") || &cp
finish
endif
"
let g:LatexSupportVersion= "1.1.1" " version number of this script; do not change
"
"=== FUNCTION ================================================================
" NAME: latex_SetGlobalVariable {{{1
" DESCRIPTION: Define a global variable and assign a default value if nor
" already defined
" PARAMETERS: name - global variable
" default - default value
"===============================================================================
function! s:latex_SetGlobalVariable ( name, default )
if !exists('g:'.a:name)
exe 'let g:'.a:name." = '".a:default."'"
else
" check for an empty initialization
exe 'let val = g:'.a:name
if empty(val)
exe 'let g:'.a:name." = '".a:default."'"
endif
endif
endfunction " ---------- end of function s:latex_SetGlobalVariable ----------
"
"=== FUNCTION ================================================================
" NAME: GetGlobalSetting {{{1
" DESCRIPTION: take over a global setting
" PARAMETERS: varname - variable to set
" RETURNS:
"===============================================================================
function! s:GetGlobalSetting ( varname )
if exists ( 'g:'.a:varname )
exe 'let s:'.a:varname.' = g:'.a:varname
endif
endfunction " ---------- end of function s:GetGlobalSetting ----------
"
"------------------------------------------------------------------------------
" *** PLATFORM SPECIFIC ITEMS *** {{{1
"------------------------------------------------------------------------------
let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95")
let s:UNIX = has("unix") || has("macunix") || has("win32unix")
"
let s:installation = '*undefined*'
let s:Latex_GlobalTemplateFile = ''
let s:Latex_LocalTemplateFile = ''
let s:Latex_FilenameEscChar = ''
let s:Latex_Typesetter = 'pdflatex'
let s:Latex_ToolboxDir = []
if s:MSWIN
" ========== MS Windows ======================================================
"
" typesetter
let s:Latex_Latex = 'latex.exe -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Tex = 'tex.exe -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Pdflatex = 'pdflatex.exe -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Pdftex = 'pdftex.exe -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Bibtex = 'bibtex.exe'
"
" viewer
let s:Latex_DviViewer = 'dviout.exe'
let s:Latex_PsViewer = ''
let s:Latex_PdfViewer = ''
"
" converter
let s:Latex_DviPdf = 'dvipdfm.exe'
let s:Latex_DviPng = 'dvipng.exe'
let s:Latex_DviPs = 'dvips.exe'
let s:Latex_PdfPng = ''
let s:Latex_PsPdf = 'ps2pdf.exe'
"
let s:plugin_dir = substitute( expand('<sfile>:p:h:h'), '\', '/', 'g' )
"
" change '\' to '/' to avoid interpretation as escape character
if match( substitute( expand("<sfile>"), '\', '/', 'g' ),
\ substitute( expand("$HOME"), '\', '/', 'g' ) ) == 0
"
" USER INSTALLATION ASSUMED
let s:installation = 'local'
let s:Latex_LocalTemplateFile = s:plugin_dir.'/latex-support/templates/Templates'
let s:Latex_ToolboxDir += [ s:plugin_dir.'/autoload/mmtoolbox/' ]
else
"
" SYSTEM WIDE INSTALLATION
let s:installation = 'system'
let s:Latex_GlobalTemplateFile= s:plugin_dir.'/latex-support/templates/Templates'
let s:Latex_LocalTemplateFile = $HOME.'/vimfiles/latex-support/templates/Templates'
let s:Latex_ToolboxDir += [
\ s:plugin_dir.'/autoload/mmtoolbox/',
\ $HOME.'/vimfiles/autoload/mmtoolbox/' ]
endif
"
let s:Latex_FilenameEscChar = ''
"
else
" ========== Linux/Unix ======================================================
"
" typesetter
let s:Latex_Latex = 'latex -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Tex = 'tex -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Pdflatex = 'pdflatex -src-specials -file-line-error -interaction=nonstopmode'
let s:Latex_Pdftex = 'pdftex -src-specials -file-line-error -interaction=nonstopmode'
"
" viewer
let s:Latex_DviViewer = "xdvi"
let s:Latex_PsViewer = "gv"
let s:Latex_PdfViewer = "acroread"
let s:Latex_Bibtex = "bibtex"
"
" converter
let s:Latex_DviPdf = 'dvipdft'
let s:Latex_DviPng = 'dvipng'
let s:Latex_DviPs = 'dvips'
let s:Latex_PdfPng = 'convert'
let s:Latex_PsPdf = 'ps2pdf'
"
let s:plugin_dir = expand('<sfile>:p:h:h')
"
if match( expand("<sfile>"), resolve( expand("$HOME") ) ) == 0
"
" USER INSTALLATION ASSUMED
let s:installation = 'local'
let s:Latex_LocalTemplateFile = s:plugin_dir.'/latex-support/templates/Templates'
let s:Latex_ToolboxDir += [ s:plugin_dir.'/autoload/mmtoolbox/' ]
else
"
" SYSTEM WIDE INSTALLATION
let s:installation = 'system'
let s:Latex_GlobalTemplateFile= s:plugin_dir.'/latex-support/templates/Templates'
let s:Latex_LocalTemplateFile = $HOME.'/.vim/latex-support/templates/Templates'
let s:Latex_ToolboxDir += [
\ s:plugin_dir.'/autoload/mmtoolbox/',
\ $HOME.'/.vim/autoload/mmtoolbox/' ]
endif
"
let s:Latex_FilenameEscChar = ' \%#[]'
"
endif
"
let s:Latex_CodeSnippets = s:plugin_dir.'/latex-support/codesnippets/'
call s:latex_SetGlobalVariable( 'Latex_CodeSnippets', s:Latex_CodeSnippets )
"
"
" g:Latex_Dictionary_File must be global
"
if !exists("g:Latex_Dictionary_File")
let g:Latex_Dictionary_File = s:plugin_dir.'/latex-support/wordlists/latex-keywords.list'
endif
"
"----------------------------------------------------------------------
" *** MODUL GLOBAL VARIABLES *** {{{1
"----------------------------------------------------------------------
"
let s:escfilename = ' \%#[]'
let s:Latex_TexFlavor = 'latex'
let s:Latex_CreateMenusDelayed = 'yes'
let s:Latex_MenuVisible = 'no'
let s:Latex_GuiSnippetBrowser = 'gui' " gui / commandline
let s:Latex_LoadMenus = 'yes' " load the menus?
let s:Latex_RootMenu = 'LaTe&X' " name of the root menu
let s:Latex_UseToolbox = 'yes'
call s:latex_SetGlobalVariable ( 'Latex_UseTool_make', 'yes' )
let s:Latex_LineEndCommColDefault = 49
let s:Latex_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N"
let s:Latex_TemplateJumpTarget = ''
let s:Latex_Errorformat = 'latex:\ %f:%l:\ %m'
let s:Latex_Wrapper = s:plugin_dir.'/latex-support/scripts/wrapper.sh'
let s:Latex_InsertFileProlog = 'yes'
" overwrite the mapleader, we should not use use "\" in LaTeX
call s:latex_SetGlobalVariable ( 'Latex_MapLeader', '´' )
call s:GetGlobalSetting( 'Latex_CreateMenusDelayed' )
call s:GetGlobalSetting( 'Latex_DviPdf' )
call s:GetGlobalSetting( 'Latex_DviPng' )
call s:GetGlobalSetting( 'Latex_DviPs' )
call s:GetGlobalSetting( 'Latex_DviViewer' )
call s:GetGlobalSetting( 'Latex_GlobalTemplateFile' )
call s:GetGlobalSetting( 'Latex_GuiSnippetBrowser' )
call s:GetGlobalSetting( 'Latex_InsertFileProlog' )
call s:GetGlobalSetting( 'Latex_Latex' )
call s:GetGlobalSetting( 'Latex_LineEndCommColDefault' )
call s:GetGlobalSetting( 'Latex_LoadMenus' )
call s:GetGlobalSetting( 'Latex_LocalTemplateFile' )
call s:GetGlobalSetting( 'Latex_PdfPng' )
call s:GetGlobalSetting( 'Latex_PdfViewer' )
call s:GetGlobalSetting( 'Latex_Pdflatex' )
call s:GetGlobalSetting( 'Latex_Pdftex' )
call s:GetGlobalSetting( 'Latex_Printheader' )
call s:GetGlobalSetting( 'Latex_PsPdf' )
call s:GetGlobalSetting( 'Latex_PsViewer' )
call s:GetGlobalSetting( 'Latex_RootMenu' )
call s:GetGlobalSetting( 'Latex_Tex' )
call s:GetGlobalSetting( 'Latex_TexFlavor' )
call s:GetGlobalSetting( 'Latex_Typesetter' )
call s:GetGlobalSetting( 'Latex_UseToolbox' )
let s:Latex_TypesetterCall = {
\ 'latex' : s:Latex_Latex ,
\ 'tex' : s:Latex_Tex ,
\ 'pdflatex' : s:Latex_Pdflatex,
\ 'pdftex' : s:Latex_Pdftex ,
\ }
let s:Latex_ConverterCall = {
\ 'dvi-pdf' : [ s:Latex_DviPdf , "no" ],
\ 'dvi-png' : [ s:Latex_DviPng , "no" ],
\ 'dvi-ps' : [ s:Latex_DviPs , "no" ],
\ 'pdf-png' : [ s:Latex_PdfPng , "yes"],
\ 'ps-pdf' : [ s:Latex_PsPdf , "no" ],
\ }
let s:Latex_ViewerCall = {
\ 'dvi' : s:Latex_DviViewer,
\ 'pdf' : s:Latex_PdfViewer,
\ 'ps' : s:Latex_PsViewer,
\ }
"
let s:Latex_Printheader = escape( s:Latex_Printheader, ' %' )
let s:Latex_saved_global_option = {}
"------------------------------------------------------------------------------
" Latex_SaveGlobalOption {{{1
" param 1 : option name
" param 2 : characters to be escaped (optional)
"------------------------------------------------------------------------------
function! s:Latex_SaveGlobalOption ( option, ... )
exe 'let escaped =&'.a:option
if a:0 == 0
let escaped = escape( escaped, ' |"\' )
else
let escaped = escape( escaped, ' |"\'.a:1 )
endif
let s:Latex_saved_global_option[a:option] = escaped
endfunction " ---------- end of function Latex_SaveGlobalOption ----------
"
"------------------------------------------------------------------------------
" Latex_RestoreGlobalOption {{{1
"------------------------------------------------------------------------------
function! s:Latex_RestoreGlobalOption ( option )
exe ':set '.a:option.'='.s:Latex_saved_global_option[a:option]
endfunction " ---------- end of function Latex_RestoreGlobalOption ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_Input {{{1
" DESCRIPTION: Input after a highlighted prompt
" PARAMETERS: prompt - prompt string
" defaultreply - default reply
" ... - completion
" RETURNS: reply
"===============================================================================
function! Latex_Input ( prompt, defaultreply, ... )
echohl Search " highlight prompt
call inputsave() " preserve typeahead
if a:0 == 0 || empty(a:1)
let retval =input( a:prompt, a:defaultreply )
else
let retval =input( a:prompt, a:defaultreply, a:1 )
endif
call inputrestore() " restore typeahead
echohl None " reset highlighting
let retval = substitute( retval, '^\s\+', '', '' ) " remove leading whitespaces
let retval = substitute( retval, '\s\+$', '', '' ) " remove trailing whitespaces
return retval
endfunction " ---------- end of function Latex_Input ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_AdjustLineEndComm {{{1
" DESCRIPTION: adjust end-of-line comments
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! Latex_AdjustLineEndComm ( ) range
"
" patterns to ignore when adjusting line-end comments (maybe incomplete):
let s:AlignRegex = [
\ '\([^"]*"[^"]*"\)\+' ,
\ ]
if !exists("b:Latex_LineEndCommentColumn")
let b:Latex_LineEndCommentColumn = s:Latex_LineEndCommColDefault
endif
let save_cursor = getpos('.')
let save_expandtab = &expandtab
exe ':set expandtab'
let linenumber = a:firstline
exe ':'.a:firstline
while linenumber <= a:lastline
let line= getline('.')
let idx1 = 1 + match( line, '\s*%.*$', 0 )
let idx2 = 1 + match( line, '%.*$', 0 )
" comment with leading whitespaces left unchanged
if match( line, '^\s*%' ) == 0
let idx1 = 0
let idx2 = 0
endif
for regex in s:AlignRegex
if match( line, regex ) > -1
let start = matchend( line, regex )
let idx1 = 1 + match( line, '\s*%.*$', start )
let idx2 = 1 + match( line, '%.*$', start )
break
endif
endfor
let ln = line('.')
call setpos('.', [ 0, ln, idx1, 0 ] )
let vpos1 = virtcol('.')
call setpos('.', [ 0, ln, idx2, 0 ] )
let vpos2 = virtcol('.')
if ! ( vpos2 == b:Latex_LineEndCommentColumn
\ || vpos1 > b:Latex_LineEndCommentColumn
\ || idx2 == 0 )
exe ':.,.retab'
" insert some spaces
if vpos2 < b:Latex_LineEndCommentColumn
let diff = b:Latex_LineEndCommentColumn-vpos2
call setpos('.', [ 0, ln, vpos2, 0 ] )
let @" = ' '
exe 'normal! '.diff.'P'
end
" remove some spaces
if vpos1 < b:Latex_LineEndCommentColumn && vpos2 > b:Latex_LineEndCommentColumn
let diff = vpos2 - b:Latex_LineEndCommentColumn
call setpos('.', [ 0, ln, b:Latex_LineEndCommentColumn, 0 ] )
exe 'normal! '.diff.'x'
end
end
let linenumber=linenumber+1
normal! j
endwhile
" restore tab expansion settings and cursor position
let &expandtab = save_expandtab
call setpos('.', save_cursor)
endfunction " ---------- end of function Latex_AdjustLineEndComm ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_GetLineEndCommCol {{{1
" DESCRIPTION: get end-of-line comment position
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! Latex_GetLineEndCommCol ()
let actcol = virtcol(".")
if actcol+1 == virtcol("$")
let b:Latex_LineEndCommentColumn = ''
while match( b:Latex_LineEndCommentColumn, '^\s*\d\+\s*$' ) < 0
let b:Latex_LineEndCommentColumn = Latex_Input( 'start line-end comment at virtual column : ', actcol, '' )
endwhile
else
let b:Latex_LineEndCommentColumn = virtcol(".")
endif
echomsg "line end comments will start at column ".b:Latex_LineEndCommentColumn
endfunction " ---------- end of function Latex_GetLineEndCommCol ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_EndOfLineComment {{{1
" DESCRIPTION: end-of-line comment
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! Latex_EndOfLineComment ( ) range
if !exists("b:Latex_LineEndCommentColumn")
let b:Latex_LineEndCommentColumn = s:Latex_LineEndCommColDefault
endif
" ----- trim whitespaces -----
exe a:firstline.','.a:lastline.'s/\s*$//'
for line in range( a:lastline, a:firstline, -1 )
silent exe ":".line
if getline(line) !~ '^\s*$'
let linelength = virtcol( [line, "$"] ) - 1
let diff = 1
if linelength < b:Latex_LineEndCommentColumn
let diff = b:Latex_LineEndCommentColumn -1 -linelength
endif
exe "normal! ".diff."A "
call mmtemplates#core#InsertTemplate(g:Latex_Templates, 'Comments.end-of-line comment')
endif
endfor
endfunction " ---------- end of function Latex_EndOfLineComment ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_CommentToggle {{{1
" DESCRIPTION: toggle comment
"===============================================================================
function! Latex_CommentToggle () range
let comment=1
for line in range( a:firstline, a:lastline )
if match( getline(line), '^%') == -1 " no comment
let comment = 0
break
endif
endfor
if comment == 0
exe a:firstline.','.a:lastline."s/^/%/"
else
exe a:firstline.','.a:lastline."s/^%//"
endif
endfunction " ---------- end of function Latex_CommentToggle ----------
"
"------------------------------------------------------------------------------
" === Templates API === {{{1
"------------------------------------------------------------------------------
"
"------------------------------------------------------------------------------
" Latex_SetMapLeader {{{2
"------------------------------------------------------------------------------
function! Latex_SetMapLeader ()
if exists ( 'g:Latex_MapLeader' )
call mmtemplates#core#SetMapleader ( g:Latex_MapLeader )
endif
endfunction " ---------- end of function Latex_SetMapLeader ----------
"
"------------------------------------------------------------------------------
" Latex_ResetMapLeader {{{2
"------------------------------------------------------------------------------
function! Latex_ResetMapLeader ()
if exists ( 'g:Latex_MapLeader' )
call mmtemplates#core#ResetMapleader ()
endif
endfunction " ---------- end of function Latex_ResetMapLeader ----------
" }}}2
"
"=== FUNCTION ================================================================
" NAME: Latex_RereadTemplates {{{1
" DESCRIPTION: Reread the templates. Also set the character which starts
" the comments in the template files.
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! Latex_RereadTemplates ( displaymsg )
"
"-------------------------------------------------------------------------------
" SETUP TEMPLATE LIBRARY
"-------------------------------------------------------------------------------
let g:Latex_Templates = mmtemplates#core#NewLibrary ()
"
" mapleader
if empty ( g:Latex_MapLeader )
call mmtemplates#core#Resource ( g:Latex_Templates, 'set', 'property', 'Templates::Mapleader', '\' )
else
call mmtemplates#core#Resource ( g:Latex_Templates, 'set', 'property', 'Templates::Mapleader', g:Latex_MapLeader )
endif
"
" map: choose style
call mmtemplates#core#Resource ( g:Latex_Templates, 'set', 'property', 'Templates::ChooseStyle::Map', 'nts' )
"
" syntax: comments
call mmtemplates#core#ChangeSyntax ( g:Latex_Templates, 'comment', '§' )
let s:Latex_TemplateJumpTarget = mmtemplates#core#Resource ( g:Latex_Templates, "jumptag" )[0]
"
let messsage = ''
"
if s:installation == 'system'
"-------------------------------------------------------------------------------
" SYSTEM INSTALLATION
"-------------------------------------------------------------------------------
if filereadable( s:Latex_GlobalTemplateFile )
call mmtemplates#core#ReadTemplates ( g:Latex_Templates, 'load', s:Latex_GlobalTemplateFile )
else
echomsg "Global template file '".s:Latex_GlobalTemplateFile."' not readable."
return
endif
let messsage = "Templates read from '".s:Latex_GlobalTemplateFile."'"
"
"-------------------------------------------------------------------------------
" handle local template files
"-------------------------------------------------------------------------------
let templ_dir = fnamemodify( s:Latex_GlobalTemplateFile, ":p:h" ).'/'
"
if finddir( templ_dir ) == ''
" try to create a local template directory
if exists("*mkdir")
try
call mkdir( templ_dir, "p" )
catch /.*/
endtry
endif
endif
if isdirectory( templ_dir ) && !filereadable( s:Latex_LocalTemplateFile )
" write a default local template file
let template = [ ]
let sample_template_file = s:plugin_dir.'/latex-support/rc/sample_template_file'
if filereadable( sample_template_file )
for line in readfile( sample_template_file )
call add( template, line )
endfor
call writefile( template, s:Latex_LocalTemplateFile )
endif
endif
"
if filereadable( s:Latex_LocalTemplateFile )
call mmtemplates#core#ReadTemplates ( g:Latex_Templates, 'load', s:Latex_LocalTemplateFile )
let messsage = messsage." and '".s:Latex_LocalTemplateFile."'"
if mmtemplates#core#ExpandText( g:Latex_Templates, '|AUTHOR|' ) == 'YOUR NAME'
echomsg "Please set your personal details in file '".s:Latex_LocalTemplateFile."'."
endif
endif
"
else
"-------------------------------------------------------------------------------
" LOCAL INSTALLATION
"-------------------------------------------------------------------------------
if filereadable( s:Latex_LocalTemplateFile )
call mmtemplates#core#ReadTemplates ( g:Latex_Templates, 'load', s:Latex_LocalTemplateFile )
let messsage = "Templates read from '".s:Latex_LocalTemplateFile."'"
else
echomsg "Local template file '".s:Latex_LocalTemplateFile."' not readable."
return
endif
"
endif
if a:displaymsg == 'yes'
echomsg messsage.'.'
endif
endfunction " ---------- end of function Latex_RereadTemplates ----------
"
"=== FUNCTION ================================================================
" NAME: InitMenus {{{1
" DESCRIPTION: Initialize menus.
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! s:InitMenus()
"
if ! has ( 'menu' )
return
endif
"
" Preparation
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'do_reset' )
"
" get the mapleader (correctly escaped)
let [ esc_mapl, err ] = mmtemplates#core#Resource ( g:Latex_Templates, 'escaped_mapleader' )
"
exe 'amenu '.s:Latex_RootMenu.'.LaTeX <Nop>'
exe 'amenu '.s:Latex_RootMenu.'.-Sep00- <Nop>'
"
"-------------------------------------------------------------------------------
" menu headers
"-------------------------------------------------------------------------------
"
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'sub_menu', '&Comments', 'priority', 500 )
" the other, automatically created menus go here; their priority is the standard priority 500
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'sub_menu', 'S&nippets', 'priority', 600 )
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'sub_menu', '&Wizard' , 'priority', 700 )
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'sub_menu', '&Run' , 'priority', 800 )
if s:Latex_UseToolbox == 'yes' && mmtoolbox#tools#Property ( s:Latex_Toolbox, 'empty-menu' ) == 0
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'sub_menu', 'Tool Bo&x', 'priority', 900 )
endif
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'sub_menu', '&Help' , 'priority', 1000 )
"
"-------------------------------------------------------------------------------
" comments
"-------------------------------------------------------------------------------
"
let head = 'noremenu <silent> '.s:Latex_RootMenu.'.Comments.'
let ahead = 'anoremenu <silent> '.s:Latex_RootMenu.'.Comments.'
let ihead = 'inoremenu <silent> '.s:Latex_RootMenu.'.Comments.'
let vhead = 'vnoremenu <silent> '.s:Latex_RootMenu.'.Comments.'
"
exe ahead.'end-of-&line\ comment<Tab>'.esc_mapl.'cl :call Latex_EndOfLineComment()<CR>'
exe vhead.'end-of-&line\ comment<Tab>'.esc_mapl.'cl :call Latex_EndOfLineComment()<CR>'
exe ahead.'ad&just\ end-of-line\ com\.<Tab>'.esc_mapl.'cj :call Latex_AdjustLineEndComm()<CR>'
exe ihead.'ad&just\ end-of-line\ com\.<Tab>'.esc_mapl.'cj <Esc>:call Latex_AdjustLineEndComm()<CR>'
exe vhead.'ad&just\ end-of-line\ com\.<Tab>'.esc_mapl.'cj :call Latex_AdjustLineEndComm()<CR>'
exe head.'&set\ end-of-line\ com\.\ col\.<Tab>'.esc_mapl.'cs <Esc>:call Latex_GetLineEndCommCol()<CR>'
"
exe ahead.'&comment<TAB>'.esc_mapl.'cc :call Latex_CommentToggle()<CR>j'
exe ihead.'&comment<TAB>'.esc_mapl.'cc <C-C>:call Latex_CommentToggle()<CR>j'
exe vhead.'&comment<TAB>'.esc_mapl.'cc :call Latex_CommentToggle()<CR>j'
exe ahead.'-Sep02- :'
"
"-------------------------------------------------------------------------------
" generate menus from the templates
"-------------------------------------------------------------------------------
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'do_templates' )
"
"-------------------------------------------------------------------------------
" snippets
"-------------------------------------------------------------------------------
"
let ahead = 'anoremenu <silent> '.s:Latex_RootMenu.'.S&nippets.'
let ihead = 'inoremenu <silent> '.s:Latex_RootMenu.'.S&nippets.'
let vhead = 'vnoremenu <silent> '.s:Latex_RootMenu.'.S&nippets.'
"
exe ahead.'&read\ code\ snippet<Tab>'.esc_mapl.'nr :call Latex_CodeSnippet("read")<CR>'
exe ihead.'&read\ code\ snippet<Tab>'.esc_mapl.'nr <C-C>:call Latex_CodeSnippet("read")<CR>'
exe ahead.'&view\ code\ snippet<Tab>'.esc_mapl.'nv :call Latex_CodeSnippet("view")<CR>'
exe ihead.'&view\ code\ snippet<Tab>'.esc_mapl.'nv <C-C>:call Latex_CodeSnippet("view")<CR>'
exe ahead.'&write\ code\ snippet<Tab>'.esc_mapl.'nw :call Latex_CodeSnippet("write")<CR>'
exe ihead.'&write\ code\ snippet<Tab>'.esc_mapl.'nw <C-C>:call Latex_CodeSnippet("write")<CR>'
exe vhead.'&write\ code\ snippet<Tab>'.esc_mapl.'nw <C-C>:call Latex_CodeSnippet("writemarked")<CR>'
exe ahead.'&edit\ code\ snippet<Tab>'.esc_mapl.'ne :call Latex_CodeSnippet("edit")<CR>'
exe ihead.'&edit\ code\ snippet<Tab>'.esc_mapl.'ne <C-C>:call Latex_CodeSnippet("edit")<CR>'
exe ahead.'-SepSnippets- :'
"
exe ahead.'edit\ &local\ templates<Tab>'.esc_mapl.'ntl :call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,-1)<CR>'
exe ihead.'edit\ &local\ templates<Tab>'.esc_mapl.'ntl <C-C>:call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,-1)<CR>'
if s:installation == 'system'
exe ahead.'edit\ &global\ templates<Tab>'.esc_mapl.'ntg :call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,0)<CR>'
exe ihead.'edit\ &global\ templates<Tab>'.esc_mapl.'ntg <C-C>:call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,0)<CR>'
endif
"
exe ahead.'reread\ &templates<Tab>'.esc_mapl.'ntr :call mmtemplates#core#ReadTemplates(g:Latex_Templates,"reload","all")<CR>'
exe ihead.'reread\ &templates<Tab>'.esc_mapl.'ntr <C-C>:call mmtemplates#core#ReadTemplates(g:Latex_Templates,"reload","all")<CR>'
"
call mmtemplates#core#CreateMenus ( 'g:Latex_Templates', s:Latex_RootMenu, 'do_styles',
\ 'specials_menu', 'Snippets' )
"
"-------------------------------------------------------------------------------
" wizard
"-------------------------------------------------------------------------------
"
let ahead = 'anoremenu <silent> '.s:Latex_RootMenu.'.&Wizard.'
let ihead = 'inoremenu <silent> '.s:Latex_RootMenu.'.&Wizard.'
let vhead = 'vnoremenu <silent> '.s:Latex_RootMenu.'.&Wizard.'
"
exe ahead.'tables.tabbing<Tab>'.esc_mapl.'wtg :call Latex_Tabbing()<CR>k0a'
exe ihead.'tables.tabbing<Tab>'.esc_mapl.'wtg <C-C>:call Latex_Tabbing()<CR>k0a'
exe ahead.'tables.tabular<Tab>'.esc_mapl.'wtr :call Latex_Tabular()<CR>3k0a'
exe ihead.'tables.tabular<Tab>'.esc_mapl.'wtr <C-C>:call Latex_Tabular()<CR>3k0a'
"
exe ahead.'li&gatures.ligatures<Tab>LaTeX <Nop>'
exe ahead.'li&gatures.-SEP3- :'
exe ahead.'li&gatures.find\ double <C-C>:/f[filt]<CR>'
exe ahead.'li&gatures.find\ triple <C-C>:/ff[filt]<CR>'
exe ahead.'li&gatures.split\ with\ \\\/ <C-C>a\/<Esc>'
exe ahead.'li&gatures.highlight\ off <C-C>:nohlsearch<CR>'
"
"-------------------------------------------------------------------------------
" run
"-------------------------------------------------------------------------------
"
let ahead = 'amenu <silent> '.s:Latex_RootMenu.'.&Run.'
let ihead = 'imenu <silent> '.s:Latex_RootMenu.'.&Run.'
let vhead = 'vmenu <silent> '.s:Latex_RootMenu.'.&Run.'
"
exe ahead.'save\ +\ &run\ typesetter<Tab>'.esc_mapl.'rr\ <C-F9> :call Latex_Compile()<CR><CR>'
exe ihead.'save\ +\ &run\ typesetter<Tab>'.esc_mapl.'rr\ <C-F9> <C-C>:call Latex_Compile()<CR><CR>'
"
exe ahead.'save\ +\ &run\ lacheck<Tab>'.esc_mapl.'rla :call Latex_Lacheck()<CR><CR>'
exe ihead.'save\ +\ &run\ lacheck<Tab>'.esc_mapl.'rla <C-C>:call Latex_Lacheck()<CR><CR>'
"
exe ahead.'view\ &DVI<Tab>'.esc_mapl.'rdvi :call Latex_View("dvi")<CR>'
exe ihead.'view\ &DVI<Tab>'.esc_mapl.'rdvi <C-C>:call Latex_View("dvi")<CR>'
exe ahead.'view\ &PDF<Tab>'.esc_mapl.'rpdf :call Latex_View("pdf")<CR>'
exe ihead.'view\ &PDF<Tab>'.esc_mapl.'rpdf <C-C>:call Latex_View("pdf")<CR>'
exe ahead.'view\ &PS<Tab>'.esc_mapl.'rps :call Latex_View("ps" )<CR>'
exe ihead.'view\ &PS<Tab>'.esc_mapl.'rps <C-C>:call Latex_View("ps" )<CR>'
"
exe ahead.'-SEP1- :'
exe ahead.'run\ make&index<Tab>'.esc_mapl.'rmi :call Latex_Makeindex()<CR>'
exe ihead.'run\ make&index<Tab>'.esc_mapl.'rmi <C-C>:call Latex_Makeindex()<CR>'
exe ahead.'run\ &bibtex<Tab>'.esc_mapl.'rbi :call Latex_RunBibtex()<CR>'
exe ihead.'run\ &bibtex<Tab>'.esc_mapl.'rbi <C-C>:call Latex_RunBibtex()<CR>'
exe ahead.'-SEP2- :'
exe ahead.'Convert<Tab>'.esc_mapl.'rc.Convert<Tab>LaTeX <Nop>'
exe ahead.'Convert<Tab>'.esc_mapl.'.-SEP3- :'
exe ahead.'Convert<Tab>'.esc_mapl.'rc.DVI->PDF :call Latex_Conversions( "dvi-pdf")<CR>'
exe ahead.'Convert<Tab>'.esc_mapl.'rc.DVI->PS :call Latex_Conversions( "dvi-ps" )<CR>'
exe ahead.'Convert<Tab>'.esc_mapl.'rc.DVI->PNG :call Latex_Conversions( "dvi-png")<CR>'
exe ahead.'Convert<Tab>'.esc_mapl.'rc.PDF->PNG :call Latex_Conversions( "pdf-png")<CR>'
exe ahead.'Convert<Tab>'.esc_mapl.'rc.PS->PDF :call Latex_Conversions( "ps-pdf" )<CR>'
exe ahead.'-SEP3- :'
exe ahead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh :call Latex_Hardcopy("n")<CR>'
exe vhead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call Latex_Hardcopy("v")<CR>'
exe ahead.'plugin\ &settings<Tab>'.esc_mapl.'rse :call Latex_Settings()<CR>'
"
"-------------------------------------------------------------------------------
" toolbox
"-------------------------------------------------------------------------------
"
if s:Latex_UseToolbox == 'yes' && mmtoolbox#tools#Property ( s:Latex_Toolbox, 'empty-menu' ) == 0
call mmtoolbox#tools#AddMenus ( s:Latex_Toolbox, s:Latex_RootMenu.'.Tool\ Box' )
endif
"
"-------------------------------------------------------------------------------
" help
"-------------------------------------------------------------------------------
"
let ahead = 'amenu <silent> '.s:Latex_RootMenu.'.Help.'
let ihead = 'imenu <silent> '.s:Latex_RootMenu.'.Help.'
"
exe ahead.'&texdoc<Tab>'.esc_mapl.'ht :call Latex_texdoc()<CR>'
exe ihead.'&texdoc<Tab>'.esc_mapl.'ht <C-C>:call Latex_texdoc()<CR>'
exe ahead.'-SEP1- :'
exe ahead.'&help\ (Latex-Support)<Tab>'.esc_mapl.'hp :call Latex_HelpLatexSupport()<CR>'
exe ihead.'&help\ (Latex-Support)<Tab>'.esc_mapl.'hp <C-C>:call Latex_HelpLatexSupport()<CR>'
endfunction " ---------- end of function s:InitMenus ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_ConvertInput
" DESCRIPTION: read cppcheck severity from the command line
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! Latex_ConvertInput ()
let retval = input( "start converter (tab exp.): ", '', 'customlist,Latex_ConverterList' )
redraw!
call Latex_Conversions( retval )
return
endfunction " ---------- end of function Latex_ConvertInput ----------
"=== FUNCTION ================================================================
" NAME: Latex_ConverterList {{{1
" DESCRIPTION: cppcheck severity : callback function for completion
" PARAMETERS: ArgLead -
" CmdLine -
" CursorPos -
" RETURNS:
"===============================================================================
function! Latex_ConverterList ( ArgLead, CmdLine, CursorPos )
return filter( copy( sort( keys( s:Latex_ConverterCall ) ) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' )
endfunction " ---------- end of function Latex_ConverterList ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_JumpForward {{{1
" DESCRIPTION: Jump to the next target, otherwise behind the current string.
" PARAMETERS: -
" RETURNS: empty string
"===============================================================================
function! Latex_JumpForward ()
let match = search( s:Latex_TemplateJumpTarget, 'c' )
if match > 0
" remove the target
call setline( match, substitute( getline('.'), s:Latex_TemplateJumpTarget, '', '' ) )
else
" try to jump behind parenthesis or strings
call search( "[\]})\"'`]", 'W' )
normal! l
endif
return ''
endfunction " ---------- end of function Latex_JumpForward ----------
"
"=== FUNCTION ================================================================
" NAME: Latex_CodeSnippet {{{1
" DESCRIPTION: read / write / edit code sni
" PARAMETERS: mode - edit, read, write, writemarked, view
"===============================================================================
function! Latex_CodeSnippet(mode)
if isdirectory(g:Latex_CodeSnippets)
"
" read snippet file, put content below current line
"
if a:mode == "read"
if has("gui_running") && s:Latex_GuiSnippetBrowser == 'gui'
let l:snippetfile=browse(0,"read a code snippet",g:Latex_CodeSnippets,"")
else
let l:snippetfile=input("read snippet ", g:Latex_CodeSnippets, "file" )
endif
if filereadable(l:snippetfile)
let linesread= line("$")
let l:old_cpoptions = &cpoptions " Prevent the alternate buffer from being set to this files
setlocal cpoptions-=a
:execute "read ".l:snippetfile
let &cpoptions = l:old_cpoptions " restore previous options
"
let linesread= line("$")-linesread-1
if linesread>=0 && match( l:snippetfile, '\.\(ni\|noindent\)$' ) < 0
silent exe "normal! =".linesread."+"
endif
endif
endif
"
" update current buffer / split window / edit snippet file
"
if a:mode == "edit"
if has("gui_running") && s:Latex_GuiSnippetBrowser == 'gui'
let l:snippetfile=browse(0,"edit a code snippet",g:Latex_CodeSnippets,"")
else
let l:snippetfile=input("edit snippet ", g:Latex_CodeSnippets, "file" )
endif
if !empty(l:snippetfile)
:execute "update! | split | edit ".l:snippetfile
endif
endif
"
" update current buffer / split window / view snippet file
"
if a:mode == "view"
if has("gui_running") && s:Latex_GuiSnippetBrowser == 'gui'
let l:snippetfile=browse(0,"view a code snippet",g:Latex_CodeSnippets,"")
else
let l:snippetfile=input("view snippet ", g:Latex_CodeSnippets, "file" )
endif
if !empty(l:snippetfile)
:execute "update! | split | view ".l:snippetfile
endif
endif
"
" write whole buffer or marked area into snippet file
"
if a:mode == "write" || a:mode == "writemarked"
if has("gui_running") && s:Latex_GuiSnippetBrowser == 'gui'
let l:snippetfile=browse(1,"write a code snippet",g:Latex_CodeSnippets,"")
else
let l:snippetfile=input("write snippet ", g:Latex_CodeSnippets, "file" )
endif
if !empty(l:snippetfile)
if filereadable(l:snippetfile)
if confirm("File ".l:snippetfile." exists ! Overwrite ? ", "&Cancel\n&No\n&Yes") != 3
return
endif
endif
if a:mode == "write"
:execute ":write! ".l:snippetfile
else
:execute ":*write! ".l:snippetfile
endif
endif
endif
else
redraw!
echohl ErrorMsg
echo "code snippet directory ".g:Latex_CodeSnippets." does not exist"
echohl None
endif
endfunction " ---------- end of function Latex_CodeSnippet ----------
"
"=== FUNCTION ================================================================
" NAME: CreateAdditionalMaps {{{1
" DESCRIPTION: create additional maps
" PARAMETERS: -
" RETURNS:
"===============================================================================
function! s:CreateAdditionalMaps ()
"
" ---------- Latex dictionary -------------------------------------------------
" This will enable keyword completion for Latex
" using Vim's dictionary feature |i_CTRL-X_CTRL-K|.
"
if exists("g:Latex_Dictionary_File")
silent! exe 'setlocal dictionary+='.g:Latex_Dictionary_File
endif
"
"-------------------------------------------------------------------------------
" settings - local leader
"-------------------------------------------------------------------------------
if ! empty ( g:Latex_MapLeader )
if exists ( 'g:maplocalleader' )
let ll_save = g:maplocalleader
endif
let g:maplocalleader = g:Latex_MapLeader
endif
"
"-------------------------------------------------------------------------------
" comments
"-------------------------------------------------------------------------------
nnoremap <buffer> <silent> <LocalLeader>cl :call Latex_EndOfLineComment()<CR>
inoremap <buffer> <silent> <LocalLeader>cl <C-C>:call Latex_EndOfLineComment()<CR>
vnoremap <buffer> <silent> <LocalLeader>cl :call Latex_EndOfLineComment()<CR>
"
nnoremap <buffer> <silent> <LocalLeader>cj :call Latex_AdjustLineEndComm()<CR>
inoremap <buffer> <silent> <LocalLeader>cj <C-C>:call Latex_AdjustLineEndComm()<CR>
vnoremap <buffer> <silent> <LocalLeader>cj :call Latex_AdjustLineEndComm()<CR>
"
nnoremap <buffer> <silent> <LocalLeader>cs :call Latex_GetLineEndCommCol()<CR>
inoremap <buffer> <silent> <LocalLeader>cs <C-C>:call Latex_GetLineEndCommCol()<CR>
vnoremap <buffer> <silent> <LocalLeader>cs <C-C>:call Latex_GetLineEndCommCol()<CR>
"
nnoremap <buffer> <silent> <LocalLeader>cc :call Latex_CommentToggle()<CR>j
inoremap <buffer> <silent> <LocalLeader>cc <C-C>:call Latex_CommentToggle()<CR>j
vnoremap <buffer> <silent> <LocalLeader>cc :call Latex_CommentToggle()<CR>j
"
"-------------------------------------------------------------------------------
" snippets
"-------------------------------------------------------------------------------
"
nnoremap <buffer> <silent> <LocalLeader>nr :call Latex_CodeSnippet("read")<CR>
inoremap <buffer> <silent> <LocalLeader>nr <Esc>:call Latex_CodeSnippet("read")<CR>
nnoremap <buffer> <silent> <LocalLeader>nw :call Latex_CodeSnippet("write")<CR>
inoremap <buffer> <silent> <LocalLeader>nw <Esc>:call Latex_CodeSnippet("write")<CR>
vnoremap <buffer> <silent> <LocalLeader>nw <Esc>:call Latex_CodeSnippet("writemarked")<CR>
nnoremap <buffer> <silent> <LocalLeader>ne :call Latex_CodeSnippet("edit")<CR>
inoremap <buffer> <silent> <LocalLeader>ne <Esc>:call Latex_CodeSnippet("edit")<CR>
nnoremap <buffer> <silent> <LocalLeader>nv :call Latex_CodeSnippet("view")<CR>
inoremap <buffer> <silent> <LocalLeader>nv <Esc>:call Latex_CodeSnippet("view")<CR>
"
" ---------- snippet menu : templates ----------------------------------------
"
nnoremap <buffer> <silent> <LocalLeader>ntl :call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,-1)<CR>
inoremap <buffer> <silent> <LocalLeader>ntl <C-C>:call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,-1)<CR>
if s:installation == 'system'
nnoremap <buffer> <silent> <LocalLeader>ntg :call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,0)<CR>
inoremap <buffer> <silent> <LocalLeader>ntg <C-C>:call mmtemplates#core#EditTemplateFiles(g:Latex_Templates,0)<CR>
endif
nnoremap <buffer> <silent> <LocalLeader>ntr :call mmtemplates#core#ReadTemplates(g:Latex_Templates,"reload","all")<CR>
inoremap <buffer> <silent> <LocalLeader>ntr <C-C>:call mmtemplates#core#ReadTemplates(g:Latex_Templates,"reload","all")<CR>
nnoremap <buffer> <silent> <LocalLeader>nts :call mmtemplates#core#ChooseStyle(g:Latex_Templates,"!pick")<CR>
inoremap <buffer> <silent> <LocalLeader>nts <C-C>:call mmtemplates#core#ChooseStyle(g:Latex_Templates,"!pick")<CR>
"
"-------------------------------------------------------------------------------
" wizard
"-------------------------------------------------------------------------------
"
nnoremap <buffer> <silent> <LocalLeader>wtg :call Latex_Tabbing()<CR>k0a'
inoremap <buffer> <silent> <LocalLeader>wtg <C-C>:call Latex_Tabbing()<CR>k0a'
nnoremap <buffer> <silent> <LocalLeader>wtr :call Latex_Tabular()<CR>3k0a'
inoremap <buffer> <silent> <LocalLeader>wtr <C-C>:call Latex_Tabular()<CR>3k0a'
"
"-------------------------------------------------------------------------------
" run
"-------------------------------------------------------------------------------
"
noremap <buffer> <C-F9> :call Latex_Compile()<CR><CR>
inoremap <buffer> <C-F9> <Esc>:call Latex_Compile()<CR><CR>
vnoremap <buffer> <C-F9> <Esc>:call Latex_Compile()<CR><CR>
noremap <buffer> <M-F9> :call Latex_View('choose')<CR><CR>
inoremap <buffer> <M-F9> <Esc>:call Latex_View('choose')<CR><CR>
vnoremap <buffer> <M-F9> <Esc>:call Latex_View('choose')<CR><CR>
noremap <buffer> <silent> <LocalLeader>rr :call Latex_Compile()<CR><CR>
inoremap <buffer> <silent> <LocalLeader>rr <C-C>:call Latex_Compile()<CR><CR>
vnoremap <buffer> <silent> <LocalLeader>rr <C-C>:call Latex_Compile()<CR><CR>
noremap <buffer> <silent> <LocalLeader>rla :call Latex_Lacheck()<CR>
inoremap <buffer> <silent> <LocalLeader>rla <C-C>:call Latex_Lacheck()<CR>
vnoremap <buffer> <silent> <LocalLeader>rla <C-C>:call Latex_Lacheck()<CR>
noremap <buffer> <silent> <LocalLeader>rdvi :call Latex_View("dvi")<CR>
inoremap <buffer> <silent> <LocalLeader>rdvi <C-C>:call Latex_View("dvi")<CR>
vnoremap <buffer> <silent> <LocalLeader>rdvi <C-C>:call Latex_View("dvi")<CR>
noremap <buffer> <silent> <LocalLeader>rpdf :call Latex_View("pdf")<CR>
inoremap <buffer> <silent> <LocalLeader>rpdf <C-C>:call Latex_View("pdf")<CR>
vnoremap <buffer> <silent> <LocalLeader>rpdf <C-C>:call Latex_View("pdf")<CR>
noremap <buffer> <silent> <LocalLeader>rps :call Latex_View("ps" )<CR>
inoremap <buffer> <silent> <LocalLeader>rps <C-C>:call Latex_View("ps" )<CR>
vnoremap <buffer> <silent> <LocalLeader>rps <C-C>:call Latex_View("ps" )<CR>
"
noremap <buffer> <silent> <LocalLeader>rmi :call Latex_Makeindex()<CR>
inoremap <buffer> <silent> <LocalLeader>rmi <C-C>:call Latex_Makeindex()<CR>
vnoremap <buffer> <silent> <LocalLeader>rmi <C-C>:call Latex_Makeindex()<CR>
noremap <buffer> <silent> <LocalLeader>rbi :call Latex_RunBibtex()<CR>
inoremap <buffer> <silent> <LocalLeader>rbi <C-C>:call Latex_RunBibtex()<CR>
vnoremap <buffer> <silent> <LocalLeader>rbi <C-C>:call Latex_RunBibtex()<CR>
"
nnoremap <buffer> <silent> <LocalLeader>rse :call Latex_Settings()<CR>
"
noremap <buffer> <silent> <LocalLeader>rh :call Latex_Hardcopy("n")<CR>
vnoremap <buffer> <silent> <LocalLeader>rh <C-C>:call Latex_Hardcopy("v")<CR>
inoremap <buffer> <silent> <LocalLeader>rh <C-C>:call Latex_Hardcopy("n")<CR>
"
noremap <buffer> <silent> <LocalLeader>rc :call Latex_ConvertInput()<CR>