This commit is contained in:
Adam Stankiewicz
2021-07-28 17:54:35 +02:00
parent 554a6ac757
commit ce31cd1d2f
16 changed files with 209 additions and 87 deletions

View File

@@ -8,7 +8,7 @@ endif
" Original Author: Mikhail Wolfson <mywolfson@gmail.com> " Original Author: Mikhail Wolfson <mywolfson@gmail.com>
" Maintainer: bfrg <https://github.com/bfrg> " Maintainer: bfrg <https://github.com/bfrg>
" Website: https://github.com/bfrg/vim-cpp-modern " Website: https://github.com/bfrg/vim-cpp-modern
" Last Change: Nov 23, 2020 " Last Change: Jul 24, 2021
" "
" This syntax file is based on: " This syntax file is based on:
" https://github.com/octol/vim-cpp-enhanced-highlight " https://github.com/octol/vim-cpp-enhanced-highlight
@@ -20,7 +20,7 @@ syn keyword cTodo contained BUG NOTE
" Highlight function names " Highlight function names
if !get(g:, 'cpp_no_function_highlight', 0) if get(g:, 'cpp_function_highlight', 1)
syn match cUserFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cParen,cCppParen syn match cUserFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cParen,cCppParen
hi def link cUserFunction Function hi def link cUserFunction Function
endif endif

View File

@@ -12,6 +12,15 @@ let g:loaded_autoload_fsharp = 1
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
" basic setups
let s:script_root_dir = expand('<sfile>:p:h') . "/../"
if has('nvim-0.5')
lua ionide = require("ionide")
endif
function! s:prompt(msg) function! s:prompt(msg)
let height = &cmdheight let height = &cmdheight
if height < 2 if height < 2
@@ -21,6 +30,9 @@ function! s:prompt(msg)
let &cmdheight = height let &cmdheight = height
endfunction endfunction
" FSAC payload interfaces
function! s:PlainNotification(content) function! s:PlainNotification(content)
return { 'Content': a:content } return { 'Content': a:content }
endfunction endfunction
@@ -80,8 +92,24 @@ function! s:FsdnRequest(query)
return { 'Query': a:query } return { 'Query': a:query }
endfunction endfunction
" LSP functions
function! s:call(method, params, cont) function! s:call(method, params, cont)
if g:fsharp#backend == 'languageclient-neovim'
call LanguageClient#Call(a:method, a:params, a:cont) call LanguageClient#Call(a:method, a:params, a:cont)
elseif g:fsharp#backend == 'nvim'
let key = fsharp#register_callback(a:cont)
call luaeval('ionide.call(_A[1], _A[2], _A[3])', [a:method, a:params, key])
endif
endfunction
function! s:notify(method, params)
if g:fsharp#backend == 'languageclient-neovim'
call LanguageClient#Notify(a:method, a:params)
elseif g:fsharp#backend == 'nvim'
call luaeval('ionide.notify(_A[1], _A[2])', [a:method, a:params])
endif
endfunction endfunction
function! s:signature(filePath, line, character, cont) function! s:signature(filePath, line, character, cont)
@@ -121,6 +149,9 @@ function! s:documentationSymbol(xmlSig, assembly, cont)
return s:call('fsharp/documentationSymbol', s:DocumentationForSymbolRequest(a:xmlSig, a:assembly), a:cont) return s:call('fsharp/documentationSymbol', s:DocumentationForSymbolRequest(a:xmlSig, a:assembly), a:cont)
endfunction endfunction
" FSAC configuration
" FSharpConfigDto from https://github.com/fsharp/FsAutoComplete/blob/master/src/FsAutoComplete/LspHelpers.fs " FSharpConfigDto from https://github.com/fsharp/FsAutoComplete/blob/master/src/FsAutoComplete/LspHelpers.fs
" "
" * The following options seems not working with workspace/didChangeConfiguration " * The following options seems not working with workspace/didChangeConfiguration
@@ -160,7 +191,7 @@ let s:config_keys_camel =
\ ] \ ]
let s:config_keys = [] let s:config_keys = []
function! fsharp#toSnakeCase(str) function! s:toSnakeCase(str)
let sn = substitute(a:str, '\(\<\u\l\+\|\l\+\)\(\u\)', '\l\1_\l\2', 'g') let sn = substitute(a:str, '\(\<\u\l\+\|\l\+\)\(\u\)', '\l\1_\l\2', 'g')
if sn == a:str | return tolower(a:str) | endif if sn == a:str | return tolower(a:str) | endif
return sn return sn
@@ -170,7 +201,7 @@ function! s:buildConfigKeys()
if len(s:config_keys) == 0 if len(s:config_keys) == 0
for key_camel in s:config_keys_camel for key_camel in s:config_keys_camel
let key = {} let key = {}
let key.snake = fsharp#toSnakeCase(key_camel.key) let key.snake = s:toSnakeCase(key_camel.key)
let key.camel = key_camel.key let key.camel = key_camel.key
if has_key(key_camel, 'default') if has_key(key_camel, 'default')
let key.default = key_camel.default let key.default = key_camel.default
@@ -180,7 +211,7 @@ function! s:buildConfigKeys()
endif endif
endfunction endfunction
function! g:fsharp#getServerConfig() function! fsharp#getServerConfig()
let fsharp = {} let fsharp = {}
call s:buildConfigKeys() call s:buildConfigKeys()
for key in s:config_keys for key in s:config_keys
@@ -196,12 +227,76 @@ function! g:fsharp#getServerConfig()
return fsharp return fsharp
endfunction endfunction
function! g:fsharp#updateServerConfig() function! fsharp#updateServerConfig()
let fsharp = fsharp#getServerConfig() let fsharp = fsharp#getServerConfig()
let settings = {'settings': {'FSharp': fsharp}} let settings = {'settings': {'FSharp': fsharp}}
call LanguageClient#Notify('workspace/didChangeConfiguration', settings) call s:notify('workspace/didChangeConfiguration', settings)
endfunction endfunction
" handlers for notifications
let s:handlers = {
\ 'fsharp/notifyWorkspace': 'fsharp#handle_notifyWorkspace',
\ }
function! s:registerAutocmds()
if g:fsharp#backend == 'nvim' && g:fsharp#lsp_codelens
augroup FSharp_AutoRefreshCodeLens
autocmd!
autocmd CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh()
augroup END
endif
if g:fsharp#backend != 'disable'
augroup FSharp_OnCursorMove
autocmd!
autocmd CursorMoved *.fs,*.fsi,*.fsx call fsharp#OnCursorMove()
augroup END
endif
endfunction
function! fsharp#initialize()
echom '[FSAC] Initialized'
if g:fsharp#backend == 'languageclient-neovim'
call LanguageClient_registerHandlers(s:handlers)
endif
call fsharp#updateServerConfig()
call s:registerAutocmds()
endfunction
" nvim-lsp specific functions
" handlers are picked up by ionide.setup()
function! fsharp#get_handlers()
return s:handlers
endfunction
let s:callbacks = {}
function! fsharp#register_callback(fn)
if g:fsharp#backend != 'nvim'
return -1
endif
let rnd = reltimestr(reltime())
let s:callbacks[rnd] = a:fn
return rnd
endfunction
function! fsharp#resolve_callback(key, arg)
if g:fsharp#backend != 'nvim'
return
endif
if has_key(s:callbacks, a:key)
let Callback = s:callbacks[a:key]
call Callback(a:arg)
call remove(s:callbacks, a:key)
endif
endfunction
" .NET/F# specific operations
function! s:findWorkspace(dir, cont) function! s:findWorkspace(dir, cont)
let s:cont_findWorkspace = a:cont let s:cont_findWorkspace = a:cont
function! s:callback_findWorkspace(result) function! s:callback_findWorkspace(result)
@@ -237,13 +332,20 @@ endfunction
let s:workspace = [] let s:workspace = []
function! fsharp#handle_notifyWorkspace(payload) abort
let content = json_decode(a:payload.content)
if content.Kind == 'projectLoading'
echom "[FSAC] Loading" content.Data.Project
let s:workspace = uniq(sort(add(s:workspace, content.Data.Project)))
elseif content.Kind == 'workspaceLoad' && content.Data.Status == 'finished'
echom printf("[FSAC] Workspace loaded (%d project(s))", len(s:workspace))
call fsharp#updateServerConfig()
endif
endfunction
function! s:load(arg) function! s:load(arg)
let s:loading_workspace = a:arg call s:workspaceLoad(a:arg, v:null)
function! s:callback_load(_)
echo "[FSAC] Workspace loaded: " . join(s:loading_workspace, ', ')
let s:workspace = s:workspace + s:loading_workspace
endfunction
call s:workspaceLoad(a:arg, function("s:callback_load"))
endfunction endfunction
function! fsharp#loadProject(...) function! fsharp#loadProject(...)
@@ -254,23 +356,15 @@ function! fsharp#loadProject(...)
call s:load(prjs) call s:load(prjs)
endfunction endfunction
function! fsharp#loadWorkspaceAuto() function! fsharp#showLoadedProjects()
if &ft == 'fsharp' for proj in s:workspace
call fsharp#updateServerConfig() echo "-" proj
if g:fsharp#automatic_workspace_init endfor
echom "[FSAC] Loading workspace..."
let bufferDirectory = fnamemodify(resolve(expand('%:p')), ':h')
call s:findWorkspace(bufferDirectory, function("s:load"))
endif
endif
endfunction endfunction
function! fsharp#reloadProjects() function! fsharp#reloadProjects()
if len(s:workspace) > 0 if len(s:workspace) > 0
function! s:callback_reloadProjects(_) call s:workspaceLoad(s:workspace, v:null)
call s:prompt("[FSAC] Workspace reloaded.")
endfunction
call s:workspaceLoad(s:workspace, function("s:callback_reloadProjects"))
else else
echom "[FSAC] Workspace is empty" echom "[FSAC] Workspace is empty"
endif endif
@@ -288,7 +382,7 @@ function! fsharp#showSignature()
if exists('result.result.content') if exists('result.result.content')
let content = json_decode(result.result.content) let content = json_decode(result.result.content)
if exists('content.Data') if exists('content.Data')
echom substitute(content.Data, '\n\+$', ' ', 'g') echo substitute(content.Data, '\n\+$', ' ', 'g')
endif endif
endif endif
endfunction endfunction
@@ -306,13 +400,21 @@ function! fsharp#showF1Help()
echo result echo result
endfunction endfunction
function! s:hover()
if g:fsharp#backend == 'languageclient-neovim'
call LanguageClient#textDocument_hover()
elseif g:fsharp#backend == 'nvim'
lua vim.lsp.buf.hover()
endif
endfunction
function! fsharp#showTooltip() function! fsharp#showTooltip()
function! s:callback_showTooltip(result) function! s:callback_showTooltip(result)
let result = a:result let result = a:result
if exists('result.result.content') if exists('result.result.content')
let content = json_decode(result.result.content) let content = json_decode(result.result.content)
if exists('content.Data') if exists('content.Data')
call LanguageClient#textDocument_hover() call s:hover()
endif endif
endif endif
endfunction endfunction
@@ -320,12 +422,8 @@ function! fsharp#showTooltip()
call s:signature(expand('%:p'), line('.') - 1, col('.') - 1, function("s:callback_showTooltip")) call s:signature(expand('%:p'), line('.') - 1, col('.') - 1, function("s:callback_showTooltip"))
endfunction endfunction
let s:script_root_dir = expand('<sfile>:p:h') . "/../"
let s:fsac = fnamemodify(s:script_root_dir . "fsac/fsautocomplete.dll", ":p") " FSAC update utils
let g:fsharp#languageserver_command =
\ ['dotnet', s:fsac,
\ '--background-service-enabled'
\ ]
function! s:update_win() function! s:update_win()
echom "[FSAC] Downloading FSAC. This may take a while..." echom "[FSAC] Downloading FSAC. This may take a while..."
@@ -357,6 +455,9 @@ function! fsharp#updateFSAC(...)
endif endif
endfunction endfunction
" FSI integration
let s:fsi_buffer = -1 let s:fsi_buffer = -1
let s:fsi_job = -1 let s:fsi_job = -1
let s:fsi_width = 0 let s:fsi_width = 0
@@ -385,7 +486,6 @@ endfunction
function! fsharp#openFsi(returnFocus) function! fsharp#openFsi(returnFocus)
if bufwinid(s:fsi_buffer) <= 0 if bufwinid(s:fsi_buffer) <= 0
let fsi_command = s:get_fsi_command() let fsi_command = s:get_fsi_command()
" Neovim
if exists('*termopen') || exists('*term_start') if exists('*termopen') || exists('*term_start')
let current_win = win_getid() let current_win = win_getid()
execute g:fsharp#fsi_window_command execute g:fsharp#fsi_window_command
@@ -429,7 +529,7 @@ function! fsharp#openFsi(returnFocus)
if a:returnFocus | call s:win_gotoid_safe(current_win) | endif if a:returnFocus | call s:win_gotoid_safe(current_win) | endif
return s:fsi_buffer return s:fsi_buffer
else else
echom "[FSAC] Your Vim does not support terminal". echom "[FSAC] Your (neo)vim does not support terminal".
return 0 return 0
endif endif
endif endif
@@ -517,6 +617,7 @@ function! fsharp#sendAllToFsi()
return fsharp#sendFsi(text) return fsharp#sendFsi(text)
endfunction endfunction
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@@ -2,11 +2,11 @@ if polyglot#init#is_disabled(expand('<sfile>:p'), 'puppet', 'autoload/puppet/ali
finish finish
endif endif
function! puppet#align#IndentLevel(lnum) function! puppet#align#IndentLevel(lnum) abort
return indent(a:lnum) / &shiftwidth return indent(a:lnum) / &shiftwidth
endfunction endfunction
function! puppet#align#LinesInBlock(lnum) function! puppet#align#LinesInBlock(lnum) abort
let lines = [] let lines = []
let indent_level = puppet#align#IndentLevel(a:lnum) let indent_level = puppet#align#IndentLevel(a:lnum)

View File

@@ -10,9 +10,9 @@ endif
let s:ctags_options_dir = expand('<sfile>:p:h:h:h') . '/ctags/' let s:ctags_options_dir = expand('<sfile>:p:h:h:h') . '/ctags/'
" Return full path to option file for ctags application " Return full path to option file for ctags application
function! puppet#ctags#OptionFile() function! puppet#ctags#OptionFile() abort
if puppet#ctags#Type() == 'universal' if puppet#ctags#Type() ==? 'universal'
let l:ctags_options = 'puppet_u.ctags' let l:ctags_options = 'puppet_u.ctags'
else else
let l:ctags_options = 'puppet.ctags' let l:ctags_options = 'puppet.ctags'
@@ -22,13 +22,13 @@ endfunction
" Return type of installed ctags application, " Return type of installed ctags application,
" can be 'universal' or 'exuberant' " can be 'universal' or 'exuberant'
function! puppet#ctags#Type() function! puppet#ctags#Type() abort
if !s:ctags_type if !s:ctags_type
let l:version = system('ctags --version') let l:version = system('ctags --version')
if l:version =~ 'Universal Ctags' if l:version =~? 'Universal Ctags'
let s:ctags_type = 'universal' let s:ctags_type = 'universal'
elseif l:version =~ 'Exuberant Ctags' elseif l:version =~? 'Exuberant Ctags'
let s:ctags_type = 'exuberant' let s:ctags_type = 'exuberant'
else else
echoerr 'Unknown version of Ctags' echoerr 'Unknown version of Ctags'

View File

@@ -6,12 +6,12 @@ endif
" Compiler: puppet-lint " Compiler: puppet-lint
" Maintainer: Doug Kearns <dougkearns@gmail.com> " Maintainer: Doug Kearns <dougkearns@gmail.com>
if exists("current_compiler") if exists('current_compiler')
finish finish
endif endif
let current_compiler = "puppet-lint" let current_compiler = 'puppet-lint'
if exists(":CompilerSet") != 2 " older Vim always used :setlocal if exists(':CompilerSet') != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args> command -nargs=* CompilerSet setlocal <args>
endif endif

View File

@@ -9,7 +9,7 @@ endif
" Last Change: 2019-09-01 " Last Change: 2019-09-01
" Only do this when not done yet for this buffer " Only do this when not done yet for this buffer
if exists("b:did_ftplugin") if exists('b:did_ftplugin')
finish finish
endif endif
@@ -17,23 +17,23 @@ let s:save_cpo = &cpo
set cpo-=C set cpo-=C
" Define some defaults in case the included ftplugins don't set them. " Define some defaults in case the included ftplugins don't set them.
let s:undo_ftplugin = "" let s:undo_ftplugin = ''
let s:browsefilter = "All Files (*.*)\t*.*\n" let s:browsefilter = "All Files (*.*)\t*.*\n"
let s:match_words = "" let s:match_words = ''
runtime! ftplugin/sh.vim runtime! ftplugin/sh.vim
unlet! b:did_ftplugin unlet! b:did_ftplugin
" Override our defaults if these were set by an included ftplugin. " Override our defaults if these were set by an included ftplugin.
if exists("b:undo_ftplugin") if exists('b:undo_ftplugin')
let s:undo_ftplugin = b:undo_ftplugin let s:undo_ftplugin = b:undo_ftplugin
unlet b:undo_ftplugin unlet b:undo_ftplugin
endif endif
if exists("b:browsefilter") if exists('b:browsefilter')
let s:browsefilter = b:browsefilter let s:browsefilter = b:browsefilter
unlet b:browsefilter unlet b:browsefilter
endif endif
if exists("b:match_words") if exists('b:match_words')
let s:match_words = b:match_words let s:match_words = b:match_words
unlet b:match_words unlet b:match_words
endif endif
@@ -46,13 +46,13 @@ runtime! ftplugin/puppet.vim
let b:did_ftplugin = 1 let b:did_ftplugin = 1
" Combine the new set of values with those previously included. " Combine the new set of values with those previously included.
if exists("b:undo_ftplugin") if exists('b:undo_ftplugin')
let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin let s:undo_ftplugin = b:undo_ftplugin . ' | ' . s:undo_ftplugin
endif endif
if exists ("b:browsefilter") if exists ('b:browsefilter')
let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
endif endif
if exists("b:match_words") if exists('b:match_words')
let s:match_words = b:match_words . ',' . s:match_words let s:match_words = b:match_words . ',' . s:match_words
endif endif
@@ -64,14 +64,14 @@ let &l:suffixesadd = s:suffixesadd . (s:suffixesadd =~# ',$\|^$' ? '' : ',') . &
unlet s:include s:path s:suffixesadd unlet s:include s:path s:suffixesadd
" Load the combined list of match_words for matchit.vim " Load the combined list of match_words for matchit.vim
if exists("loaded_matchit") if exists('loaded_matchit')
let b:match_words = s:match_words let b:match_words = s:match_words
endif endif
" TODO: comments= " TODO: comments=
setlocal commentstring=<%#%s%> setlocal commentstring=<%#%s%>
let b:undo_ftplugin = "setl cms< " let b:undo_ftplugin = 'setl cms< '
\ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
let &cpo = s:save_cpo let &cpo = s:save_cpo

View File

@@ -8,7 +8,7 @@ endif
" URL: https://github.com/rodjek/vim-puppet " URL: https://github.com/rodjek/vim-puppet
" Last Change: 2019-08-31 " Last Change: 2019-08-31
if (exists("b:did_ftplugin")) if (exists('b:did_ftplugin'))
finish finish
endif endif
let b:did_ftplugin = 1 let b:did_ftplugin = 1
@@ -25,8 +25,8 @@ setlocal commentstring=#\ %s
setlocal formatoptions-=t formatoptions+=croql setlocal formatoptions-=t formatoptions+=croql
setlocal formatexpr=puppet#format#Format() setlocal formatexpr=puppet#format#Format()
let b:undo_ftplugin = " let b:undo_ftplugin = '
\ setlocal tabstop< tabstop< softtabstop< shiftwidth< expandtab< \ setlocal tabstop< tabstop< softtabstop< shiftwidth< expandtab<
\| setlocal keywordprg< iskeyword< comments< commentstring< \| setlocal keywordprg< iskeyword< comments< commentstring<
\| setlocal formatoptions< formatexpr< \| setlocal formatoptions< formatexpr<
\" \'

View File

@@ -25,7 +25,7 @@ let g:tagbar_type_puppet = {
\], \],
\} \}
if puppet#ctags#Type() == 'universal' if puppet#ctags#Type() ==? 'universal'
" There no sense to split objects by colon " There no sense to split objects by colon
let g:tagbar_type_puppet.sro = '__' let g:tagbar_type_puppet.sro = '__'
let g:tagbar_type_puppet.kind2scope = { let g:tagbar_type_puppet.kind2scope = {

View File

@@ -30,9 +30,6 @@ if exists('s:hcl_fold_sections_save')
let g:hcl_fold_sections = s:hcl_fold_sections_save let g:hcl_fold_sections = s:hcl_fold_sections_save
end end
let s:cpo_save = &cpoptions
set cpoptions&vim
if !exists('g:terraform_binary_path') if !exists('g:terraform_binary_path')
let g:terraform_binary_path='terraform' let g:terraform_binary_path='terraform'
endif endif

View File

@@ -8,7 +8,7 @@ endif
" Last Change: 2009 Aug 19 " Last Change: 2009 Aug 19
" vim: set sw=4 sts=4: " vim: set sw=4 sts=4:
if exists("b:did_indent") if exists('b:did_indent')
finish finish
endif endif
let b:did_indent = 1 let b:did_indent = 1
@@ -17,11 +17,11 @@ setlocal autoindent smartindent
setlocal indentexpr=GetPuppetIndent() setlocal indentexpr=GetPuppetIndent()
setlocal indentkeys+=0],0) setlocal indentkeys+=0],0)
let b:undo_indent = " let b:undo_indent = '
\ setlocal autoindent< smartindent< indentexpr< indentkeys< \ setlocal autoindent< smartindent< indentexpr< indentkeys<
\" \'
if exists("*GetPuppetIndent") if exists('*GetPuppetIndent')
finish finish
endif endif
@@ -37,7 +37,7 @@ function! s:PartOfInclude(lnum)
if line !~ ',$' if line !~ ',$'
break break
endif endif
if line =~ '^\s*include\s\+[^,]\+,$' && line !~ '[=>]>' if line =~# '^\s*include\s\+[^,]\+,$' && line !~ '[=>]>'
return 1 return 1
endif endif
endwhile endwhile
@@ -84,7 +84,7 @@ function! GetPuppetIndent(...)
" the same indent here would be premature since for that particular case " the same indent here would be premature since for that particular case
" we want to instead get the indent level of the matching opening brace or " we want to instead get the indent level of the matching opening brace or
" parenthenses. " parenthenses.
if pline =~ '^\s*#' && line !~ '^\s*\(}\(,\|;\)\?$\|]:\|],\|}]\|];\?$\|)\)' if pline =~# '^\s*#' && line !~# '^\s*\(}\(,\|;\)\?$\|]:\|],\|}]\|];\?$\|)\)'
return ind return ind
endif endif
@@ -123,12 +123,12 @@ function! GetPuppetIndent(...)
endif endif
" Match } }, }; ] ]: ], ]; ) " Match } }, }; ] ]: ], ]; )
if line =~ '^\s*\(}\(,\|;\)\?$\|]:\|],\|}]\|];\?$\|)\)' if line =~# '^\s*\(}\(,\|;\)\?$\|]:\|],\|}]\|];\?$\|)\)'
let ind = indent(s:OpenBrace(v:lnum)) let ind = indent(s:OpenBrace(v:lnum))
endif endif
" Don't actually shift over for } else { " Don't actually shift over for } else {
if line =~ '^\s*}\s*els\(e\|if\).*{\s*$' if line =~# '^\s*}\s*els\(e\|if\).*{\s*$'
let ind -= &sw let ind -= &sw
endif endif
" Don't indent resources that are one after another with a ->(ordering arrow) " Don't indent resources that are one after another with a ->(ordering arrow)

View File

@@ -93,6 +93,9 @@ let s:ruby_indent_keywords =
\ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>'
" Def without an end clause: def method_call(...) = <expression>
let s:ruby_endless_def = '\<def\s\+\k\+[!?]\=\%((.*)\|\s\)\s*='
" Regex used for words that, at the start of a line, remove a level of indent. " Regex used for words that, at the start of a line, remove a level of indent.
let s:ruby_deindent_keywords = let s:ruby_deindent_keywords =
\ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>' \ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>'
@@ -112,10 +115,26 @@ let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>
" Regex that defines the end-match for the 'end' keyword. " Regex that defines the end-match for the 'end' keyword.
let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>' let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>'
" Expression used for searchpair() call for finding match for 'end' keyword. " Expression used for searchpair() call for finding a match for an 'end' keyword.
let s:end_skip_expr = s:skip_expr . function! s:EndSkipExpr()
\ ' || (expand("<cword>") == "do"' . if eval(s:skip_expr)
\ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")' return 1
elseif expand('<cword>') == 'do'
\ && getline(".") =~ '^\s*\<\(while\|until\|for\):\@!\>'
return 1
elseif getline('.') =~ s:ruby_endless_def
return 1
elseif getline('.') =~ '\<def\s\+\k\+[!?]\=([^)]*$'
" Then it's a `def method(` with a possible `) =` later
call search('\<def\s\+\k\+\zs(', 'W', line('.'))
normal! %
return getline('.') =~ ')\s*='
else
return 0
endif
endfunction
let s:end_skip_expr = function('s:EndSkipExpr')
" Regex that defines continuation lines, not including (, {, or [. " Regex that defines continuation lines, not including (, {, or [.
let s:non_bracket_continuation_regex = let s:non_bracket_continuation_regex =
@@ -575,6 +594,11 @@ function! s:AfterUnbalancedBracket(pline_info) abort
call cursor(info.plnum, closing.pos + 1) call cursor(info.plnum, closing.pos + 1)
normal! % normal! %
if strpart(info.pline, closing.pos) =~ '^)\s*='
" special case: the closing `) =` of an endless def
return indent(s:GetMSL(line('.')))
endif
if s:Match(line('.'), s:ruby_indent_keywords) if s:Match(line('.'), s:ruby_indent_keywords)
return indent('.') + info.sw return indent('.') + info.sw
else else
@@ -613,7 +637,7 @@ function! s:AfterIndentKeyword(pline_info) abort
let info = a:pline_info let info = a:pline_info
let col = s:Match(info.plnum, s:ruby_indent_keywords) let col = s:Match(info.plnum, s:ruby_indent_keywords)
if col > 0 if col > 0 && s:Match(info.plnum, s:ruby_endless_def) <= 0
call cursor(info.plnum, col) call cursor(info.plnum, col)
let ind = virtcol('.') - 1 + info.sw let ind = virtcol('.') - 1 + info.sw
" TODO: make this better (we need to count them) (or, if a searchpair " TODO: make this better (we need to count them) (or, if a searchpair
@@ -660,7 +684,7 @@ function! s:IndentingKeywordInMSL(msl_info) abort
" TODO: this does not take into account contrived things such as " TODO: this does not take into account contrived things such as
" module Foo; class Bar; end " module Foo; class Bar; end
let col = s:Match(info.plnum_msl, s:ruby_indent_keywords) let col = s:Match(info.plnum_msl, s:ruby_indent_keywords)
if col > 0 if col > 0 && s:Match(info.plnum_msl, s:ruby_endless_def) <= 0
let ind = indent(info.plnum_msl) + info.sw let ind = indent(info.plnum_msl) + info.sw
if s:Match(info.plnum_msl, s:end_end_regex) if s:Match(info.plnum_msl, s:end_end_regex)
let ind = ind - info.sw let ind = ind - info.sw

View File

@@ -92,7 +92,7 @@ if exists("g:ansible_extra_keywords_highlight")
\ debugger always_run check_mode diff no_log args tags force_handlers \ debugger always_run check_mode diff no_log args tags force_handlers
\ vars vars_files vars_prompt delegate_facts delegate_to \ vars vars_files vars_prompt delegate_facts delegate_to
\ any_errors_fatal ignore_errors ignore_unreachable max_fail_percentage \ any_errors_fatal ignore_errors ignore_unreachable max_fail_percentage
\ connection hosts port remote_user module_defaults \ connection children hosts port remote_user module_defaults
\ environment fact_path gather_facts gather_subset gather_timeout \ environment fact_path gather_facts gather_subset gather_timeout
\ async poll throttle timeout order run_once serial strategy \ async poll throttle timeout order run_once serial strategy
\ containedin='.s:yamlKey.' contained' \ containedin='.s:yamlKey.' contained'

View File

@@ -36,7 +36,7 @@ syntax keyword typescriptClassStatic static
syntax keyword typescriptAccessibilityModifier public private protected contained syntax keyword typescriptAccessibilityModifier public private protected contained
syntax keyword typescriptReadonlyModifier readonly contained syntax keyword typescriptReadonlyModifier readonly override contained
syntax region typescriptStringMember contained syntax region typescriptStringMember contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1/ \ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1/

View File

@@ -9,7 +9,7 @@ endif
" Last Change: 2019-09-01 " Last Change: 2019-09-01
" quit when a syntax file was already loaded {{{1 " quit when a syntax file was already loaded {{{1
if exists("b:current_syntax") if exists('b:current_syntax')
finish finish
endif endif
@@ -29,5 +29,5 @@ syn region ePuppetComment matchgroup=ePuppetDelimiter start="<%-\=#" end=
hi def link ePuppetDelimiter PreProc hi def link ePuppetDelimiter PreProc
hi def link ePuppetComment Comment hi def link ePuppetComment Comment
let b:current_syntax = "epuppet" let b:current_syntax = 'epuppet'

View File

@@ -33,7 +33,7 @@ syn match gitDiffAdded "{+[^}]*+}" contained containedin=gitDiff
syn match gitDiffRemoved "^ \+-.*" contained containedin=gitDiffMerge syn match gitDiffRemoved "^ \+-.*" contained containedin=gitDiffMerge
syn match gitDiffRemoved "\[-[^]]*-\]" contained containedin=gitDiff syn match gitDiffRemoved "\[-[^]]*-\]" contained containedin=gitDiff
syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\|gpgsig\|summary\|boundary\|filename\|previous\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite contains=@NoSpell syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\|gpgsig\%(-\w\+\)\=\|summary\|boundary\|filename\|previous\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite contains=@NoSpell
syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite contains=@NoSpell syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite contains=@NoSpell
syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell
syn match gitMode /^\d\{6\}\>/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite syn match gitMode /^\d\{6\}\>/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite

View File

@@ -10,7 +10,7 @@ endif
" and heredoc was copied from ruby and then modified to comply with Puppet syntax. " and heredoc was copied from ruby and then modified to comply with Puppet syntax.
" Prelude {{{1 " Prelude {{{1
if exists("b:current_syntax") if exists('b:current_syntax')
finish finish
endif endif
@@ -437,4 +437,4 @@ HiLink puppetComment Comment
delcommand HiLink delcommand HiLink
let b:current_syntax = "puppet" let b:current_syntax = 'puppet'