From 08ada1d85be50ca5c87c830285e7787c528cf0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sun, 28 Apr 2024 18:14:29 +0200 Subject: [PATCH] chore: remove unnecessary trim wrapper --- autoload/vimtex/cmd.vim | 6 +++--- autoload/vimtex/complete.vim | 4 ++-- autoload/vimtex/env.vim | 2 +- autoload/vimtex/fold/bib.vim | 2 +- autoload/vimtex/include.vim | 2 +- autoload/vimtex/info.vim | 4 ++-- autoload/vimtex/parser/bib.vim | 2 +- autoload/vimtex/parser/toc/beamer_frame.vim | 10 +++++----- autoload/vimtex/util.vim | 11 ----------- 9 files changed, 16 insertions(+), 27 deletions(-) diff --git a/autoload/vimtex/cmd.vim b/autoload/vimtex/cmd.vim index 74164da025..7bd0cda55f 100644 --- a/autoload/vimtex/cmd.vim +++ b/autoload/vimtex/cmd.vim @@ -345,14 +345,14 @@ function! s:get_frac_cmd() abort " {{{1 let l:blurp = matchstr(l:part, '^\s*{[^}]*}') if !empty(l:blurp) - let l:frac[l:key] = vimtex#util#trim(l:blurp)[1:-2] + let l:frac[l:key] = trim(l:blurp)[1:-2] let l:frac.col_end += len(l:blurp) continue endif let l:blurp = matchstr(l:part, '^\s*\w') if !empty(l:blurp) - let l:frac[l:key] = vimtex#util#trim(l:blurp) + let l:frac[l:key] = trim(l:blurp) let l:frac.col_end += len(l:blurp) endif endfor @@ -529,7 +529,7 @@ endfunction " }}}1 function! s:get_inline_trim(str) abort " {{{1 - let l:str = vimtex#util#trim(a:str) + let l:str = trim(a:str) return substitute(l:str, '^(\(.*\))$', '\1', '') endfunction diff --git a/autoload/vimtex/complete.vim b/autoload/vimtex/complete.vim index a9a360b1f1..b419fa8caa 100644 --- a/autoload/vimtex/complete.vim +++ b/autoload/vimtex/complete.vim @@ -569,9 +569,9 @@ function! s:completer_gls.init() dict abort " {{{2 if empty(l:matches) | continue | endif while !empty(l:matches) - let l:key = vimtex#util#trim(remove(l:matches, 0)) + let l:key = trim(remove(l:matches, 0)) if l:key ==# 'src' - let l:value = vimtex#util#trim(remove(l:matches, 0)) + let l:value = trim(remove(l:matches, 0)) let l:value = substitute(l:value, '^{', '', '') let l:value = substitute(l:value, '[]}]\s*', '', 'g') let b:vimtex.complete.glsbib = l:value diff --git a/autoload/vimtex/env.vim b/autoload/vimtex/env.vim index a495f758d3..9f88c813ac 100644 --- a/autoload/vimtex/env.vim +++ b/autoload/vimtex/env.vim @@ -155,7 +155,7 @@ function! vimtex#env#change_to_inline_math(open, close, new) abort " {{{1 let l:line = substitute(getline(a:close.lnum - 1), '\s*$', a:new[1], '') call setline(a:close.lnum - 1, l:line) execute a:close.lnum . 'delete _' - if !empty(vimtex#util#trim(getline(a:close.lnum))) + if !empty(trim(getline(a:close.lnum))) execute (a:close.lnum - 1) . 'join' endif elseif l:before =~# '^\s*$' diff --git a/autoload/vimtex/fold/bib.vim b/autoload/vimtex/fold/bib.vim index 4edcf12318..cbc927c303 100644 --- a/autoload/vimtex/fold/bib.vim +++ b/autoload/vimtex/fold/bib.vim @@ -21,7 +21,7 @@ endfunction function! vimtex#fold#bib#level(lnum) abort " {{{1 " Handle blank lines - if empty(vimtex#util#trim(getline(a:lnum))) + if empty(trim(getline(a:lnum))) if a:lnum == 1 | return 0 | endif let l:prev_level = vimtex#fold#bib#level(a:lnum - 1) diff --git a/autoload/vimtex/include.vim b/autoload/vimtex/include.vim index bb84ba4dde..30265412f7 100644 --- a/autoload/vimtex/include.vim +++ b/autoload/vimtex/include.vim @@ -85,7 +85,7 @@ function! s:parse_package_documentclass(fname) abort " {{{1 let l:result = l:args[0].text endif - return vimtex#util#trim(l:result) + return trim(l:result) endfunction let s:re_cmds = '\v\s*\\%(' . join([ diff --git a/autoload/vimtex/info.vim b/autoload/vimtex/info.vim index ebef8ec7b6..ffbd923019 100644 --- a/autoload/vimtex/info.vim +++ b/autoload/vimtex/info.vim @@ -198,8 +198,8 @@ function! s:get_os_info() abort " {{{1 let l:win_info = vimtex#jobs#cached('systeminfo') try - let l:name = vimtex#util#trim(matchstr(l:win_info[1], ':\s*\zs.*')) - let l:version = vimtex#util#trim(matchstr(l:win_info[2], ':\s*\zs.*')) + let l:name = trim(matchstr(l:win_info[1], ':\s*\zs.*')) + let l:version = trim(matchstr(l:win_info[2], ':\s*\zs.*')) return l:name . ' (' . l:version . ')' catch return 'Windows (' . string(l:win_info) . ')' diff --git a/autoload/vimtex/parser/bib.vim b/autoload/vimtex/parser/bib.vim index e7826f7dab..184fe532df 100644 --- a/autoload/vimtex/parser/bib.vim +++ b/autoload/vimtex/parser/bib.vim @@ -28,7 +28,7 @@ function! vimtex#parser#bib#parse_cheap(start_line, end_line, opts) abort " {{{1 let l:entries = [] let l:firstlines = filter( \ range(a:start_line, a:end_line), - \ {_, i -> vimtex#util#trim(getline(i))[0] == "@"}) + \ {_, i -> trim(getline(i))[0] == "@"}) let l:total_entries = len(l:firstlines) let l:entry_lines = map(l:firstlines, {idx, val -> [val, \ idx == l:total_entries - 1 diff --git a/autoload/vimtex/parser/toc/beamer_frame.vim b/autoload/vimtex/parser/toc/beamer_frame.vim index b6108bd51d..8af17a6e04 100644 --- a/autoload/vimtex/parser/toc/beamer_frame.vim +++ b/autoload/vimtex/parser/toc/beamer_frame.vim @@ -32,10 +32,10 @@ function! s:matcher.get_entry(context) abort dict " {{{1 " Handle subtitles, e.g. \begin{frame}{title}{subtitle} let l:parts = split(matchstr(a:context.line, self.re_match), '}\s*{') if len(l:parts) > 1 - let self.title = vimtex#util#trim(l:parts[0]) - let self.subtitle = vimtex#util#trim(l:parts[1]) + let self.title = trim(l:parts[0]) + let self.subtitle = trim(l:parts[1]) elseif len(l:parts) > 0 - let self.title = vimtex#util#trim(l:parts[0]) + let self.title = trim(l:parts[0]) endif if empty(self.title) @@ -71,11 +71,11 @@ endfunction " }}}1 function! s:matcher.continue(context) abort dict " {{{1 if empty(self.title) - let self.title = vimtex#util#trim( + let self.title = trim( \ matchstr(a:context.line, '^\s*\\frametitle\s*{\zs[^}]*')) endif if empty(self.subtitle) - let self.subtitle = vimtex#util#trim( + let self.subtitle = trim( \ matchstr(a:context.line, '^\s*\\framesubtitle\s*{\zs[^}]*')) endif diff --git a/autoload/vimtex/util.vim b/autoload/vimtex/util.vim index 050e46ac5d..74705e9b4d 100644 --- a/autoload/vimtex/util.vim +++ b/autoload/vimtex/util.vim @@ -177,7 +177,6 @@ function! vimtex#util#tex2unicode(line) abort " {{{1 return l:line endfunction -" " Define list for converting compositions like \"u to unicode ű let s:tex2unicode_list = map([ \ ['\\"A', 'Ä'], @@ -458,16 +457,6 @@ function! vimtex#util#texsplit(str) abort " {{{1 return parts endfunction -" }}}1 -function! vimtex#util#trim(str) abort " {{{1 - if exists('*trim') | return trim(a:str) | endif - - let l:str = substitute(a:str, '^\s*', '', '') - let l:str = substitute(l:str, '\s*$', '', '') - - return l:str -endfunction - " }}}1 function! vimtex#util#uniq_unsorted(list) abort " {{{1 if len(a:list) <= 1 | return deepcopy(a:list) | endif