mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:1afe8c3: runtime(rust): improve loading time
fixes: vim/vim#17745
closes: vim/vim#17749
1afe8c3a4d
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:

committed by
Christian Clason

parent
8dfad04ce9
commit
14cafbcc85
@@ -1,6 +1,8 @@
|
|||||||
" Author: Stephen Sugden <stephen@stephensugden.com>
|
" Author: Stephen Sugden <stephen@stephensugden.com>
|
||||||
" Last Modified: 2023-09-11
|
" Last Modified: 2023-09-11
|
||||||
" Last Change: 2025 Mar 31 by Vim project (rename s:RustfmtConfigOptions())
|
" Last Change:
|
||||||
|
" 2025 Mar 31 by Vim project (rename s:RustfmtConfigOptions())
|
||||||
|
" 2025 Jul 14 by Vim project (don't parse rustfmt version automatically #17745)
|
||||||
"
|
"
|
||||||
" Adapted from https://github.com/fatih/vim-go
|
" Adapted from https://github.com/fatih/vim-go
|
||||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||||
@@ -22,6 +24,12 @@ if !exists("g:rustfmt_fail_silently")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! rustfmt#DetectVersion()
|
function! rustfmt#DetectVersion()
|
||||||
|
let s:rustfmt_version = "0"
|
||||||
|
let s:rustfmt_help = ""
|
||||||
|
let s:rustfmt_unstable_features = ""
|
||||||
|
if !get(g:, 'rustfmt_detect_version', 0)
|
||||||
|
return s:rustfmt_version
|
||||||
|
endif
|
||||||
" Save rustfmt '--help' for feature inspection
|
" Save rustfmt '--help' for feature inspection
|
||||||
silent let s:rustfmt_help = system(g:rustfmt_command . " --help")
|
silent let s:rustfmt_help = system(g:rustfmt_command . " --help")
|
||||||
let s:rustfmt_unstable_features = s:rustfmt_help =~# "--unstable-features"
|
let s:rustfmt_unstable_features = s:rustfmt_help =~# "--unstable-features"
|
||||||
@@ -30,9 +38,7 @@ function! rustfmt#DetectVersion()
|
|||||||
silent let l:rustfmt_version_full = system(g:rustfmt_command . " --version")
|
silent let l:rustfmt_version_full = system(g:rustfmt_command . " --version")
|
||||||
let l:rustfmt_version_list = matchlist(l:rustfmt_version_full,
|
let l:rustfmt_version_list = matchlist(l:rustfmt_version_full,
|
||||||
\ '\vrustfmt ([0-9]+[.][0-9]+[.][0-9]+)')
|
\ '\vrustfmt ([0-9]+[.][0-9]+[.][0-9]+)')
|
||||||
if len(l:rustfmt_version_list) < 3
|
if len(l:rustfmt_version_list) >= 3
|
||||||
let s:rustfmt_version = "0"
|
|
||||||
else
|
|
||||||
let s:rustfmt_version = l:rustfmt_version_list[1]
|
let s:rustfmt_version = l:rustfmt_version_list[1]
|
||||||
endif
|
endif
|
||||||
return s:rustfmt_version
|
return s:rustfmt_version
|
||||||
@@ -63,6 +69,12 @@ function! s:RustfmtWriteMode()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! rustfmt#RustfmtConfigOptions()
|
function! rustfmt#RustfmtConfigOptions()
|
||||||
|
let default = '--edition 2018'
|
||||||
|
|
||||||
|
if !get(g:, 'rustfmt_find_toml', 0)
|
||||||
|
return default
|
||||||
|
endif
|
||||||
|
|
||||||
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
|
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
|
||||||
if l:rustfmt_toml !=# ''
|
if l:rustfmt_toml !=# ''
|
||||||
return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p"))
|
return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p"))
|
||||||
@@ -74,7 +86,7 @@ function! rustfmt#RustfmtConfigOptions()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Default to edition 2018 in case no rustfmt.toml was found.
|
" Default to edition 2018 in case no rustfmt.toml was found.
|
||||||
return '--edition 2018'
|
return default
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RustfmtCommandRange(filename, line1, line2)
|
function! s:RustfmtCommandRange(filename, line1, line2)
|
||||||
|
@@ -160,7 +160,18 @@ g:rustfmt_emit_files ~
|
|||||||
provided) instead of '--write-mode=overwrite'. >vim
|
provided) instead of '--write-mode=overwrite'. >vim
|
||||||
let g:rustfmt_emit_files = 0
|
let g:rustfmt_emit_files = 0
|
||||||
<
|
<
|
||||||
|
*g:rustfmt_detect_version*
|
||||||
|
g:rustfmt_detect_version ~
|
||||||
|
When set to 1, will try to parse the version output from "rustfmt".
|
||||||
|
Disabled by default for performance reasons >vim
|
||||||
|
let g:rustfmt_detect_version = 1
|
||||||
|
<
|
||||||
|
*g:rustfmt_find_toml*
|
||||||
|
g:rustfmt_emit_files ~
|
||||||
|
When set to 1, will try to find "rustfmt.toml" file by searching from
|
||||||
|
current path upwards. Disabled by default for performance reasons >vim
|
||||||
|
let g:rustfmt_find_toml = 1
|
||||||
|
<
|
||||||
*g:rust_playpen_url*
|
*g:rust_playpen_url*
|
||||||
g:rust_playpen_url ~
|
g:rust_playpen_url ~
|
||||||
Set this option to override the url for the playpen to use: >vim
|
Set this option to override the url for the playpen to use: >vim
|
||||||
|
Reference in New Issue
Block a user