···11+local api = vim.api
22+-- Note: The functions used here will be upstreamed eventually.
33+local ts_utils = require('nvim-treesitter.ts_utils')
44+55+local function get_ast_nodes()
66+ local wininfo = vim.fn.getwininfo(api.nvim_get_current_win())[1]
77+ -- Get current TS node.
88+ local cur_node = ts_utils.get_node_at_cursor(0)
99+ if not cur_node then return end
1010+ -- Get parent nodes recursively.
1111+ local nodes = { cur_node }
1212+ local parent = cur_node:parent()
1313+ while parent do
1414+ table.insert(nodes, parent)
1515+ parent = parent:parent()
1616+ end
1717+ -- Create Leap targets from TS nodes.
1818+ local targets = {}
1919+ local startline, startcol
2020+ for _, node in ipairs(nodes) do
2121+ startline, startcol, _, _ = node:range() -- (0,0)
2222+ if startline + 1 >= wininfo.topline then
2323+ local target = { node = node, pos = { startline + 1, startcol + 1 } }
2424+ table.insert(targets, target)
2525+ end
2626+ end
2727+ if #targets >= 1 then return targets end
2828+end
2929+3030+local function select_range(target)
3131+ local mode = api.nvim_get_mode().mode
3232+ if not mode:match('n?o') then
3333+ -- Force going back to Normal (implies mode = v | V | ).
3434+ vim.cmd('normal! ' .. mode)
3535+ end
3636+ ts_utils.update_selection(0, target.node,
3737+ mode:match('V') and 'linewise' or
3838+ mode:match('') and 'blockwise' or
3939+ 'charwise'
4040+ )
4141+end
4242+4343+local function leap()
4444+ require('leap').leap {
4545+ targets = get_ast_nodes(),
4646+ action = api.nvim_get_mode().mode ~= 'n' and select_range, -- or jump
4747+ backward = true
4848+ }
4949+end
5050+5151+return { leap = leap }
···11+" Only apply to .txt files...
22+augroup HelpInTabs
33+ autocmd!
44+ autocmd BufEnter *.txt call HelpInNewTab()
55+augroup END
66+77+" Only apply to help files...
88+function! HelpInNewTab ()
99+ if &buftype == 'help' && g:help_in_tabs
1010+ "Convert the help window to a tab...
1111+ execute "normal \<C-W>T"
1212+ endif
1313+endfunction
1414+1515+let g:help_in_tabs = 0
1616+
···11+" Vim syntax file
22+" Language: Kotlin
33+" Maintainer: Alexander Udalov
44+" Latest Revision: 13 July 2020
55+66+if exists('b:current_syntax')
77+ finish
88+endif
99+1010+syn keyword ktStatement break continue return
1111+syn keyword ktConditional if else when
1212+syn keyword ktRepeat do for while
1313+syn keyword ktOperator in is by
1414+syn keyword ktKeyword get set out super this where
1515+syn keyword ktException try catch finally throw
1616+1717+syn keyword ktInclude import package
1818+1919+" The following is generated by generate-stdlib-class-names.main.kts
2020+syn keyword ktType AbstractCollection AbstractCoroutineContextElement AbstractCoroutineContextKey AbstractDoubleTimeSource AbstractIterator AbstractList AbstractLongTimeSource
2121+syn keyword ktType AbstractMap AbstractMutableCollection AbstractMutableList AbstractMutableMap AbstractMutableSet AbstractSet AccessDeniedException Accessor Annotation
2222+syn keyword ktType AnnotationRetention AnnotationTarget Any Appendable ArithmeticException Array ArrayDeque ArrayList AssertionError Boolean BooleanArray BooleanIterator
2323+syn keyword ktType BuilderInference Byte ByteArray ByteIterator CallsInPlace CancellationException Char CharArray CharCategory CharDirectionality CharIterator CharProgression
2424+syn keyword ktType CharRange CharSequence CharacterCodingException Charsets ClassCastException Cloneable ClosedFloatingPointRange ClosedRange Collection Comparable Comparator
2525+syn keyword ktType ConcurrentModificationException ConditionalEffect Continuation ContinuationInterceptor ContractBuilder CoroutineContext DeepRecursiveFunction DeepRecursiveScope
2626+syn keyword ktType Delegates Deprecated DeprecatedSinceKotlin DeprecationLevel Destructured Double DoubleArray DoubleIterator DslMarker Duration DurationUnit Effect Element
2727+syn keyword ktType EmptyCoroutineContext Entry Enum Error Exception Experimental ExperimentalContracts ExperimentalJsExport ExperimentalMultiplatform ExperimentalStdlibApi
2828+syn keyword ktType ExperimentalTime ExperimentalTypeInference ExperimentalUnsignedTypes ExtensionFunctionType FileAlreadyExistsException FileSystemException FileTreeWalk
2929+syn keyword ktType FileWalkDirection Float FloatArray FloatIterator Function Function0 Function1 Function10 Function11 Function12 Function13 Function14 Function15 Function16
3030+syn keyword ktType Function17 Function18 Function19 Function2 Function20 Function21 Function22 Function3 Function4 Function5 Function6 Function7 Function8 Function9 FunctionN
3131+syn keyword ktType Getter Grouping HashMap HashSet IllegalArgumentException IllegalStateException IndexOutOfBoundsException IndexedValue Int IntArray IntIterator IntProgression
3232+syn keyword ktType IntRange InvocationKind Iterable Iterator JsExport JsName JvmDefault JvmDefaultWithoutCompatibility JvmField JvmMultifileClass JvmName JvmOverloads JvmStatic
3333+syn keyword ktType JvmSuppressWildcards JvmSynthetic JvmWildcard KAnnotatedElement KCallable KClass KClassifier KDeclarationContainer KFunction KMutableProperty KMutableProperty0
3434+syn keyword ktType KMutableProperty1 KMutableProperty2 KParameter KProperty KProperty0 KProperty1 KProperty2 KType KTypeParameter KTypeProjection KVariance KVisibility Key Kind
3535+syn keyword ktType KotlinNullPointerException KotlinReflectionNotSupportedError KotlinVersion Lazy LazyThreadSafetyMode Level LinkedHashMap LinkedHashSet List ListIterator Long
3636+syn keyword ktType LongArray LongIterator LongProgression LongRange Map MatchGroup MatchGroupCollection MatchNamedGroupCollection MatchResult Metadata Monotonic MustBeDocumented
3737+syn keyword ktType MutableCollection MutableEntry MutableIterable MutableIterator MutableList MutableListIterator MutableMap MutableSet NoSuchElementException NoSuchFileException
3838+syn keyword ktType NoWhenBranchMatchedException NotImplementedError Nothing NullPointerException Number NumberFormatException ObservableProperty OnErrorAction OptIn
3939+syn keyword ktType OptionalExpectation OverloadResolutionByLambdaReturnType Pair ParameterName PropertyDelegateProvider PublishedApi PurelyImplements Random RandomAccess
4040+syn keyword ktType ReadOnlyProperty ReadWriteProperty Regex RegexOption Repeatable ReplaceWith RequiresOptIn RestrictsSuspension Result Retention Returns ReturnsNotNull
4141+syn keyword ktType RuntimeException Sequence SequenceScope Set Setter SharedImmutable Short ShortArray ShortIterator SimpleEffect SinceKotlin Strictfp String StringBuilder Suppress
4242+syn keyword ktType Synchronized Target TestTimeSource ThreadLocal Throwable Throws TimeMark TimeSource TimedValue Transient Triple TypeCastException Typography UByte UByteArray
4343+syn keyword ktType UByteIterator UInt UIntArray UIntIterator UIntProgression UIntRange ULong ULongArray ULongIterator ULongProgression ULongRange UShort UShortArray UShortIterator
4444+syn keyword ktType UninitializedPropertyAccessException Unit UnsafeVariance UnsupportedOperationException UseExperimental Volatile
4545+4646+syn keyword ktModifier annotation companion enum inner internal private protected public abstract final open override sealed vararg dynamic expect actual
4747+syn keyword ktStructure class object interface typealias fun val var constructor init
4848+4949+syn keyword ktReservedKeyword typeof
5050+5151+syn keyword ktBoolean true false
5252+syn keyword ktConstant null
5353+5454+syn keyword ktModifier data tailrec lateinit reified external inline noinline crossinline const operator infix suspend
5555+5656+syn match ktOperator "\v\?:|::|\<\=? | \>\=?|[!=]\=\=?|<as>\??|[-!%&*+/|]"
5757+5858+syn keyword ktTodo TODO FIXME XXX contained
5959+syn match ktShebang "\v^#!.*$"
6060+syn match ktLineComment "\v//.*$" contains=ktTodo,@Spell
6161+syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contains=ktComment,ktTodo,@Spell
6262+6363+syn region ktDocComment start="/\*\*" end="\*/" contains=ktDocTag,ktTodo,@Spell
6464+syn match ktDocTag "\v\@(author|constructor|receiver|return|since|suppress)>" contained
6565+syn match ktDocTag "\v\@(exception|param|property|throws|see|sample)>\s*\S+" contains=ktDocTagParam contained
6666+syn match ktDocTagParam "\v(\s|\[)\S+" contained
6767+syn match ktComment "/\*\*/"
6868+6969+syn match ktSpecialCharError "\v\\." contained
7070+syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained
7171+syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
7272+syn region ktString start='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation
7373+syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError
7474+syn match ktCharacter "\v'\\''" contains=ktSpecialChar
7575+syn match ktCharacter "\v'[^\\]'"
7676+7777+" TODO: highlight label in 'this@Foo'
7878+syn match ktAnnotation "\v(\w)@<!\@[[:alnum:]_.]*(:[[:alnum:]_.]*)?"
7979+syn match ktLabel "\v\w+\@"
8080+8181+syn match ktSimpleInterpolation "\v\$\h\w*" contained
8282+syn region ktComplexInterpolation matchgroup=ktComplexInterpolationBrace start="\v\$\{" end="\v\}" contains=ALLBUT,ktSimpleInterpolation,ktTodo,ktSpecialCharError,ktSpecialChar,ktDocTag,ktDocTagParam
8383+8484+syn match ktNumber "\v<\d+[_[:digit:]]*(uL?|UL?|[LFf])?"
8585+syn match ktNumber "\v<0[Xx]\x+[_[:xdigit:]]*(uL?|UL?|L)?"
8686+syn match ktNumber "\v<0[Bb][01]+[_01]*(uL?|UL?|L)?"
8787+syn match ktFloat "\v<\d*(\d[eE][-+]?\d+|\.\d+([eE][-+]?\d+)?)[Ff]?"
8888+8989+syn match ktEscapedName "\v`.*`"
9090+9191+syn match ktExclExcl "!!"
9292+syn match ktArrow "->"
9393+9494+hi def link ktStatement Statement
9595+hi def link ktConditional Conditional
9696+hi def link ktRepeat Repeat
9797+hi def link ktOperator Operator
9898+hi def link ktKeyword Keyword
9999+hi def link ktException Exception
100100+hi def link ktReservedKeyword Error
101101+102102+hi def link ktInclude Include
103103+104104+hi def link ktType Type
105105+hi def link ktModifier StorageClass
106106+hi def link ktStructure Structure
107107+hi def link ktTypedef Typedef
108108+109109+hi def link ktBoolean Boolean
110110+hi def link ktConstant Constant
111111+112112+hi def link ktTodo Todo
113113+hi def link ktShebang Comment
114114+hi def link ktLineComment Comment
115115+hi def link ktComment Comment
116116+hi def link ktCommentMatchGroup Comment
117117+hi def link ktDocComment Comment
118118+hi def link ktDocTag Special
119119+hi def link ktDocTagParam Identifier
120120+121121+hi def link ktSpecialChar SpecialChar
122122+hi def link ktSpecialCharError Error
123123+hi def link ktString String
124124+hi def link ktCharacter Character
125125+126126+hi def link ktAnnotation Identifier
127127+hi def link ktLabel Identifier
128128+129129+hi def link ktSimpleInterpolation Identifier
130130+hi def link ktComplexInterpolationBrace Identifier
131131+132132+hi def link ktNumber Number
133133+hi def link ktFloat Float
134134+135135+hi def link ktExclExcl Special
136136+hi def link ktArrow Structure
137137+138138+let b:current_syntax = 'kotlin'
139139+
+106
syntax/proto.vim
···11+" Protocol Buffers - Google's data interchange format
22+" Copyright 2008 Google Inc. All rights reserved.
33+" https://developers.google.com/protocol-buffers/
44+"
55+" Redistribution and use in source and binary forms, with or without
66+" modification, are permitted provided that the following conditions are
77+" met:
88+"
99+" * Redistributions of source code must retain the above copyright
1010+" notice, this list of conditions and the following disclaimer.
1111+" * Redistributions in binary form must reproduce the above
1212+" copyright notice, this list of conditions and the following disclaimer
1313+" in the documentation and/or other materials provided with the
1414+" distribution.
1515+" * Neither the name of Google Inc. nor the names of its
1616+" contributors may be used to endorse or promote products derived from
1717+" this software without specific prior written permission.
1818+"
1919+" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020+" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2121+" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2222+" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2323+" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2424+" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2525+" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2626+" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2727+" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2828+" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929+" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030+3131+" This is the Vim syntax file for Google Protocol Buffers.
3232+"
3333+" Usage:
3434+"
3535+" 1. cp proto.vim ~/.vim/syntax/
3636+" 2. Add the following to ~/.vimrc:
3737+"
3838+" augroup filetype
3939+" au! BufRead,BufNewFile *.proto setfiletype proto
4040+" augroup end
4141+"
4242+" Or just create a new file called ~/.vim/ftdetect/proto.vim with the
4343+" previous lines on it.
4444+4545+if version < 600
4646+ syntax clear
4747+elseif exists("b:current_syntax")
4848+ finish
4949+endif
5050+5151+syn case match
5252+5353+syn keyword pbTodo contained TODO FIXME XXX
5454+syn cluster pbCommentGrp contains=pbTodo
5555+5656+syn keyword pbSyntax syntax import option
5757+syn keyword pbStructure package message group oneof
5858+syn keyword pbRepeat optional required repeated
5959+syn keyword pbDefault default
6060+syn keyword pbExtend extend extensions to max reserved
6161+syn keyword pbRPC service rpc returns
6262+6363+syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
6464+syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
6565+syn keyword pbType float double bool string bytes
6666+syn keyword pbTypedef enum
6767+syn keyword pbBool true false
6868+6969+syn match pbInt /-\?\<\d\+\>/
7070+syn match pbInt /\<0[xX]\x+\>/
7171+syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
7272+syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp
7373+syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp
7474+syn region pbString start=/"/ skip=/\\./ end=/"/
7575+syn region pbString start=/'/ skip=/\\./ end=/'/
7676+7777+if version >= 508 || !exists("did_proto_syn_inits")
7878+ if version < 508
7979+ let did_proto_syn_inits = 1
8080+ command -nargs=+ HiLink hi link <args>
8181+ else
8282+ command -nargs=+ HiLink hi def link <args>
8383+ endif
8484+8585+ HiLink pbTodo Todo
8686+8787+ HiLink pbSyntax Include
8888+ HiLink pbStructure Structure
8989+ HiLink pbRepeat Repeat
9090+ HiLink pbDefault Keyword
9191+ HiLink pbExtend Keyword
9292+ HiLink pbRPC Keyword
9393+ HiLink pbType Type
9494+ HiLink pbTypedef Typedef
9595+ HiLink pbBool Boolean
9696+9797+ HiLink pbInt Number
9898+ HiLink pbFloat Float
9999+ HiLink pbComment Comment
100100+ HiLink pbString String
101101+102102+ delcommand HiLink
103103+endif
104104+105105+let b:current_syntax = "proto"
106106+