Skip to content

Commit 7f98e94

Browse files
committed
Update
1 parent ce31cd1 commit 7f98e94

37 files changed

+491
-249
lines changed

autoload/dart.vim

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ endfunction
3131

3232
function! dart#fmt(...) abort
3333
let l:dartfmt = s:FindDartFmt()
34-
if type(l:dartfmt) != type('') | return | endif
34+
if empty(l:dartfmt) | return | endif
3535
let buffer_content = getline(1, '$')
36-
let l:cmd = [l:dartfmt, '--stdin-name', shellescape(expand('%'))]
36+
let l:cmd = extend(l:dartfmt, ['--stdin-name', shellescape(expand('%'))])
3737
if exists('g:dartfmt_options')
3838
call extend(l:cmd, g:dartfmt_options)
3939
endif
@@ -64,14 +64,30 @@ function! dart#fmt(...) abort
6464
endfunction
6565

6666
function! s:FindDartFmt() abort
67-
if executable('dartfmt') | return 'dartfmt' | endif
67+
if executable('dart')
68+
let l:version_text = system('dart --version')
69+
let l:match = matchlist(l:version_text,
70+
\ '\vDart SDK version: (\d+)\.(\d+)\.\d+.*')
71+
if empty(l:match)
72+
call s:error('Unable to determine dart version')
73+
return []
74+
endif
75+
let l:major = l:match[1]
76+
let l:minor = l:match[2]
77+
if l:major > 2 || l:major == 2 && l:minor >= 14
78+
return ['dart', 'format']
79+
endif
80+
endif
81+
" Legacy fallback for Dart SDK pre 2.14
82+
if executable('dartfmt') | return ['dartfmt'] | endif
6883
if executable('flutter')
6984
let l:flutter_cmd = resolve(exepath('flutter'))
7085
let l:bin = fnamemodify(l:flutter_cmd, ':h')
7186
let l:dartfmt = l:bin.'/cache/dart-sdk/bin/dartfmt'
72-
if executable(l:dartfmt) | return l:dartfmt | endif
87+
if executable(l:dartfmt) | return [l:dartfmt] | endif
7388
endif
7489
call s:error('Cannot find a `dartfmt` command')
90+
return []
7591
endfunction
7692

7793
function! dart#analyzer(q_args) abort

autoload/elixir/indent.vim

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function! elixir#indent#indent(lnum)
2424
call cursor(lnum, 0)
2525

2626
let handlers = [
27+
\'inside_embedded_view',
2728
\'top_of_file',
2829
\'starts_with_string_continuation',
2930
\'following_trailing_binary_operator',
@@ -69,6 +70,17 @@ function! s:prev_starts_with(context, expr)
6970
return s:_starts_with(a:context.prev_nb_text, a:expr, a:context.prev_nb_lnum)
7071
endfunction
7172

73+
function! s:in_embedded_view()
74+
let groups = map(synstack(line('.'), col('.')), "synIDattr(v:val, 'name')")
75+
for group in ['elixirPhoenixESigil', 'elixirLiveViewSigil', 'elixirSurfaceSigil']
76+
if index(groups, group) >= 0
77+
return 1
78+
endif
79+
endfor
80+
81+
return 0
82+
endfunction
83+
7284
" Returns 0 or 1 based on whether or not the text starts with the given
7385
" expression and is not a string or comment
7486
function! s:_starts_with(text, expr, lnum)
@@ -160,6 +172,104 @@ function! s:find_last_pos(lnum, text, match)
160172
return -1
161173
endfunction
162174

175+
function! elixir#indent#handle_inside_embedded_view(context)
176+
if !s:in_embedded_view()
177+
return -1
178+
endif
179+
180+
" Multi-line Surface data delimiters
181+
let pair_lnum = searchpair('{{', '', '}}', 'bW', "line('.') == ".a:context.lnum." || s:is_string_or_comment(line('.'), col('.'))", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
182+
if pair_lnum
183+
if a:context.text =~ '}}$'
184+
return indent(pair_lnum)
185+
elseif a:context.text =~ '}}*>$'
186+
return -1
187+
elseif s:prev_ends_with(a:context, '[\|%{')
188+
return indent(a:context.prev_nb_lnum) + s:sw()
189+
elseif a:context.prev_nb_text =~ ',$'
190+
return indent(a:context.prev_nb_lnum)
191+
else
192+
return indent(pair_lnum) + s:sw()
193+
endif
194+
endif
195+
196+
" Multi-line opening tag -- >, />, or %> are on a different line that their opening <
197+
let pair_lnum = searchpair('^\s\+<.*[^>]$', '', '^[^<]*[/%}]\?>$', 'bW', "line('.') == ".a:context.lnum." || s:is_string_or_comment(line('.'), col('.'))", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
198+
if pair_lnum
199+
if a:context.text =~ '^\s\+\%\(>\|\/>\|%>\|}}>\)$'
200+
call s:debug("current line is a lone >, />, or %>")
201+
return indent(pair_lnum)
202+
elseif a:context.text =~ '\%\(>\|\/>\|%>\|}}>\)$'
203+
call s:debug("current line ends in >, />, or %>")
204+
if s:prev_ends_with(a:context, ',')
205+
return indent(a:context.prev_nb_lnum)
206+
else
207+
return -1
208+
endif
209+
else
210+
call s:debug("in the body of a multi-line opening tag")
211+
return indent(pair_lnum) + s:sw()
212+
endif
213+
endif
214+
215+
" Special cases
216+
if s:prev_ends_with(a:context, '^[^<]*do\s%>')
217+
call s:debug("prev line closes a multi-line do block")
218+
return indent(a:context.prev_nb_lnum)
219+
elseif a:context.prev_nb_text =~ 'do\s*%>$'
220+
call s:debug("prev line opens a do block")
221+
return indent(a:context.prev_nb_lnum) + s:sw()
222+
elseif a:context.text =~ '^\s\+<\/[a-zA-Z0-9\.\-_]\+>\|<% end %>'
223+
call s:debug("a single closing tag")
224+
if a:context.prev_nb_text =~ '^\s\+<[^%\/]*[^/]>.*<\/[a-zA-Z0-9\.\-_]\+>$'
225+
call s:debug("opening and closing tags are on the same line")
226+
return indent(a:context.prev_nb_lnum) - s:sw()
227+
elseif a:context.prev_nb_text =~ '^\s\+<[^%\/]*[^/]>\|\s\+>'
228+
call s:debug("prev line is opening html tag or single >")
229+
return indent(a:context.prev_nb_lnum)
230+
elseif s:prev_ends_with(a:context, '^[^<]*\%\(do\s\)\@<!%>')
231+
call s:debug("prev line closes a multi-line eex tag")
232+
return indent(a:context.prev_nb_lnum) - 2 * s:sw()
233+
else
234+
return indent(a:context.prev_nb_lnum) - s:sw()
235+
endif
236+
elseif a:context.text =~ '^\s*<%\s*\%(end\|else\|catch\|rescue\)\>.*%>'
237+
call s:debug("eex middle or closing eex tag")
238+
return indent(a:context.prev_nb_lnum) - s:sw()
239+
elseif a:context.prev_nb_text =~ '\s*<\/\|<% end %>$'
240+
call s:debug("prev is closing tag")
241+
return indent(a:context.prev_nb_lnum)
242+
elseif a:context.prev_nb_text =~ '^\s\+<[^%\/]*[^/]>.*<\/[a-zA-Z0-9\.\-_]\+>$'
243+
call s:debug("opening and closing tags are on the same line")
244+
return indent(a:context.prev_nb_lnum)
245+
elseif s:prev_ends_with(a:context, '\s\+\/>')
246+
call s:debug("prev ends with a single \>")
247+
return indent(a:context.prev_nb_lnum)
248+
elseif s:prev_ends_with(a:context, '^[^<]*\/>')
249+
call s:debug("prev line is closing a multi-line self-closing tag")
250+
return indent(a:context.prev_nb_lnum) - s:sw()
251+
elseif s:prev_ends_with(a:context, '^\s\+<.*\/>')
252+
call s:debug("prev line is closing self-closing tag")
253+
return indent(a:context.prev_nb_lnum)
254+
elseif a:context.prev_nb_text =~ '^\s\+%\?>$'
255+
call s:debug("prev line is a single > or %>")
256+
return indent(a:context.prev_nb_lnum) + s:sw()
257+
endif
258+
259+
" Simple HTML (ie, opening tag is not split across lines)
260+
let pair_lnum = searchpair('^\s\+<[^%\/].*[^\/>]>$', '', '^\s\+<\/\w\+>$', 'bW', "line('.') == ".a:context.lnum." || s:is_string_or_comment(line('.'), col('.'))", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
261+
if pair_lnum
262+
call s:debug("simple HTML")
263+
if a:context.text =~ '^\s\+<\/\w\+>$'
264+
return indent(pair_lnum)
265+
else
266+
return indent(pair_lnum) + s:sw()
267+
endif
268+
endif
269+
270+
return -1
271+
endfunction
272+
163273
function! elixir#indent#handle_top_of_file(context)
164274
if a:context.prev_nb_lnum == 0
165275
return 0

autoload/fsharp.vim

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,107 @@ function! fsharp#updateServerConfig()
233233
call s:notify('workspace/didChangeConfiguration', settings)
234234
endfunction
235235

236+
function! fsharp#loadConfig()
237+
if exists('s:config_is_loaded')
238+
return
239+
endif
240+
241+
if !exists('g:fsharp#fsautocomplete_command')
242+
let s:fsac = fnamemodify(s:script_root_dir . "fsac/fsautocomplete.dll", ":p")
243+
244+
" check if FSAC exists
245+
if empty(glob(s:fsac))
246+
echoerr "FSAC not found. :FSharpUpdateFSAC to download."
247+
let &cpo = s:cpo_save
248+
finish
249+
endif
250+
251+
let g:fsharp#fsautocomplete_command =
252+
\ ['dotnet', s:fsac,
253+
\ '--background-service-enabled'
254+
\ ]
255+
endif
256+
if !exists('g:fsharp#use_recommended_server_config')
257+
let g:fsharp#use_recommended_server_config = 1
258+
endif
259+
call fsharp#getServerConfig()
260+
if !exists('g:fsharp#automatic_workspace_init')
261+
let g:fsharp#automatic_workspace_init = 1
262+
endif
263+
if !exists('g:fsharp#automatic_reload_workspace')
264+
let g:fsharp#automatic_reload_workspace = 1
265+
endif
266+
if !exists('g:fsharp#show_signature_on_cursor_move')
267+
let g:fsharp#show_signature_on_cursor_move = 1
268+
endif
269+
if !exists('g:fsharp#fsi_command')
270+
let g:fsharp#fsi_command = "dotnet fsi"
271+
endif
272+
if !exists('g:fsharp#fsi_keymap')
273+
let g:fsharp#fsi_keymap = "vscode"
274+
endif
275+
if !exists('g:fsharp#fsi_window_command')
276+
let g:fsharp#fsi_window_command = "botright 10new"
277+
endif
278+
if !exists('g:fsharp#fsi_focus_on_send')
279+
let g:fsharp#fsi_focus_on_send = 0
280+
endif
281+
if !exists('g:fsharp#backend')
282+
if has('nvim-0.5')
283+
if exists('g:LanguageClient_loaded')
284+
let g:fsharp#backend = "languageclient-neovim"
285+
else
286+
let g:fsharp#backend = "nvim"
287+
endif
288+
else
289+
let g:fsharp#backend = "languageclient-neovim"
290+
endif
291+
endif
292+
293+
" backend configuration
294+
if g:fsharp#backend == 'languageclient-neovim'
295+
if !exists('g:LanguageClient_serverCommands')
296+
let g:LanguageClient_serverCommands = {}
297+
endif
298+
if !has_key(g:LanguageClient_serverCommands, 'fsharp')
299+
let g:LanguageClient_serverCommands.fsharp = {
300+
\ 'name': 'fsautocomplete',
301+
\ 'command': g:fsharp#fsautocomplete_command,
302+
\ 'initializationOptions': {},
303+
\}
304+
if g:fsharp#automatic_workspace_init
305+
let g:LanguageClient_serverCommands.fsharp.initializationOptions = {
306+
\ 'AutomaticWorkspaceInit': v:true,
307+
\}
308+
endif
309+
endif
310+
311+
if !exists('g:LanguageClient_rootMarkers')
312+
let g:LanguageClient_rootMarkers = {}
313+
endif
314+
if !has_key(g:LanguageClient_rootMarkers, 'fsharp')
315+
let g:LanguageClient_rootMarkers.fsharp = ['*.sln', '*.fsproj', '.git']
316+
endif
317+
elseif g:fsharp#backend == 'nvim'
318+
if !exists('g:fsharp#lsp_auto_setup')
319+
let g:fsharp#lsp_auto_setup = 1
320+
endif
321+
if !exists('g:fsharp#lsp_recommended_colorscheme')
322+
let g:fsharp#lsp_recommended_colorscheme = 1
323+
endif
324+
if !exists('g:fsharp#lsp_codelens')
325+
let g:fsharp#lsp_codelens = 1
326+
endif
327+
328+
else
329+
if g:fsharp#backend != 'disable'
330+
echoerr "[FSAC] Invalid backend: " . g:fsharp#backend
331+
endif
332+
endif
333+
334+
let s:config_is_loaded = 1
335+
endfunction
336+
236337

237338
" handlers for notifications
238339

@@ -617,7 +718,6 @@ function! fsharp#sendAllToFsi()
617718
return fsharp#sendFsi(text)
618719
endfunction
619720

620-
621721
let &cpo = s:cpo_save
622722
unlet s:cpo_save
623723

autoload/polyglot/ft.vim

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ func polyglot#ft#ProtoCheck(default)
264264
endfunc
265265

266266
func polyglot#ft#FTm()
267+
if exists("g:filetype_m")
268+
exe "setf " . g:filetype_m
269+
return
270+
endif
271+
272+
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>'
273+
267274
let n = 1
268275
let saw_comment = 0 " Whether we've seen a multiline comment leader.
269276
while n < 100
@@ -278,6 +285,13 @@ func polyglot#ft#FTm()
278285
setf objc
279286
return
280287
endif
288+
if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' ||
289+
\ line =~ '^\s*unwind_protect\>' ||
290+
\ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
291+
setf octave
292+
return
293+
endif
294+
" TODO: could be Matlab or Octave
281295
if line =~ '^\s*%'
282296
setf matlab
283297
return
@@ -298,11 +312,8 @@ func polyglot#ft#FTm()
298312
" or Murphi based on the comment leader. Assume the former as it is more
299313
" common.
300314
setf objc
301-
elseif exists("g:filetype_m")
302-
" Use user specified default filetype for .m
303-
exe "setf " . g:filetype_m
304315
else
305-
" Default is matlab
316+
" Default is Matlab
306317
setf matlab
307318
endif
308319
endfunc

autoload/polyglot/init.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ if !has_key(g:polyglot_is_disabled, 'jsonnet')
22652265
endif
22662266

22672267
if !has_key(g:polyglot_is_disabled, 'json')
2268-
au BufNewFile,BufRead *.JSON-tmLanguage,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.json,*.jsonl,*.jsonp,*.mcmeta,*.template,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,{.,}arcconfig,{.,}htmlhintrc,{.,}imgbotconfig,{.,}tern-config,{.,}tern-project,{.,}watchmanconfig,Pipfile.lock,composer.lock,mcmod.info setf json
2268+
au BufNewFile,BufRead *.JSON-tmLanguage,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.json,*.jsonl,*.jsonp,*.mcmeta,*.template,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,{.,}arcconfig,{.,}auto-changelog,{.,}c8rc,{.,}htmlhintrc,{.,}imgbotconfig,{.,}nycrc,{.,}tern-config,{.,}tern-project,{.,}watchmanconfig,Pipfile.lock,composer.lock,mcmod.info setf json
22692269
endif
22702270

22712271
if !has_key(g:polyglot_is_disabled, 'json5')

autoload/polyglot/sleuth.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ let s:globs = {
264264
\ 'jovial': '*.jov,*.j73,*.jovial',
265265
\ 'jproperties': '*.properties,*.properties_??,*.properties_??_??,*.properties_??_??_*',
266266
\ 'jq': '*.jq,.jqrc,.jqrc*',
267-
\ 'json': '*.json,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.JSON-tmLanguage,*.jsonl,*.mcmeta,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,*.jsonp,*.template,.arcconfig,.htmlhintrc,.imgbotconfig,.tern-config,.tern-project,.watchmanconfig,Pipfile.lock,composer.lock,mcmod.info',
267+
\ 'json': '*.json,*.avsc,*.geojson,*.gltf,*.har,*.ice,*.JSON-tmLanguage,*.jsonl,*.mcmeta,*.tfstate,*.tfstate.backup,*.topojson,*.webapp,*.webmanifest,*.yy,*.yyp,*.jsonp,*.template,.arcconfig,.auto-changelog,.c8rc,.htmlhintrc,.imgbotconfig,.nycrc,.tern-config,.tern-project,.watchmanconfig,Pipfile.lock,composer.lock,mcmod.info',
268268
\ 'json5': '*.json5',
269269
\ 'jsonc': '*.cjson,*.jsonc,coc-settings.json,.eslintrc.json,.babelrc,.jshintrc,.jslintrc,.mocharc.json,coffeelint.json,tsconfig.json,jsconfig.json',
270270
\ 'jsonnet': '*.jsonnet,*.libsonnet',

0 commit comments

Comments
 (0)