Skip to content

Commit

Permalink
chore: remove unnecessary trim wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Apr 28, 2024
1 parent 27a538a commit 08ada1d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 27 deletions.
6 changes: 3 additions & 3 deletions autoload/vimtex/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions autoload/vimtex/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/env.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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*$'
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/fold/bib.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/include.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
4 changes: 2 additions & 2 deletions autoload/vimtex/info.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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) . ')'
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/parser/bib.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions autoload/vimtex/parser/toc/beamer_frame.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions autoload/vimtex/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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', 'Ä'],
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 08ada1d

Please sign in to comment.