Skip to content

Commit 0f49942

Browse files
committed
Merge branch 'tagbar-batteries-included'
* tagbar-batteries-included: Nix overbearing ctags executable check Include Scala ctags definition for Tagbar Add standard plugin guards, modelines Remove help plugin stuff
2 parents aa662c5 + 77637d4 commit 0f49942

File tree

10 files changed

+188
-100
lines changed

10 files changed

+188
-100
lines changed

after/plugin/help.vim

-50
This file was deleted.

after/syntax/help.vim

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
let b:current_syntax = ''
2-
unlet b:current_syntax
1+
" Extends standard help syntax with highlighting of Scala code.
2+
"
3+
" Place code between !sc! and !/sc! delimiters. These will be hidden if Vim is
4+
" built with conceal support.
5+
6+
unlet! b:current_syntax
7+
38
syntax include @ScalaCode syntax/scala.vim
9+
410
if has('conceal')
511
syntax region rgnScala matchgroup=Ignore concealends start='!sc!' end='!/sc!' contains=@ScalaCode
612
else

compiler/sbt.vim

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
" Vim compiler file for sbt, the Scala build tool.
1+
" Vim compiler file
2+
" Language: Scala SBT (http://www.scala-sbt.org/)
3+
" Maintainer: Derek Wyatt
4+
" URL: https://github.com/derekwyatt/vim-scala
5+
" License: Apache 2
6+
" ----------------------------------------------------------------------------
27

38
if exists('current_compiler')
49
finish
@@ -22,3 +27,4 @@ CompilerSet errorformat=
2227
let &cpo = s:cpo_save
2328
unlet s:cpo_save
2429

30+
" vim:set sw=2 sts=2 ts=8 et:

ctags/scala.ctags

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--langdef=scala
2+
--langmap=scala:.scala
3+
4+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*(private[^ ]*|protected)?[ \t ]*class[ \t ]+([a-zA-Z0-9_]+)/\4/c,classes/
5+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*(private[^ ]*|protected)?[ \t ]*object[ \t ]+([a-zA-Z0-9_]+)/\4/c,objects/
6+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*(private[^ ]*|protected)?[ \t ]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*case class[ \t ]+([a-zA-Z0-9_]+)/\6/c,case classes/
7+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*(private[^ ]*|protected)?[ \t ]*case object[ \t ]+([a-zA-Z0-9_]+)/\4/c,case objects/
8+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*(private[^ ]*|protected)?[ \t ]*trait[ \t ]+([a-zA-Z0-9_]+)/\4/t,traits/
9+
--regex-scala=/^[ \t ]*type[ \t ]+([a-zA-Z0-9_]+)/\1/T,types/
10+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy|private[^ ]*(\[[a-z]*\])*|protected)[ \t ]*)*def[ \t ]+([a-zA-Z0-9_]+)/\4/m,methods/
11+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy|private[^ ]*|protected)[ \t ]*)*val[ \t ]+([a-zA-Z0-9_]+)/\3/l,constants/
12+
--regex-scala=/^[ \t ]*((abstract|final|sealed|implicit|lazy|private[^ ]*|protected)[ \t ]*)*var[ \t ]+([a-zA-Z0-9_]+)/\3/l,variables/
13+
--regex-scala=/^[ \t ]*package[ \t ]+([a-zA-Z0-9_.]+)/\1/p,packages/

doc/scala.txt

+74-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
11
*scala.txt* Syntax highlighting and helper functions for the Scala language.
22

3+
This plugin is only available if 'compatible' is not set.
4+
{Vi does not have any of this}
5+
6+
==============================================================================
37
INTRODUCTION *scala*
48

5-
Syntax highlighting and helper functions for the scala language.
9+
Syntax highlighting and helper functions for the scala language. Extras
10+
include:
11+
12+
- Sorting of import statements, configurable to your conventions.
13+
- Tagbar support to navigate definitions within a file in the plugin's
14+
sidebar window.
15+
- ...and probably more that we've forgotten to update in this doc.
16+
17+
==============================================================================
18+
OPTIONS *scala-options*
19+
20+
Use these options to control behavior of the plugin. Default values are
21+
indicated in the examples.
622

23+
*'g:scala_use_builtin_tagbar_defs'*
24+
If you are using the Tagbar Vim plugin, vim-scala includes a Tagbar type
25+
definition and ctags definition for Scala, so you can use Tagbar immediately.
26+
If you have your own ctags definition in `~/.ctags` and prefer to use it, set
27+
this option to 0 (we would appreciate contributions if you've improved the
28+
ctags definition!).
29+
30+
Note that Tagbar's ctags definition for Scala is not used to generate a
31+
|tags| file that Vim can use to navigate to definitions in other files, only
32+
for the plugin sidebar. Feel free to copy `vim-scala/ctags/scala.ctags` into
33+
your own `~/.ctags` if you wish to generate |tags| files.
34+
>
35+
let g:scala_use_builtin_tagbar_defs = 1
36+
<
37+
*'g:scala_use_default_keymappings'*
38+
Set this option to disable definition of all mappings provided by vim-scala.
39+
See |scala-mappings|.
40+
>
41+
let g:scala_use_default_keymappings = 1
42+
<
43+
==============================================================================
744
COMMANDS *scala-commands*
845

946
*:SortScalaImports*
@@ -41,4 +78,40 @@ COMMANDS *scala-commands*
4178
g:scala_first_party_namespaces=
4279
\ '\(controllers\|views\|models\)'
4380

81+
==============================================================================
82+
MAPPINGS *scala-mappings*
83+
84+
Currently the only mappings defined are for FuzzyFinder users--these will
85+
only be enabled if FuzzyFinder is detected.
86+
87+
*scala-leader-fs*
88+
<Leader>fs "Find src". Primes |:FufFile| with `src/main/scala`,
89+
and goes deeper still if only a single directory
90+
exists below that. Helpful for package namespacing
91+
like `src/main/scala/com/myorg`.
92+
93+
*scala-leader-ft*
94+
<Leader>ft "Find test". Like |scala-leader-fs|, but with
95+
`src/test/scala`.
96+
97+
*scala-leader-fr*
98+
<Leader>fr "Find from root". For the rarer cases when you want to
99+
start FuzzyFinder at project root (parent of `src/`).
100+
101+
Disabling Mappings~
102+
103+
If you wish to disable the default key mappings, write the following line in
104+
your ~/.vimrc: >
105+
106+
let g:scala_use_default_keymappings = 0
107+
108+
==============================================================================
109+
CREDITS *scala-credits*
110+
111+
Developed by Derek Wyatt, building on initial work by Stefan Matthias Aust.
112+
Distributed under the Apache 2 license.
113+
114+
Project's home and Git repository: https://github.com/derekwyatt/vim-scala
44115

116+
------------------------------------------------------------------------------
117+
vim:tw=78:ts=8:ft=help:norl:

ftplugin/scala.vim

+14-44
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
" Vim filetype plugin
2+
" Language: Scala
3+
" Maintainer: Derek Wyatt
4+
" URL: https://github.com/derekwyatt/vim-scala
5+
" License: Apache 2
6+
" ----------------------------------------------------------------------------
7+
8+
if exists('b:did_ftplugin') || &cp
9+
finish
10+
endif
11+
let b:did_ftplugin = 1
12+
113
setlocal formatoptions+=ro
214

315
" Just like c.vim, but additionally doesn't wrap text onto /** line when
@@ -130,49 +142,6 @@ if globpath(&rtp, 'plugin/fuf.vim') != ''
130142
endif
131143
endif
132144

133-
" If you want to disable the default key mappings, write the following line in
134-
" your ~/.vimrc
135-
" let g:scala_use_default_keymappings = 0
136-
if get(g:, 'scala_use_default_keymappings', 1)
137-
nnoremap <buffer> <Leader>jt :call JustifyCurrentLine()<cr>
138-
endif
139-
140-
"
141-
" TagBar
142-
"
143-
let g:tagbar_type_scala = {
144-
\ 'ctagstype' : 'scala',
145-
\ 'kinds' : [
146-
\ 'p:packages:1',
147-
\ 'V:values',
148-
\ 'v:variables',
149-
\ 'T:types',
150-
\ 't:traits',
151-
\ 'o:objects',
152-
\ 'a:aclasses',
153-
\ 'c:classes',
154-
\ 'r:cclasses',
155-
\ 'm:methods'
156-
\ ],
157-
\ 'sro' : '.',
158-
\ 'kind2scope' : {
159-
\ 'T' : 'type',
160-
\ 't' : 'trait',
161-
\ 'o' : 'object',
162-
\ 'a' : 'abstract class',
163-
\ 'c' : 'class',
164-
\ 'r' : 'case class'
165-
\ },
166-
\ 'scope2kind' : {
167-
\ 'type' : 'T',
168-
\ 'trait' : 't',
169-
\ 'object' : 'o',
170-
\ 'abstract class' : 'a',
171-
\ 'class' : 'c',
172-
\ 'case class' : 'r'
173-
\ }
174-
\ }
175-
176145
function! s:CreateOrExpression(keywords)
177146
return '('.join(a:keywords, '|').')'
178147
endfunction
@@ -194,5 +163,6 @@ function! s:NextSection(backwards)
194163
endfunction
195164

196165
noremap <script> <buffer> <silent> ]] :call <SID>NextSection(0)<cr>
197-
198166
noremap <script> <buffer> <silent> [[ :call <SID>NextSection(1)<cr>
167+
168+
" vim:set sw=2 sts=2 ts=8 et:

ftplugin/scala/tagbar.vim

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"
2+
" Support for Tagbar -- https://github.com/majutsushi/tagbar
3+
"
4+
" Hat tip to Leonard Ehrenfried for the built-in ctags deffile:
5+
" https://leonard.io/blog/2013/04/editing-scala-with-vim/
6+
"
7+
if !exists(':Tagbar')
8+
finish
9+
endif
10+
11+
let g:tagbar_type_scala = {
12+
\ 'ctagstype' : 'scala',
13+
\ 'kinds' : [
14+
\ 'p:packages:1',
15+
\ 'V:values',
16+
\ 'v:variables',
17+
\ 'T:types',
18+
\ 't:traits',
19+
\ 'o:objects',
20+
\ 'a:aclasses',
21+
\ 'c:classes',
22+
\ 'r:cclasses',
23+
\ 'm:methods'
24+
\ ],
25+
\ 'sro' : '.',
26+
\ 'kind2scope' : {
27+
\ 'T' : 'type',
28+
\ 't' : 'trait',
29+
\ 'o' : 'object',
30+
\ 'a' : 'abstract class',
31+
\ 'c' : 'class',
32+
\ 'r' : 'case class'
33+
\ },
34+
\ 'scope2kind' : {
35+
\ 'type' : 'T',
36+
\ 'trait' : 't',
37+
\ 'object' : 'o',
38+
\ 'abstract class' : 'a',
39+
\ 'class' : 'c',
40+
\ 'case class' : 'r'
41+
\ }
42+
\ }
43+
44+
" In case you've updated/customized your ~/.ctags and prefer to use it.
45+
if get(g:, 'scala_use_builtin_tagbar_defs', 1)
46+
let g:tagbar_type_scala.deffile = expand('<sfile>:p:h:h:h') . '/ctags/scala.ctags'
47+
endif

indent/scala.vim

+2-1
Original file line numberDiff line numberDiff line change
@@ -597,5 +597,6 @@ function! GetScalaIndent()
597597

598598
return ind
599599
endfunction
600-
" vim:set ts=2 sts=2 sw=2:
600+
601+
" vim:set sw=2 sts=2 ts=8 et:
601602
" vim600:fdm=marker fdl=1 fdc=0:

plugin/scala.vim

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
" Vim plugin file
2+
" Language: Scala
3+
" Maintainer: Derek Wyatt
4+
" URL: https://github.com/derekwyatt/vim-scala
5+
" License: Apache 2
6+
" ----------------------------------------------------------------------------
7+
8+
if exists('g:loaded_scala') || &cp
9+
finish
10+
endif
11+
let g:loaded_scala = 1
12+
113
"
214
" Sort imports
315
"
416
" author: Leonard Ehrenfried <[email protected]>
517
"
6-
718
function! SortScalaImports()
819
let save_cursor = getpos(".")
920

@@ -130,3 +141,5 @@ function! s:sortIgnoreCase(i1, i2)
130141
endfunction
131142

132143
command! SortScalaImports call SortScalaImports()
144+
145+
" vim:set sw=2 sts=2 ts=8 et:

syntax/scala.vim

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Vim syntax file
2+
" Language: Scala
3+
" Maintainer: Derek Wyatt
4+
" URL: https://github.com/derekwyatt/vim-scala
5+
" License: Apache 2
6+
" ----------------------------------------------------------------------------
7+
18
if !exists('main_syntax')
29
if version < 600
310
syntax clear
@@ -201,3 +208,5 @@ let b:current_syntax = 'scala'
201208
if main_syntax ==# 'scala'
202209
unlet main_syntax
203210
endif
211+
212+
" vim:set sw=2 sts=2 ts=8 et:

0 commit comments

Comments
 (0)